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