summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/make-assets.sh4
-rwxr-xr-xtools/make-firefox.sh2
-rwxr-xr-xtools/make-mv3.sh116
3 files changed, 69 insertions, 53 deletions
diff --git a/tools/make-assets.sh b/tools/make-assets.sh
index 2719f1d..139abbf 100755
--- a/tools/make-assets.sh
+++ b/tools/make-assets.sh
@@ -14,10 +14,10 @@ cp -R ./assets $DES/
VERSION=$(cat ./dist/version)
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "*** Removing $DES/assets.dev.json"
- rm $DES/assets.dev.json
+ rm -f $DES/assets.dev.json
else
echo "*** Removing $DES/assets.json"
- rm $DES/assets.json
+ rm -f $DES/assets.json
fi
mkdir $DES/thirdparties
diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh
index 2278c58..fc5a196 100755
--- a/tools/make-firefox.sh
+++ b/tools/make-firefox.sh
@@ -8,8 +8,8 @@ echo "*** uBlock0.firefox: Creating web store package"
BLDIR=dist/build
DES="$BLDIR"/uBlock0.firefox
-rm -rf $DES
mkdir -p $DES
+rm -rf $DES/*
echo "*** uBlock0.firefox: Copying common files"
bash ./tools/copy-common-files.sh $DES
diff --git a/tools/make-mv3.sh b/tools/make-mv3.sh
index 8b1b2ab..13f82f4 100755
--- a/tools/make-mv3.sh
+++ b/tools/make-mv3.sh
@@ -13,28 +13,30 @@ for i in "$@"; do
case $i in
quick)
QUICK="yes"
- shift # past argument=value
;;
full)
FULL="yes"
- shift # past argument=value
;;
firefox)
PLATFORM="firefox"
- shift # past argument=value
;;
chromium)
PLATFORM="chromium"
- shift # past argument=value
;;
- (uBOLite_+([0-9]).+([0-9]).+([0-9]).+([0-9]))
+ uBOLite_+([0-9]).+([0-9]).+([0-9]).+([0-9]))
TAGNAME="$i"
FULL="yes"
- shift # past argument=value
+ ;;
+ before=+([[:print:]]))
+ BEFORE="${i:7}"
;;
esac
done
+echo "PLATFORM=$PLATFORM"
+echo "TAGNAME=$TAGNAME"
+echo "BEFORE=$BEFORE"
+
DES="dist/build/uBOLite.$PLATFORM"
if [ "$QUICK" != "yes" ]; then
@@ -46,9 +48,9 @@ cd $DES
DES=$(pwd)
cd - > /dev/null
-mkdir -p $DES/css/fonts
-mkdir -p $DES/js
-mkdir -p $DES/img
+mkdir -p "$DES"/css/fonts
+mkdir -p "$DES"/js
+mkdir -p "$DES"/img
if [ -n "$UBO_VERSION" ]; then
UBO_REPO="https://github.com/gorhill/uBlock.git"
@@ -65,60 +67,74 @@ else
fi
echo "*** uBOLite.mv3: Copying common files"
-cp -R $UBO_DIR/src/css/fonts/* $DES/css/fonts/
-cp $UBO_DIR/src/css/themes/default.css $DES/css/
-cp $UBO_DIR/src/css/common.css $DES/css/
-cp $UBO_DIR/src/css/dashboard-common.css $DES/css/
-cp $UBO_DIR/src/css/fa-icons.css $DES/css/
+cp -R "$UBO_DIR"/src/css/fonts/* "$DES"/css/fonts/
+cp "$UBO_DIR"/src/css/themes/default.css "$DES"/css/
+cp "$UBO_DIR"/src/css/common.css "$DES"/css/
+cp "$UBO_DIR"/src/css/dashboard-common.css "$DES"/css/
+cp "$UBO_DIR"/src/css/fa-icons.css "$DES"/css/
-cp $UBO_DIR/src/js/dom.js $DES/js/
-cp $UBO_DIR/src/js/fa-icons.js $DES/js/
-cp $UBO_DIR/src/js/i18n.js $DES/js/
-cp $UBO_DIR/src/lib/punycode.js $DES/js/
+cp "$UBO_DIR"/src/js/dom.js "$DES"/js/
+cp "$UBO_DIR"/src/js/fa-icons.js "$DES"/js/
+cp "$UBO_DIR"/src/js/i18n.js "$DES"/js/
+cp "$UBO_DIR"/src/lib/punycode.js "$DES"/js/
-cp -R $UBO_DIR/src/img/flags-of-the-world $DES/img
+cp -R "$UBO_DIR/src/img/flags-of-the-world" "$DES"/img
-cp LICENSE.txt $DES/
+cp LICENSE.txt "$DES"/
echo "*** uBOLite.mv3: Copying mv3-specific files"
if [ "$PLATFORM" = "firefox" ]; then
- cp platform/mv3/firefox/background.html $DES/
+ cp platform/mv3/firefox/background.html "$DES"/
fi
-cp platform/mv3/extension/*.html $DES/
-cp platform/mv3/extension/*.json $DES/
-cp platform/mv3/extension/css/* $DES/css/
-cp -R platform/mv3/extension/js/* $DES/js/
-cp platform/mv3/extension/img/* $DES/img/
-cp -R platform/mv3/extension/_locales $DES/
-cp platform/mv3/README.md $DES/
+cp platform/mv3/extension/*.html "$DES"/
+cp platform/mv3/extension/*.json "$DES"/
+cp platform/mv3/extension/css/* "$DES"/css/
+cp -R platform/mv3/extension/js/* "$DES"/js/
+cp platform/mv3/extension/img/* "$DES"/img/
+cp -R platform/mv3/extension/_locales "$DES"/
+cp platform/mv3/README.md "$DES/"
if [ "$QUICK" != "yes" ]; then
echo "*** uBOLite.mv3: Generating rulesets"
TMPDIR=$(mktemp -d)
- mkdir -p $TMPDIR
+ mkdir -p "$TMPDIR"
if [ "$PLATFORM" = "chromium" ]; then
- cp platform/mv3/chromium/manifest.json $DES/
+ cp platform/mv3/chromium/manifest.json "$DES"/
elif [ "$PLATFORM" = "firefox" ]; then
- cp platform/mv3/firefox/manifest.json $DES/
+ cp platform/mv3/firefox/manifest.json "$DES"/
+ fi
+ ./tools/make-nodejs.sh "$TMPDIR"
+ cp platform/mv3/package.json "$TMPDIR"/
+ cp platform/mv3/*.js "$TMPDIR"/
+ cp platform/mv3/*.mjs "$TMPDIR"/
+ cp platform/mv3/extension/js/utils.js "$TMPDIR"/js/
+ cp "$UBO_DIR"/assets/assets.json "$TMPDIR"/
+ cp "$UBO_DIR"/assets/resources/scriptlets.js "$TMPDIR"/
+ cp -R platform/mv3/scriptlets "$TMPDIR"/
+ mkdir -p "$TMPDIR"/web_accessible_resources
+ cp "$UBO_DIR"/src/web_accessible_resources/* "$TMPDIR"/web_accessible_resources/
+ cd "$TMPDIR"
+ node --no-warnings make-rulesets.js output="$DES" platform="$PLATFORM"
+ if [ -n "$BEFORE" ]; then
+ echo "*** uBOLite.mv3: salvaging rule ids to minimize diff size"
+ echo " before=$BEFORE/$PLATFORM"
+ echo " after=$DES"
+ node salvage-ruleids.mjs before="$BEFORE"/"$PLATFORM" after="$DES"
fi
- ./tools/make-nodejs.sh $TMPDIR
- cp platform/mv3/package.json $TMPDIR/
- cp platform/mv3/*.js $TMPDIR/
- cp platform/mv3/extension/js/utils.js $TMPDIR/js/
- cp $UBO_DIR/assets/assets.json $TMPDIR/
- cp $UBO_DIR/assets/resources/scriptlets.js $TMPDIR/
- cp -R platform/mv3/scriptlets $TMPDIR/
- mkdir -p $TMPDIR/web_accessible_resources
- cp $UBO_DIR/src/web_accessible_resources/* $TMPDIR/web_accessible_resources/
- cd $TMPDIR
- node --no-warnings make-rulesets.js output=$DES platform="$PLATFORM"
cd - > /dev/null
- rm -rf $TMPDIR
+ rm -rf "$TMPDIR"
fi
echo "*** uBOLite.mv3: extension ready"
echo "Extension location: $DES/"
+# Local build: use a different extension id than the official one
+if [ -z "$TAGNAME" ] && [ "$PLATFORM" = "firefox" ]; then
+ tmp=$(mktemp)
+ jq '.browser_specific_settings.gecko.id = "uBOLite.dev@raymondhill.net"' "$DES/manifest.json" > "$tmp" \
+ && mv "$tmp" "$DES/manifest.json"
+fi
+
if [ "$FULL" = "yes" ]; then
EXTENSION="zip"
if [ "$PLATFORM" = "firefox" ]; then
@@ -126,7 +142,7 @@ if [ "$FULL" = "yes" ]; then
fi
echo "*** uBOLite.mv3: Creating publishable package..."
if [ -z "$TAGNAME" ]; then
- TAGNAME="uBOLite_$(jq -r .version $DES/manifest.json)"
+ TAGNAME="uBOLite_$(jq -r .version "$DES"/manifest.json)"
else
tmp=$(mktemp)
jq --arg version "${TAGNAME:8}" '.version = $version' "$DES/manifest.json" > "$tmp" \
@@ -134,12 +150,12 @@ if [ "$FULL" = "yes" ]; then
fi
PACKAGENAME="$TAGNAME.$PLATFORM.mv3.$EXTENSION"
TMPDIR=$(mktemp -d)
- mkdir -p $TMPDIR
- cp -R $DES/* $TMPDIR/
- cd $TMPDIR > /dev/null
- zip $PACKAGENAME -qr ./*
+ mkdir -p "$TMPDIR"
+ cp -R "$DES"/* "$TMPDIR"/
+ cd "$TMPDIR" > /dev/null
+ zip "$PACKAGENAME" -qr ./*
cd - > /dev/null
- cp $TMPDIR/$PACKAGENAME dist/build/
- rm -rf $TMPDIR
+ cp "$TMPDIR"/"$PACKAGENAME" dist/build/
+ rm -rf "$TMPDIR"
echo "Package location: $(pwd)/dist/build/$PACKAGENAME"
fi