2021-07-25 08:55:35 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# This script assumes a linux environment
|
|
|
|
|
|
|
|
DES=dist/build/uBlock0.nodejs
|
|
|
|
|
|
|
|
mkdir -p $DES/js
|
|
|
|
cp src/js/base64-custom.js $DES/js
|
|
|
|
cp src/js/biditrie.js $DES/js
|
|
|
|
cp src/js/filtering-context.js $DES/js
|
|
|
|
cp src/js/globals.js $DES/js
|
|
|
|
cp src/js/hntrie.js $DES/js
|
|
|
|
cp src/js/static-filtering-parser.js $DES/js
|
|
|
|
cp src/js/static-net-filtering.js $DES/js
|
|
|
|
cp src/js/static-filtering-io.js $DES/js
|
|
|
|
cp src/js/text-iterators.js $DES/js
|
|
|
|
cp src/js/uri-utils.js $DES/js
|
|
|
|
|
|
|
|
mkdir -p $DES/lib
|
|
|
|
cp -R src/lib/punycode.js $DES/lib/
|
|
|
|
cp -R src/lib/publicsuffixlist $DES/lib/
|
|
|
|
cp -R src/lib/regexanalyzer $DES/lib/
|
|
|
|
|
2021-07-28 17:40:11 -06:00
|
|
|
# Use existing uAssets, or git-clone a temporary one
|
|
|
|
if [ -d "../uAssets" ]; then
|
|
|
|
UASSETS=../uAssets
|
|
|
|
else
|
|
|
|
echo "*** ../uAssets not present, git-cloning..."
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
UASSETS=$TMPDIR/uAssets
|
|
|
|
git clone --depth=1 https://github.com/uBlockOrigin/uAssets.git $UASSETS
|
|
|
|
fi
|
|
|
|
|
2021-07-28 08:38:24 -06:00
|
|
|
# https://github.com/uBlockOrigin/uBlock-issues/issues/1664#issuecomment-888332409
|
2021-07-28 17:40:11 -06:00
|
|
|
THIRDPARTY=$UASSETS/thirdparties/publicsuffix.org
|
2021-07-25 08:55:35 -06:00
|
|
|
mkdir -p $DES/data
|
2021-07-28 08:38:24 -06:00
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/list/effective_tld_names.dat', 'utf8'))" \
|
|
|
|
> $DES/data/effective_tld_names.json
|
2021-07-28 17:40:11 -06:00
|
|
|
THIRDPARTY=$UASSETS/thirdparties/easylist-downloads.adblockplus.org
|
2021-07-28 08:38:24 -06:00
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/easylist.txt', 'utf8'))" \
|
|
|
|
> $DES/data/easylist.json
|
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/easyprivacy.txt', 'utf8'))" \
|
|
|
|
> $DES/data/easyprivacy.json
|
2021-07-25 08:55:35 -06:00
|
|
|
|
2021-07-28 17:40:11 -06:00
|
|
|
# Remove temporary git-clone uAssets
|
|
|
|
if [ -n "$TMPDIR" ]; then
|
|
|
|
echo "*** Removing temporary $TMPDIR"
|
|
|
|
rm -rf $TMPDIR
|
|
|
|
fi
|
|
|
|
|
2021-07-25 08:55:35 -06:00
|
|
|
cp platform/nodejs/*.js $DES/
|
|
|
|
cp platform/nodejs/*.json $DES/
|
|
|
|
cp LICENSE.txt $DES/
|
2021-07-28 17:40:11 -06:00
|
|
|
|
|
|
|
if [ "$1" = all ]; then
|
|
|
|
echo "*** uBlock0.nodejs: Creating plain package..."
|
|
|
|
pushd $(dirname $DES/) > /dev/null
|
|
|
|
zip uBlock0.nodejs.zip -qr $(basename $DES/)/*
|
|
|
|
popd > /dev/null
|
|
|
|
elif [ -n "$1" ]; then
|
|
|
|
echo "*** uBlock0.nodejs: Creating versioned package..."
|
|
|
|
pushd $(dirname $DES/) > /dev/null
|
|
|
|
zip uBlock0_"$1".nodejs.zip -qr $(basename $DES/)/*
|
|
|
|
popd > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "*** uBlock0.nodejs: Package done."
|