exit(1); } array_shift($_SERVER['argv']); // shift the script name $restrictedDirectory = ''; $options = array('verbose' => false); if (substr($_SERVER['argv'][0], 0, 1) == '-') { $sw = substr(array_shift($_SERVER['argv']), 1); $options['verbose'] = strpos($sw, 'v') !== false; if (strpos($sw, 'd') !== false) { $restrictedDirectory = array_shift($_SERVER['argv']); } } list($sourcefile, $distfile) = $_SERVER['argv']; if ($restrictedDirectory != '') { $s = realpath($sourcefile); if (strpos($s, $restrictedDirectory) !== 0) { exit(1); } } try { $proc = new jPreProcessor(); $proc->setVars($_SERVER); $dist = $proc->parseFile($sourcefile); } catch (Exception $e) { echo $e; exit(1); } jBuildUtils::createDir(dirname($distfile)); file_put_contents($distfile, $dist); exit(0);
$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__)); } exit(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"); } } }
if ($VERSION == 'SERIAL') { $VERSION = 'SERIAL-' . $SOURCE_REVISION; $IS_NIGHTLY = true; } else { $IS_NIGHTLY = false; } if ($PACKAGE_TAR_GZ || $PACKAGE_ZIP) { $BUILD_SUBPATH = 'additionnal-modules/'; if ($IS_NIGHTLY) { $PACKAGE_NAME = 'additionnal-modules-nightly'; } else { $PACKAGE_NAME = 'additionnal-modules-HG-' . $SOURCE_REVISION; } } else { $BUILD_SUBPATH = 'lib/jelix-modules/'; } //----------------- Génération des sources //... creation des repertoires jBuildUtils::createDir($MAIN_TARGET_PATH . $BUILD_SUBPATH); //... execution des manifests jManifest::process('build/manifests/jelix-modules.mn', 'lib/jelix-modules/', $MAIN_TARGET_PATH . $BUILD_SUBPATH, ENV::getAll()); //... packages if ($PACKAGE_TAR_GZ) { exec('tar czf ' . $MAIN_TARGET_PATH . $PACKAGE_NAME . '.tar.gz -C ' . $MAIN_TARGET_PATH . ' ' . $BUILD_SUBPATH); } if ($PACKAGE_ZIP) { chdir($MAIN_TARGET_PATH); exec('zip -r ' . $PACKAGE_NAME . '.zip ' . $BUILD_SUBPATH); chdir(dirname(__FILE__)); } exit(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; }
$PACKAGE_NAME = $APPNAME . '-' . $VERSION; } Env::setFromFile('LIB_VERSION', 'lib/jelix/VERSION', true); $IS_LIB_NIGHTLY = strpos($LIB_VERSION, 'SERIAL') !== false; if ($IS_LIB_NIGHTLY) { $LIB_VERSION = str_replace('SERIAL', $SOURCE_REVISION, $LIB_VERSION); } if (preg_match('/\\.([a-z0-9\\-]+)$/i', $LIB_VERSION, $m)) { $LIB_VERSION_MAX = substr($LIB_VERSION, 0, -strlen($m[1])) . "*"; } else { $LIB_VERSION_MAX = $LIB_VERSION; } if ($PACKAGE_TAR_GZ || $PACKAGE_ZIP) { //$MAIN_TARGET_PATH = jBuildUtils::normalizeDir($MAIN_TARGET_PATH).$PACKAGE_NAME; } //----------------- Génération des sources //... creation des repertoires jBuildUtils::createDir($MAIN_TARGET_PATH); //... execution des manifests jManifest::process('build/manifests/' . $APPNAME . '.mn', '.', $MAIN_TARGET_PATH, ENV::getAll()); file_put_contents($MAIN_TARGET_PATH . $APPDIR . '/VERSION', $VERSION); //... packages if ($PACKAGE_TAR_GZ) { exec('tar czf ' . $MAIN_TARGET_PATH . $PACKAGE_NAME . '.tar.gz -C ' . $MAIN_TARGET_PATH . ' ' . $APPNAME); } if ($PACKAGE_ZIP) { chdir($MAIN_TARGET_PATH); exec('zip -r ' . $PACKAGE_NAME . '.zip ' . $APPNAME); chdir(dirname(__FILE__)); } exit(0);
jManifest::process('build/manifests/jelix-admin-modules.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); if ($INCLUDE_ALL_FONTS) { jManifest::process('build/manifests/fonts.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); } if ($ENABLE_PHP_JELIX && ($PACKAGE_TAR_GZ || $PACKAGE_ZIP)) { jManifest::process('build/manifests/jelix-ext-php.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); } // jtpl standalone for wizard Env::setFromFile('JTPL_VERSION', 'lib/jelix/tpl/VERSION', true); if ($IS_NIGHTLY) { $JTPL_VERSION = str_replace('SERIAL', $SOURCE_REVISION, $JTPL_VERSION); } $var = ENV::getAll(); $var['JTPL_STANDALONE'] = true; $jtplpath = $BUILD_TARGET_PATH . 'lib/installwizard/jtpl/'; jBuildUtils::createDir($jtplpath); jManifest::process('build/manifests/jtpl-standalone.mn', '.', $jtplpath, $var); file_put_contents($jtplpath . '/VERSION', $JTPL_VERSION); // the standalone checker $var = ENV::getAll(); $var['STANDALONE_CHECKER'] = true; jManifest::process('build/manifests/jelix-checker.mn', '.', $BUILD_TARGET_PATH, $var); file_put_contents($BUILD_TARGET_PATH . 'lib/jelix/VERSION', $LIB_VERSION); // creation du fichier d'infos sur le build $view = array('EDITION_NAME', 'PHP_VERSION_TARGET', 'SOURCE_REVISION', 'ENABLE_PHP_XMLRPC', 'ENABLE_PHP_JELIX', 'WITH_BYTECODE_CACHE', 'ENABLE_DEVELOPER', 'ENABLE_OPTIMIZED_SOURCE', 'STRIP_COMMENT'); $infos = '; --- build date: ' . date('Y-m-d H:i') . "\n; --- lib version: {$LIB_VERSION}\n" . ENV::getIniContent($view); file_put_contents($BUILD_TARGET_PATH . 'lib/jelix/BUILD', $infos); //... packages if ($PACKAGE_TAR_GZ || $PACKAGE_ZIP) { file_put_contents($MAIN_TARGET_PATH . '/PACKAGE_NAME', $PACKAGE_NAME); }
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; }