cvs: pear-core /PEAR/Command Package.php
| From: | Greg Beaver | Date: | Sat, 25 Mar 2006 20:53:26 +0000 |
| Subject: | cvs: pear-core /PEAR/Command Package.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-4649@lists.php.net to get a copy of this message | ||
cellog Sat Mar 25 20:53:26 2006 UTC
Modified files:
/pear-core/PEAR/Command Package.php
Log:
as discussed, remove deprecated make-rpm from PEAR 1.5.0
improve detection of PEAR_Command_Packaging
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Command/Package.php?r1=1.119&r2=1.120&diff_format=u Index: pear-core/PEAR/Command/Package.php diff -u pear-core/PEAR/Command/Package.php:1.119 pear-core/PEAR/Command/Package.php:1.120 --- pear-core/PEAR/Command/Package.php:1.119 Thu Mar 2 18:14:13 2006 +++ pear-core/PEAR/Command/Package.php Sat Mar 25 20:53:26 2006 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.119 2006/03/02 18:14:13 cellog Exp $ + * @version CVS: $Id: Package.php,v 1.120 2006/03/25 20:53:26 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -737,7 +737,10 @@ function &getCommandPackaging(&$ui, &$config) { if (!class_exists('PEAR_Command_Packaging')) { - @include_once 'PEAR/Command/Packaging.php'; + if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) { + fclose($fp); + include_once 'PEAR/Command/Packaging.php'; + } } if (class_exists('PEAR_Command_Packaging')) { @@ -752,8 +755,6 @@ function doMakeRPM($command, $options, $params) { - require_once 'System.php'; - require_once 'Archive/Tar.php'; // Check to see if PEAR_Command_Packaging is installed, and // transparently switch to use the "make-rpm-spec" command from it @@ -765,352 +766,10 @@ 'newer "make-rpm-spec" command instead'); return $packaging_cmd->run('make-rpm-spec', $options, $params); } else { - $this->ui->outputData('WARNING: "pear makerpm" is now deprecated; an '. + $this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '. 'improved version is available via "pear make-rpm-spec", which '. 'is available by installing PEAR_Command_Packaging'); } - - if (sizeof($params) != 1) { - return $this->raiseError("bad parameter(s), try \"help $command\""); - } - if (!file_exists($params[0])) { - return $this->raiseError("file does not exist: $params[0]"); - } - $reg = &$this->config->getRegistry(); - $pkg = &$this->getPackageFile($this->config, $this->_debug); - $pf = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); - if (PEAR::isError($pf)) { - $u = $pf->getUserinfo(); - if (is_array($u)) { - foreach ($u as $err) { - if (is_array($err)) { - $err = $err['message']; - } - $this->ui->outputData($err); - } - } - return $this->raiseError("$params[0] is not a valid package"); - } - $tmpdir = System::mktemp(array('-d', 'pear2rpm')); - $instroot = System::mktemp(array('-d', 'pear2rpm')); - $tmp = $this->config->get('verbose'); - $this->config->set('verbose', 0); - $installer = $this->getInstaller($this->ui); - require_once 'PEAR/Downloader/Package.php'; - $pack = new PEAR_Downloader_Package($installer); - $pack->setPackageFile($pf); - $params[0] = &$pack; - $installer->setOptions(array('installroot' => $instroot, - 'nodeps' => true, 'soft' => true)); - $installer->setDownloadedPackages($params); - $info = $installer->install($params[0], - array('installroot' => $instroot, - 'nodeps' => true, 'soft' => true)); - $pkgdir = $pf->getPackage() . '-' . $pf->getVersion(); - $info['rpm_xml_dir'] = '/var/lib/pear'; - $this->config->set('verbose', $tmp); - if (isset($options['spec-template'])) { - $spec_template = $options['spec-template']; - } else { - $spec_template = '@DATA-DIR@/PEAR/template.spec'; - } - $info['possible_channel'] = ''; - $info['extra_config'] = ''; - if (isset($options['rpm-pkgname'])) { - $rpm_pkgname_format = $options['rpm-pkgname']; - } else { - if ($pf->getChannel() == 'pear.php.net' || $pf->getChannel() == 'pecl.php.net') { - $alias = 'PEAR'; - } else { - $chan = &$reg->getChannel($pf->getChannel()); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $alias = $chan->getAlias(); - $alias = strtoupper($alias); - $info['possible_channel'] = $pf->getChannel() . '/'; - } - $rpm_pkgname_format = $alias . '::%s'; - } - - $info['extra_headers'] = ''; - $info['doc_files'] = ''; - $info['files'] = ''; - $info['package2xml'] = ''; - $info['rpm_package'] = sprintf($rpm_pkgname_format, $pf->getPackage()); - $srcfiles = 0; - foreach ($info['filelist'] as $name => $attr) { - if (!isset($attr['role'])) { - continue; - } - $name = preg_replace('![/:\\\\]!', '/', $name); - if ($attr['role'] == 'doc') { - $info['doc_files'] .= " $name"; - // Map role to the rpm vars - } else { - $c_prefix = '%{_libdir}/php/pear'; - switch ($attr['role']) { - case 'php': - $prefix = $c_prefix; - break; - case 'ext': - $prefix = '%{_libdir}/php'; - break; // XXX good place? - case 'src': - $srcfiles++; - $prefix = '%{_includedir}/php'; - break; // XXX good place? - case 'test': - $prefix = "$c_prefix/tests/" . $pf->getPackage(); - break; - case 'data': - $prefix = "$c_prefix/data/" . $pf->getPackage(); - break; - case 'script': - $prefix = '%{_bindir}'; - break; - default: // non-standard roles - $prefix = "$c_prefix/$attr[role]/" . $pf->getPackage(); - $info['extra_config'] .= - "\n -d {$attr[role]}_dir=$c_prefix/{$attr[role]} \\"; - $this->ui->outputData('WARNING: role "' . $attr['role'] . '" used, ' . - 'and will be installed in "' . $c_prefix . '/' . $attr['role'] . - '/' . $pf->getPackage() . - ' - hand-edit the final .spec if this is wrong', $command); - break; - } - $name = str_replace('\\', '/', $name); - $info['files'] .= "$prefix/$name\n"; - } - } - if ($srcfiles > 0) { - require_once 'OS/Guess.php'; - $os = new OS_Guess; - $arch = $os->getCpu(); - } else { - $arch = 'noarch'; - } - $cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir', - 'bin_dir', 'data_dir', 'test_dir'); - foreach ($cfg as $k) { - if ($k == 'master_server') { - $chan = $reg->getChannel($pf->getChannel()); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $info[$k] = $chan->getServer(); - continue; - } - $info[$k] = $this->config->get($k); - } - $info['arch'] = $arch; - $fp = @fopen($spec_template, "r"); - if (!$fp) { - return $this->raiseError("could not open RPM spec file template $spec_template: $php_errormsg"); - } - $info['package'] = $pf->getPackage(); - $info['version'] = $pf->getVersion(); - $info['release_license'] = $pf->getLicense(); - if ($pf->getDeps()) { - if ($pf->getPackagexmlVersion() == '1.0') { - $requires = $conflicts = array(); - foreach ($pf->getDeps() as $dep) { - if (isset($dep['optional']) && $dep['optional'] == 'yes') { - continue; - } - if ($dep['type'] != 'pkg') { - continue; - } - if (isset($dep['channel']) && $dep['channel'] != 'pear.php.net' && - $dep['channel'] != 'pecl.php.net') { - $chan = &$reg->getChannel($dep['channel']); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $package = strtoupper($chan->getAlias()) . '::' . $dep['name']; - } else { - $package = 'PEAR::' . $dep['name']; - } - $trans = array( - '>' => '>', - '<' => '<', - '>=' => '>=', - '<=' => '<=', - '=' => '=', - 'gt' => '>', - 'lt' => '<', - 'ge' => '>=', - 'le' => '<=', - 'eq' => '=', - ); - if ($dep['rel'] == 'has') { - $requires[] = $package; - } elseif ($dep['rel'] == 'not') { - $conflicts[] = $package; - } elseif ($dep['rel'] == 'ne') { - $conflicts[] = $package . ' = ' . $dep['version']; - } elseif (isset($trans[$dep['rel']])) { - $requires[] = $package . ' ' . $trans[$dep['rel']] . ' ' . $dep['version']; - } - } - if (count($requires)) { - $info['extra_headers'] .= 'Requires: ' . implode(', ', $requires) . "\n"; - } - if (count($conflicts)) { - $info['extra_headers'] .= 'Conflicts: ' . implode(', ', $conflicts) . "\n"; - } - } else { - $info['package2xml'] = '2'; // tell the spec to use package2.xml - $requires = $conflicts = array(); - $deps = $pf->getDeps(true); - if (isset($deps['required']['package'])) { - if (!isset($deps['required']['package'][0])) { - $deps['required']['package'] = array($deps['required']['package']); - } - foreach ($deps['required']['package'] as $dep) { - if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { - $chan = &$reg->getChannel($dep['channel']); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $package = strtoupper($chan->getAlias()) . '::' . $dep['name']; - } else { - $package = 'PEAR::' . $dep['name']; - } - if (isset($dep['conflicts']) && (isset($dep['min']) || - isset($dep['max']))) { - $deprange = array(); - if (isset($dep['min'])) { - $deprange[] = array($dep['min'],'>='); - } - if (isset($dep['max'])) { - $deprange[] = array($dep['max'], '<='); - } - if (isset($dep['exclude'])) { - if (!is_array($dep['exclude']) || - !isset($dep['exclude'][0])) { - $dep['exclude'] = array($dep['exclude']); - } - if (count($deprange)) { - $excl = $dep['exclude']; - // change >= to > if excluding the min version - // change <= to < if excluding the max version - for($i = 0; $i < count($excl); $i++) { - if (isset($deprange[0]) && - $excl[$i] == $deprange[0][0]) { - $deprange[0][1] = '<'; - unset($dep['exclude'][$i]); - } - if (isset($deprange[1]) && - $excl[$i] == $deprange[1][0]) { - $deprange[1][1] = '>'; - unset($dep['exclude'][$i]); - } - } - } - if (count($dep['exclude'])) { - $dep['exclude'] = array_values($dep['exclude']); - $newdeprange = array(); - // remove excludes that are outside the existing range - for ($i = 0; $i < count($dep['exclude']); $i++) { - if ($dep['exclude'][$i] < $dep['min'] || - $dep['exclude'][$i] > $dep['max']) { - unset($dep['exclude'][$i]); - } - } - $dep['exclude'] = array_values($dep['exclude']); - usort($dep['exclude'], 'version_compare'); - // take the remaining excludes and - // split the dependency into sub-ranges - $lastmin = $deprange[0]; - for ($i = 0; $i < count($dep['exclude']) - 1; $i++) { - $newdeprange[] = '(' . - $package . " {$lastmin[1]} {$lastmin[0]} and " . - $package . ' < ' . $dep['exclude'][$i] . ')'; - $lastmin = array($dep['exclude'][$i], '>'); - } - if (isset($dep['max'])) { - $newdeprange[] = '(' . $package . - " {$lastmin[1]} {$lastmin[0]} and " . - $package . ' < ' . $dep['max'] . ')'; - } - $conflicts[] = implode(' or ', $deprange); - } else { - $conflicts[] = $package . - " {$deprange[0][1]} {$deprange[0][0]}" . - (isset($deprange[1]) ? - " and $package {$deprange[1][1]} {$deprange[1][0]}" - : ''); - } - } - continue; - } - if (!isset($dep['min']) && !isset($dep['max']) && - !isset($dep['exclude'])) { - if (isset($dep['conflicts'])) { - $conflicts[] = $package; - } else { - $requires[] = $package; - } - } else { - if (isset($dep['min'])) { - $requires[] = $package . ' >= ' . $dep['min']; - } - if (isset($dep['max'])) { - $requires[] = $package . ' <= ' . $dep['max']; - } - if (isset($dep['exclude'])) { - $ex = $dep['exclude']; - if (!is_array($ex)) { - $ex = array($ex); - } - foreach ($ex as $ver) { - $conflicts[] = $package . ' = ' . $ver; - } - } - } - } - require_once 'Archive/Tar.php'; - $tar = new Archive_Tar($pf->getArchiveFile()); - $tar->pushErrorHandling(PEAR_ERROR_RETURN); - $a = $tar->extractInString('package2.xml'); - $tar->popErrorHandling(); - if ($a === null || PEAR::isError($a)) { - $info['package2xml'] = ''; - // this doesn't have a package.xml version 1.0 - $requires[] = 'PEAR::PEAR >= ' . - $deps['required']['pearinstaller']['min']; - } - if (count($requires)) { - $info['extra_headers'] .= 'Requires: ' . implode(', ', $requires) . "\n"; - } - if (count($conflicts)) { - $info['extra_headers'] .= 'Conflicts: ' . implode(', ', $conflicts) . "\n"; - } - } - } - } - - // remove the trailing newline - $info['extra_headers'] = trim($info['extra_headers']); - if (function_exists('file_get_contents')) { - fclose($fp); - $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', - file_get_contents($spec_template)); - } else { - $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', - fread($fp, filesize($spec_template))); - fclose($fp); - } - $spec_file = "$info[rpm_package]-$info[version].spec"; - $wp = fopen($spec_file, "wb"); - if (!$wp) { - return $this->raiseError("could not write RPM spec file $spec_file: $php_errormsg"); - } - fwrite($wp, $spec_contents); - fclose($wp); - $this->ui->outputData("Wrote RPM spec file $spec_file", $command); - return true; }
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Command/Package.php?r1=1.119&r2=1.120&diff_format=u Index: pear-core/PEAR/Command/Package.php diff -u pear-core/PEAR/Command/Package.php:1.119 pear-core/PEAR/Command/Package.php:1.120 --- pear-core/PEAR/Command/Package.php:1.119 Thu Mar 2 18:14:13 2006 +++ pear-core/PEAR/Command/Package.php Sat Mar 25 20:53:26 2006 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.119 2006/03/02 18:14:13 cellog Exp $ + * @version CVS: $Id: Package.php,v 1.120 2006/03/25 20:53:26 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -737,7 +737,10 @@ function &getCommandPackaging(&$ui, &$config) { if (!class_exists('PEAR_Command_Packaging')) { - @include_once 'PEAR/Command/Packaging.php'; + if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) { + fclose($fp); + include_once 'PEAR/Command/Packaging.php'; + } } if (class_exists('PEAR_Command_Packaging')) { @@ -752,8 +755,6 @@ function doMakeRPM($command, $options, $params) { - require_once 'System.php'; - require_once 'Archive/Tar.php'; // Check to see if PEAR_Command_Packaging is installed, and // transparently switch to use the "make-rpm-spec" command from it @@ -765,352 +766,10 @@ 'newer "make-rpm-spec" command instead'); return $packaging_cmd->run('make-rpm-spec', $options, $params); } else { - $this->ui->outputData('WARNING: "pear makerpm" is now deprecated; an '. + $this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '. 'improved version is available via "pear make-rpm-spec", which '. 'is available by installing PEAR_Command_Packaging'); } - - if (sizeof($params) != 1) { - return $this->raiseError("bad parameter(s), try \"help $command\""); - } - if (!file_exists($params[0])) { - return $this->raiseError("file does not exist: $params[0]"); - } - $reg = &$this->config->getRegistry(); - $pkg = &$this->getPackageFile($this->config, $this->_debug); - $pf = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); - if (PEAR::isError($pf)) { - $u = $pf->getUserinfo(); - if (is_array($u)) { - foreach ($u as $err) { - if (is_array($err)) { - $err = $err['message']; - } - $this->ui->outputData($err); - } - } - return $this->raiseError("$params[0] is not a valid package"); - } - $tmpdir = System::mktemp(array('-d', 'pear2rpm')); - $instroot = System::mktemp(array('-d', 'pear2rpm')); - $tmp = $this->config->get('verbose'); - $this->config->set('verbose', 0); - $installer = $this->getInstaller($this->ui); - require_once 'PEAR/Downloader/Package.php'; - $pack = new PEAR_Downloader_Package($installer); - $pack->setPackageFile($pf); - $params[0] = &$pack; - $installer->setOptions(array('installroot' => $instroot, - 'nodeps' => true, 'soft' => true)); - $installer->setDownloadedPackages($params); - $info = $installer->install($params[0], - array('installroot' => $instroot, - 'nodeps' => true, 'soft' => true)); - $pkgdir = $pf->getPackage() . '-' . $pf->getVersion(); - $info['rpm_xml_dir'] = '/var/lib/pear'; - $this->config->set('verbose', $tmp); - if (isset($options['spec-template'])) { - $spec_template = $options['spec-template']; - } else { - $spec_template = '@DATA-DIR@/PEAR/template.spec'; - } - $info['possible_channel'] = ''; - $info['extra_config'] = ''; - if (isset($options['rpm-pkgname'])) { - $rpm_pkgname_format = $options['rpm-pkgname']; - } else { - if ($pf->getChannel() == 'pear.php.net' || $pf->getChannel() == 'pecl.php.net') { - $alias = 'PEAR'; - } else { - $chan = &$reg->getChannel($pf->getChannel()); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $alias = $chan->getAlias(); - $alias = strtoupper($alias); - $info['possible_channel'] = $pf->getChannel() . '/'; - } - $rpm_pkgname_format = $alias . '::%s'; - } - - $info['extra_headers'] = ''; - $info['doc_files'] = ''; - $info['files'] = ''; - $info['package2xml'] = ''; - $info['rpm_package'] = sprintf($rpm_pkgname_format, $pf->getPackage()); - $srcfiles = 0; - foreach ($info['filelist'] as $name => $attr) { - if (!isset($attr['role'])) { - continue; - } - $name = preg_replace('![/:\\\\]!', '/', $name); - if ($attr['role'] == 'doc') { - $info['doc_files'] .= " $name"; - // Map role to the rpm vars - } else { - $c_prefix = '%{_libdir}/php/pear'; - switch ($attr['role']) { - case 'php': - $prefix = $c_prefix; - break; - case 'ext': - $prefix = '%{_libdir}/php'; - break; // XXX good place? - case 'src': - $srcfiles++; - $prefix = '%{_includedir}/php'; - break; // XXX good place? - case 'test': - $prefix = "$c_prefix/tests/" . $pf->getPackage(); - break; - case 'data': - $prefix = "$c_prefix/data/" . $pf->getPackage(); - break; - case 'script': - $prefix = '%{_bindir}'; - break; - default: // non-standard roles - $prefix = "$c_prefix/$attr[role]/" . $pf->getPackage(); - $info['extra_config'] .= - "\n -d {$attr[role]}_dir=$c_prefix/{$attr[role]} \\"; - $this->ui->outputData('WARNING: role "' . $attr['role'] . '" used, ' . - 'and will be installed in "' . $c_prefix . '/' . $attr['role'] . - '/' . $pf->getPackage() . - ' - hand-edit the final .spec if this is wrong', $command); - break; - } - $name = str_replace('\\', '/', $name); - $info['files'] .= "$prefix/$name\n"; - } - } - if ($srcfiles > 0) { - require_once 'OS/Guess.php'; - $os = new OS_Guess; - $arch = $os->getCpu(); - } else { - $arch = 'noarch'; - } - $cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir', - 'bin_dir', 'data_dir', 'test_dir'); - foreach ($cfg as $k) { - if ($k == 'master_server') { - $chan = $reg->getChannel($pf->getChannel()); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $info[$k] = $chan->getServer(); - continue; - } - $info[$k] = $this->config->get($k); - } - $info['arch'] = $arch; - $fp = @fopen($spec_template, "r"); - if (!$fp) { - return $this->raiseError("could not open RPM spec file template $spec_template: $php_errormsg"); - } - $info['package'] = $pf->getPackage(); - $info['version'] = $pf->getVersion(); - $info['release_license'] = $pf->getLicense(); - if ($pf->getDeps()) { - if ($pf->getPackagexmlVersion() == '1.0') { - $requires = $conflicts = array(); - foreach ($pf->getDeps() as $dep) { - if (isset($dep['optional']) && $dep['optional'] == 'yes') { - continue; - } - if ($dep['type'] != 'pkg') { - continue; - } - if (isset($dep['channel']) && $dep['channel'] != 'pear.php.net' && - $dep['channel'] != 'pecl.php.net') { - $chan = &$reg->getChannel($dep['channel']); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $package = strtoupper($chan->getAlias()) . '::' . $dep['name']; - } else { - $package = 'PEAR::' . $dep['name']; - } - $trans = array( - '>' => '>', - '<' => '<', - '>=' => '>=', - '<=' => '<=', - '=' => '=', - 'gt' => '>', - 'lt' => '<', - 'ge' => '>=', - 'le' => '<=', - 'eq' => '=', - ); - if ($dep['rel'] == 'has') { - $requires[] = $package; - } elseif ($dep['rel'] == 'not') { - $conflicts[] = $package; - } elseif ($dep['rel'] == 'ne') { - $conflicts[] = $package . ' = ' . $dep['version']; - } elseif (isset($trans[$dep['rel']])) { - $requires[] = $package . ' ' . $trans[$dep['rel']] . ' ' . $dep['version']; - } - } - if (count($requires)) { - $info['extra_headers'] .= 'Requires: ' . implode(', ', $requires) . "\n"; - } - if (count($conflicts)) { - $info['extra_headers'] .= 'Conflicts: ' . implode(', ', $conflicts) . "\n"; - } - } else { - $info['package2xml'] = '2'; // tell the spec to use package2.xml - $requires = $conflicts = array(); - $deps = $pf->getDeps(true); - if (isset($deps['required']['package'])) { - if (!isset($deps['required']['package'][0])) { - $deps['required']['package'] = array($deps['required']['package']); - } - foreach ($deps['required']['package'] as $dep) { - if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { - $chan = &$reg->getChannel($dep['channel']); - if (PEAR::isError($chan)) { - return $this->raiseError($chan); - } - $package = strtoupper($chan->getAlias()) . '::' . $dep['name']; - } else { - $package = 'PEAR::' . $dep['name']; - } - if (isset($dep['conflicts']) && (isset($dep['min']) || - isset($dep['max']))) { - $deprange = array(); - if (isset($dep['min'])) { - $deprange[] = array($dep['min'],'>='); - } - if (isset($dep['max'])) { - $deprange[] = array($dep['max'], '<='); - } - if (isset($dep['exclude'])) { - if (!is_array($dep['exclude']) || - !isset($dep['exclude'][0])) { - $dep['exclude'] = array($dep['exclude']); - } - if (count($deprange)) { - $excl = $dep['exclude']; - // change >= to > if excluding the min version - // change <= to < if excluding the max version - for($i = 0; $i < count($excl); $i++) { - if (isset($deprange[0]) && - $excl[$i] == $deprange[0][0]) { - $deprange[0][1] = '<'; - unset($dep['exclude'][$i]); - } - if (isset($deprange[1]) && - $excl[$i] == $deprange[1][0]) { - $deprange[1][1] = '>'; - unset($dep['exclude'][$i]); - } - } - } - if (count($dep['exclude'])) { - $dep['exclude'] = array_values($dep['exclude']); - $newdeprange = array(); - // remove excludes that are outside the existing range - for ($i = 0; $i < count($dep['exclude']); $i++) { - if ($dep['exclude'][$i] < $dep['min'] || - $dep['exclude'][$i] > $dep['max']) { - unset($dep['exclude'][$i]); - } - } - $dep['exclude'] = array_values($dep['exclude']); - usort($dep['exclude'], 'version_compare'); - // take the remaining excludes and - // split the dependency into sub-ranges - $lastmin = $deprange[0]; - for ($i = 0; $i < count($dep['exclude']) - 1; $i++) { - $newdeprange[] = '(' . - $package . " {$lastmin[1]} {$lastmin[0]} and " . - $package . ' < ' . $dep['exclude'][$i] . ')'; - $lastmin = array($dep['exclude'][$i], '>'); - } - if (isset($dep['max'])) { - $newdeprange[] = '(' . $package . - " {$lastmin[1]} {$lastmin[0]} and " . - $package . ' < ' . $dep['max'] . ')'; - } - $conflicts[] = implode(' or ', $deprange); - } else { - $conflicts[] = $package . - " {$deprange[0][1]} {$deprange[0][0]}" . - (isset($deprange[1]) ? - " and $package {$deprange[1][1]} {$deprange[1][0]}" - : ''); - } - } - continue; - } - if (!isset($dep['min']) && !isset($dep['max']) && - !isset($dep['exclude'])) { - if (isset($dep['conflicts'])) { - $conflicts[] = $package; - } else { - $requires[] = $package; - } - } else { - if (isset($dep['min'])) { - $requires[] = $package . ' >= ' . $dep['min']; - } - if (isset($dep['max'])) { - $requires[] = $package . ' <= ' . $dep['max']; - } - if (isset($dep['exclude'])) { - $ex = $dep['exclude']; - if (!is_array($ex)) { - $ex = array($ex); - } - foreach ($ex as $ver) { - $conflicts[] = $package . ' = ' . $ver; - } - } - } - } - require_once 'Archive/Tar.php'; - $tar = new Archive_Tar($pf->getArchiveFile()); - $tar->pushErrorHandling(PEAR_ERROR_RETURN); - $a = $tar->extractInString('package2.xml'); - $tar->popErrorHandling(); - if ($a === null || PEAR::isError($a)) { - $info['package2xml'] = ''; - // this doesn't have a package.xml version 1.0 - $requires[] = 'PEAR::PEAR >= ' . - $deps['required']['pearinstaller']['min']; - } - if (count($requires)) { - $info['extra_headers'] .= 'Requires: ' . implode(', ', $requires) . "\n"; - } - if (count($conflicts)) { - $info['extra_headers'] .= 'Conflicts: ' . implode(', ', $conflicts) . "\n"; - } - } - } - } - - // remove the trailing newline - $info['extra_headers'] = trim($info['extra_headers']); - if (function_exists('file_get_contents')) { - fclose($fp); - $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', - file_get_contents($spec_template)); - } else { - $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', - fread($fp, filesize($spec_template))); - fclose($fp); - } - $spec_file = "$info[rpm_package]-$info[version].spec"; - $wp = fopen($spec_file, "wb"); - if (!$wp) { - return $this->raiseError("could not write RPM spec file $spec_file: $php_errormsg"); - } - fwrite($wp, $spec_contents); - fclose($wp); - $this->ui->outputData("Wrote RPM spec file $spec_file", $command); - return true; }