diff --git a/tools/make-assets.sh b/tools/make-assets.sh index b301d5b8f..2962a3e1e 100755 --- a/tools/make-assets.sh +++ b/tools/make-assets.sh @@ -4,26 +4,35 @@ DES=$1/assets -printf "*** Packaging assets in $DES... " - -if [ -n "${TRAVIS_TAG}" ]; then - pushd .. > /dev/null - git clone --depth 1 https://github.com/uBlockOrigin/uAssets.git - popd > /dev/null -fi +echo "*** Packaging assets in $DES... " rm -rf $DES cp -R ./assets $DES/ mkdir $DES/thirdparties -cp -R ../uAssets/thirdparties/easylist-downloads.adblockplus.org $DES/thirdparties/ -cp -R ../uAssets/thirdparties/pgl.yoyo.org $DES/thirdparties/ -cp -R ../uAssets/thirdparties/publicsuffix.org $DES/thirdparties/ -cp -R ../uAssets/thirdparties/urlhaus-filter $DES/thirdparties/ + +# 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 + +cp -R $UASSETS/thirdparties/easylist-downloads.adblockplus.org $DES/thirdparties/ +cp -R $UASSETS/thirdparties/pgl.yoyo.org $DES/thirdparties/ +cp -R $UASSETS/thirdparties/publicsuffix.org $DES/thirdparties/ +cp -R $UASSETS/thirdparties/urlhaus-filter $DES/thirdparties/ mkdir $DES/ublock -cp -R ../uAssets/filters/* $DES/ublock/ +cp -R $UASSETS/filters/* $DES/ublock/ # Optional filter lists: do not include in package rm $DES/ublock/annoyances.txt -echo "done." +# Remove temporary git-clone uAssets +if [ -n "$TMPDIR" ]; then + echo "*** Removing temporary $TMPDIR" + rm -rf $TMPDIR +fi diff --git a/tools/make-nodejs.sh b/tools/make-nodejs.sh index 7b987f5db..91a4d36e2 100755 --- a/tools/make-nodejs.sh +++ b/tools/make-nodejs.sh @@ -21,17 +21,47 @@ cp -R src/lib/punycode.js $DES/lib/ cp -R src/lib/publicsuffixlist $DES/lib/ cp -R src/lib/regexanalyzer $DES/lib/ +# 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 + # https://github.com/uBlockOrigin/uBlock-issues/issues/1664#issuecomment-888332409 -THIRDPARTY=../uAssets/thirdparties/publicsuffix.org +THIRDPARTY=$UASSETS/thirdparties/publicsuffix.org mkdir -p $DES/data node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/list/effective_tld_names.dat', 'utf8'))" \ > $DES/data/effective_tld_names.json -THIRDPARTY=../uAssets/thirdparties/easylist-downloads.adblockplus.org +THIRDPARTY=$UASSETS/thirdparties/easylist-downloads.adblockplus.org 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 +# Remove temporary git-clone uAssets +if [ -n "$TMPDIR" ]; then + echo "*** Removing temporary $TMPDIR" + rm -rf $TMPDIR +fi + cp platform/nodejs/*.js $DES/ cp platform/nodejs/*.json $DES/ cp LICENSE.txt $DES/ + +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."