Exemplo n.º 1
0
    public function main()
    {
        require_once 'PEAR/PackageFileManager2.php';
        require_once 'PEAR/Exception.php';
        PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'PEAR_ErrorToPEAR_Exception');
        if (!$this->baseDir || !file_exists($this->baseDir)) {
            throw new BuildException('Base directory is not defined or does not exist.');
        }
        if (!$this->buildDir || !file_exists($this->buildDir)) {
            throw new BuildException('Build directory is not defined or does not exist.');
        }
        set_time_limit(0);
        $this->log("Adding .keep files to empty directories", PROJECT_MSG_INFO);
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath('samples')), RecursiveIteratorIterator::CHILD_FIRST) as $dir) {
            if ($dir->isDir()) {
                foreach (new DirectoryIterator($dir->getPathname()) as $d) {
                    if (!in_array($d->getFilename(), array('.', '..'))) {
                        continue 2;
                    }
                }
                touch($dir->getPathname() . '/.keep');
            }
        }
        $this->log("Building package contents in: {$this->dir}", PROJECT_MSG_INFO);
        $version = $this->project->getProperty('agavi.pear.version');
        $status = $this->project->getProperty('agavi.status');
        // Modify short description. Try to keep under 80 chars width
        $shortDesc = <<<EOD
PHP5 MVC Application Framework
EOD;
        // Modify long description. Try to keep under 80 chars width
        $longDesc = <<<EOD
Agavi is a full-featured MVC-style framework for PHP5 with a strong focus on structure, code reusability and flexibility.
EOD;
        $p2 = new PEAR_PackageFileManager2();
        $p2->setOptions(array('filelistgenerator' => 'file', 'outputdirectory' => $this->baseDir, 'packagedirectory' => $this->buildDir, 'baseinstalldir' => 'agavi', 'ignore' => array('.svn/'), 'addhiddenfiles' => true, 'dir_roles' => array('/' => 'php', 'bin' => 'script', 'samples' => 'data'), 'installexceptions' => array('bin/agavi-dist' => '/', 'bin/agavi.bat-dist' => '/'), 'exceptions' => array('API_CHANGELOG' => 'doc', 'CHANGELOG' => 'doc', 'COPYRIGHT' => 'doc', 'INSTALL' => 'doc', 'LICENSE' => 'doc', 'LICENSE-AGAVI' => 'doc', 'LICENSE-ICU' => 'doc', 'LICENSE-SCHEMATRON' => 'doc', 'LICENSE-UNICODE_CLDR' => 'doc', 'RELEASE_NOTES' => 'doc', 'UPGRADING' => 'doc')));
        $p2->setPackageType('php');
        $p2->setPackage('agavi');
        $p2->addMaintainer('lead', 'david', 'David Zülke', '*****@*****.**');
        $p2->addMaintainer('developer', 'dominik', 'Dominik del Bondio', '*****@*****.**');
        $p2->addMaintainer('developer', 'felix', 'Felix Gilcher', '*****@*****.**');
        $p2->addMaintainer('developer', 'impl', 'Noah Fontes', '*****@*****.**');
        $p2->addMaintainer('developer', 'v-dogg', 'Veikko Mäkinen', '*****@*****.**');
        $p2->setChannel('pear.agavi.org');
        $p2->setReleaseVersion($version);
        $p2->setAPIVersion($version);
        $p2->setReleaseStability($status);
        $p2->setAPIStability($status);
        $p2->setSummary($shortDesc);
        $p2->setDescription($longDesc);
        $p2->setNotes("To see what's new, please refer to the RELEASE_NOTES. Also, the CHANGELOG contains a full list of changes.\n\nFor installation instructions, consult INSTALL. Information on how to migrate applications written using previous releases can be found in UPGRADING.");
        // this must be the most stupid syntax I've ever seen.
        $p2->addRelease();
        $p2->setOSInstallCondition('windows');
        $p2->addInstallAs('bin/agavi.bat-dist', 'agavi.bat');
        $p2->addIgnoreToRelease('bin/agavi-dist');
        // and the next release... very cool, eh? how utterly stupid is that
        $p2->addRelease();
        $p2->addInstallAs('bin/agavi-dist', 'agavi');
        $p2->addIgnoreToRelease('bin/agavi.bat-dist');
        $p2->addPackageDepWithChannel('required', 'phing', 'pear.phing.info', '2.4.0');
        $p2->addPackageDepWithChannel('optional', 'PHPUnit', 'pear.phpunit.de', '3.7.0');
        $p2->addConflictingPackageDepWithChannel('phing', 'pear.php.net');
        $p2->setPhpDep('5.2.0');
        $p2->addExtensionDep('required', 'dom');
        $p2->addExtensionDep('required', 'libxml');
        $p2->addExtensionDep('required', 'SPL');
        $p2->addExtensionDep('required', 'Reflection');
        $p2->addExtensionDep('required', 'pcre');
        $p2->addExtensionDep('optional', 'xsl');
        $p2->addExtensionDep('optional', 'tokenizer');
        $p2->addExtensionDep('optional', 'session');
        $p2->addExtensionDep('optional', 'xmlrpc');
        $p2->addExtensionDep('optional', 'PDO');
        $p2->addExtensionDep('optional', 'iconv');
        $p2->addExtensionDep('optional', 'gettext');
        $p2->setPearinstallerDep('1.4.0');
        $p2->setLicense('LGPL', 'http://www.gnu.org/copyleft/lesser.html');
        $p2->addReplacement('bin/agavi-dist', 'pear-config', '@PEAR-DIR@', 'php_dir');
        $p2->addReplacement('bin/agavi-dist', 'pear-config', '@PHP-BIN@', 'php_bin');
        $p2->addReplacement('bin/agavi.bat-dist', 'pear-config', '@PEAR-DIR@', 'php_dir');
        $p2->addReplacement('bin/agavi.bat-dist', 'pear-config', '@PHP-BIN@', 'php_bin');
        $p2->addReplacement('src/build/build.xml', 'pear-config', '@PEAR-DIR@', 'php_dir');
        $p2->generateContents();
        try {
            $p2->writePackageFile();
        } catch (PEAR_Exception $e) {
            $this->log("Oops! Caught PEAR Exception: " . $e->getMessage());
        }
    }
 public function buildSubPackage($dir, $baseinstalldir, $info)
 {
     $package = str_replace('/', '_', $baseinstalldir);
     $opts = array('packagedirectory' => $dir, 'filelistgenerator' => 'file', 'ignore' => array('*composer.json', '*package.xml'), 'baseinstalldir' => '/' . $info['target-dir'], 'packagefile' => 'package.xml');
     $pfm = new PEAR_PackageFileManager2();
     $e = $pfm->setOptions($opts);
     $pfm->setPackage($package);
     $pfm->setSummary($info['description']);
     $pfm->setDescription($info['description']);
     $pfm->setPackageType('php');
     $pfm->setChannel('guzzlephp.org/pear');
     $pfm->setAPIVersion('3.0.0');
     $pfm->setReleaseVersion($this->getVersion());
     $pfm->setAPIStability('stable');
     $pfm->setReleaseStability('stable');
     $pfm->setNotes($this->changelog_notes);
     $pfm->setPackageType('php');
     $pfm->setLicense('MIT', 'http://github.com/guzzle/guzzle/blob/master/LICENSE');
     $pfm->addMaintainer('lead', 'mtdowling', 'Michael Dowling', '*****@*****.**', 'yes');
     $pfm->setDate($this->changelog_release_date);
     $pfm->generateContents();
     $phpdep = $this->guzzleinfo['require']['php'];
     $phpdep = str_replace('>=', '', $phpdep);
     $pfm->setPhpDep($phpdep);
     $pfm->setPearinstallerDep('1.4.6');
     foreach ($info['require'] as $type => $version) {
         if ($type == 'php') {
             continue;
         }
         if ($type == 'symfony/event-dispatcher') {
             $pfm->addPackageDepWithChannel('required', 'EventDispatcher', 'pear.symfony.com', '2.1.0');
         }
         if ($type == 'ext-curl') {
             $pfm->addExtensionDep('required', 'curl');
         }
         if (substr($type, 0, 6) == 'guzzle') {
             $gdep = str_replace('/', ' ', $type);
             $gdep = ucwords($gdep);
             $gdep = str_replace(' ', '_', $gdep);
             $pfm->addPackageDepWithChannel('required', $gdep, 'guzzlephp.org/pear', $this->getVersion());
         }
     }
     // can't have main Guzzle package AND sub-packages
     $pfm->addConflictingPackageDepWithChannel('Guzzle', 'guzzlephp.org/pear', false, $apiversion);
     ob_start();
     $startdir = getcwd();
     chdir((string) $this->basedir . '/build/pearwork');
     echo "DEBUGGING GENERATED PACKAGE FILE\n";
     $result = $pfm->debugPackageFile();
     if ($result) {
         $out = $pfm->writePackageFile();
         echo "\n\n\nWRITE PACKAGE FILE RESULT:\n";
         var_dump($out);
         // load up package file and build package
         $packager = new PEAR_Packager();
         echo "\n\n\nBUILDING PACKAGE FROM PACKAGE FILE:\n";
         $dest_package = $packager->package($opts['packagedirectory'] . '/package.xml');
         var_dump($dest_package);
     } else {
         echo "\n\n\nDEBUGGING RESULT:\n";
         var_dump($result);
     }
     echo "removing package.xml";
     unlink($opts['packagedirectory'] . '/package.xml');
     $log = ob_get_clean();
     file_put_contents((string) $this->basedir . '/build/artifacts/logs/pear_package_' . $package . '.log', $log);
     chdir($startdir);
 }