2020-02-22 00:04:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-02-24 22:45:44 +00:00
|
|
|
set -ex
|
2020-02-22 00:04:53 +00:00
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
BASEDIR="$(dirname "$0")"
|
2020-02-22 00:04:53 +00:00
|
|
|
|
|
|
|
cd "$BASEDIR/.."
|
|
|
|
|
|
|
|
TARGET_VERSION="12.16.1"
|
|
|
|
TARGET_PLATFORM="$1"
|
|
|
|
TARGET_ARCH="$2"
|
|
|
|
|
|
|
|
echo "Target version: $TARGET_VERSION"
|
|
|
|
echo "Target platform: $TARGET_PLATFORM"
|
|
|
|
echo "Target arch: $TARGET_ARCH"
|
|
|
|
|
|
|
|
git clean -fdx
|
|
|
|
|
|
|
|
mkdir -p vendor
|
|
|
|
cd vendor
|
|
|
|
|
|
|
|
TARGET="node-v$TARGET_VERSION-$TARGET_PLATFORM-$TARGET_ARCH"
|
|
|
|
TARBALL="$TARGET.tar.gz"
|
|
|
|
URL="https://nodejs.org/dist/v$TARGET_VERSION/$TARBALL"
|
|
|
|
|
|
|
|
wget "$URL"
|
2020-02-25 15:38:16 +00:00
|
|
|
tar -xvf "$TARBALL" "$TARGET/bin/node"
|
2020-02-22 00:04:53 +00:00
|
|
|
rm -rf "$TARBALL"
|
|
|
|
cd ..
|
|
|
|
|
2020-02-24 22:45:44 +00:00
|
|
|
# Avoid building anything from source.
|
|
|
|
npm ci --only=prod --ignore-scripts --no-audit --no-fund
|
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
BINARY_NAME="oasis"
|
2020-02-22 00:04:53 +00:00
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
# Append .appimage for double-click support on Linux
|
|
|
|
if [ "$TARGET_PLATFORM" = "linux" ]; then
|
|
|
|
BINARY_NAME="$BINARY_NAME.appimage"
|
|
|
|
fi
|
2020-02-22 00:04:53 +00:00
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
echo $BINARY_NAME
|
2020-02-22 00:04:53 +00:00
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
cat << EOF > "$BINARY_NAME"
|
|
|
|
#!/bin/sh
|
|
|
|
BASEDIR="\$(cd "\$(dirname "\$0")" && pwd)"
|
|
|
|
node="\$BASEDIR/vendor/node-v$TARGET_VERSION-$TARGET_PLATFORM-$TARGET_ARCH/bin/node"
|
2020-02-24 22:45:44 +00:00
|
|
|
verify () {
|
2020-02-25 20:58:36 +00:00
|
|
|
node -e "require('\$1')" || echo "Error: \$1 may not work correctly on your platform"
|
2020-02-24 22:45:44 +00:00
|
|
|
}
|
|
|
|
verify_optional () {
|
2020-02-25 20:58:36 +00:00
|
|
|
node -e "require('\$1')" > /dev/null 2>&1 || rm -rf "node_modules/\$1"
|
2020-02-24 22:45:44 +00:00
|
|
|
}
|
|
|
|
verify_all () {
|
|
|
|
verify leveldown
|
|
|
|
verify sodium-native
|
|
|
|
verify_optional sharp
|
|
|
|
}
|
|
|
|
verify_all
|
2020-02-25 15:38:16 +00:00
|
|
|
exec "\$node" "src/index.js" "\$@"
|
2020-02-22 00:04:53 +00:00
|
|
|
EOF
|
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
chmod +x "$BINARY_NAME"
|
|
|
|
|
|
|
|
# I think if the zip already exists it's adding files to the existing archive?
|
|
|
|
ZIP_PATH="/tmp/oasis-$TARGET_PLATFORM-$TARGET_ARCH.zip"
|
|
|
|
rm -f "$ZIP_PATH"
|
2020-02-22 00:04:53 +00:00
|
|
|
|
2020-02-25 15:38:16 +00:00
|
|
|
zip -r "$ZIP_PATH" . -x ".git/**"
|
2020-02-22 00:04:53 +00:00
|
|
|
git clean -fdx
|