Example #1
0
 function getFilePath($file)
 {
     $role = \PEAR2\Pyrus\Installer\Role::factory($this->packagefile->getPackageType(), $this->packagefile->packagingcontents[$file]['attribs']['role']);
     list(, $path) = $role->getRelativeLocation($this->packagefile, new \PEAR2\Pyrus\PackageFile\v2Iterator\FileTag($this->packagefile->packagingcontents[$file], '', $this->packagefile), true);
     $dir = \PEAR2\Pyrus\Config::singleton($this->registry->getPath())->{$role->getLocationConfig()};
     return $dir . DIRECTORY_SEPARATOR . $path;
 }
 /**
  * Construct simple channel server
  *
  * @param PEAR2_SimpleChannelServer_Channel $channel   channel object
  * @param string $webpath   full path to web files eg: /var/www/pear/
  * @param string $pyruspath Path to the pyrus controlled PEAR installation
  */
 function __construct(\PEAR2\Pyrus\Channel $channel, $webpath, $pyruspath = null)
 {
     if (!realpath($webpath) || !is_writable($webpath)) {
         throw new PEAR2_SimpleChannelServer_Exception('Path to channel web files ' .
             $webpath .
             ' must exist and be writable');
     } else {
         $this->webpath = $webpath;
     }
     if (!$pyruspath) {
     	$pyruspath = __DIR__;
     }
     $rest = $channel->protocols->rest;
     foreach ($rest as $restpath) {
         $restpath = str_replace('http://'.$channel->name.'/', '', $restpath);
         break;
     }
     if (dirname($restpath . 'a') . '/' !== $restpath) {
         $restpath .= '/';
     }
     $this->uri     = 'http://' . $channel->name . '/';
     $this->channel = $channel;
     $this->rest    = new PEAR2_SimpleChannelServer_REST_Manager($webpath.'/'.$restpath, $channel->name,
         $restpath);
     $this->get     = new PEAR2_SimpleChannelServer_Get($webpath.'/get', $pyruspath);
     try {
         $a = \PEAR2\Pyrus\Config::singleton($pyruspath);
     } catch (Exception $e) {
         throw new PEAR2_SimpleChannelServer_Exception('Cannot initialize Pyrus Config',
             $e);
     }
 }
 /**
  * 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;
     }
 }
Example #4
0
    function __construct($__DIR__)
    {
        set_include_path($__DIR__);
        $c = \PEAR2\Pyrus\Config::singleton(dirname($__DIR__), dirname($__DIR__) . '/pearconfig.xml');
        $c->bin_dir = $__DIR__ . '/bin';
        restore_include_path();
        $c->saveConfig();

        $chan = new PEAR2\SimpleChannelServer\Channel('pear2.php.net', 'unit test channel');
        $scs = new PEAR2\SimpleChannelServer\Main($chan, $__DIR__, dirname($__DIR__) . '/PEAR2');

        $scs->saveChannel();
        $this->chan = $chan;
        $this->scs = $scs;
        $this->__DIR__ = $__DIR__;
    }
Example #5
0
}
$cert = explode(PATH_SEPARATOR, $_ENV['CERT']);
if (count($cert) != 2 || !file_exists($cert[0])) {
    die('set the CERT environment variable to the /path/to/cert' . PATH_SEPARATOR . 'password');
}

$certinfo = array();
$pkcs = openssl_pkcs12_read(file_get_contents($cert[0]), $certinfo, $cert[1]);
if (!$pkcs) {
    die('Invalid certificate: ' . $cert[0] . ', or invalid password');
}

require __DIR__ . '/../../../../../autoload.php';

set_include_path(__DIR__);
$c = \PEAR2\Pyrus\Config::singleton(dirname(__DIR__), dirname(__DIR__) . '/pearconfig.xml');
$c->bin_dir = __DIR__ . '/bin';
restore_include_path();
$c->saveConfig();

$chan = new PEAR2\SimpleChannelServer\Channel('pear2.php.net', 'unit test channel');
$scs = new PEAR2\SimpleChannelServer\Main($chan, __DIR__, dirname(__DIR__) . '/PEAR2');

$scs->saveChannel();

$pf = new \PEAR2\Pyrus\PackageFile\v2;

for ($i = 1; $i <= 1; $i++) {
    file_put_contents(__DIR__ . "/glooby$i", 'hi');
}
Example #6
0
 public function readConfig()
 {
     $this->config = \PEAR2\Pyrus\Config::singleton($this->getPyrusDir(), $this->getPearConfig());
     $this->config->pluginregistry->scan();
 }
Example #7
0
 /**
  * Set a configuration option.
  *
  * @param array $args
  */
 function set($args, $options)
 {
     $conf = $current = \PEAR2\Pyrus\Config::current();
     if ($options['plugin']) {
         $conf = \PEAR2\Pyrus\Config::singleton(\PEAR2\Pyrus\Config::current()->plugins_dir);
     }
     if (in_array($args['variable'], $conf->uservars)) {
         echo "Setting {$args['variable']} in " . $conf->userfile . "\n";
         $conf->{$args['variable']} = $args['value'];
     } elseif (in_array($args['variable'], $conf->systemvars)) {
         echo "Setting {$args['variable']} in system paths\n";
         $conf->{$args['variable']} = $args['value'];
     } else {
         echo "Unknown config variable: {$args['variable']}\n";
         exit(1);
     }
     $conf->saveConfig();
     if ($options['plugin']) {
         \PEAR2\Pyrus\Config::setCurrent($current->path);
     }
 }
Example #8
0
<?php

/**
 * This file generates the pyrus.phar file and PEAR2 package for Pyrus.
 */
$current = \PEAR2\Pyrus\Config::current();
$config = \PEAR2\Pyrus\Config::singleton(__DIR__ . '/vendor');
$extrafiles = array($config->registry->toPackage('PEAR2_HTTP_Request', 'pear2.php.net'), $config->registry->toPackage('PEAR2_Console_CommandLine', 'pear2.php.net'), $config->registry->toPackage('PEAR2_Exception', 'pear2.php.net'), $config->registry->toPackage('PEAR2_MultiErrors', 'pear2.php.net'));
\PEAR2\Pyrus\Config::setCurrent($current->path);