Package: datatables.js / 1.10.20+dfsg-1

use-tempdir-and-errexit.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Subject: Use a temporary directory to build, run the make.sh script under errexit. Closes: #850879
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bug-Debian: https://bugs.debian.org/850879
Forwarded: https://github.com/DataTables/DataTablesSrc/issues/91

--- a/build/include.sh
+++ b/build/include.sh
@@ -5,6 +5,8 @@
 CLOSURE="/usr/share/java/closure-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=(
@@ -125,23 +127,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.js /tmp/$FILE.js
-		perl -i -0pe "s/^\/\*! (.*)$/\/** \@license \$1/s" /tmp/$FILE.js
+		cp $DIR/$FILE.js $TMPDIR/$FILE.js
+		perl -i -0pe "s/^\/\*! (.*)$/\/** \@license \$1/s" $TMPDIR/$FILE.js
 
-		rm /tmp/closure_error.log
-		java -jar $CLOSURE --charset 'utf-8' --js /tmp/$FILE.js > /tmp/$FILE.min.js 2> /tmp/closure_error.log
+		rm -f $TMPDIR/closure_error.log || true
+		java -jar $CLOSURE --charset 'utf-8' --js $TMPDIR/$FILE.js > $TMPDIR/$FILE.min.js 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.js
+		perl -i -0pe "s/^\/\*/\/*!/s" $TMPDIR/$FILE.min.js
 
-		mv /tmp/$FILE.min.js $DIR/$FILE.min.js
-		rm /tmp/$FILE.js
+		mv $TMPDIR/$FILE.min.js $DIR/$FILE.min.js
+		rm $TMPDIR/$FILE.js
 
 		echo_msg "  File size: $(ls -l $DIR/$FILE.min.js | awk -F" " '{ print $5 }')"
 	fi
@@ -161,9 +163,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)
@@ -177,7 +180,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
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+set -e
+
 . include.sh
 
 export DT_BUILD=1
@@ -36,9 +38,10 @@
 	OLD_IFS=$IFS
 	IFS='%'
 	cp DataTables.js 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)
@@ -52,7 +55,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
@@ -72,7 +75,7 @@
 
 	js_compress $OUT_FILE
 
-	cp jquery.js $OUT_DIR
+	#cp jquery.js $OUT_DIR
 	cp integration/* $OUT_DIR
 
 	# Compress the integration files