コード例 #1
0
 /**
  * Install a PEAR package.
  *
  * @param string $package Name of the package to install. PEAR2_Templates_Savant
  *
  * @return void
  */
 static function installPackage($package)
 {
     $config = \PEAR2\Pyrus\Config::singleton(self::$autoload_registry);
     $config->preferred_state = 'alpha';
     $p = new \PEAR2\Pyrus\Package($package);
     try {
         \PEAR2\Pyrus\Installer::begin();
         \PEAR2\Pyrus\Installer::prepare($p);
         \PEAR2\Pyrus\Installer::commit();
     } catch (Exception $e) {
         \PEAR2\Pyrus\Installer::rollback();
         echo $e;
     }
 }
コード例 #2
0
ファイル: Commands.php プロジェクト: rosstuck/PEAR2_Pyrus
 /**
  * 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);
     }
 }
コード例 #3
0
ファイル: Pyrus.php プロジェクト: naderman/PyrusBundle
    public function installCustomRole()
    {
        $pf = new \PEAR2\Pyrus\PackageFile\v2;

        $pf->name = 'PyrusBundlePlugin';
        $pf->channel = 'pear2.php.net';
        $pf->summary = 'Local';
        $pf->description = 'Description';
        $pf->notes = 'My Notes';
        $pf->maintainer['naderman']->role('lead')->email('*****@*****.**')->active('yes')->name('Nils Adermann');
        $pf->files['Bundle.xml'] = array(
            'attribs' => array('role' => 'customrole'),
        );
        $pf->files['PyrusBundlePlugin/Role/Bundle.php'] = array(
            'attribs' => array('role' => 'php'),
        );

        $package_xml = __DIR__ . '/plugin/package.xml';
        $pf->setPackagefile($package_xml);

        $package = new \PEAR2\Pyrus\Package(false);
        $xmlcontainer = new \PEAR2\Pyrus\PackageFile($pf);
        $xml = new \PEAR2\Pyrus\Package\Xml($package_xml, $package, $xmlcontainer);
        $package->setInternalPackage($xml);
        \PEAR2\Pyrus\Main::$options['install-plugins'] = true;

        \PEAR2\Pyrus\Installer::begin();
        \PEAR2\Pyrus\Installer::prepare($package);
        \PEAR2\Pyrus\Installer::commit();

        $this->readConfig();
    }
コード例 #4
0
ファイル: Commands.php プロジェクト: naderman/PEAR2_Pyrus
    /**
     * 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;
        }
    }