Ejemplo n.º 1
0
 function getFilePath($file)
 {
     $role = \Pyrus\Installer\Role::factory($this->packagefile->getPackageType(), $this->packagefile->packagingcontents[$file]['attribs']['role']);
     list(, $path) = $role->getRelativeLocation($this->packagefile, new \Pyrus\PackageFile\v2Iterator\FileTag($this->packagefile->packagingcontents[$file], '', $this->packagefile), true);
     $dir = \Pyrus\Config::singleton($this->registry->getPath())->{$role->getLocationConfig()};
     return $dir . DIRECTORY_SEPARATOR . $path;
 }
Ejemplo n.º 2
0
 /**
  * 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(\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 = \Pyrus\Config::singleton($pyruspath);
     } catch (Exception $e) {
         throw new PEAR2_SimpleChannelServer_Exception('Cannot initialize Pyrus Config', $e);
     }
 }
Ejemplo n.º 3
0
 /**
  * Construct simple channel server
  *
  * @param Pyrus\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($channel, $webpath, $pyruspath = null)
 {
     if (!realpath($webpath) || !is_writable($webpath)) {
         throw new 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) {
         if (preg_match('/https?:\\/\\/' . $channel->name . '\\//', $restpath, $matches)) {
             $this->uri = $matches[0];
             $restpath = str_replace($matches[0], '', $restpath);
             break;
         }
     }
     if (dirname($restpath . 'a') . '/' !== $restpath) {
         $restpath .= '/';
     }
     $this->restpath = $webpath . '/' . $restpath;
     $this->channel = $channel;
     $this->rest = new REST\Manager($this->restpath, $channel, $restpath);
     $this->get = new Get($webpath . '/get', $pyruspath);
     try {
         $a = \Pyrus\Config::singleton($pyruspath);
     } catch (Exception $e) {
         throw new Exception('Cannot initialize Pyrus Config', $e);
     }
 }
Ejemplo n.º 4
0
 function __construct($__DIR__)
 {
     set_include_path($__DIR__);
     $c = \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__;
 }
Ejemplo n.º 5
0
<?php

/**
 * This file generates the pyrus.phar file and PEAR2 package for Pyrus.
 */
$current = \Pyrus\Config::current();
$config = \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'));
\Pyrus\Config::setCurrent($current->path);
Ejemplo n.º 6
0
/**
 * In order to test excluding all possible versions
 * 
 * Create a dependency tree like so:
 *
 * P1 -> P2 min 1.1.0, exclude 1.2.0
 * P3 -> P2 max 1.3.0, exclude 1.2.3
 *
 * P2 only has releases for 1.0.0, 1.2.0, 1.2.3, and 1.3.1
 *
 * to test composite dep failure
 */
require __DIR__ . '/../../../../../autoload.php';
set_include_path(__DIR__);
$c = \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 \Pyrus\PackageFile\v2();
for ($i = 1; $i <= 6; $i++) {
    file_put_contents(__DIR__ . "/glooby{$i}", 'hi');
}
$pf->name = 'P1';
$pf->channel = 'pear2.php.net';
$pf->summary = 'testing';
$pf->version['release'] = '1.0.0';
$pf->stability['release'] = 'stable';
Ejemplo n.º 7
0
 /**
  * Set a configuration option.
  *
  * @param array $args
  */
 function set($args, $options)
 {
     $conf = $current = \Pyrus\Config::current();
     if ($options['plugin']) {
         $conf = \Pyrus\Config::singleton(\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']) {
         \Pyrus\Config::setCurrent($current->path);
     }
 }
Ejemplo n.º 8
0
 /**
  * Set a configuration option.
  *
  * @param array $args
  */
 function set($args, $options)
 {
     $conf = $current = \Pyrus\Config::current();
     if ($options['plugin']) {
         $conf = \Pyrus\Config::singleton(\Pyrus\Config::current()->plugins_dir);
     }
     if (in_array($args['variable'], $conf->channelvars)) {
         if ($options['channel']) {
             $oldDefaultChannel = $conf->default_channel;
             $channel = $conf->channelregistry->get($options['channel'], false);
             $conf->default_channel = $channel->name;
         }
         echo "Setting {$args['variable']} for " . $conf->default_channel . " in " . $conf->userfile . "\n";
         $conf->{$args['variable']} = $args['value'];
         if ($options['channel']) {
             $conf->default_channel = $oldDefaultChannel;
         }
     } elseif (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']) {
         \Pyrus\Config::setCurrent($current->path);
     }
 }