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