File cleanup.php of Package php-pear
1
2
3
#
4
# Usage: php cleanup.php /path/to/pear.conf /usr/share
5
#
6
$file = $_SERVER['argv'][1];
7
$data = $_SERVER['argv'][2];
8
9
# Keys to be removed if exists
10
$remove = [
11
'ext_dir',
12
'http_proxy',
13
];
14
# Keys to be added
15
$add = [
16
'__channels' => [
17
'pecl.php.net' => [
18
'doc_dir' => "$data/doc/pecl",
19
'test_dir' => "$data/tests/pecl",
20
]
21
]
22
];
23
24
$input = file_get_contents($file);
25
list($header, $config) = explode("\n", $input);
26
$config = unserialize($config);
27
28
foreach ($remove as $key) unset($config[$key]);
29
$config = array_merge($config, $add);
30
$config = serialize($config);
31
32
file_put_contents($file, "$header\n$config");
33
34