Skip to content

Instantly share code, notes, and snippets.

@dotysan
Last active November 17, 2021 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotysan/7428c144f93652e3e12f0461104c85d9 to your computer and use it in GitHub Desktop.
Save dotysan/7428c144f93652e3e12f0461104c85d9 to your computer and use it in GitHub Desktop.
my notes on installing personal nodejs
#! /usr/bin/env bash
#
# my notes on installing personal nodejs
#
set -ex
THIS='src/node'
V='v17.1.0'
SRC="node-$V"
BIN="$SRC-linux-x64"
main() {
get
#time src &
#bin
wait
}
get() {
#getsrc &
#sleep 1
getbin
wait
}
getsrc() {
wget --no-verbose --timestamping \
"https://nodejs.org/dist/$V/$SRC.tar.xz"
if [ -d "$SRC" ]
then rm -fr "$SRC"
fi
tar --extract --xz --file "$SRC.tar.xz"
}
getbin() {
wget --no-verbose --timestamping \
"https://nodejs.org/dist/$V/$BIN.tar.xz"
if [ -d "$BIN" ]
then rm -fr "$BIN"
fi
tar --extract --xz --file "$BIN.tar.xz"
}
bin() {
local inst=~/.local
# bin
mkdir -p "$inst/bin"
for b in $BIN/bin/*
do ln --force --symbolic --target-directory="$inst/bin/" "../../$THIS/$b"
done
# lib
mkdir -p "$inst/lib"
ln --force --symbolic --no-dereference \
"../../$THIS/$BIN/lib/node_modules" "$inst/lib/node_modules"
# include
mkdir -p "$inst/include"
ln --force --symbolic --no-dereference \
"../../$THIS/$BIN/include/node" "$inst/include/node"
# share
mkdir -p $inst/share/{doc,man/man1,systemtap/tapset}
ln --force --symbolic --no-dereference \
"../../../$THIS/$BIN/share/doc/node" "$inst/share/doc/node"
ln --force --symbolic --no-dereference \
"../../../../$THIS/$BIN/share/man/man1/node.1" \
"$inst/share/man/man1/node.1"
ln --force --symbolic --no-dereference \
"../../../../$THIS/$BIN/share/systemtap/tapset/node.stp" \
"$inst/share/systemtap/tapset/node.stp"
}
src() {
pushd "$SRC"
./configure --prefix=~/.local
#make clean
local cores=$(awk '/^siblings/{print$3;exit}' /proc/cpuinfo)
#make --jobs="$[cores+1]"
make --jobs="$[cores+1]" install
popd
}
main
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment