Beispiel #1
0
 /**
  * delete files indicated in the given manifest file, from the indicated target
  * directory.
  * @param string $ficlist manifest file name
  * @param string $distpath directory were files are copied
  */
 public static function removeFiles($ficlist, $distpath)
 {
     $distdir = jBuildUtils::normalizeDir($distpath);
     $script = file($ficlist);
     $currentdestdir = '';
     $preproc = new jPreProcessor();
     foreach ($script as $nbline => $line) {
         $nbline++;
         if (preg_match(';^(cd|rmd)?\\s+([a-zA-Z0-9\\/.\\-_]+)\\s*$;m', $line, $m)) {
             if ($m[1] == 'rmd') {
                 $currentdestdir = jBuildUtils::normalizeDir($m[2]);
                 jBuildUtils::removeDir($distdir . $currentdestdir, self::$usedVcs);
             } elseif ($m[1] == 'cd') {
                 $currentdestdir = jBuildUtils::normalizeDir($m[2]);
             } else {
                 if ($m[2] == '') {
                     throw new Exception("{$ficlist} : file required on line {$nbline} \n");
                 }
                 $destfile = $distdir . $currentdestdir . $m[2];
                 if (!file_exists($destfile)) {
                     if (self::$verbose) {
                         echo "cannot remove {$destfile}. It doesn't exist.\n";
                     }
                     continue;
                 }
                 if (self::$verbose) {
                     echo "remove  " . $destfile . "\n";
                 }
                 switch (self::$usedVcs) {
                     case '':
                     case 'rm':
                         if (!unlink($destfile)) {
                             throw new Exception(" {$ficlist}: cannot remove file " . $m[2] . ", line {$nbline} \n");
                         }
                         break;
                     case 'svn':
                         $d = getcwd();
                         chdir(dirname($destfile));
                         exec("svn remove {$destfile}");
                         chdir($d);
                         break;
                     case 'hg':
                         $d = getcwd();
                         chdir(dirname($destfile));
                         exec("hg remove {$destfile}");
                         chdir($d);
                         break;
                 }
             }
         } elseif (preg_match("!^\\s*(\\#.*)?\$!", $line)) {
             // we ignore comments
         } else {
             throw new Exception("{$ficlist} : syntax error on line {$nbline} \n");
         }
     }
 }
Beispiel #2
0
 public static function revision($path = '.')
 {
     $path = jBuildUtils::normalizeDir($path);
     $rev = -1;
     if (file_exists($path . '.hg')) {
         $rev = `hg tip --template "{rev}" -R {$path}`;
         if (preg_match("/(\\d+)/", $rev, $m)) {
             $rev = $m[1];
         }
     }
     return $rev;
 }
Beispiel #3
0
$SOURCE_REVISION = Git::revision(dirname(__FILE__) . '/../');
$IS_NIGHTLY = strpos($LIB_VERSION, 'SERIAL') !== false;
if ($IS_NIGHTLY) {
    $PACKAGE_NAME = 'jelix-' . str_replace('SERIAL', '', $LIB_VERSION);
    if (substr($PACKAGE_NAME, -1, 1) == '.') {
        $PACKAGE_NAME = substr($PACKAGE_NAME, 0, -1);
    }
    $PACKAGE_NAME .= '-pdf-fonts';
    $LIB_VERSION = str_replace('SERIAL', $SOURCE_REVISION, $LIB_VERSION);
} else {
    $PACKAGE_NAME = 'jelix-' . $LIB_VERSION . '-pdf-fonts';
}
if ($PACKAGE_ZIP) {
    $BUILD_TARGET_PATH = jBuildUtils::normalizeDir($MAIN_TARGET_PATH) . $PACKAGE_NAME . '/';
} else {
    $BUILD_TARGET_PATH = jBuildUtils::normalizeDir($MAIN_TARGET_PATH);
}
//----------------- build the package
//... directory creation
jBuildUtils::createDir($BUILD_TARGET_PATH);
//... copying files
jManifest::process('build/manifests/fonts.mn', '.', $BUILD_TARGET_PATH, ENV::getAll());
//... packages
//if($PACKAGE_TAR_GZ){
//    exec('tar czf '.$MAIN_TARGET_PATH.'/'.$PACKAGE_NAME.'.tar.gz -C '.$MAIN_TARGET_PATH.' '.$PACKAGE_NAME);
//}
if ($PACKAGE_ZIP) {
    chdir($MAIN_TARGET_PATH);
    exec('zip -r ' . $PACKAGE_NAME . '.zip ' . $PACKAGE_NAME);
    chdir(dirname(__FILE__));
}
Beispiel #4
0
 public static function revision($path = '.')
 {
     $path = jBuildUtils::normalizeDir($path);
     $rev = -1;
     if (file_exists($path . '.git')) {
         $logs = `git shortlog -s`;
         $logs = explode("\n", $logs);
         $rev = 0;
         foreach ($logs as $log) {
             if (preg_match("/^\\s*(\\d+)/", $log, $m)) {
                 $rev += intval($m[1]);
             }
         }
     }
     return $rev;
 }