Node.js
Posted: 09 May 2025, 11:15
update_node script below updates (installs?) Node as a mountable squashfs module:
It relies on a tiny squashfs_create script encapsulating your favorite compression method:
Node.sqfs with lz4: 70Mb, std: 40Mb; both mountable as 180Mb ./Node folder.
Code: Select all
#!/usr/bin/bash
# Updates a portable Node installation in the directory:
cd /I
mkdir -p Node
mount -t squashfs Node.sqfs Node
current=$(Node/bin/node -v | tail -c+2)
URL=https://nodejs.org/dist/latest/
#Assuming e.g. https://nodejs.org/dist/latest/node-v23.11.0-linux-x64.tar.xz
FILE=$(curl -s $URL | grep -oE 'node-v[0-9.]+-linux-x64.tar.xz' | head -n 1)
latest=${FILE#*v}
latest=${latest%*-l*}
echo "$latest > $current"
if [[ $(printf '%s\n' "$current" "$latest" | sort -V | tail -n1) != "$current" ]]; then
echo "Upgrading from $current to $latest"
umount Node.sqfs
wget -Nq --show-progress $URL$FILE
tar -xf $FILE -C Node --strip-components=1
squashfs_create Node
rm $FILE
rm -rf Node/*
mount -t squashfs Node.sqfs Node
Node/bin/node -v
fi
Code: Select all
#!/bin/bash
#mksquashfs $1 $1.sqfs -noappend -comp zstd -b 256K -Xcompression-level 22
#mksquashfs $1 $1.sqfs -noappend -comp zstd -b 256K
mksquashfs $1 $1.sqfs -noappend -comp lz4