当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Downloader_Package::setPackageFile方法代码示例

本文整理汇总了PHP中PEAR_Downloader_Package::setPackageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Downloader_Package::setPackageFile方法的具体用法?PHP PEAR_Downloader_Package::setPackageFile怎么用?PHP PEAR_Downloader_Package::setPackageFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR_Downloader_Package的用法示例。


在下文中一共展示了PEAR_Downloader_Package::setPackageFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validatePackage

 /**
  * validate a downloaded package against installed packages
  * 
  * As of PEAR 1.4.3, this will only validate
  *
  * @param array|PEAR_Downloader_Package|PEAR_PackageFile_v1|PEAR_PackageFile_v2
  *              $pkg package identifier (either
  *                   array('package' => blah, 'channel' => blah) or an array with
  *                   index 'info' referencing an object)
  * @param PEAR_Downloader $dl
  * @param array $params full list of packages to install
  * @return true|PEAR_Error
  */
 function validatePackage($pkg, &$dl, $params = array())
 {
     if (is_array($pkg) && isset($pkg['info'])) {
         $deps = $this->_dependencydb->getDependentPackageDependencies($pkg['info']);
     } else {
         $deps = $this->_dependencydb->getDependentPackageDependencies($pkg);
     }
     $fail = false;
     if ($deps) {
         if (!class_exists('PEAR_Downloader_Package')) {
             require_once 'PEAR/Downloader/Package.php';
         }
         $dp = new PEAR_Downloader_Package($dl);
         if (is_object($pkg)) {
             $dp->setPackageFile($pkg);
         } else {
             $dp->setDownloadURL($pkg);
         }
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         foreach ($deps as $channel => $info) {
             foreach ($info as $package => $ds) {
                 foreach ($params as $packd) {
                     if (strtolower($packd->getPackage()) == strtolower($package) && $packd->getChannel() == $channel) {
                         $dl->log(3, 'skipping installed package check of "' . $this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . '", version "' . $packd->getVersion() . '" will be ' . 'downloaded and installed');
                         continue 2;
                         // jump to next package
                     }
                 }
                 foreach ($ds as $d) {
                     $checker = new PEAR_Dependency2($this->_config, $this->_options, array('channel' => $channel, 'package' => $package), $this->_state);
                     $dep = $d['dep'];
                     $required = $d['type'] == 'required';
                     $ret = $checker->_validatePackageDownload($dep, $required, array(&$dp));
                     if (is_array($ret)) {
                         $dl->log(0, $ret[0]);
                     } elseif (PEAR::isError($ret)) {
                         $dl->log(0, $ret->getMessage());
                         $fail = true;
                     }
                 }
             }
         }
         PEAR::popErrorHandling();
     }
     if ($fail) {
         return $this->raiseError('%s cannot be installed, conflicts with installed packages');
     }
     return true;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:62,代码来源:Dependency2.php

示例2: doMakeRPM

 function doMakeRPM($command, $options, $params)
 {
     require_once 'System.php';
     require_once 'Archive/Tar.php';
     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());
             $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?
                 // XXX good place?
                 case 'src':
                     $srcfiles++;
                     $prefix = '%{_includedir}/php';
                     break;
                     // XXX good place?
                 // 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;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:101,代码来源:Package.php

示例3: foreach

 /**
  * Set the output macros based on a package source
  */
 function _doMakeRPMFromPackage($source_file, $command, $options, $params)
 {
     // Merge the "core" output macros with those for packages only
     $this->_output += $this->_output_package;
     // Set the name of the template spec file to use by default
     $this->_template_spec_name = 'template.spec';
     // Create a PEAR_PackageFile object and fill it with info from the
     // source package
     $reg =& $this->config->getRegistry();
     $pkg =& $this->getPackageFile($this->config, $this->_debug);
     $pf =& $pkg->fromAnyFile($source_file, 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("{$source_file} is not a valid package");
     }
     // Install the package into a temporary directory
     $tmpdir = $this->makeTempDir();
     $instroot = $this->makeTempDir();
     // Save a channel object for the channel our package is part of
     // We will need this later to stick back into the temporary
     // installation directory
     $chan = $reg->getChannel($pf->getChannel(), true);
     if (PEAR::isError($chan)) {
         $this->ui->outputData($chan->getMessage());
         return $this->raiseError("Could not find channel data for channel '" . $pf->getChannel() . " - you need to channel-discover or channel-add " . "the channel before building packages based on it.");
     }
     // Set the role prefixes - package won't actually be installed here
     // but we can pull the final install paths back out later to put into
     // our spec
     foreach ($this->_file_prefixes as $role => $prefix) {
         // if role is 'script' the corresponding option is bin_dir
         if ($role == 'script') {
             $role = 'bin';
         }
         // save the original config options to restore later
         $orig_config_options["{$role}_dir"] = $this->config->get("{$role}_dir");
         // Substitute the package name into the file prefix
         $prefix = str_replace('%s', $pf->getPackage(), $prefix);
         // Set the temporary role prefix for installation
         $this->config->set("{$role}_dir", $prefix);
     }
     // Construct a fake registry inside the ultimate destination
     // temporary directory, and load the necessary channel into it
     $regdir = $instroot . $this->config->get('php_dir');
     $fakereg = new PEAR_Registry($regdir);
     $fakereg->addChannel($chan);
     $tmp = $this->config->get('verbose');
     $this->config->set('verbose', 0);
     $installer = $this->getInstaller($this->ui);
     $installer->setConfig($this->config);
     require_once 'PEAR/Downloader/Package.php';
     $pack = new PEAR_Downloader_Package($installer);
     $pack->setPackageFile($pf);
     $params[0] =& $pack;
     $installer->setOptions(array('packagingroot' => $instroot, 'nodeps' => true, 'soft' => true));
     $installer->setDownloadedPackages($params);
     // Don't change $params[0] below to $source_file - it's not the same
     // any more (see $params[0] a few lines above here)
     $package_info = $installer->install($params[0], array('packagingroot' => $instroot, 'nodeps' => true, 'soft' => true));
     if (PEAR::isError($package_info)) {
         $this->ui->outputData($package_info->getMessage());
         return $this->raiseError('Failed to do a temporary installation of the package');
     }
     // Restore the original config options
     foreach ($orig_config_options as $key => $val) {
         $this->config->set($key, $val);
     }
     // Restore the original config verbosity
     $this->config->set('verbose', $tmp);
     // Set up some of the basic macros
     $this->_output['rpm_package'] = $this->_getRPMName($pf->getPackage(), $pf->getChannel(), null, 'pkg');
     $this->_output['description'] = wordwrap($package_info['description']);
     $this->_output['summary'] = trim($package_info['summary']);
     $this->_output['possible_channel'] = $pf->getChannel();
     $this->_output['channel_alias'] = $this->_getChannelAlias($pf->getPackage(), $pf->getChannel());
     $this->_output['package'] = $pf->getPackage();
     $this->_output['version'] = $pf->getVersion();
     $this->_output['release_license'] = $pf->getLicense();
     $this->_output['release_state'] = $pf->getState();
     // Remove trailing dots from summaries
     if (substr($this->_output['summary'], -1) == '.') {
         $this->_output['summary'] = substr($this->_output['summary'], 0, -1);
     }
     // Figure out the master server for the package's channel
     $chan = $reg->getChannel($pf->getChannel());
     $this->_output['master_server'] = $chan->getServer();
     // Put some standard PEAR config options into the output macros. These
     // will probably be deprecated in future
     $cfg = array('php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'test_dir');
//.........这里部分代码省略.........
开发者ID:cmooony,项目名称:d4d-studio,代码行数:101,代码来源:Packaging.php


注:本文中的PEAR_Downloader_Package::setPackageFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。