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


PHP PEAR_Installer::install方法代码示例

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


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

示例1: doMakeRPM

 function doMakeRPM($command, $options, $params)
 {
     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']}");
     }
     include_once "Archive/Tar.php";
     include_once "PEAR/Installer.php";
     include_once "System.php";
     $tar = new Archive_Tar($params[0]);
     $tmpdir = System::mktemp('-d pear2rpm');
     $instroot = System::mktemp('-d pear2rpm');
     $tmp = $this->config->get('verbose');
     $this->config->set('verbose', 0);
     $installer = new PEAR_Installer($this->ui);
     $info = $installer->install($params[0], array('installroot' => $instroot, 'nodeps' => true));
     $pkgdir = "{$info['package']}-{$info['version']}";
     $info['rpm_xml_dir'] = '/var/lib/pear';
     $this->config->set('verbose', $tmp);
     if (!$tar->extractList("package.xml", $tmpdir, $pkgdir)) {
         return $this->raiseError("failed to extract {$params['0']}");
     }
     if (!file_exists("{$tmpdir}/package.xml")) {
         return $this->raiseError("no package.xml found in {$params['0']}");
     }
     if (isset($options['spec-template'])) {
         $spec_template = $options['spec-template'];
     } else {
         $spec_template = $this->config->get('data_dir') . '/PEAR/template.spec';
     }
     if (isset($options['rpm-pkgname'])) {
         $rpm_pkgname_format = $options['rpm-pkgname'];
     } else {
         $rpm_pkgname_format = "PEAR::%s";
     }
     $info['extra_headers'] = '';
     $info['doc_files'] = '';
     $info['files'] = '';
     $info['rpm_package'] = sprintf($rpm_pkgname_format, $info['package']);
     $srcfiles = 0;
     foreach ($info['filelist'] as $name => $attr) {
         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/" . $info['package'];
                     break;
                 case 'data':
                     $prefix = "{$c_prefix}/data/" . $info['package'];
                     break;
                 case 'script':
                     $prefix = '%{_bindir}';
                     break;
             }
             $info['files'] .= "{$prefix}/{$name}\n";
         }
     }
     if ($srcfiles > 0) {
         include_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) {
         $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}");
     }
     $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);
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:Package.php

示例2: doInstallPlugin

 /**
  * Installs a plugin
  *
  * @see installPlugin()
  */
 protected function doInstallPlugin($plugin, $options = array())
 {
     $channel = isset($options['channel']) ? $options['channel'] : $this->environment->getConfig()->get('default_channel');
     $stability = isset($options['stability']) ? $options['stability'] : $this->environment->getConfig()->get('preferred_state', null, $channel);
     $version = isset($options['version']) ? $options['version'] : null;
     $isPackage = true;
     if (0 === strpos($plugin, 'http://') || file_exists($plugin)) {
         if (0 === strpos($plugin, 'http://plugins.symfony-project.')) {
             throw new sfPluginException("You try to install a symfony 1.0 plugin.\nPlease read the help message of this task to know how to install a plugin for the current version of symfony.");
         }
         $download = $plugin;
         $isPackage = false;
     } else {
         if (false !== strpos($plugin, '/')) {
             list($channel, $plugin) = explode('/', $plugin);
         }
     }
     $this->dispatcher->notify(new sfEvent($this, 'plugin.pre_install', array('channel' => $channel, 'plugin' => $plugin, 'is_package' => $isPackage)));
     if ($isPackage) {
         $this->environment->getRest()->setChannel($channel);
         if (!preg_match(PEAR_COMMON_PACKAGE_NAME_PREG, $plugin)) {
             throw new sfPluginException(sprintf('Plugin name "%s" is not a valid package name', $plugin));
         }
         if (!$version) {
             $version = $this->getPluginVersion($plugin, $stability);
         } else {
             if (!$this->isPluginCompatible($plugin, $version)) {
                 throw new sfPluginDependencyException(sprintf('Plugin "%s" in version "%s" is not compatible with the current application', $plugin, $version));
             }
         }
         if (!preg_match(PEAR_COMMON_PACKAGE_VERSION_PREG, $version)) {
             throw new sfPluginException(sprintf('Plugin version "%s" is not a valid version', $version));
         }
         $existing = $this->environment->getRegistry()->packageInfo($plugin, 'version', $channel);
         if (version_compare($existing, $version) === 0) {
             $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Plugin is already installed')));
             return true;
         }
         // skip if the plugin is already installing and we are here through a dependency)
         if (isset($this->installing[$channel . '/' . $plugin])) {
             return true;
         }
         // convert the plugin package into a discrete download URL
         $download = $this->environment->getRest()->getPluginDownloadURL($plugin, $version, $stability);
         if (PEAR::isError($download)) {
             throw new sfPluginException(sprintf('Problem downloading the plugin "%s": %s', $plugin, $download->getMessage()));
         }
     }
     // download the plugin and install
     $class = $this->environment->getOption('downloader_base_class');
     $downloader = new $class($this, array('upgrade' => true), $this->environment->getConfig());
     $this->installing[$channel . '/' . $plugin] = true;
     if ($isPackage) {
         $this->checkPluginDependencies($plugin, $version, isset($options['install_deps']) ? (bool) $options['install_deps'] : false);
     }
     // download the actual URL to the plugin
     $downloaded = $downloader->download(array($download));
     if (PEAR::isError($downloaded)) {
         throw new sfPluginException(sprintf('Problem when downloading "%s": %s', $download, $downloaded->getMessage()));
     }
     $errors = $downloader->getErrorMsgs();
     if (count($errors)) {
         $err = array();
         foreach ($errors as $error) {
             $err[] = $error;
         }
         if (!count($downloaded)) {
             throw new sfPluginException(sprintf('Plugin "%s" installation failed: %s', $plugin, implode("\n", $err)));
         }
     }
     $pluginPackage = $downloaded[0];
     $installer = new PEAR_Installer($this);
     $installer->setOptions(array('upgrade' => true));
     $packages = array($pluginPackage);
     $installer->sortPackagesForInstall($packages);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $err = $installer->setDownloadedPackages($packages);
     if (PEAR::isError($err)) {
         PEAR::staticPopErrorHandling();
         throw new sfPluginException($err->getMessage());
     }
     $info = $installer->install($pluginPackage, array('upgrade' => true));
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($info)) {
         throw new sfPluginException(sprintf('Installation of "%s" plugin failed: %s', $plugin, $info->getMessage()));
     }
     if (is_array($info)) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Installation successful for plugin "%s"', $plugin))));
         $this->dispatcher->notify(new sfEvent($this, 'plugin.post_install', array('channel' => $channel, 'plugin' => $plugin)));
         unset($this->installing[$channel . '/' . $plugin]);
         return true;
     } else {
         throw new sfPluginException(sprintf('Installation of "%s" plugin failed', $plugin));
     }
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:100,代码来源:sfPluginManager.class.php

示例3: array

     continue;
 }
 $new_ver = $info->getVersion();
 $downloaderpackage = new PEAR_Downloader_Package($installer);
 $err = $downloaderpackage->initialize($instfile);
 if (PEAR::isError($err)) {
     $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
     continue;
 }
 if ($reg->packageExists($package)) {
     $old_ver = $reg->packageInfo($package, 'version');
     if (version_compare($new_ver, $old_ver, 'gt')) {
         $installer->setOptions($options);
         $dp = array($downloaderpackage);
         $installer->setDownloadedPackages($dp);
         $err = $installer->install($downloaderpackage, $options);
         if (PEAR::isError($err)) {
             $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
             continue;
         }
         $ui->outputData(sprintf("[PEAR] %-15s- upgraded:  %s", $package, $new_ver));
     } else {
         if ($force) {
             $options['force'] = true;
             $installer->setOptions($options);
             $dp = array($downloaderpackage);
             $installer->setDownloadedPackages($dp);
             $err = $installer->install($downloaderpackage, $options);
             if (PEAR::isError($err)) {
                 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
                 continue;
开发者ID:phpsource,项目名称:pear-core,代码行数:31,代码来源:install-pear.php


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