From 99ff0c0408c069caca0f76d799eb6fd9646abf6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Javier=20Fern=C3=A1ndez-Sanguino?= Date: Wed, 3 Apr 2013 18:53:22 +0000 Subject: [PATCH] Check that all binaries needed are installed before running git-svn-id: https://projectaon.org/data/trunk@2222 f6f3e2d7-ff33-0410-aaf5-b4bee2cdac11 --- common/scripts/gbtopml.pl | 15 ++++++++++++++- common/scripts/gbtosvg.pl | 13 +++++++++++++ common/scripts/gbtoxhtml-less-simple.pl | 11 +++++++++++ common/scripts/gbtoxhtml-simple.pl | 15 +++++++++++++-- common/scripts/gbtoxhtml.pl | 11 +++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/common/scripts/gbtopml.pl b/common/scripts/gbtopml.pl index c8a87c2..9bbf88a 100755 --- a/common/scripts/gbtopml.pl +++ b/common/scripts/gbtopml.pl @@ -14,6 +14,19 @@ my $PATH_PREFIX = "$ENV{'HOME'}/aon/data"; my $XML_PATH = "$PATH_PREFIX/xml"; my $PML_PATH = "$PATH_PREFIX/pml"; +my $JAVA = '/usr/bin/java'; + +# Check that all the binaries are were want them + +my @BINARIES; +push @BINARIES, ($JAVA); + +foreach (@BINARIES) { + if ( ! -e $_ ) { + die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n"; + } +} + ## unless( $ARGV[ 0 ] ) { die "Usage:\n\t${PROGRAM_NAME} book-code\n"; } @@ -87,4 +100,4 @@ elsif( $bookCode eq "12tmod" ) { } else{ die "Error:\n\tUknown book code.\n"; } -print qx{java org.apache.xalan.xslt.Process -IN $XML_PATH/$XML_SOURCE -XSL $XML_PATH/pml.xsl -OUT $PML_PATH/$BOOK_PATH/$bookCode.txt -PARAM use-illustrators \"$USE_ILLUSTRATORS\"}; +print qx{$JAVA org.apache.xalan.xslt.Process -IN $XML_PATH/$XML_SOURCE -XSL $XML_PATH/pml.xsl -OUT $PML_PATH/$BOOK_PATH/$bookCode.txt -PARAM use-illustrators \"$USE_ILLUSTRATORS\"}; diff --git a/common/scripts/gbtosvg.pl b/common/scripts/gbtosvg.pl index f996ccb..e9fa73f 100755 --- a/common/scripts/gbtosvg.pl +++ b/common/scripts/gbtosvg.pl @@ -16,6 +16,19 @@ my $JAVA = '/usr/bin/java'; my $XALAN_JAR = '/usr/share/java/xalan2.jar'; my $DOT = '/usr/local/bin/dot'; + +# Check that all the binaries are were want them + +my @BINARIES; +push @BINARIES, ($RXP, $JAVA, $XALAN_JAR, $DOT); + +foreach (@BINARIES) { + if ( ! -e $_ ) { + die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n"; + } +} + + ### my $bookCode = ''; diff --git a/common/scripts/gbtoxhtml-less-simple.pl b/common/scripts/gbtoxhtml-less-simple.pl index db9cc78..feae705 100755 --- a/common/scripts/gbtoxhtml-less-simple.pl +++ b/common/scripts/gbtoxhtml-less-simple.pl @@ -21,6 +21,17 @@ my $ZIP = '/usr/bin/zip'; my $JAVA = '/usr/bin/java'; my $XALAN_JAR = '/usr/share/java/xalan2.jar'; +# Check that all the binaries are were want them + +my @BINARIES; +push @BINARIES, ($RXP, $CP, $MV, $ZIP, $JAVA, $XALAN_JAR, $RM); + +foreach (@BINARIES) { + if ( ! -e $_ ) { + die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n"; + } +} + ### my $bookCode = ''; diff --git a/common/scripts/gbtoxhtml-simple.pl b/common/scripts/gbtoxhtml-simple.pl index fc1df53..09dc2a5 100755 --- a/common/scripts/gbtoxhtml-simple.pl +++ b/common/scripts/gbtoxhtml-simple.pl @@ -18,7 +18,7 @@ unless( -e $RXP && -x $RXP ) { # try somewhere else $RXP = '/usr/local/bin/rxp'; } -my $ZIP = '/usr/bin/zip -q'; +my $ZIP = '/usr/bin/zip'; my $JAVA = '/usr/bin/java'; # latest binary download names the relevant jar "xalan.jar" # older installations may have "xalan2.jar" @@ -28,6 +28,17 @@ unless( -e $XALAN_JAR ) { $XALAN_JAR = '/usr/share/java/xalan2.jar'; } +# Check that all the binaries are were want them + +my @BINARIES; +push @BINARIES, ($RXP, $ZIP, $JAVA, $XALAN_JAR); + +foreach (@BINARIES) { + if ( ! -e $_ ) { + die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n"; + } +} + ### my $bookCode = ''; @@ -122,7 +133,7 @@ if( $bookXML =~ m{^([-\w\@./]+)$} ) { my $bookPath = "$outPath${FILENAME_SEPARATOR}${bookCode}"; print qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "${bookXML}" -XSL "${xhtmlXSL}" -OUT "${bookPath}.htm" -PARAM use-illustrators "$rulesHash{'use-illustrators'}"}; - print qx{$ZIP $bookPath.zip $bookPath.htm}; + print qx{$ZIP -q $bookPath.zip $bookPath.htm}; } print "Success\n" if $verbose; diff --git a/common/scripts/gbtoxhtml.pl b/common/scripts/gbtoxhtml.pl index 194c30b..2a4bd3d 100755 --- a/common/scripts/gbtoxhtml.pl +++ b/common/scripts/gbtoxhtml.pl @@ -24,6 +24,17 @@ my $XALAN_JAR = '/usr/share/java/xalan2.jar'; my $RM = '/bin/rm'; my $CHMOD = '/bin/chmod'; +# Check that all the binaries are were want them + +my @BINARIES; +push @BINARIES, ($RXP, $CP, $MV, $TAR, $ZIP, $BZIP2, $JAVA, $XALAN_JAR, $RM, $CHMOD); + +foreach (@BINARIES) { + if ( ! -e $_ ) { + die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n"; + } +} + ### my $bookCode = ''; -- 2.17.1