]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-php-requires.php
- fix peardeps finding
[packages/rpm.git] / rpm-php-requires.php
1 #!/usr/bin/php
2 <?php
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
12 /**
13  * Produce old style pear(Path/To/File.php) deps
14  */
15 function peardeps($files) {
16         // all files must begin with $RPM_BUILD_ROOT%{php_pear_dir}
17         $prefix = RPM_BUILD_ROOT. PHP_PEAR_DIR . DIRECTORY_SEPARATOR;
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 }
27
28 /**
29  * Produce dependencies for extensions using PEAR PHP_CompatInfo package.
30  */
31 function extdeps($files) {
32         require_once 'PHP/CompatInfo.php';
33
34         $info = new PHP_CompatInfo('null');
35         $res = $info->parseData($files);
36
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";
52
53         // process extensions
54         foreach ($res['extensions'] as $ext) {
55                 if (in_array($ext, $staticmods)) {
56                         continue;
57                 }
58
59                 if ($compat) {
60                         echo "php(", $ext, ")\n";
61                 } else {
62                         echo "php-", $ext, "\n";
63                 }
64         }
65 }
66
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')));
74 }
75
76 peardeps($files);
77 extdeps($files);
This page took 0.039262 seconds and 4 git commands to generate.