Пример #1
0
 function setUI($ui = null)
 {
     if (!$ui) {
         $this->_ui = PEAR_Frontend::singleton();
     } else {
         $this->_ui = $ui;
     }
 }
Пример #2
0
 function init(&$config, &$pkg, $lastversion)
 {
     $this->_config =& $config;
     $this->_registry =& $config->getRegistry();
     $this->_ui =& PEAR_Frontend::singleton();
     $this->_pkg =& $pkg;
     $this->_lastversion = $lastversion;
     $this->_wwwDirectory = $this->_config->get('www_dir');
     if ($this->_wwwDirectory === false || !file_exists($this->_wwwDirectory)) {
         $this->_ui->log("Failed to find a web directory {$this->_wwwDirectory}");
         return false;
     }
     $sfile = $this->_wwwDirectory . DIRECTORY_SEPARATOR . 'LocalSettings.php.sample';
     $this->contents = file_get_contents($sfile, true);
     if ($this->contents === false) {
         $this->_ui->log("Failed to load '{$sfile}'");
         return false;
     }
     $this->_ui->log("Loaded '{$sfile}'");
     return true;
 }
Пример #3
0
 /**
  * Logging method.
  *
  * @param int    $level  log level (0 is quiet, higher is noisier)
  * @param string $msg    message to write to the log
  *
  * @return void
  *
  * @access public
  * @static
  */
 function log($level, $msg, $append_crlf = true)
 {
     if ($this->debug >= $level) {
         if (!class_exists('PEAR_Frontend')) {
             require_once 'PEAR/Frontend.php';
         }
         $ui =& PEAR_Frontend::singleton();
         if (is_a($ui, 'PEAR_Frontend')) {
             $ui->log($msg, $append_crlf);
         } else {
             print "{$msg}\n";
         }
     }
 }
Пример #4
0
 /**
  * Get instance of frontend object.
  *
  * @return object|PEAR_Error
  * @static
  */
 function &getFrontendObject()
 {
     $a =& PEAR_Frontend::singleton();
     return $a;
 }
Пример #5
0
 /**
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @return bool
  * @access private
  */
 function _addPackage2($info)
 {
     if (!is_a($info, 'PEAR_PackageFile_v1') && !is_a($info, 'PEAR_PackageFile_v2')) {
         return false;
     }
     if (!$info->validate()) {
         if (class_exists('PEAR_Common')) {
             $ui = PEAR_Frontend::singleton();
             if ($ui) {
                 foreach ($info->getValidationWarnings() as $err) {
                     $ui->log($err['message'], true);
                 }
             }
         }
         return false;
     }
     $channel = $info->getChannel();
     $package = $info->getPackage();
     $save = $info;
     if ($this->_packageExists($package, $channel)) {
         return false;
     }
     if (!$this->_channelExists($channel, true)) {
         return false;
     }
     $info = $info->toArray(true);
     if (!$info) {
         return false;
     }
     $fp = $this->_openPackageFile($package, 'wb', $channel);
     if ($fp === null) {
         return false;
     }
     $info['_lastmodified'] = time();
     fwrite($fp, serialize($info));
     $this->_closePackageFile($fp);
     $this->_rebuildFileMap();
     return true;
 }
Пример #6
0
 function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false)
 {
     $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml');
     if (PEAR::isError($packagelist)) {
         return $packagelist;
     }
     if ($this->_rest->config->get('verbose') > 0) {
         $ui =& PEAR_Frontend::singleton();
         $ui->log('Retrieving data...0%', false);
     }
     $ret = array();
     if (!is_array($packagelist) || !isset($packagelist['p'])) {
         return $ret;
     }
     if (!is_array($packagelist['p'])) {
         $packagelist['p'] = array($packagelist['p']);
     }
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $next = 0.1;
     foreach ($packagelist['p'] as $progress => $package) {
         if ($this->_rest->config->get('verbose') > 0) {
             if ($progress / count($packagelist['p']) >= $next) {
                 if ($next == 0.5) {
                     $ui->log('50%', false);
                 } else {
                     $ui->log('.', false);
                 }
                 $next += 0.1;
             }
         }
         if ($basic) {
             // remote-list command
             if ($dostable) {
                 $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/stable.txt');
             } else {
                 $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/latest.txt');
             }
             if (PEAR::isError($latest)) {
                 $latest = false;
             }
             $info = array('stable' => $latest);
         } else {
             // list-all command
             $inf = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
             if (PEAR::isError($inf)) {
                 PEAR::popErrorHandling();
                 return $inf;
             }
             if ($searchpackage) {
                 $found = !empty($searchpackage) && stristr($package, $searchpackage) !== false;
                 if (!$found && !(isset($searchsummary) && !empty($searchsummary) && (stristr($inf['s'], $searchsummary) !== false || stristr($inf['d'], $searchsummary) !== false))) {
                     continue;
                 }
             }
             $releases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
             if (PEAR::isError($releases)) {
                 continue;
             }
             if (!isset($releases['r'][0])) {
                 $releases['r'] = array($releases['r']);
             }
             unset($latest);
             unset($unstable);
             unset($stable);
             unset($state);
             foreach ($releases['r'] as $release) {
                 if (!isset($latest)) {
                     if ($dostable && $release['s'] == 'stable') {
                         $latest = $release['v'];
                         $state = 'stable';
                     }
                     if (!$dostable) {
                         $latest = $release['v'];
                         $state = $release['s'];
                     }
                 }
                 if (!isset($stable) && $release['s'] == 'stable') {
                     $stable = $release['v'];
                     if (!isset($unstable)) {
                         $unstable = $stable;
                     }
                 }
                 if (!isset($unstable) && $release['s'] != 'stable') {
                     $latest = $unstable = $release['v'];
                     $state = $release['s'];
                 }
                 if (isset($latest) && !isset($state)) {
                     $state = $release['s'];
                 }
                 if (isset($latest) && isset($stable) && isset($unstable)) {
                     break;
                 }
             }
             $deps = array();
             if (!isset($unstable)) {
                 $unstable = false;
                 $state = 'stable';
                 if (isset($stable)) {
                     $latest = $unstable = $stable;
                 }
             } else {
                 $latest = $unstable;
             }
             if (!isset($latest)) {
                 $latest = false;
             }
             if ($latest) {
                 $d = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $latest . '.txt');
                 if (!PEAR::isError($d)) {
                     $d = unserialize($d);
                     if ($d) {
                         if (isset($d['required'])) {
                             if (!class_exists('PEAR_PackageFile_v2')) {
                                 require_once 'PEAR/PackageFile/v2.php';
                             }
                             if (!isset($pf)) {
                                 $pf = new PEAR_PackageFile_v2();
                             }
                             $pf->setDeps($d);
                             $tdeps = $pf->getDeps();
                         } else {
                             $tdeps = $d;
                         }
                         foreach ($tdeps as $dep) {
                             if ($dep['type'] !== 'pkg') {
                                 continue;
                             }
                             $deps[] = $dep;
                         }
                     }
                 }
             }
             if (!isset($stable)) {
                 $stable = '-n/a-';
             }
             if (!$searchpackage) {
                 $info = array('stable' => $latest, 'summary' => $inf['s'], 'description' => $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
             } else {
                 $info = array('stable' => $stable, 'summary' => $inf['s'], 'description' => $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
             }
         }
         $ret[$package] = $info;
     }
     PEAR::popErrorHandling();
     return $ret;
 }
Пример #7
0
 function runPostinstallScripts()
 {
     if ($this->initPostinstallScripts()) {
         $ui =& PEAR_Frontend::singleton();
         if ($ui) {
             $ui->runPostinstallScripts($this->_scripts, $this);
         }
     }
 }
Пример #8
0
        // extreme debugging
        exit;
    }
}
// end print
$php_dir = $config->get('php_dir');
$options = array();
$options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
    $options['packagingroot'] = $install_root;
    $reg =& new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir);
} else {
    $reg = $config->getRegistry('default');
}
$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
if (PEAR::isError($ui)) {
    die($ui->getMessage());
}
$installer = new PEAR_Installer($ui);
$pkg = new PEAR_PackageFile($config, $debug);
foreach ($install_files as $package => $instfile) {
    $info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING);
    if (PEAR::isError($info)) {
        if (is_array($info->getUserInfo())) {
            foreach ($info->getUserInfo() as $err) {
                $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message']));
            }
        }
        $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
        continue;
 /**
  * Initializes the PEAR Frontend instance.
  */
 protected function initializeFrontend()
 {
     $this->frontend = PEAR_Frontend::singleton('sfPearFrontendPlugin');
     if (PEAR::isError($this->frontend)) {
         throw new sfPluginException(sprintf('Unable to initialize PEAR Frontend object: %s', $this->frontend->getMessage()));
     }
     $this->frontend->setEventDispatcher($this->dispatcher);
 }
Пример #10
0
 function init(&$config, &$pkg, $lastversion)
 {
     $this->_ui =& PEAR_Frontend::singleton();
     $this->lastversion = $lastversion;
     return true;
 }
Пример #11
0
 private function nativePearInstall($package, $channel)
 {
     if (!class_exists('PEAR_Command')) {
         @(include 'PEAR/command.php');
         // loads frontend, among other things
         if (!class_exists('PEAR_Command')) {
             throw new pakeException('PEAR subsystem is unavailable (not in include_path?)');
         }
     }
     $front = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
     $cfg = PEAR_Config::singleton();
     $cmd = PEAR_Command::factory('install', $cfg);
     ob_start();
     $result = $cmd->doInstall('install', array(), array($channel . '/' . $package));
     ob_end_clean();
     // we don't need output
     if ($result instanceof PEAR_Error) {
         throw new pakeException($result->getMessage());
     }
 }
Пример #12
0
 /**
  * Logging method.
  *
  * @param int    $level  log level (0 is quiet, higher is noisier)
  * @param string $msg    message to write to the log
  *
  * @return void
  *
  * @access public
  * @static
  */
 function log($level, $msg, $append_crlf = true)
 {
     if ($this->debug >= $level) {
         $ui =& PEAR_Frontend::singleton();
         if (is_a($ui, 'PEAR_Frontend')) {
             $ui->log($msg, $append_crlf);
         } else {
             print "{$msg}\n";
         }
     }
 }
 private static function nativePearUpgrade($package, $channel)
 {
     pake_echo_action('pear', 'upgrading ' . $channel . '/' . $package);
     self::initPearClasses();
     $front = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
     $cfg = PEAR_Config::singleton();
     $cmd = PEAR_Command::factory('upgrade', $cfg);
     ob_start();
     $result = $cmd->doInstall('upgrade', array(), array($channel . '/' . $package));
     ob_end_clean();
     // we don't need output
     if ($result instanceof PEAR_Error) {
         throw new pakeException($result->getMessage());
     }
 }