예제 #1
0
 function saveRelease(\PEAR2\Pyrus\Package $new)
 {
     $outfile = $this->get.'/'.$new->name.'-'.$new->version['release'];
     if (!$new->isNewPackage()) {
         // this is a PEAR 1.x package
         $internal = $new->getInternalPackage();
         if ($internal instanceof \PEAR2\Pyrus\Package\Tar || $internal instanceof \PEAR2\Pyrus\Package\Phar) {
             $path = $internal->getTarballPath();
             $fp = fopen($path, 'rb');
             if (fread($fp, 3) == "\x1f\x8b\x08") {
                 // tgz
                 fclose($fp);
                 copy($path, $outfile . '.tgz');
                 $gp = gzopen($path, 'rb');
                 $fp = fopen($outfile . 'tar', 'wb');
                 stream_copy_to_stream($gp, $fp);
                 fclose($gp);
                 fclose($fp);
             } else {
                 // tar
                 copy($path, $outfile . '.tar');
                 $gp = gzopen($outfile . 'tgz', 'wb');
                 rewind($fp);
                 stream_copy_to_stream($fp, $gp);
                 fclose($gp);
                 fclose($fp);
             }
             return;
         }
     }
     $a = new \PEAR2\Pyrus\Package\Creator(array(
                 new \PEAR2\Pyrus\Developer\Creator\Phar($outfile.'.tar', false, Phar::TAR, Phar::NONE,
                                                        array(
                                                              array('tgz', Phar::TAR, Phar::GZ),
                                                              array('zip', Phar::ZIP, Phar::NONE),
                                                             ))),
                 $this->pyruspath,
                 $this->pyruspath,
                 $this->pyruspath);
     return $a->render($new);
 }
예제 #2
0
$outfile = $package->name.'-'.$package->version['release'];
$a = new \PEAR2\Pyrus\Package\Creator(array(
                    //new \PEAR2\Pyrus\Developer\Creator\Tar($outfile.'.tar', 'none'),
                    new \PEAR2\Pyrus\Developer\Creator\Phar($outfile.'.tgz', false, Phar::TAR, Phar::GZ),),
                    dirname(__FILE__).'/../../Exception/src',
					dirname(__FILE__).'/../../Autoload/src',
					dirname(__FILE__).'/../../MultiErrors/src');
$a->render($package);

$a = new \PEAR2\Pyrus\Package\Creator(array(
                    new \PEAR2\Pyrus\Developer\Creator\Phar\PHPArchive(__DIR__ . '/pearscs.phar', '<?php
function __autoload($class)
{
    include \'phar://\' . PYRUS_PHAR_FILE . \'/php/\' . implode(\'/\', explode(\'_\', $class)) . \'.php\';
}
set_include_path(\'phar://\' . PYRUS_PHAR_FILE . \'/php/\'.PATH_SEPARATOR.get_include_path());
$cli = new pear\SimpleChannelServer\CLI();
$cli->process();
'),),
                    dirname(__FILE__) . '/../../Exception/src',
                    dirname(__FILE__) . '/../../Autoload/src',
                    dirname(__FILE__) . '/../../MultiErrors/src');
$b = new \PEAR2\Pyrus\Package(__DIR__ . '/package.xml');
$rp = __DIR__ . '/../../HTTP_Request/src/HTTP';

$additional_files = array(
    'php/PEAR2/HTTP/Request.php'                   => $rp . '/Request.php',
    'php/PEAR2/HTTP/Request/Adapter.php'           => $rp . '/Request/Adapter.php',
    'php/PEAR2/HTTP/Request/Adapter/Phpsocket.php' => $rp . '/Request/Adapter/Phpsocket.php',
    'php/PEAR2/HTTP/Request/Adapter/Phpstream.php' => $rp . '/Request/Adapter/Phpstream.php',
    'php/PEAR2/HTTP/Request/Exception.php'         => $rp . '/Request/Exception.php',
 * A full featured package for managing command-line options and arguments 
 * hightly inspired from python optparse module, it allows the developper to 
 * easily build complex command line interfaces.
 *
 * PHP version 5
 *
 * LICENSE: This source file is subject to the MIT license that is available
 * through the world-wide-web at the following URI:
 * http://opensource.org/licenses/mit-license.php
 *
 * @category  Console 
 * @package   PEAR2_Console_CommandLine
 * @author    David JEAN LOUIS <*****@*****.**>
 * @copyright 2007-2009 David JEAN LOUIS
 * @license   http://opensource.org/licenses/mit-license.php MIT License 
 * @version   SVN: $Id$
 * @link      http://pear.php.net/package/Console_CommandLine
 * @since     Class available since release 0.1.0
 */
// ensure that errors will be printed
error_reporting(E_ALL);
ini_set('display_errors', true);
// uncomment this when package won't be in the SandBox anymore
// $basedir = __DIR__ . '/..';
$basedir = __DIR__ . '/../..';
require_once $basedir . '/autoload.php';
new \PEAR2\Pyrus\Developer\PackageFile\PEAR2SVN(__DIR__, 'PEAR2_Console_CommandLine');
$package = new \PEAR2\Pyrus\Package('package.xml');
$outfile = $package->name . '-' . $package->version['release'];
$creator = new \PEAR2\Pyrus\Package\Creator(new \PEAR2\Pyrus\Developer\Creator\Phar($outfile . '.tgz', false, Phar::TAR, Phar::GZ), $basedir . '/Exception/src', $basedir . '/Autoload/src', $basedir . '/MultiErrors/src');
$creator->render($package);
예제 #4
0
 /** @todo Consider simply injecting the Package object as appropriate */
 function package($frontend, $args, $options)
 {
     $path = getcwd() . DIRECTORY_SEPARATOR;
     $package = new \PEAR2\Pyrus\Package(null);
     if (!isset($args['packagexml']) && !file_exists($path . 'package.xml') && !file_exists($path . 'package2.xml')) {
         throw new \PEAR2\Pyrus\PackageFile\Exception("No package.xml or package2.xml found in " . $path);
     }
     if (isset($args['packagexml'])) {
         $package = new \PEAR2\Pyrus\Package($args['packagexml']);
     } else {
         // first try ./package.xml
         if (file_exists($path . 'package.xml')) {
             try {
                 $package = new \PEAR2\Pyrus\Package($path . 'package.xml');
             } catch (\PEAR2\Pyrus\PackageFile\Exception $e) {
                 if ($e->getCode() != -3) {
                     throw $e;
                 }
                 if (!file_exists($path . 'package2.xml')) {
                     throw $e;
                 }
                 $package = new \PEAR2\Pyrus\Package($path . 'package2.xml');
                 // now the creator knows to do the magic of package2.xml/package.xml
                 $package->thisIsOldAndCrustyCompatible();
             }
         }
         // Alternatively; there's only a package2.xml
         if (file_exists($path . 'package2.xml') && !file_exists($path . 'package.xml')) {
             $package = new \PEAR2\Pyrus\Package($path . 'package2.xml');
         }
     }
     if ($package->isNewPackage()) {
         if (!$options['phar'] && !$options['zip'] && !$options['tar'] && !$options['tgz']) {
             // try tgz first
             if (extension_loaded('zlib')) {
                 $options['tgz'] = true;
             } else {
                 $options['tar'] = true;
             }
         }
         if ($options['phar'] && ini_get('phar.readonly')) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception("Cannot create phar archive, pass -dphar.readonly=0");
         }
     } else {
         if ($options['zip'] || $options['phar']) {
             echo "Zip and Phar archives can only be created for PEAR2 packages, ignoring\n";
         }
         if (extension_loaded('zlib')) {
             $options['tgz'] = true;
         } else {
             $options['tar'] = true;
         }
     }
     // get openssl cert if set, and password
     if (\PEAR2\Pyrus\Config::current()->openssl_cert) {
         if ('yes' == $frontend->ask('Sign package?', array('yes', 'no'), 'yes')) {
             $cert = \PEAR2\Pyrus\Config::current()->openssl_cert;
             if (!file_exists($cert)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('OpenSSL certificate ' . $cert . ' does not exist');
             }
             $releaser = \PEAR2\Pyrus\Config::current()->handle;
             $maintainers = array();
             foreach ($package->maintainer as $maintainer) {
                 $maintainers[] = $maintainer->user;
             }
             if (!strlen($releaser)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('handle configuration variable must be from ' . 'package.xml (one of ' . implode(', ', $maintainers) . ')');
             }
             if (!in_array($releaser, $maintainers)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('handle configuration variable must be from ' . 'package.xml (one of ' . implode(', ', $maintainers) . ')');
             }
             $passphrase = $frontend->ask('passphrase for OpenSSL PKCS#12 certificate?');
             if (!$passphrase) {
                 $passphrase = '';
             }
         } else {
             $releaser = $cert = null;
             $passphrase = '';
         }
     } else {
         $releaser = $cert = null;
         $passphrase = '';
     }
     $sourcepath = \PEAR2\Pyrus\Main::getSourcePath();
     if (0 !== strpos($sourcepath, 'phar://')) {
         // running from svn, assume we're in a standard package layout with a vendor dir
         // TODO: Improve this to automatically find latest releases from pear2.php.net
         $exceptionpath = $autoloadpath = $multierrorspath = realpath($sourcepath . '/../../vendor/php') . '/PEAR2';
         if (!file_exists($exceptionpath . '/Exception.php')) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('Cannot locate PEAR2/Exception in a local vendor/ dir. ' . 'It is best to install the latest versions of these locally.');
         }
     } else {
         $exceptionpath = $autoloadpath = $multierrorspath = dirname($sourcepath) . '/PEAR2';
     }
     $extras = array();
     $stub = false;
     if ($options['tgz'] && extension_loaded('zlib')) {
         $mainfile = $package->name . '-' . $package->version['release'] . '.tgz';
         $mainformat = \Phar::TAR;
         $maincompress = \Phar::GZ;
     } elseif ($options['tgz']) {
         $options['tar'] = true;
     }
     if ($options['tar']) {
         if (isset($mainfile)) {
             $extras[] = array('tar', \Phar::TAR, \Phar::NONE);
         } else {
             $mainfile = $package->name . '-' . $package->version['release'] . '.tar';
             $mainformat = \Phar::TAR;
             $maincompress = \Phar::NONE;
         }
     }
     if ($options['phar']) {
         if (isset($mainfile)) {
             $extras[] = array('phar', \Phar::PHAR, \Phar::GZ);
         } else {
             $mainfile = $package->name . '-' . $package->version['release'] . '.phar';
             $mainformat = \Phar::PHAR;
             $maincompress = \Phar::NONE;
         }
         if (!$options['stub'] && file_exists(dirname($package->archivefile) . '/stub.php')) {
             $stub = file_get_contents(dirname($package->archivefile) . '/stub.php');
         } elseif ($options['stub'] && file_exists($options['stub'])) {
             $stub = file_get_contents($options['stub']);
         }
         $stub = str_replace('@PACKAGE_VERSION' . '@', $package->version['release'], $stub);
     }
     if ($options['zip']) {
         if (isset($mainfile)) {
             $extras[] = array('zip', \Phar::ZIP, \Phar::NONE);
         } else {
             $mainfile = $package->name . '-' . $package->version['release'] . '.zip';
             $mainformat = \Phar::ZIP;
             $maincompress = \Phar::NONE;
         }
     }
     if (isset($options['outputfile'])) {
         $mainfile = $options['outputfile'];
     }
     echo "Creating ", $mainfile, "\n";
     if (null == $cert) {
         $cloner = new \PEAR2\Pyrus\Package\Cloner($mainfile);
         $clone = $extras;
         $extras = array();
     } else {
         foreach ($extras as $stuff) {
             echo "Creating ", $package->name, '-', $package->version['release'], '.', $stuff[0], "\n";
         }
         $clone = array();
     }
     $creator = new \PEAR2\Pyrus\Package\Creator(array(new \PEAR2\Pyrus\Developer\Creator\Phar($mainfile, $stub, $mainformat, $maincompress, $extras, $releaser, $package, $cert, $passphrase)), $exceptionpath, $autoloadpath, $multierrorspath);
     if (!$options['extrasetup'] && file_exists(dirname($package->archivefile) . '/extrasetup.php')) {
         $options['extrasetup'] = 'extrasetup.php';
     }
     if ($options['extrasetup']) {
         // encapsulate the extrafiles inside a closure so there is no access to the variables in this function
         $getinfo = function () use($options, $package) {
             $file = $options['extrasetup'];
             if (!file_exists(dirname($package->archivefile) . '/' . $file)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file must be in the same directory as package.xml');
             }
             include dirname($package->archivefile) . '/' . $file;
             if (!isset($extrafiles)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file must set $extrafiles variable to an array of files');
             }
             if (!is_array($extrafiles)) {
                 throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file must set $extrafiles variable to an array of files');
             }
             foreach ($extrafiles as $path => $file) {
                 if (is_object($file)) {
                     if ($file instanceof \PEAR2\Pyrus\PackageInterface || $file instanceof \PEAR2\Pyrus\PackageFileInterface) {
                         continue;
                     }
                     throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file object must implement \\PEAR2\\Pyrus\\PackageInterface or \\PEAR2\\Pyrus\\PackageFileInterface');
                 }
                 if (!file_exists($file)) {
                     throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file ' . $file . ' does not exist');
                 }
                 if (!is_string($path)) {
                     throw new \PEAR2\Pyrus\Developer\Creator\Exception('extrasetup file ' . $file . ' index should be the path to save in the' . ' release');
                 }
             }
             return $extrafiles;
         };
         $extrafiles = $getinfo();
     } else {
         $extrafiles = array();
     }
     $creator->render($package, $extrafiles);
     if (count($clone)) {
         foreach ($clone as $extra) {
             echo "Creating ", $package->name, '-', $package->version['release'], '.', $extra[0], "\n";
             $cloner->{'to' . $extra[0]}();
         }
     }
     echo "done\n";
 }