Blame SOURCES/cleanup.php

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