/** * install a local or remote package * * @param array $args */ function install($args, $options) { if ($options['plugin']) { \PEAR2\Pyrus\Main::$options['install-plugins'] = true; } if ($options['force']) { \PEAR2\Pyrus\Main::$options['force'] = true; } if (isset($options['packagingroot']) && $options['packagingroot']) { \PEAR2\Pyrus\Main::$options['packagingroot'] = $options['packagingroot']; } if ($options['optionaldeps']) { \PEAR2\Pyrus\Main::$options['optionaldeps'] = $options['optionaldeps']; } \PEAR2\Pyrus\Installer::begin(); try { $packages = array(); foreach ($args['package'] as $arg) { \PEAR2\Pyrus\Installer::prepare($packages[] = new \PEAR2\Pyrus\Package($arg)); } \PEAR2\Pyrus\Installer::commit(); foreach (\PEAR2\Pyrus\Installer::getInstalledPackages() as $package) { echo 'Installed ' . $package->channel . '/' . $package->name . '-' . $package->version['release'] . "\n"; if ($package->type === 'extsrc' || $package->type === 'zendextsrc') { echo " ==> To build this PECL package, use the build command\n"; } } $optionals = \PEAR2\Pyrus\Installer::getIgnoredOptionalDeps(); if (count($optionals)) { echo "Optional dependencies that will not be installed, use --optionaldeps:\n"; } foreach ($optionals as $dep => $packages) { echo $dep, ' depended on by ', implode(', ', array_keys($packages)), "\n"; } } catch (\Exception $e) { if ($e instanceof \PEAR2\Pyrus\Channel\Exception && strpos($arg, '/') === false) { echo "Sorry there was an error retrieving " . \PEAR2\Pyrus\Config::current()->default_channel . "/{$arg} from the default channel\n"; } // If this is an undiscovered channel, handle it gracefully if ($e instanceof \PEAR2\Pyrus\Package\Exception && $e->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\Exception && $e->getPrevious()->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\ParseException && $e->getPrevious()->getPrevious()->why == 'channel' && strpos($arg, '/') !== false) { $channel = substr($arg, 0, strrpos($arg, '/')); echo "Sorry, the channel \"{$channel}\" is unknown.\n"; return $this->installUnknownChannelExceptionHandler($args, $options, $e, $channel); } if ($e instanceof \PEAR2\Pyrus\ChannelRegistry\Exception && $e->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\ParseException && $e->getPrevious()->why == 'channel' && preg_match('/^unknown channel \\"(.*)\\" in \\"(.*)\\"$/', $e->getPrevious()->getMessage(), $matches)) { echo "Sorry, {$arg} references an unknown channel {$matches[1]} for {$matches[2]}\n"; return $this->installUnknownChannelExceptionHandler($args, $options, $e, $matches[1]); } $this->exceptionHandler($e); exit(1); } }
/** * install a local or remote package * * @param array $args */ function install($args, $options) { if ($options['plugin']) { \PEAR2\Pyrus\Main::$options['install-plugins'] = true; } if ($options['force']) { \PEAR2\Pyrus\Main::$options['force'] = true; } if (isset($options['packagingroot']) && $options['packagingroot']) { \PEAR2\Pyrus\Main::$options['packagingroot'] = $options['packagingroot']; } if ($options['optionaldeps']) { \PEAR2\Pyrus\Main::$options['optionaldeps'] = $options['optionaldeps']; } \PEAR2\Pyrus\Installer::begin(); try { $packages = array(); foreach ($args['package'] as $arg) { \PEAR2\Pyrus\Installer::prepare($packages[] = new \PEAR2\Pyrus\Package($arg)); } \PEAR2\Pyrus\Installer::commit(); foreach (\PEAR2\Pyrus\Installer::getInstalledPackages() as $package) { echo 'Installed ' . $package->channel . '/' . $package->name . '-' . $package->version['release'] . "\n"; if ($package->type === 'extsrc' || $package->type === 'zendextsrc') { echo " ==> To build this PECL package, use the build command\n"; } } $optionals = \PEAR2\Pyrus\Installer::getIgnoredOptionalDeps(); if (count($optionals)) { echo "Optional dependencies that will not be installed, use --optionaldeps:\n"; } foreach ($optionals as $dep => $packages) { echo $dep, ' depended on by ', implode(', ', array_keys($packages)), "\n"; } } catch (\Exception $e) { // If this is an undiscovered channel, handle it gracefully if ($e instanceof \PEAR2\Pyrus\Package\Exception && $e->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\Exception && $e->getPrevious()->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\ParseException && $e->getPrevious()->getPrevious()->why == 'channel' && strpos($arg, '/') !== false) { $channel = strstr($arg, '/', true); echo "Sorry, the channel \"{$channel}\" is unknown.\n"; if ('yes' === $this->ask('Do you want to add this channel and continue the install?', array('yes', 'no'), 'yes')) { $this->channelDiscover(array('channel' => $channel)); $this->install($args, $options); return; } echo "Ok. I understand.\n"; } $this->exceptionHandler($e); exit -1; } }