]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-php-requires.php
- the both php versions autoprovs are not possible as this script is run for each...
[packages/rpm.git] / rpm-php-requires.php
CommitLineData
e7daca0a
ER
1#!/usr/bin/php
2<?php
4553acd5
ER
3/**
4 *
5 * Check system dependences between php-pear modules.
b56286b3 6 * Based on Perl version rpm-php-requires.
4553acd5
ER
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 */
ec981489 12
e7daca0a 13/**
ec981489 14 * Produce old style pear(Path/To/File.php) deps
e7daca0a 15 */
ec981489
ER
16function peardeps($files) {
17 // all files must begin with $RPM_BUILD_ROOT%{php_pear_dir}
4083bfec 18 $prefix = RPM_BUILD_ROOT. PHP_PEAR_DIR . DIRECTORY_SEPARATOR;
ec981489
ER
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}
e7daca0a 28
ec981489
ER
29/**
30 * Produce dependencies for extensions using PEAR PHP_CompatInfo package.
31 */
32function extdeps($files) {
33 require_once 'PHP/CompatInfo.php';
e7daca0a 34
ec981489
ER
35 $info = new PHP_CompatInfo('null');
36 $res = $info->parseData($files);
e7daca0a 37
ec981489
ER
38 if (version_compare($res['version'], '5.0.0', 'ge')) {
39 $epoch = 4;
fc20423e
ER
40 // session, pcre are statically compiled in
41 // date, SPL, SimpleXML are internal for php
42 // sapi_apache?
43 $staticmods = array('standard', 'ereg', 'session', 'pcre', 'date', 'spl', 'simplexml');
ec981489
ER
44 } else {
45 $epoch = 3;
ec981489 46 // session has always been compiled in
fc20423e 47 $staticmods = array('standard', 'ereg', 'session');
ec981489
ER
48 }
49 echo "php-common >= ", $epoch, ":", $res['version'], "\n";
e7daca0a 50
ec981489
ER
51 // process extensions
52 foreach ($res['extensions'] as $ext) {
53 if (in_array($ext, $staticmods)) {
54 continue;
55 }
e7daca0a 56
b56286b3 57 echo "php(", $ext, ")\n";
e7daca0a 58 }
ec981489 59}
e7daca0a 60
ec981489
ER
61define('RPM_BUILD_ROOT', getenv('RPM_BUILD_ROOT'));
62define('PHP_PEAR_DIR', '/usr/share/pear');
63
64if ($argc > 1) {
65 $files = array_splice($argv, 1);
66} else {
67 $files = split(PHP_EOL, trim(file_get_contents('php://stdin')));
e7daca0a 68}
ec981489
ER
69
70peardeps($files);
71extdeps($files);
This page took 0.030886 seconds and 4 git commands to generate.