cvs: peardoc /scripts pearwebbuild.php

From: Date: Tue, 30 Dec 2008 15:39:26 +0000
Subject: cvs: peardoc /scripts pearwebbuild.php
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-11405@lists.php.net to get a copy of this message
cweiske Tue Dec 30 15:39:26 2008 UTC Modified files: /peardoc/scripts pearwebbuild.php Log: - output directory for php files - don't stop script if a language build fails http://cvs.php.net/viewvc.cgi/peardoc/scripts/pearwebbuild.php?r1=1.10&r2=1.11&diff_format=u Index: peardoc/scripts/pearwebbuild.php diff -u peardoc/scripts/pearwebbuild.php:1.10 peardoc/scripts/pearwebbuild.php:1.11 --- peardoc/scripts/pearwebbuild.php:1.10 Fri Dec 19 10:38:30 2008 +++ peardoc/scripts/pearwebbuild.php Tue Dec 30 15:39:26 2008 @@ -4,30 +4,56 @@ * * This script runs the configure scripts, and generates the bightml, chunked, and pearweb * files for use in the pearweb project. - * Currently at http://ucommbieber.unl.edu/peardoc/build/, rsync://ucommbieber.unl.edu/peardoc + * Used at http://pear.php.net/ and + * http://ucommbieber.unl.edu/peardoc/build/, rsync://ucommbieber.unl.edu/peardoc * - * Usage: php pearwebuild.php [updatecvs [updatephd]] + * Usage: php pearwebuild.php [--updatecvs] [--updatephd] */ -$cwd = getcwd(); - $php_executable = 'php'; $phd_executable = 'phd'; $pear_executable = 'pear'; +$tobuildlog = ' >> build/build.log 2>&1'; +$fails = 0; if (isset($_SERVER['_'])) { $php_executable = $_SERVER['_']; } -if (isset($_SERVER['argv'], $_SERVER['argv'][1]) - && $_SERVER['argv'][1] == 'updatecvs') { +require_once 'Console/CommandLine.php'; +$parser = new Console_CommandLine(); +$parser->description = 'Builds the full manual'; +$parser->version = '$Id: pearwebbuild.php,v 1.11 2008/12/30 15:39:26 cweiske Exp $'; +$parser->addOption('updatecvs', array( + 'long_name' => '--updatecvs', + 'description' => 'Update peardoc from CVS', + 'action' => 'StoreTrue' +)); +$parser->addOption('updatephd', array( + 'long_name' => '--updatephd', + 'description' => 'Update phd from CVS', + 'action' => 'StoreTrue' +)); +$parser->addOption('phpdir', array( + 'long_name' => '--phpdir', + 'description' => 'Directory to copy php manual to', + 'action' => 'StoreString' +)); + +try { + $cmdline = $parser->parse(); +} catch (Exception $exc) { + $parser->displayError($exc->getMessage()); +} + + +if ($cmdline->options['updatecvs']) { chdir(dirname(dirname(dirname(__FILE__)))); // Update cvs shell_exec('cvs -d :pserver:cvsread@cvs.php.net:/repository checkout peardoc'); } -if (isset($_SERVER['argv'], $_SERVER['argv'][2]) - && $_SERVER['argv'][2] == 'updatephd') { +if ($cmdline->options['updatephd']) { chdir(dirname(dirname(dirname(__FILE__)))); // Update cvs shell_exec('cvs -d :pserver:cvsread@cvs.php.net:/repository checkout phd'); @@ -36,26 +62,39 @@ } +function logAndEcho($message) +{ + echo $message . PHP_EOL; + file_put_contents('build/build.log', + '[pearwebbuild] ' . $message . PHP_EOL, + FILE_APPEND + ); +} + + chdir(dirname(dirname(__FILE__))); passthru('rm -rf build/ && mkdir build'); logAndEcho("Starting Build\n".date('Y-m-d H:i:s')); $langs = glob('??{,_??}', GLOB_ONLYDIR | GLOB_BRACE); + foreach ($langs as $lang) { logAndEcho("Building peardoc/$lang with php configure.php --lang=$lang"); - exec("$php_executable configure.php --lang=$lang", $output, $return); + exec("$php_executable configure.php --no-display-untranslated --lang=$lang", $output, $return); + if ($return == 0) { if ($lang == 'en') { logAndEcho("Building pearweb package tocs"); - shell_exec("$php_executable scripts/pearwebpackagetocs.php >> build/build.log"); + shell_exec("$php_executable scripts/pearwebpackagetocs.php" . $tobuildlog); } logAndEcho("Now running phd for $lang"); //bightml logAndEcho(' Rendering and bzipping pearbightml downloadable file'); - shell_exec("$phd_executable -f xhtml -t pearbightml -o build/$lang -d giant.xml >> build/build.log"); + shell_exec("$phd_executable -f xhtml -t pearbightml -o build/$lang -d giant.xml" . $tobuildlog); + passthru('bzip2' . ' ' . escapeshellarg("build/$lang/pear_manual_en.html") . ' --stdout' @@ -72,7 +111,7 @@ //chunkedhtml logAndEcho(' Rendering and bzipping pearchunked downloadable zip'); - shell_exec("$phd_executable -f xhtml -t pearchunkedhtml -o build/$lang -d giant.xml >> build/build.log"); + shell_exec("$phd_executable -f xhtml -t pearchunkedhtml -o build/$lang -d giant.xml" . $tobuildlog); passthru( "cd build/$lang/ && mv html pear_manual_$lang && " . 'tar cj --to-stdout' @@ -86,28 +125,38 @@ . ' ' . escapeshellarg("pear_manual_$lang.zip") . ' ' . escapeshellarg("pear_manual_$lang") - . ' >> build/build.log' + . $tobuildlog ); //pearweb - shell_exec("$phd_executable -f xhtml -t pearweb -o build/$lang -d giant.xml >> build/build.log"); + shell_exec("$phd_executable -f xhtml -t pearweb -o build/$lang -d giant.xml" . $tobuildlog); + + if ($cmdline->options['phpdir']) { + //copy pearweb build to directory + $phplangdir = $cmdline->options['phpdir'] . '/' . $lang; + if (file_exists($phplangdir)) { + shell_exec('rm -rf ' . escapeshellarg($phplangdir) . $tobuildlog); + } + if (!file_exists($cmdline->options['phpdir'])) { + mkdir($cmdline->options['phpdir'], 0755, true); + } + shell_exec("mv build/$lang/php " . escapeshellarg($phplangdir) . $tobuildlog); + } // Remove chm build until we can get a chm compiler going. - //shell_exec("$phd_executable -f xhtml -t pearchm -o build/$lang -d giant.xml >> build/build.log"); + //shell_exec("$phd_executable -f xhtml -t pearchm -o build/$lang -d giant.xml" . $tobuildlog); logAndEcho(" Finished peardoc/$lang"); } else { - logAndEcho('Error configuring:'); + logAndEcho("Error configuring --lang=$lang:"); logAndEcho(implode("\n", $output)); - exit(1); + ++$fails; } + logAndEcho("\n"); } logAndEcho("Build complete\n" . date('Y-m-d H:i:s')); +$fails && logAndEcho($fails . ' failed builds'); -function logAndEcho($message) -{ - echo $message.PHP_EOL; - file_put_contents('build/build.log', $message.PHP_EOL, FILE_APPEND); -} - +exit($fails); +?> \ No newline at end of file

« previous php.pear.doc (#11405) next »