summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorhackademix2018-07-01 01:01:23 +0200
committerhackademix2018-07-01 01:01:23 +0200
commiteceae7187a6f0e9510bc1165f6977256b87f490f (patch)
treed943f1ec73c09efa70954dcedb55eac82a726148 /build.sh
downloadnoscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.gz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.xz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.zip
Initial commit starting at version 10.1.8.3rc4.
Diffstat (limited to 'build.sh')
-rw-r--r--build.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..0159a17
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+BASE=$PWD
+SRC="$BASE/src"
+BUILD="$BASE/build"
+MANIFEST_IN="$SRC/manifest.json"
+MANIFEST_OUT="$BUILD/manifest.json"
+
+VER=$(grep '"version":' "$SRC/manifest.json" | sed -re 's/.*": "(.*?)".*/\1/')
+XPI_DIR="$BASE/xpi"
+XPI="$XPI_DIR/noscript-$VER"
+LIB="$SRC/lib"
+TLD="$BASE/TLD"
+
+if ! [ $(date -r "$LIB/tld.js" +'%Y%m%d') -ge $(date +'%Y%m%d') ] && "$TLD/generate.sh"; then
+ cp -u "$TLD/tld.js" $LIB
+fi
+
+./html5_events.pl
+
+rm -rf $BUILD $XPI
+cp -pR $SRC $BUILD
+
+
+if [[ $VER == *rc* ]]; then
+ sed -re 's/^(\s+)"strict_min_version":.*$/\1"update_url": "https:\/\/secure.informaction.com\/update\/?v='$VER'",\n\0/' \
+ "$MANIFEST_IN" > "$MANIFEST_OUT"
+else
+ grep -v '"update_url":' "$MANIFEST_IN" > "$MANIFEST_OUT"
+fi
+if ! grep '"id":' "$MANIFEST_OUT" >/dev/null; then
+ echo >&2 "Cannot build manifest.json"
+ exit 1
+fi
+
+sed -re 's/\/\/\s*(.*)\s*\/\/ XPI_ONLY/\1/' $SRC/content/content.js > $BUILD/content/content.js
+
+if [ "$1" == "sign" ]; then
+ BUILD_CMD="$BASE/../../we-sign"
+ BUILD_OPTS=""
+else
+ BUILD_CMD="web-ext"
+ BUILD_OPTS="build"
+fi
+
+echo "Creating $XPI.xpi..."
+mkdir -p $XPI_DIR
+
+"$BUILD_CMD" $BUILD_OPTS --source-dir=$(cygpath -w $BUILD) --artifacts-dir=$(cygpath -w $XPI_DIR) --ignore-files=test/XSS_test.js
+SIGNED="$XPI_DIR/noscript_security_suite-$VER-an+fx.xpi"
+if [ -f "$SIGNED" ]; then
+ mv "$SIGNED" "$XPI.xpi"
+elif [ -f "$XPI.zip" ]; then
+ mv "$XPI.zip" "$XPI.xpi"
+else
+ echo >&2 "ERROR: Could not create $XPI.xpi!"
+ exit 3
+fi
+echo "Created $XPI.xpi"
+
+rm -rf "$BUILD"