svn: /pear/peardoc/trunk/scripts/ pearwebbuild.php
[email protected] (Christian Weiske)
| Newsgroups | php.pear.doc |
|---|---|
| Message-ID | <[email protected]> |
cweiske Tue, 08 Dec 2009 06:53:23 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=291862
Log:
always check for errors. and we see: zipping does not work
Changed paths:
U pear/peardoc/trunk/scripts/pearwebbuild.php
svn-diffs-291862.txt
(text/x-diff, 12.8 KB)
Modified: pear/peardoc/trunk/scripts/pearwebbuild.php
===================================================================
--- pear/peardoc/trunk/scripts/pearwebbuild.php 2009-12-08 06:29:59 UTC (rev 291861)
+++ pear/peardoc/trunk/scripts/pearwebbuild.php 2009-12-08 06:53:23 UTC (rev 291862)
@@ -87,6 +87,41 @@
);
}
+/**
+ * Calls passthru() and checks the return value
+ *
+ * @param string $command Command to passthru()
+ *
+ * @return void
+ * @uses checkReturn()
+ */
+function passthruCheckReturn($command)
+{
+ passthru($command, $return);
+ checkReturn($return, $command);
+}
+
+/**
+ * Check the given return value and show error when it
+ * is != 0. Also die(), since the error should not occur.
+ *
+ * @param integer $retval Return code
+ * @param string $command Command that was executed
+ *
+ * @return void
+ */
+function checkReturn($retval, $command = null)
+{
+ if ($retval === 0) {
+ return;
+ }
+ logAndEcho(' Return value is not 0 but ' . $retval);
+ if ($command) {
+ logAndEcho( 'Command was: ' . $command);
+ }
+ exit(9);
+}
+
$render = !$cmdline->options['norender'];
chdir(dirname(dirname(__FILE__)));
@@ -107,165 +142,184 @@
$return = 0;
}
- if ($return == 0) {
- logAndEcho("Now running phd for $lang");
+ if ($return != 0) {
+ logAndEcho("Error configuring --lang=$lang:");
+ logAndEcho(implode("\n", $output) . "\n");
+ ++$fails;
+ continue;
+ }
- $extracopyfiles = '';
+ logAndEcho("Now running phd for $lang");
- //bightml
- if ($render) {
- logAndEcho(' Rendering all pear themes');
- shell_exec("$phd_executable -L $lang -P PEAR -o build/$lang -d .manual.xml" . $tobuildlog);
- } else {
- logAndEcho(' Skipping rendering');
- }
+ $extracopyfiles = '';
- // bzip2
- logAndEcho(' Bzipping pearbightml downloadable file');
- passthru(
- 'bzip2'
- . ' ' . escapeshellarg("build/$lang/pear-bigxhtml.html")
- . ' --stdout'
- . ' > ' . escapeshellarg("build/$lang/pear_manual_$lang.html.bz2")
+ //all output formats
+ if ($render) {
+ logAndEcho(' Rendering all pear themes');
+ exec(
+ "$phd_executable -L $lang -P PEAR -o build/$lang -d .manual.xml" . $tobuildlog,
+ $output,
+ $return
);
+ checkReturn($return);
+ } else {
+ logAndEcho(' Skipping rendering');
+ }
- // gz
- passthru(
- 'gzip'
- . ' ' . escapeshellarg("build/$lang/pear-bigxhtml.html")
- . ' --stdout'
- . ' > ' . escapeshellarg("build/$lang/pear_manual_$lang.html.gz")
- );
+ // bzip2
+ logAndEcho(' Packing up pearbightml downloadable file');
+ passthruCheckReturn(
+ 'bzip2'
+ . ' ' . escapeshellarg("build/$lang/pear-bigxhtml.html")
+ . ' --stdout'
+ . ' > ' . escapeshellarg("build/$lang/pear_manual_$lang.html.bz2")
+ );
- // zip
- passthru(
- "cd build/$lang/ &&"
- . 'zip -q'
- . ' ' . escapeshellarg("pear_manual_$lang.html.zip")
- . ' ' . escapeshellarg("pear_manual_en.html")
- . $tobuildlog
- );
+ // gz
+ passthruCheckReturn(
+ 'gzip'
+ . ' ' . escapeshellarg("build/$lang/pear-bigxhtml.html")
+ . ' --stdout'
+ . ' > ' . escapeshellarg("build/$lang/pear_manual_$lang.html.gz")
+ );
- //chunkedhtml
- logAndEcho(' Bzipping pearchunked downloadable zip');
+ // zip
+ passthruCheckReturn(
+ "cd build/$lang/ &&"
+ . 'zip -q'
+ . ' ' . escapeshellarg("pear_manual_$lang.html.zip")
+ . ' ' . escapeshellarg("pear_manual_en.html")
+ . $tobuildlog
+ );
- // tar.bz2
- passthru(
- "cd build/$lang/ &&"
- . " mv pear-chunked-xhtml pear_manual_$lang &&"
- . ' tar cj --to-stdout'
- . ' ' . escapeshellarg("pear_manual_$lang")
- . ' > '
- . escapeshellarg("pear_manual_$lang.tar.bz2")
- );
- // tar.gz
- passthru(
- "cd build/$lang/ &&"
- . ' tar cfz ' . escapeshellarg("pear_manual_$lang.tar.gz")
- . ' ' . escapeshellarg("pear_manual_$lang")
- . $tobuildlog
- );
- // zip
- passthru(
- "cd build/$lang/ &&"
- . 'zip -r'
- . ' ' . escapeshellarg("pear_manual_$lang.zip")
- . ' '
- . escapeshellarg("pear_manual_$lang")
- . $tobuildlog
- );
+ logAndEcho(' Packing up pearchunked downloadable files');
- //restore old directory name for re-runs without recompilation
- passthru(
- "cd build/$lang/ &&"
- . " mv pear_manual_$lang pear-chunked-xhtml"
- );
+ // tar.bz2
+ passthruCheckReturn(
+ "cd build/$lang/ &&"
+ . " mv pear-chunked-xhtml pear_manual_$lang &&"
+ . ' tar cj --to-stdout'
+ . ' ' . escapeshellarg("pear_manual_$lang")
+ . ' > '
+ . escapeshellarg("pear_manual_$lang.tar.bz2")
+ );
+ // tar.gz
+ passthruCheckReturn(
+ "cd build/$lang/ &&"
+ . ' tar cfz ' . escapeshellarg("pear_manual_$lang.tar.gz")
+ . ' ' . escapeshellarg("pear_manual_$lang")
+ . $tobuildlog
+ );
+ // zip
+ passthruCheckReturn(
+ "cd build/$lang/ &&"
+ . 'zip -r'
+ . ' ' . escapeshellarg("pear_manual_$lang.zip")
+ . ' '
+ . escapeshellarg("pear_manual_$lang")
+ . $tobuildlog
+ );
+ //restore old directory name for re-runs without recompilation
+ passthruCheckReturn(
+ "cd build/$lang/ &&"
+ . " mv pear_manual_$lang pear-chunked-xhtml"
+ );
- //pearweb package tocs
- if ($lang == 'en') {
- if ($render) {
- logAndEcho(' Building pearweb package tocs');
- shell_exec("$php_executable scripts/pearwebpackagetocs.php" . $tobuildlog);
- } else {
- logAndEcho(' Skipping rendering pearweb package tocs');
- }
+
+ //pearweb package tocs
+ if ($lang == 'en') {
+ if ($render) {
+ logAndEcho(' Building pearweb package tocs');
+ exec(
+ "$php_executable scripts/pearwebpackagetocs.php" . $tobuildlog,
+ $output, $return
+ );
+ checkReturn($return);
+ } else {
+ logAndEcho(' Skipping rendering pearweb package tocs');
}
+ }
- 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/pear-web " . escapeshellarg($phplangdir) . $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);
+ }
+ exec(
+ "mv build/$lang/pear-web " . escapeshellarg($phplangdir) . $tobuildlog,
+ $output, $return
+ );
+ checkReturn($return);
- //move packagetoc over, too
- if (file_exists("build/$lang/packagetocs")) {
- shell_exec("mv build/$lang/packagetocs " . escapeshellarg($phplangdir . '/packagetocs/') . $tobuildlog);
- }
+ //move packagetoc over, too
+ if (file_exists("build/$lang/packagetocs")) {
+ exec(
+ "mv build/$lang/packagetocs " . escapeshellarg($phplangdir . '/packagetocs/') . $tobuildlog,
+ $output, $return
+ );
+ checkReturn($return);
}
+ }
- if ($cmdline->options['hhc']) {
- // we need to chmod the chm dir since the html help compiler
- // is being run as an own user
- if ($render) {
- logAndEcho(' Compiling chm manual');
- passthru(
- "chmod og+w build/$lang/pear-chm &&"
- . " cd build/$lang/pear-chm && "
- . $cmdline->options['hhc']
- . ' pear_manual_' . $lang . '.hhp'
- . $tobuildlog
- );
- } else {
- logAndEcho(' Skipping compiling chm manual');
- }
+ if ($cmdline->options['hhc']) {
+ // we need to chmod the chm dir since the html help compiler
+ // is being run as an own user
+ if ($render) {
+ logAndEcho(' Compiling chm manual');
+ passthruCheckReturn(
+ "chmod og+w build/$lang/pear-chm &&"
+ . " cd build/$lang/pear-chm && "
+ . $cmdline->options['hhc']
+ . ' pear_manual_' . $lang . '.hhp'
+ . $tobuildlog
+ );
+ } else {
+ logAndEcho(' Skipping compiling chm manual');
+ }
- $chmfile = "build/$lang/chm/pear_manual_$lang.chm";
- if (file_exists($chmfile)) {
- $extracopyfiles .= ' ' . escapeshellarg($chmfile);
- } else {
- logAndEcho('Tried to compile chm, but chm file does not exist.');
- logAndEcho($chmfile);
- }
+ $chmfile = "build/$lang/chm/pear_manual_$lang.chm";
+ if (file_exists($chmfile)) {
+ $extracopyfiles .= ' ' . escapeshellarg($chmfile);
+ } else {
+ logAndEcho('Tried to compile chm, but chm file does not exist.');
+ logAndEcho($chmfile);
}
+ }
- // move compressed downloadable files to downloaddir
- if ($cmdline->options['downloaddir'] !== null) {
- if (is_writeable($cmdline->options['downloaddir'])) {
- logAndEcho(
- ' Moving downloadable file to '
- . escapeshellarg($cmdline->options['downloaddir'])
- );
- shell_exec(
- 'mv'
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.bz2")
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.gz")
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.zip")
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.tar.bz2")
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.tar.gz")
- . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.zip")
- . ' ' . $extracopyfiles
- . ' ' . escapeshellarg($cmdline->options['downloaddir'])
- . $tobuildlog
- );
- }
+ // move compressed downloadable files to downloaddir
+ if ($cmdline->options['downloaddir'] !== null) {
+ if (is_writeable($cmdline->options['downloaddir'])) {
+ logAndEcho(
+ ' Moving downloadable file to '
+ . escapeshellarg($cmdline->options['downloaddir'])
+ );
+ exec(
+ 'mv'
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.bz2")
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.gz")
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.html.zip")
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.tar.bz2")
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.tar.gz")
+ . ' ' . escapeshellarg("build/$lang/pear_manual_$lang.zip")
+ . ' ' . $extracopyfiles
+ . ' ' . escapeshellarg($cmdline->options['downloaddir'])
+ . $tobuildlog,
+ $output, $return
+ );
+ checkReturn($return);
}
+ }
- // Remove chm build until we can get a chm compiler going.
- //shell_exec("$phd_executable -f xhtml -t pearchm -o build/$lang -d .manual.xml" . $tobuildlog);
+ // Remove chm build until we can get a chm compiler going.
+ //shell_exec("$phd_executable -f xhtml -t pearchm -o build/$lang -d .manual.xml" . $tobuildlog);
- logAndEcho(" Finished peardoc/$lang");
- } else {
- logAndEcho("Error configuring --lang=$lang:");
- logAndEcho(implode("\n", $output));
- ++$fails;
- }
+ logAndEcho(" Finished peardoc/$lang");
logAndEcho("\n");
}