Commit fe898447 authored by Lars Kruse's avatar Lars Kruse
Browse files

build(nodejs): remove manual download of nodejs

Previously (before stretch-backports provided the package with the
required version), it was necessary to download a nodejs binary in order
to fulfill the build requirements for grouprise.
Now the nodejs packages provided by Debian are just fine.
parent 701621dd
Pipeline #3112 passed with stages
in 5 minutes and 3 seconds
......@@ -19,7 +19,7 @@ URL_FONT_GOOGLE = https://fonts.googleapis.com/css?family=Roboto+Slab:300,400,70
# static output files
STAMP_STATIC_WEBPACK = $(DIR_BUILD)/.static_webpack
$(STAMP_NODE_MODULES): $(BIN_NODE) $(BIN_NPM) package.json
$(STAMP_NODE_MODULES): package.json
$(RUN_NODE) "$(BIN_NPM)" ci --no-progress
touch "$(STAMP_NODE_MODULES)"
......
BIN_NODE_SYSTEM = $(shell which nodejs node | head -1)
BIN_NPM_SYSTEM = $(shell which npm || true)
NODE_LOCAL_DIR = $(DIR_BUILD)/node
BIN_NODE ?= $(abspath $(NODE_LOCAL_DIR))/bin/node
BIN_NPM ?= $(abspath $(NODE_LOCAL_DIR))/bin/npm
NODE_VERSION_SYSTEM = $(shell if [ -n "$(BIN_NODE_SYSTEM)" ]; then "$(BIN_NODE_SYSTEM)" --version; else echo "v0.0.0"; fi)
NODE_VERSION_MIN = v10.21.0
NODE_URL_X86 = https://nodejs.org/dist/$(NODE_VERSION_MIN)/node-$(NODE_VERSION_MIN)-linux-x86.tar.xz
NODE_URL_X64 = https://nodejs.org/dist/$(NODE_VERSION_MIN)/node-$(NODE_VERSION_MIN)-linux-x64.tar.xz
NODE_URL = $(shell if [ "$(shell uname -m)" = "x86_64" ]; then echo "$(NODE_URL_X64)"; else echo "$(NODE_URL_X86)"; fi)
BIN_NODE_LOCAL = $(abspath $(NODE_LOCAL_DIR))/bin/node
BIN_NPM_LOCAL = $(abspath $(NODE_LOCAL_DIR))/bin/npm
BIN_NODE ?= $(shell if [ -e "$(BIN_NODE_LOCAL)" ]; then echo "$(BIN_NODE_LOCAL)"; else echo "$(BIN_NODE_SYSTEM)"; fi)
BIN_NPM ?= $(shell if [ -e "$(BIN_NPM_LOCAL)" ]; then echo "$(BIN_NPM_LOCAL)"; else echo "$(BIN_NPM_SYSTEM)"; fi)
# the module "phantomJS" fails to install without the environment setting OPENSSL_CONF
RUN_NODE = \
PATH="$$PATH:$$(dirname "$(BIN_NODE)")" \
PATH="$$PATH:$(NODE_LOCAL_DIR)/bin" \
DIR_BUILD="$(abspath $(DIR_BUILD))" \
OPENSSL_CONF=/etc/ssl/ \
"$(BIN_NODE)"
$(BIN_NODE):
rm -rf "$(NODE_LOCAL_DIR)"
mkdir -p "$(NODE_LOCAL_DIR)/bin"
@if [ -z "$(BIN_NPM_SYSTEM)" ] || [ -z "$(BIN_NODE_SYSTEM)" ] || [ "$(NODE_VERSION_SYSTEM)" = "$$(printf '%s\n' "$(NODE_VERSION_SYSTEM)" "$(NODE_VERSION_MIN)" | sort -V | head -n1)" ]; then \
if [ "$$(uname -s)" != "Linux" ]; then \
echo >&2 "NodeJS download for non-linux platforms is sadly not supported. Please install $(NODE_VERSION_MIN) or later manually."; \
exit 1; fi; \
echo >&2 "Local nodejs version is missing or too old (before $(NODE_VERSION_MIN)) or 'npm' is missing. Downloading from server ..."; \
if [ -n "$(shell which xzcat)" ]; then \
wget -O - "$(NODE_URL)" | tar -xJ -C "$(NODE_LOCAL_DIR)" --strip-components=1 -f -; \
else \
echo >&2 "Failed to install nodejs due to missing dependency: xz compression tool (Debian: package 'xz-utils')"; \
fi; \
else \
echo >&2 "Local nodejs version is sufficient. Symlinking executables ..."; \
ln -s "$(BIN_NODE_SYSTEM)" "$(NODE_LOCAL_DIR)/bin/node"; \
ln -s "$(BIN_NPM_SYSTEM)" "$(NODE_LOCAL_DIR)/bin/npm"; \
fi
$(BIN_NPM): $(BIN_NODE)
@# verify that "npm" (BIN_NPM) is given as full path: node will not search PATH for it
@if [ -z "$(BIN_NPM)" ] || [ ! -x "$(BIN_NPM)" ]; then echo >&2 "BIN_NPM must be a path (not an executable to be found via PATH)"; exit 1; fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment