#!/bin/bash set -x -e -v # This script is for repacking Node (and NPM) from nodejs.org. WORKSPACE=$HOME/workspace case "$1" in linux64) ARCH=linux-x64 ;; macosx64) ARCH=darwin-x64 ;; win64) ARCH=win-x64 ;; win32) ARCH=win-x86 ;; *) echo "Unknown architecture $1 not recognized in repack-node.sh" >&2 exit 1 ;; esac case "$ARCH" in linux-x64|darwin-x64) SUFFIX=tar.xz UNARCHIVE="tar xaf" REPACK_TAR_COMPRESSION_SWITCH=J REPACK_SUFFIX=tar.xz ;; win-x64|win-x86) SUFFIX=zip UNARCHIVE=unzip REPACK_TAR_COMPRESSION_SWITCH=j REPACK_SUFFIX=tar.bz2 ;; esac # Although we're only using one version at the moment, this infrastructure is # useful for when we need to do upgrades and have multiple versions of node # live in taskcluster at once. case "$2" in 10) VERSION="10.19.0" ;; *) echo "Unknown version $2 not recognized in repack-node.sh" >&2 exit 1 ;; esac case "$ARCH--$VERSION" in # From https://nodejs.org/dist/v10.19.0/SHASUMS256.txt.asc linux-x64--10.19.0) SHA256SUM=34127c7c6b1ba02d6d4dc3a926f38a5fb88bb37fc7f051349005ce331c7a53c6 ;; darwin-x64--10.19.0) SHA256SUM=91725d2ed64e4ccd265259e3e29a0e64a4d26d9d1cd9ba390e0cdec13ea7b02f ;; win-x64--10.19.0) SHA256SUM=210efd45a7f79cf4c350d8f575f990becdd3833cd922796a4c83b27996f5679e ;; win-x86--10.19.0) SHA256SUM=afd176d4f022b6a5dbd4a908d42c6d85d4f739c040f65430ab3bf60b8f3b9a96 ;; esac # From https://nodejs.org/en/download/ URL=https://nodejs.org/dist/v$VERSION/node-v$VERSION-$ARCH.$SUFFIX ARCHIVE=node-v$VERSION-$ARCH.$SUFFIX mkdir -p "$UPLOAD_DIR" cd "$WORKSPACE" wget --progress=dot:mega $URL # shasum is available on both Linux and Windows builders, but on # Windows, reading from stdin doesn't work as expected. echo "$SHA256SUM $ARCHIVE" > node.txt shasum --algorithm 256 --check node.txt $UNARCHIVE $ARCHIVE mv node-v$VERSION-$ARCH node # npx doesn't have great security characteristics (it downloads and executes # stuff directly out of npm at runtime), so let's not risk it getting into # anyone's PATH who doesn't already have it there: rm -f node/bin/npx node/bin/npx.exe tar c${REPACK_TAR_COMPRESSION_SWITCH}f "$UPLOAD_DIR"/node.$REPACK_SUFFIX node