4c171b
4c171b
4c171b
#
4c171b
# Usage: php cleanup.php /path/to/pear.conf /usr/share
4c171b
# 
4c171b
$file = $_SERVER['argv'][1];
4c171b
$data = $_SERVER['argv'][2];
4c171b
4c171b
# Keys to be removed if exists
4c171b
$remove = [
4c171b
  'ext_dir',
4c171b
  'http_proxy',
4c171b
];
4c171b
# Keys to be added
4c171b
$add = [
4c171b
  '__channels' => [
4c171b
    'pecl.php.net' => [
4c171b
      'doc_dir'  => "$data/doc/pecl",
4c171b
      'test_dir' => "$data/tests/pecl",
4c171b
    ]
4c171b
  ]
4c171b
];
4c171b
4c171b
$input = file_get_contents($file);
4c171b
list($header, $config) = explode("\n", $input);
4c171b
$config = unserialize($config);
4c171b
4c171b
foreach ($remove as $key) unset($config[$key]);
4c171b
$config = array_merge($config, $add);
4c171b
$config = serialize($config);
4c171b
4c171b
file_put_contents($file, "$header\n$config");
4c171b