2018-06-30 17:01:23 -06:00
|
|
|
#!/bin/bash
|
|
|
|
BASE=$PWD
|
|
|
|
SRC="$BASE/src"
|
|
|
|
BUILD="$BASE/build"
|
|
|
|
MANIFEST_IN="$SRC/manifest.json"
|
|
|
|
MANIFEST_OUT="$BUILD/manifest.json"
|
|
|
|
|
2018-07-08 06:05:04 -06:00
|
|
|
VER=$(grep '"version":' "$MANIFEST_IN" | sed -re 's/.*": "(.*?)".*/\1/')
|
2018-07-06 19:02:40 -06:00
|
|
|
if [ "$1" == "tag" ]; then
|
|
|
|
echo "Tagging at $VER"
|
|
|
|
git tag -a "$VER" && git push origin "$VER"
|
|
|
|
exit 0
|
|
|
|
fi
|
2018-07-08 06:05:04 -06:00
|
|
|
if [ "$1" == "bump" ]; then
|
|
|
|
echo "Bumping to $VER"
|
|
|
|
git add "$MANIFEST_IN"
|
|
|
|
git commit -m "Version bump: $VER."
|
|
|
|
exit 0
|
|
|
|
fi
|
2018-06-30 17:01:23 -06:00
|
|
|
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
|
|
|
|
|
2018-07-03 09:36:36 -06:00
|
|
|
./html5_events/html5_events.pl
|
2018-06-30 17:01:23 -06:00
|
|
|
|
2018-07-03 09:36:36 -06:00
|
|
|
rm -rf "$BUILD" "$XPI"
|
|
|
|
cp -pR "$SRC" "$BUILD"
|
|
|
|
cp -p LICENSE.txt GPL.txt "$BUILD"/
|
2018-06-30 17:01:23 -06:00
|
|
|
|
|
|
|
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..."
|
2018-07-03 09:36:36 -06:00
|
|
|
mkdir -p "$XPI_DIR"
|
2018-06-30 17:01:23 -06:00
|
|
|
|
|
|
|
"$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"
|