本文整理汇总了PHP中Archive_Tar::extractInString方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::extractInString方法的具体用法?PHP Archive_Tar::extractInString怎么用?PHP Archive_Tar::extractInString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive_Tar
的用法示例。
在下文中一共展示了Archive_Tar::extractInString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
function testBz2()
{
$oTar = new Archive_Tar($this->sFileBz2, 'bz2');
$sExpected = $oTar->extractInString('Beautifier.php');
unset($oTar);
$sActual = file_get_contents('tarz://' . $this->sFileBz2 . "#Beautifier.php");
$this->assertTrue($sExpected == $sActual, 'file_get_contents');
}
示例2: __construct
/**
* @param string $tar - path to tar file
*/
public function __construct($_tar)
{
$tar = new Archive_Tar($_tar);
$this->package_xml = $tar->extractInString('package.xml');
unset($tar);
$this->parse_package();
$files = $this->files();
// $xml = simplexml_load_string(str_replace('xmlns=', 'xmlns:default=', $this->package_xml));
// $namespaces = $xml->getNamespaces(true);
// $xml->registerXPathNamespace('default', 'default');
}
示例3: installFromFile
public function installFromFile($file)
{
require_once "/var/www/localhost/htdocs/papyrine/libraries/PEAR.php";
require_once "/var/www/localhost/htdocs/papyrine/libraries/Archive_Tar.php";
$tar = new Archive_Tar($file, 'bz2');
$about = $tar->extractInString("about.xml");
$xml = simplexml_load_string($about);
$dir = "/var/www/localhost/htdocs/papyrine/data/plugins/tmp/" . $xml->id . "/";
if (!is_dir($dir)) {
$tar->extract($dir);
}
$this->installFromDirectory($dir);
}
示例4: uploadPackage
public function uploadPackage()
{
$tgz = $this->getValue('tgz_file');
$svn = $this->getValue('svn_url');
$gitUrl = $this->getValue('git_url');
$gitCommit = $this->getValue('git_commit');
$memberId = sfContext::getInstance()->getUser()->getMemberId();
$pear = opPluginChannelServerToolkit::registerPearChannel($this->getChannel());
if ($tgz) {
require_once 'Archive/Tar.php';
$info = $pear->infoFromTgzFile($tgz->getTempName());
if ($info instanceof PEAR_Error) {
throw new RuntimeException($info->getMessage());
}
$tar = new Archive_Tar($tgz->getTempName());
$xml = '';
foreach ($tar->listContent() as $file) {
if ('package.xml' === $file['filename']) {
$xml = $tar->extractInString($file['filename']);
}
}
$file = new File();
$file->setFromValidatedFile($tgz);
$file->save();
$this->uploadToS3($file);
$release = Doctrine::getTable('PluginRelease')->createByPackageInfo($info, $file, $memberId, $xml);
$this->package->PluginRelease[] = $release;
$this->package->save();
} elseif ($svn) {
$dir = $this->importFromSvn($svn);
$this->importSCMFile($pear, $memberId, $dir);
} elseif ($gitUrl && $gitCommit) {
$dir = $this->importFromGit($gitUrl, $gitCommit);
$this->importSCMFile($pear, $memberId, $dir);
}
}
示例5: getTarContent
function getTarContent($file)
{
if (!preg_match("/\\.(tar|cbt)\$/", strtolower($file))) {
return "";
}
$tar = new Archive_Tar($file);
$content = "";
$entries = $tar->listContent();
if (count($entries)) {
$files = array();
foreach ($entries as $entry) {
$name = $entry['filename'];
if (preg_match("/\\.(png|jpeg|jpg|jpe|gif)\$/", strtolower($name))) {
$files[] = $name;
}
}
if (count($files)) {
sort($files);
$content = $tar->extractInString($files[0]);
}
}
unset($tar);
return $content;
}
示例6: substr
function get_icon()
{
global $WI;
$src = WIdirWeb . "/ipkfile.php?pack=" . $WI->settings['icon_pack'] . '&icon=' . $this->decoded_metar['icon'] . '&type=' . $WI->icon_packs[$WI->settings['icon_pack']]['formats']['format'][$WI->settings['icon_ext']];
// Change the $before tag for this element ... append
// class="wicon" to it.
$wicon_before = $this->before;
if (substr($wicon_before, -1, 1) == '>') {
$wicon_before = substr($wicon_before, 0, strlen($wicon_before) - 1) . ' class="wicon">';
}
$WI->status[] = $WI->gmtime() . " wicon_before is " . htmlentities($wicon_before);
// If the user is using IE5 or IE6 and we're using PNG images, do an IE hack because IE is retarded.
if (preg_match('/msie\\s(5\\.[5-9]|6\\.[0-9]*).*(win)/i', $_SERVER['HTTP_USER_AGENT']) && strtolower(substr($src, -4)) == '.png') {
// Get image Size (requires GD support in PHP)
if (function_exists('getimagesize')) {
$tar = new Archive_Tar(WIicondir . $WI->settings['icon_pack'] . '.ipk');
$img = $tar->extractInString($this->decoded_metar['icon'] . $WI->icon_packs[$WI->settings['icon_pack']]['formats']['format'][$WI->settings['icon_ext']]);
// Should never be empty in a properly designed image pack.
if (!empty($img)) {
$width = imagesx($img);
$height = imagesy($img);
}
} else {
$width = 80;
$height = 80;
}
return $wicon_before . '<span style="height:' . $height . 'px; width:' . $width . 'px; display:inline-block; position:relative; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' . $src . '\', sizingMethod=\'scale\');" title="' . $this->get_status() . '"></span>' . $this->after;
} else {
return $wicon_before . '<img src="' . $src . '"' . $style . ' title="' . $this->get_status() . '" alt="' . $this->get_status() . '" />' . $this->after;
}
}
示例7: dirname
<?php
define('WIdir', dirname(__FILE__));
define('WIicondir', WIdir . '/icons/');
require_once 'libraries/Tar.php';
$tar = new Archive_Tar(WIicondir . '/' . $_GET['pack'] . '.ipk');
$image = $tar->extractInString($_GET['icon'] . '.' . $_GET['type']);
header('content-type: image/' . $_GET['type']);
echo $image;
示例8: doMakeRPM
//.........这里部分代码省略.........
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;
}
示例9: array
$translations_array = array();
if (!$booleans['only_archive']) {
foreach ($found_modules as $module => $top_module) {
if ((!array_key_exists($module, $templates) || !is_array($templates[$module])) && (!array_key_exists($module, $configs) || !$configs[$module])) {
I2CE::raiseError("No translatable templates or configs for {$module}");
continue;
}
$launchpad_name = launchpad($module);
if (!$booleans['read_po_files']) {
$mo_file = $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR . $launchpad_name . '.mo';
if (!in_array($mo_file, $tar_files)) {
continue;
}
$contents = false;
I2CE::raiseError("Extracting {$mo_file}");
$contents = $tar->extractInString($mo_file);
if (!$contents) {
I2CE::raiseError("Bad extraction for {$mo_file}");
continue;
}
$mo_resource = fopen("php://temp", 'r+');
fputs($mo_resource, $contents);
rewind($mo_resource);
$translations_array[$module] = loadMO($mo_resource);
} else {
$po_file = $templates_dir . launchpad($module) . DIRECTORY_SEPARATOR . $locale . '.po';
if (!is_readable($po_file)) {
I2CE::raiseError($po_file . " is not readable for {$module}");
continue;
}
$t_translations = loadPOT($po_file);
示例10: extract
/**
*
* Extract theme from archive
* @throws Exception
* @param string $source_path archive path
*
* @return waTheme
*/
public static function extract($source_path)
{
static $white_list = array('js', 'css', 'html', 'txt', 'png', 'jpg', 'jpeg', 'jpe', 'tiff', 'bmp', 'gif', 'svg', 'htc', 'cur', 'ttf', 'eot', 'otf', 'woff', '');
$autoload = waAutoload::getInstance();
$autoload->add('Archive_Tar', 'wa-installer/lib/vendors/PEAR/Tar.php');
$autoload->add('PEAR', 'wa-installer/lib/vendors/PEAR/PEAR.php');
$instance = null;
if (class_exists('Archive_Tar')) {
try {
$tar_object = new Archive_Tar($source_path, true);
$files = $tar_object->listContent();
if (!$files) {
self::throwArchiveException('INVALID_OR_EMPTY_ARCHIVE');
}
//search theme info
$info = false;
$pattern = "@(/|^)" . wa_make_pattern(self::PATH, '@') . "\$@";
foreach ($files as $file) {
if (preg_match($pattern, $file['filename'])) {
$info = $tar_object->extractInString($file['filename']);
break;
}
}
if (!$info) {
self::throwThemeException('MISSING_THEME_XML');
}
$xml = @simplexml_load_string($info);
$app_id = (string) $xml['app'];
$id = (string) $xml['id'];
if (!$app_id) {
self::throwThemeException('MISSING_APP_ID');
} elseif (!$id) {
self::throwThemeException('MISSING_THEME_ID');
} else {
if ($app_info = wa()->getAppInfo($app_id)) {
//TODO check theme support
if ($parent_theme = (string) $xml['parent_theme_id']) {
$parent_theme = explode(':', $parent_theme, 2);
try {
if (count($parent_theme) == 2) {
new waTheme($parent_theme[1], $parent_theme[0]);
} else {
new waTheme($parent_theme[0], $app_id);
}
} catch (Exception $ex) {
self::throwThemeException('PARENT_THEME_NOT_FOUND', $ex->getMessage());
}
}
} else {
$message = sprintf(_w('Theme “%s” is for app “%s”, which is not installed in your Webasyst. Install the app, and upload theme once again.'), $id, $app_id);
throw new waException($message);
}
}
$wa_path = "wa-apps/{$app_id}/themes/{$id}";
$wa_pattern = wa_make_pattern($wa_path, '@');
$file = reset($files);
if (preg_match("@^{$wa_pattern}(/|\$)@", $file['filename'])) {
$extract_path = $wa_path;
$extract_pattern = $wa_pattern;
} else {
$extract_path = $id;
$extract_pattern = wa_make_pattern($id, '@');
if (!preg_match("@^{$extract_pattern}(/|\$)@", $file['filename'])) {
$extract_path = '';
$extract_pattern = false;
}
}
if ($extract_path) {
$extract_path = trim($extract_path, '/') . '/';
}
$missed_files = array();
foreach ($xml->xpath('/theme/files/file') as $theme_file) {
$path = (string) $theme_file['path'];
$parent = intval((string) $theme_file['parent']);
if (!in_array(pathinfo($theme_file['path'], PATHINFO_EXTENSION), array('html', 'js', 'css'))) {
self::throwThemeException('UNEXPECTED_EDITABLE_FILE_TYPE', $theme_file['path']);
}
if (!$parent) {
$missed_files[$path] = $extract_path . $path;
}
}
#angry check
foreach ($files as $file) {
if ($extract_pattern && !preg_match("@^{$extract_pattern}(/|\$)@", $file['filename'])) {
self::throwThemeException('UNEXPECTED_FILE_PATH', "{$file['filename']}. Expect files in [{$extract_path}] directory");
} elseif (preg_match('@\\.(php\\d*|pl)@', $file['filename'], $matches)) {
if (preg_match('@(^|/)build\\.php$@', $file['filename'])) {
$file['content'] = $tar_object->extractInString($file['filename']);
if (!preg_match('@^<\\?php[\\s\\n]+return[\\s\\n]+\\d+;[\\s\\n]*$@', $file['content'])) {
self::throwThemeException('UNEXPECTED_FILE_CONTENT', $file['filename']);
}
} else {
//.........这里部分代码省略.........
示例11: _extractAndParse
/**
* Unpacks the downloaded timezone database and parses all files.
*/
protected function _extractAndParse()
{
if (isset($this->_params['cache'])) {
$result = @unserialize($this->_params['cache']->get('horde_timezone', $this->_params['cachettl']));
if ($result) {
$this->_zones = $result['zones'];
$this->_rules = $result['rules'];
$this->_links = $result['links'];
return;
}
}
if (!$this->_tmpfile) {
$this->_download();
}
$tar = new Archive_Tar($this->_tmpfile);
foreach ($tar->listContent() as $file) {
if ($file['typeflag'] != 0) {
continue;
}
$this->_parse($tar->extractInString($file['filename']));
}
if (isset($this->_params['cache'])) {
$this->_params['cache']->set('horde_timezone', serialize(array('zones' => $this->_zones, 'rules' => $this->_rules, 'links' => $this->_links)), $this->_params['cachettl']);
}
}
示例12: plug_upload
function plug_upload($idclient = '0', $override = false)
{
global $rep, $cfg_cms, $sess, $s_upload, $db, $cms_db;
if (is_array($s_upload) && $override) {
$tmp_file = $s_upload;
$returncode = $s_upload['returncode'];
if ($sess->is_registered('s_upload')) {
$sess->unregister('s_upload');
}
} else {
$tmp_file = lib_get_upload('plug_upload_file');
}
//Es wurde keine Datei hochgeladen
if (!is_array($tmp_file) || $tmp_file['error'] == '-1' || $tmp_file['error'] == '-2') {
if ($tmp_file['code'] >= 1) {
//if (lib_test_safemode()) return array('1801', false);
if ($tmp_file['code'] == 1) {
return array('0708', false);
}
if ($tmp_file['code'] == 2) {
return array('0709', false);
}
if ($tmp_file['code'] == 3) {
return array('0710', false);
}
if ($tmp_file['code'] == 4) {
return array('0711', false);
}
} else {
return array('1604', false);
}
}
if (!($file_content = $rep->_file($tmp_file['copy']))) {
lib_delete_file($tmp_file['copy']);
if (lib_test_safemode()) {
return array('1801', false);
} else {
return array('1600', false);
}
}
require_once "Archive/Tar.php";
if (false === ($tar = new Archive_Tar($tmp_file['copy']))) {
$return = '1615';
if ($tar->_error_message != '') {
$error = $tar->_error_message;
}
return array($return, $error);
} elseif ($tar == '-1') {
return array('1621', false);
}
$tmp_plugin = $tar->listContent();
if ($tmp_plugin[0]['filename'] == '' || $tmp_plugin[0]['typeflag'] != 5) {
return array('1604', false);
}
$name = substr($tmp_plugin[0]['filename'], -1) == '/' ? substr($tmp_plugin[0]['filename'], 0, -1) : $tmp_plugin[0]['filename'];
$tmp_cmsplug = $tar->extractInString($name . '/' . $name . '.cmsplug');
//todo: 2remove
if (empty($tmp_cmsplug)) {
$tmp_cmsplug = $tar->extractInString($name . '/' . $name . '.dediplug');
}
list($idplug, $xml_array) = $rep->plug_import($tmp_cmsplug, $idclient, $override);
if ($idplug == '-1' || $idplug == '-2') {
$s_upload = $tmp_file;
$s_upload['returncode'] = $idplug;
$s_upload['plugversion'] = $xml_array['version'];
$s_upload['plugname'] = $xml_array['name'];
list($type, $rid, $uid) = explode(":", $xml_array['repository_id']);
$s_upload['plugrepid'] = $type . ':' . $rid;
$sess->register('s_upload');
return array('1617', false);
} elseif ($idplug == '-3') {
$s_upload = $tmp_file;
$s_upload['returncode'] = $idplug;
$s_upload['plugversion'] = $xml_array['version'];
$s_upload['plugname'] = $xml_array['name'];
list($type, $rid, $uid) = explode(":", $xml_array['repository_id']);
$s_upload['plugrepid'] = $type . ':' . $rid;
$sess->register('s_upload');
return array('1619', false);
} elseif ($idplug == '-4') {
lib_delete_file($tmp_file['copy']);
return array('1603', false);
} elseif (!$idplug || !is_array($xml_array)) {
lib_delete_file($tmp_file['copy']);
return array('1600', false);
}
if (!$tar->extract($cfg_cms['cms_path'] . 'plugins/')) {
// check error
if ($tar->_error_message != '') {
$error = $tar->_error_message;
}
// force delete the plugin
plug_delete($idplug, $idclient);
return array('1615', $error);
}
// get the new Plugin data
$plugin = $rep->plug_data($idplug, $idclient);
// Event
fire_event('plug_upload', array('idplug' => $idplug, 'name' => $plugin['name']));
if ($override && $returncode == '-1' || $returncode == '-2') {
//.........这里部分代码省略.........
示例13: readPackageFile
public static function readPackageFile($file)
{
// Sanity
if (!file_exists($file) || !is_file($file) || strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'tar') {
throw new Engine_Package_Exception('File does not exist or is not a tar file');
}
self::_loadArchiveClass();
// Create archive object
$archive = new Archive_Tar($file);
// List files
$fileList = $archive->listContent();
if (empty($fileList)) {
throw new Engine_Package_Exception('Unable to open archive');
}
// Check for root package file
$rootPackageFile = null;
foreach ($fileList as $arFile) {
if ($arFile['filename'] == 'package.json') {
$rootPackageFile = $arFile['filename'];
break;
}
}
if (null === $rootPackageFile) {
throw new Engine_Package_Exception('Root package file not found.');
}
// Start building package stuff
$packageFileObject = new Engine_Package_Manifest();
$packageFileObject->fromString($archive->extractInString($rootPackageFile), 'json');
return $packageFileObject;
}
示例14: generatePEARInfos
/**
* This method opens and validates the uploaded PEAR package
* and assembles the content of the package file itself, the
* dependencies and the release notes.
*
* @param Faett_Package_Model_Link $link The link with the PEAR package file
* @return void
*/
public function generatePEARInfos(Faett_Package_Model_Link $link)
{
// initialize the PEAR service implementation
$service = Faett_Core_Factory::get(Mage::getBaseDir());
// initialize the PEAR_PackageFile_v2 instance
$pf = $service->packageFile($packageFile = Faett_Package_Model_Link::getBasePath() . $link->getLinkFile());
// initialize the archive
$tar = new Archive_Tar($packageFile);
// try to load the content of the package2.xml file
$contents = $tar->extractInString('package2.xml');
// if not available, try to load from package.xml file
if (!$contents) {
$contents = $tar->extractInString('package.xml');
}
// load the data to assemble the link with
$link->setPackageFile($contents);
$link->setPackageName($pf->getName());
$link->setPackageSize(filesize($packageFile));
$link->setDependencies(serialize($pf->getDependencies()));
$link->setState($pf->getState());
$link->setVersion($pf->getVersion());
$link->setReleaseDate($pf->getDate());
$link->setLicence($pf->getLicense());
$link->setSummary($pf->getSummary());
$link->setDescription($pf->getDescription());
$link->setNotes($pf->getNotes());
// set the licence URI
if (is_array($loc = $pf->getLicenseLocation())) {
if (array_key_exists('uri', $loc)) {
$link->setLicenceUri($loc['uri']);
} elseif (array_key_exists('filesource', $loc)) {
$link->setLicenceUri($loc['filesource']);
}
}
// save the completed link
$link->save();
}
示例15: array
//.........这里部分代码省略.........
continue;
}
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] = $package;
}
} else {
if (isset($dep['min'])) {
$requires[$package] = $package . ' >= ' . $dep['min'];
}
if (isset($dep['max'])) {
$requires[$package] = $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)) {
$this->_output['package2xml'] = '';
// this doesn't have a package.xml version 1.0
$requires[$this->_output['pear_rpm_name']] = $this->_output['pear_rpm_name'] . ' >= ' . $deps['required']['pearinstaller']['min'];
}
if (count($requires)) {
$this->_output['extra_headers'] .= $this->_formatRpmHeader('Requires', implode(', ', $requires)) . "\n";
}
if (count($conflicts)) {
$this->_output['extra_headers'] .= $this->_formatRpmHeader('Conflicts', implode(', ', $conflicts)) . "\n";
}
}
}
}