4 * minify.spec does not see these: pear(HTTP/ConditionalGet.php) pear(HTTP/Encoder.php)
9 * Check system dependences between php-pear modules.
11 * Paweł Gołaszewski <blues@pld-linux.org> (Perl version)
12 * Michał Moskal <malekith@pld-linux.org> (Perl version)
13 * Elan Ruusamäe <glen@pld-linux.org>
15 * URL: <http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/rpm/rpm-php-requires.php>
17 * Requires: php-pear-PHP_CompatInfo
22 * Produce pear(Path/To/File.php) deps
23 * Ported to PHP from Perl version of rpm-php-requires.
25 * @TODO: use tokenizer to parse php files.
27 function peardeps($files) {
28 // files inside php_pear_dir have this prefix
29 $prefix = RPM_BUILD_ROOT. PHP_PEAR_DIR . DIRECTORY_SEPARATOR;
30 $length = strlen($prefix);
33 foreach ($files as $f) {
35 if (substr($f, -4) != '.php') {
39 // subdir inside php_pear_dir
40 if (substr($f, 0, $length) == $prefix) {
41 $file_dir = dirname(substr($f, $length));
46 foreach (file($f) as $line) {
47 // skip comments -- not perfect, matches "*" at start of line (very rare altho)
48 if (preg_match('/^\s*(#|\/\/|\*|\/\*)/', $line)) {
52 if (preg_match("/(\W|^)(require|include)(_once)?
54 (\"([^\"]*)\"|'([^']*)')
55 \s* \)? \s* ;/x", $line, $m)) {
65 if (substr($x, 0, 2) == './' || substr($x, -1) == '$') { # XXX must be: CONTAINS DOLLAR
69 if (substr($x, -4) != '.php') {
76 if (is_null($file_dir)) {
80 if (preg_match("/(\W|^)(require|include)(_once)?
81 \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s*
82 (\"([^\"]*)\"|'([^']*)')
83 \s* \)? \s* ;/x", $line, $m)) {
93 if (substr($x, -1) == '$') { # XXX must be: CONTAINS DOLLAR
96 if (substr($x, -4) != '.php') {
101 // remove double slashes
102 // TODO: resolve simpletest/test/../socket.php -> simpletest/socket.php
103 $x = str_replace("//", "/", $x);
110 foreach (array_keys($req) as $f) {
112 if (array_key_exists($f, $files)) {
120 * Produce dependencies for extensions using PEAR PHP_CompatInfo package.
122 function extdeps($files) {
123 require_once 'PHP/CompatInfo.php';
125 $info = new PHP_CompatInfo('null');
126 $res = $info->parseData($files);
128 // minimum php version we accept
129 // "%define php_min_version 5.1.2" in spec to minimum version to be 5.1.2
130 $version = max(PHP_MIN_VERSION, $res['version']);
132 if (version_compare($version, '5.0.0', 'ge')) {
133 # force php-<name> only deps when php5
134 # XXX what about php-pecl-<name> virtual provides?
141 echo "php-common >= ", $epoch, ":", $version, "\n";
143 // process extensions
144 foreach ($res['extensions'] as $ext) {
145 // bz2 ext is in php-bzip2 package
149 // libxml ext is in php-xml package
150 if ($ext == 'libxml') {
154 // these need to be lowercased
155 if (in_array($ext, array('SPL', 'PDO', 'SQLite', 'Reflection', 'SimpleXML'))) {
156 $ext = strtolower($ext);
159 printf("$fmt\n", $ext);
163 define('RPM_BUILD_ROOT', getenv('RPM_BUILD_ROOT'));
164 define('PHP_PEAR_DIR', '/usr/share/pear');
165 define('PHP_MIN_VERSION', getenv('PHP_MIN_VERSION'));
168 $files = array_splice($argv, 1);
170 $files = explode(PHP_EOL, trim(file_get_contents('php://stdin')));