fix(install): pick the .tar.gz Node.js archive when the host has no xz
`tar xf node-*.tar.xz` shells out to the xz binary; minimal Debian, DietPi and WSL images ship tar without it, so extraction died mid-way and the installer then failed on a missing directory. Select .tar.xz only when `xz` is on PATH, in both the installer and the runtime node bootstrap. Same approach as the earlier #4229 (@JoshuaMart) and #39541 (@karnull); #11278 (@vominh1919) attempted an apt-only install of xz-utils instead. Refs #11197
This commit is contained in:
@@ -1042,12 +1042,18 @@ install_node_line() {
|
||||
|
||||
# Resolve the latest v${node_line}.x.x tarball name from the index page
|
||||
local index_url="https://nodejs.org/dist/latest-v${node_line}.x/"
|
||||
local tarball_name
|
||||
tarball_name=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${node_line}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.xz" \
|
||||
| head -1)
|
||||
local tarball_name=""
|
||||
# `tar xf` shells out to xz for .tar.xz; minimal Debian/DietPi/WSL images ship tar without it
|
||||
# and the extract dies mid-way ("xz: Cannot exec"). Only pick .tar.xz when xz is present (#11197).
|
||||
if command -v xz >/dev/null 2>&1; then
|
||||
tarball_name=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${node_line}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.xz" \
|
||||
| head -1)
|
||||
else
|
||||
log_info "xz not found — using the .tar.gz Node.js archive"
|
||||
fi
|
||||
|
||||
# Fallback to .tar.gz if .tar.xz not available
|
||||
# Fallback to .tar.gz if .tar.xz not available (or xz is missing)
|
||||
if [ -z "$tarball_name" ]; then
|
||||
tarball_name=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${node_line}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.gz" \
|
||||
|
||||
@@ -271,10 +271,13 @@ _nb_install_bundled_node() {
|
||||
esac
|
||||
|
||||
local index_url="https://nodejs.org/dist/latest-v${HERMES_NODE_TARGET_MAJOR}.x/"
|
||||
local tarball
|
||||
tarball=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${HERMES_NODE_TARGET_MAJOR}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.xz" \
|
||||
| head -1)
|
||||
local tarball=""
|
||||
# `tar xf` needs the xz binary for .tar.xz; minimal images ship tar without it (#11197).
|
||||
if command -v xz >/dev/null 2>&1; then
|
||||
tarball=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${HERMES_NODE_TARGET_MAJOR}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.xz" \
|
||||
| head -1)
|
||||
fi
|
||||
if [ -z "$tarball" ]; then
|
||||
tarball=$(curl -fsSL "$index_url" \
|
||||
| grep -oE "node-v${HERMES_NODE_TARGET_MAJOR}\.[0-9]+\.[0-9]+-${node_os}-${node_arch}\.tar\.gz" \
|
||||
|
||||
Reference in New Issue
Block a user