X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm.git;a=blobdiff_plain;f=rpm-php-requires.php;h=b39802993bc09d5d25656eb32939a69a054b101e;hp=1c233a1216fe868eebd4b360c9bc29a86d9c27b9;hb=dcf91c25fee0ebfdab52a29fcf9600e19e338d90;hpb=e4759b916014aa235274264f7be6852fc693a599 diff --git a/rpm-php-requires.php b/rpm-php-requires.php index 1c233a1..b398029 100644 --- a/rpm-php-requires.php +++ b/rpm-php-requires.php @@ -1,5 +1,9 @@ #!/usr/bin/php (Perl version) * Elan Ruusamäe * + * URL: + * * Requires: php-pear-PHP_CompatInfo * Requires: php-pcre */ @@ -38,25 +44,25 @@ function peardeps($files) { } foreach (file($f) as $line) { - // skip comments + // skip comments -- not perfect, matches "*" at start of line (very rare altho) if (preg_match('/^\s*(#|\/\/|\*|\/\*)/', $line)) { continue; } - while (preg_match("/(\W|^)(require|include)(_once)? + if (preg_match("/(\W|^)(require|include)(_once)? \s* \(? \s* (\"([^\"]*)\"|'([^']*)') \s* \)? \s* ;/x", $line, $m)) { - if ($m[5] != "") { + if ($m[5]) { $x = $m[5]; - } else if ($m[6] != "") { + } else if ($m[6]) { $x = $m[6]; } else { continue 2; } - if (substr($x, 0, 2) == './' || substr($x, -1) == '$') { + if (substr($x, 0, 2) == './' || substr($x, -1) == '$') { # XXX must be: CONTAINS DOLLAR continue 2; } @@ -71,20 +77,20 @@ function peardeps($files) { continue; } - while (preg_match("/(\W|^)(require|include)(_once)? + if (preg_match("/(\W|^)(require|include)(_once)? \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s* (\"([^\"]*)\"|'([^']*)') \s* \)? \s* ;/x", $line, $m)) { - if ($m[5] != "") { + if ($m[5]) { $x = $m[5]; - } else if ($m[6] != "") { + } else if ($m[6]) { $x = $m[6]; } else { continue 2; } - if (substr($x, -1) == '$') { + if (substr($x, -1) == '$') { # XXX must be: CONTAINS DOLLAR continue 2; } if (substr($x, -4) != '.php') { @@ -92,6 +98,9 @@ function peardeps($files) { } $x = "$file_dir/$x"; + // remove double slashes + // TODO: resolve simpletest/test/../socket.php -> simpletest/socket.php + $x = str_replace("//", "/", $x); $req[$x] = 1; continue; } @@ -116,21 +125,44 @@ function extdeps($files) { $info = new PHP_CompatInfo('null'); $res = $info->parseData($files); - if (version_compare($res['version'], '5.0.0', 'ge')) { + // minimum php version we accept + // "%define php_min_version 5.1.2" in spec to minimum version to be 5.1.2 + $version = max(PHP_MIN_VERSION, $res['version']); + + if (version_compare($version, '5.0.0', 'ge')) { + # force php- only deps when php5 + # XXX what about php-pecl- virtual provides? + $fmt = 'php-%s'; $epoch = 4; } else { + $fmt = 'php(%s)'; $epoch = 3; } - echo "php-common >= ", $epoch, ":", $res['version'], "\n"; + echo "php-common >= ", $epoch, ":", $version, "\n"; // process extensions foreach ($res['extensions'] as $ext) { - echo "php(", $ext, ")\n"; + // bz2 ext is in php-bzip2 package + if ($ext == 'bz2') { + $ext = 'bzip2'; + } + // libxml ext is in php-xml package + if ($ext == 'libxml') { + $ext = 'xml'; + } + + // these need to be lowercased + if (in_array($ext, array('SPL', 'PDO', 'SQLite', 'Reflection', 'SimpleXML'))) { + $ext = strtolower($ext); + } + + printf("$fmt\n", $ext); } } define('RPM_BUILD_ROOT', getenv('RPM_BUILD_ROOT')); define('PHP_PEAR_DIR', '/usr/share/pear'); +define('PHP_MIN_VERSION', getenv('PHP_MIN_VERSION')); if ($argc > 1) { $files = array_splice($argv, 1);