Description: Use a temporary directory to build, run the make.sh script under errexit. Closes: #850879 Author: Christoph Biedl Bug-Debian: https://bugs.debian.org/850879 Forwarded: https://github.com/DataTables/DataTablesSrc/issues/91 Reviewed-By: Yadd Last-Update: 2022-03-03 --- a/build/include.sh +++ b/build/include.sh @@ -5,6 +5,8 @@ CLOSURE="/usr/local/closure_compiler/compiler.jar" JSHINT="/usr/bin/jshint" +TMPDIR="$(mktemp --directory --tmpdir "jquery-datatables.$$.XXXXX")" +trap "rm -rf \"$TMPDIR\"" EXIT # CSS styling frameworks that DataTables supports FRAMEWORKS=( @@ -123,23 +125,23 @@ # Closure Compiler doesn't support "important" comments so we add a # @license jsdoc comment to the license block to preserve it - cp $DIR/$FILE.$COMP_EXTN /tmp/$FILE.$COMP_EXTN - perl -i -0pe "s/^\/\*! (.*)$/\/** \@license \$1/s" /tmp/$FILE.$COMP_EXTN + cp $DIR/$FILE.$COMP_EXTN $TMPDIR/$FILE.$COMP_EXTN + perl -i -0pe "s/^\/\*! (.*)$/\/** \@license \$1/s" $TMPDIR/$FILE.$COMP_EXTN - rm /tmp/closure_error.log - java -jar $CLOSURE --charset 'utf-8' --language_out=ES5 --js /tmp/$FILE.$COMP_EXTN > /tmp/$FILE.min.$COMP_EXTN 2> /tmp/closure_error.log + rm $TMPDIR/closure_error.log + java -jar $CLOSURE --charset 'utf-8' --language_out=ES5 --js $TMPDIR/$FILE.$COMP_EXTN > $TMPDIR/$FILE.min.$COMP_EXTN 2> $TMPDIR/closure_error.log - if [ -e /tmp/closure_error.log ]; then + if [ -e $TMPDIR/closure_error.log ]; then if [ -z "$LOG" -o "$LOG" = "on" ]; then - cat /tmp/closure_error.log + cat $TMPDIR/closure_error.log fi fi # And add the important comment back in - perl -i -0pe "s/^\/\*/\/*!/s" /tmp/$FILE.min.$COMP_EXTN + perl -i -0pe "s/^\/\*/\/*!/s" $TMPDIR/$FILE.min.$COMP_EXTN - mv /tmp/$FILE.min.$COMP_EXTN $DIR/$FILE.min.$COMP_EXTN - rm /tmp/$FILE.$COMP_EXTN + mv $TMPDIR/$FILE.min.$COMP_EXTN $DIR/$FILE.min.$COMP_EXTN + rm $TMPDIR/$FILE.$COMP_EXTN echo_msg " File size: $(ls -l $DIR/$FILE.min.$COMP_EXTN | awk -F" " '{ print $5 }')" fi @@ -159,9 +161,10 @@ IFS='%' cp $IN_FILE $IN_FILE.build - grep "_buildInclude('" $IN_FILE.build > /dev/null + CODE=0 + grep "_buildInclude('" $IN_FILE.build > /dev/null || CODE=$? - while [ $? -eq 0 ]; do + while [ $CODE -eq 0 ]; do REQUIRE=$(grep "_buildInclude('" $IN_FILE.build | head -n 1) SPACER=$(echo ${REQUIRE} | cut -d _ -f 1) @@ -175,7 +178,7 @@ rm ${DIR}/${FILE}.build - grep "_buildInclude('" $IN_FILE.build > /dev/null + grep "_buildInclude('" $IN_FILE.build > /dev/null || CODE=$? done mv $IN_FILE.build $OUT --- a/build/make.sh +++ b/build/make.sh @@ -40,9 +40,10 @@ OLD_IFS=$IFS IFS='%' cp $IN_FILE DataTables.js.build - grep "_buildInclude('" DataTables.js.build > /dev/null + CODE=0 + grep "_buildInclude('" DataTables.js.build > /dev/null || CODE=$? - while [ $? -eq 0 ]; do + while [ $CODE -eq 0 ]; do REQUIRE=$(grep "_buildInclude('" DataTables.js.build | head -n 1) SPACER=$(echo ${REQUIRE} | cut -d _ -f 1) @@ -56,7 +57,7 @@ rm ${DIR}/${FILE}.build - grep "_buildInclude('" DataTables.js.build > /dev/null + grep "_buildInclude('" DataTables.js.build > /dev/null || CODE=$? done mv DataTables.js.build $OUT_FILE @@ -76,7 +77,7 @@ js_compress $OUT_FILE - cp jquery.js $OUT_DIR + #cp jquery.js $OUT_DIR cp integration/* $OUT_DIR # Compress the integration files