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