]>
Commit | Line | Data |
---|---|---|
e7daca0a ER |
1 | #!/usr/bin/php |
2 | <?php | |
ec981489 ER |
3 | ##################################################################### |
4 | # # | |
5 | # Check system dependences between php-pear modules # | |
6 | # # | |
7 | # Paweł Gołaszewski <blues@pld-linux.org> # | |
8 | # Michał Moskal <malekith@pld-linux.org> # | |
9 | # Elan Ruusamäe <glen@pld-linux.org> # | |
10 | ##################################################################### | |
11 | ||
e7daca0a | 12 | /** |
ec981489 | 13 | * Produce old style pear(Path/To/File.php) deps |
e7daca0a | 14 | */ |
ec981489 ER |
15 | function peardeps($files) { |
16 | // all files must begin with $RPM_BUILD_ROOT%{php_pear_dir} | |
17 | $prefix = RPM_BUILD_ROOT. PATH_SEPARATOR . PHP_PEAR_DIR; | |
18 | $length = strlen($prefix); | |
19 | foreach ($files as $f) { | |
20 | if (substr($f, 0, $length) != $prefix) { | |
21 | continue; | |
22 | } | |
23 | $f = substr($f, $length); | |
24 | echo "pear($f)\n"; | |
25 | } | |
26 | } | |
e7daca0a | 27 | |
ec981489 ER |
28 | /** |
29 | * Produce dependencies for extensions using PEAR PHP_CompatInfo package. | |
30 | */ | |
31 | function extdeps($files) { | |
32 | require_once 'PHP/CompatInfo.php'; | |
e7daca0a | 33 | |
ec981489 ER |
34 | $info = new PHP_CompatInfo('null'); |
35 | $res = $info->parseData($files); | |
e7daca0a | 36 | |
ec981489 ER |
37 | if (version_compare($res['version'], '5.0.0', 'ge')) { |
38 | $epoch = 4; | |
39 | // produce dependencies only for php5 | |
40 | $compat = false; | |
41 | // session has always been compiled in | |
42 | // date, spl are internal for php | |
43 | $staticmods = array('session', 'date', 'spl'); | |
44 | } else { | |
45 | $epoch = 3; | |
46 | // produce dependencies where php4/php5 both are ok | |
47 | $compat = true; | |
48 | // session has always been compiled in | |
49 | $staticmods = array('session'); | |
50 | } | |
51 | echo "php-common >= ", $epoch, ":", $res['version'], "\n"; | |
e7daca0a | 52 | |
ec981489 ER |
53 | // process extensions |
54 | foreach ($res['extensions'] as $ext) { | |
55 | if (in_array($ext, $staticmods)) { | |
56 | continue; | |
57 | } | |
e7daca0a | 58 | |
ec981489 ER |
59 | if ($compat) { |
60 | echo "php(", $ext, ")\n"; | |
61 | } else { | |
62 | echo "php-", $ext, "\n"; | |
63 | } | |
e7daca0a | 64 | } |
ec981489 | 65 | } |
e7daca0a | 66 | |
ec981489 ER |
67 | define('RPM_BUILD_ROOT', getenv('RPM_BUILD_ROOT')); |
68 | define('PHP_PEAR_DIR', '/usr/share/pear'); | |
69 | ||
70 | if ($argc > 1) { | |
71 | $files = array_splice($argv, 1); | |
72 | } else { | |
73 | $files = split(PHP_EOL, trim(file_get_contents('php://stdin'))); | |
e7daca0a | 74 | } |
ec981489 ER |
75 | |
76 | peardeps($files); | |
77 | extdeps($files); |