コード例 #1
0
function run_freeze($task, $args)
{
    // check that the symfony librairies are not already freeze for this project
    if (is_readable(sfConfig::get('sf_lib_dir') . '/symfony')) {
        throw new Exception('You can only freeze when lib/symfony is empty.');
    }
    if (is_readable(sfConfig::get('sf_data_dir') . '/symfony')) {
        throw new Exception('You can only freeze when data/symfony is empty.');
    }
    if (is_readable(sfConfig::get('sf_web_dir') . '/sf')) {
        throw new Exception('You can only freeze when web/sf is empty.');
    }
    if (is_link(sfConfig::get('sf_web_dir') . '/sf')) {
        pake_remove(sfConfig::get('sf_web_dir') . '/sf', '');
    }
    $symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
    $symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
    pake_echo_action('freeze', 'freezing lib found in "' . $symfony_lib_dir . '"');
    pake_echo_action('freeze', 'freezing data found in "' . $symfony_data_dir . '"');
    pake_mkdirs(sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'symfony');
    pake_mkdirs(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'symfony');
    $finder = pakeFinder::type('any')->ignore_version_control();
    pake_mirror($finder, $symfony_lib_dir, sfConfig::get('sf_lib_dir') . '/symfony');
    pake_mirror($finder, $symfony_data_dir, sfConfig::get('sf_data_dir') . '/symfony');
    pake_rename(sfConfig::get('sf_data_dir') . '/symfony/web/sf', sfConfig::get('sf_web_dir') . '/sf');
    // change symfony paths in config/config.php
    file_put_contents('config/config.php.bak', "{$symfony_lib_dir}#{$symfony_data_dir}");
    _change_symfony_dirs("dirname(__FILE__).'/../lib/symfony'", "dirname(__FILE__).'/../data/symfony'");
    // install the command line
    pake_copy($symfony_data_dir . '/bin/symfony.php', 'symfony.php');
}
コード例 #2
0
 /**
  * Downloads the extension from its source repository, removes files not to be built
  * (the list of files to be removed is in part hardcoded and in part specified in
  * the configuration file).
  * Options: skip-init, skip-init-fetch, skip-init-clean
  *
  * @todo add a dependency on a check-updates task that updates script itself?
  * @todo split this in two tasks and avoid this unsightly mess of options?
  */
 static function run_init($task = null, $args = array(), $cliopts = array())
 {
     $skip_init = @$cliopts['skip-init'];
     $skip_init_fetch = @$cliopts['skip-init-fetch'] || $skip_init;
     $skip_init_clean = @$cliopts['skip-init-clean'] || $skip_init;
     if (!$skip_init) {
         $opts = self::getOpts(@$args[0], @$args[1], $cliopts);
         pake_mkdirs(self::getBuildDir($opts));
         $destdir = self::getBuildDir($opts) . '/' . $opts['extension']['name'];
         if (!SharedLock::acquire($opts['extension']['name'], LOCK_EX, $opts)) {
             throw new PakeException("Source code locked by another process");
         }
     }
     if (!$skip_init_fetch) {
         if (@$opts['svn']['url'] != '') {
             pake_echo("Fetching code from SVN repository {$opts['svn']['url']}");
             pakeSubversion::checkout($opts['svn']['url'], $destdir);
             /// @todo test that we got at least one file
             if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                 sleep(3);
             }
         } else {
             if (@$opts['git']['url'] != '') {
                 pake_echo("Fetching code from GIT repository {$opts['git']['url']}");
                 pakeGit::clone_repository($opts['git']['url'], $destdir);
                 if (@$opts['git']['branch'] != '') {
                     /// @todo test checking out a specific branch
                     pakeGit::checkout_repo($destdir, $opts['git']['branch']);
                     /// @todo test that we got at least one file
                 }
                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                     sleep(3);
                 }
             } else {
                 if (@$opts['file']['url'] != '') {
                     pake_echo("Fetching code from local repository {$opts['file']['url']}");
                     /// @todo (!important) exclude stuff we know we're going to delete immediately afterwards
                     $files = pakeFinder::type('any')->relative()->in($opts['file']['url']);
                     if (count($files) == 0) {
                         SharedLock::release($opts['extension']['name'], LOCK_EX, $opts);
                         throw new pakeException("Empty source repo option: no files found in {$opts['file']['url']}");
                     }
                     pake_mirror($files, $opts['file']['url'], $destdir);
                 } else {
                     SharedLock::release($opts['extension']['name'], LOCK_EX, $opts);
                     throw new pakeException("Missing source repo option: either svn:url, git:url or file:url");
                 }
             }
         }
     }
     // remove files
     if (!$skip_init_clean) {
         // known files/dirs not to be packed / md5'ed
         /// @todo !important shall we make this configurable?
         /// @bug 'build' & 'dist' we should probably take from options
         $files = array('ant/', 'build.xml', '**/.svn', '.git/', 'build/', 'dist/', 'composer.phar', 'composer.lock', '.idea/', 'vendor/');
         // hack! when packing ourself, we need to keep this stuff
         if ($opts['extension']['name'] != 'ezextensionbuilder') {
             $files = array_merge($files, array('pake/', 'pakefile.php', '**/.gitignore'));
         }
         // files from user configuration
         $files = array_merge($files, $opts['files']['to_exclude']);
         /// we figured a way to allow user to specify both:
         ///       files in a specific subdir
         ///       files to be removed globally (ie. from any subdir)
         //pakeFinder::type( 'any' )->name( $files )->in( $destdir );
         $files = self::pake_antpattern($files, $destdir);
         foreach ($files as $key => $file) {
             if (is_dir($file)) {
                 pake_remove_dir($file);
                 unset($files[$key]);
             }
         }
         pake_remove($files, '');
     }
     if (!$skip_init) {
         // move package file where it has to be
         $file = pakeFinder::type('file')->name('package.xml')->maxdepth(0)->in($destdir);
         if (count($file)) {
             if ($opts['create']['tarball'] || $opts['create']['zip']) {
                 pake_rename($destdir . '/package.xml', $destdir . '/../../package.xml');
             } else {
                 pake_remove($file, '');
             }
         }
         SharedLock::release($opts['extension']['name'], LOCK_EX, $opts);
     }
 }
コード例 #3
0
ファイル: Tasks.php プロジェクト: gggeek/ezpublishbuilder
 /**
  * Downloads the build tarballs from Jenkins for further repackaging; options: --build=<buildnr>
  */
 public static function run_dist_init($task = null, $args = array(), $cliopts = array())
 {
     $opts = self::getOpts($args, $cliopts);
     $buildnr = @$cliopts['build'];
     if ($buildnr == '') {
         pake_echo('Fetching latest available build');
         $buildnr = 'lastBuild';
     }
     // get list of files from the build
     $out = self::jenkinsCall('job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr . '/api/json', $opts);
     if (!is_array($out) || !is_array(@$out['artifacts'])) {
         pake_echo('Error in retrieving build description from Jenkins or no artifacts in build');
         return;
     } else {
         if ($buildnr == 'lastBuild') {
             pake_echo('Found build ' . $out['number']);
         }
     }
     // find the correct variant
     //$buildurl = self::jenkinsUrl( 'job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr, $opts );
     $fileurl = '';
     foreach ($out['artifacts'] as $artifact) {
         if (substr($artifact['fileName'], -4) == '.bz2') {
             $fileurl = 'job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr . '/artifact/' . $artifact['relativePath'];
             break;
         }
     }
     if ($fileurl == '') {
         pake_echo("No artifacts available for build {$buildnr}");
         return;
     }
     // clean up the 'release' dir
     $rootpath = $opts['build']['dir'] . '/release';
     /// @todo this method is a bit slow, should find a faster one
     pake_remove_dir($rootpath);
     // download and unzip the file
     pake_mkdirs($rootpath);
     $filename = $rootpath . '/' . $artifact['fileName'];
     pake_write_file($filename, self::jenkinsCall($fileurl, $opts, 'GET', null, false), 'cpb');
     // and unzip eZ into it - in a folder with a specific name
     $tar = self::getTool('tar', $opts);
     pake_sh(self::getCdCmd($rootpath) . " && {$tar} -xjf " . escapeshellarg($artifact['fileName']));
     $currdir = pakeFinder::type('directory')->in($rootpath);
     $currdir = $currdir[0];
     $finaldir = $rootpath . '/' . self::getProjName();
     pake_rename($currdir, $finaldir);
     pake_echo("dir+         " . $finaldir);
 }