Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions install/user/mise-work.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ case ${OMARCHY_SETUP_CONTEXT:-runtime} in
esac

if [[ -n $NODE_PACKAGE_DIR ]]; then
NODE_TARBALL=$(find "$NODE_PACKAGE_DIR" -name "node-v*-linux-x64.tar.gz" -type f 2>/dev/null | head -n1)
# The ISO bundles the tarball for its own architecture.
case $(uname -m) in
aarch64) NODE_PLATFORM=linux-arm64 ;;
*) NODE_PLATFORM=linux-x64 ;;
esac
NODE_TARBALL=$(find "$NODE_PACKAGE_DIR" -name "node-v*-$NODE_PLATFORM.tar.gz" -type f 2>/dev/null | head -n1)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
if [[ -z $NODE_TARBALL ]]; then
if [[ ${OMARCHY_SETUP_CONTEXT:-} == "provision-owner" ]]; then
# A factory snapshot predating the bundled tarball may not have it staged.
Expand All @@ -24,7 +29,7 @@ if [[ -n $NODE_PACKAGE_DIR ]]; then
exit 1
fi
else
NODE_VERSION=$(basename "$NODE_TARBALL" | sed 's/node-v\(.*\)-linux-x64.tar.gz/\1/')
NODE_VERSION=$(basename "$NODE_TARBALL" | sed "s/node-v\(.*\)-$NODE_PLATFORM.tar.gz/\1/")
NODE_INSTALL_DIR="$HOME/.local/share/mise/installs/node/$NODE_VERSION"

mkdir -p "$NODE_INSTALL_DIR"
Expand Down
48 changes: 48 additions & 0 deletions test/shell.d/mise-work-path-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,54 @@ env \
[[ $(<"$install_log") == "use -g node@latest" ]] || fail "installer only invokes Mise for the global Node setup"
pass "new installs do not add project bin directories to PATH"

# An offline install unpacks the Node tarball the ISO bundles, and the ISO
# bundles the one for its own architecture. Both are on offer here; each
# machine must take its own. uname and the bundle directory are stand-ins.
bundle="$test_dir/bundle"
mkdir -p "$bundle" "$test_dir/node-src"
for platform in linux-x64 linux-arm64; do
mkdir -p "$test_dir/node-src/node-v24.1.0-$platform/bin"
echo "$platform" >"$test_dir/node-src/node-v24.1.0-$platform/bin/node"
tar -czf "$bundle/node-v24.1.0-$platform.tar.gz" -C "$test_dir/node-src" "node-v24.1.0-$platform"
done
cat >"$test_dir/bin/uname" <<'SH'
#!/bin/bash
[[ $* == -m ]] && { echo "$UNAME_TEST_MACHINE"; exit; }
exec /usr/bin/uname "$@"
SH
cat >"$test_dir/bin/find" <<'SH'
#!/bin/bash
[[ $1 == /opt/packages ]] && { shift; exec /usr/bin/find "$NODE_TEST_BUNDLE" "$@"; }
exec /usr/bin/find "$@"
SH
chmod +x "$test_dir/bin/uname" "$test_dir/bin/find"

for case in "x86_64 linux-x64" "aarch64 linux-arm64"; do
read -r machine platform <<<"$case"
arch_home="$test_dir/$machine-home"
arch_log="$test_dir/$machine-mise.log"
mkdir -p "$arch_home"
env \
HOME="$arch_home" \
MISE_TEST_LOG="$arch_log" \
NODE_TEST_BUNDLE="$bundle" \
UNAME_TEST_MACHINE="$machine" \
OMARCHY_SETUP_CONTEXT=iso-chroot \
PATH="$test_dir/bin:/usr/bin" \
bash -euo pipefail -c 'source "$1"' bash "$ROOT/install/user/mise-work.sh"

installed="$arch_home/.local/share/mise/installs/node/24.1.0/bin/node"
[[ -f $installed && $(<"$installed") == "$platform" ]] || fail "$machine unpacks the $platform Node tarball"
[[ $(head -n1 "$arch_log") == "use -g node@24.1.0" ]] || fail "$machine hands Mise the bundled Node version"
done
[[ ! -e $bundle/node-v24.1.0-linux-x64.tar.gz ]] || rm "$bundle/node-v24.1.0-linux-x64.tar.gz"
if env HOME="$test_dir/missing-home" MISE_TEST_LOG="$test_dir/missing.log" NODE_TEST_BUNDLE="$bundle" \
UNAME_TEST_MACHINE=x86_64 OMARCHY_SETUP_CONTEXT=iso-chroot PATH="$test_dir/bin:/usr/bin" \
bash -euo pipefail -c 'source "$1"' bash "$ROOT/install/user/mise-work.sh" 2>/dev/null; then
fail "an x86_64 install accepts another architecture's Node tarball"
fi
pass "offline installs unpack the Node tarball for the machine's architecture"

stock_home="$test_dir/stock-home"
stock_config="$stock_home/Work/.mise.toml"
stock_project="$stock_home/Work/tries/untrusted-repository"
Expand Down