diff --git a/arcup/arcup b/arcup/arcup index 3590cd36..c6300232 100755 --- a/arcup/arcup +++ b/arcup/arcup @@ -6,7 +6,7 @@ set -euo pipefail # NOTE: if you make modifications to this script, please increment the version number. # WARNING: the SemVer pattern: major.minor.patch must be followed as we use it to determine if the script is up to date. -ARCUP_INSTALLER_VERSION="0.2.0" +ARCUP_INSTALLER_VERSION="0.2.1" REPO="${ARC_REPO:-circlefin/arc-node}" if [[ -n "${ARC_REPO:-}" ]] && [[ ! "$ARC_REPO" =~ ^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]]; then @@ -750,7 +750,17 @@ main() { mkdir -p "$BIN_DIR" + # The archive is downloaded into TMP_DIR and also extracted there before + # the binaries are copied to BIN_DIR, so TMP_DIR briefly holds both the + # compressed archive and its extracted contents. TMP_DIR (from + # mktemp -d, usually /tmp) is frequently a different filesystem than + # BIN_DIR — e.g. a small tmpfs in containers — so it needs its own + # check rather than relying on the BIN_DIR check. The measured v0.8.0 + # x86_64-unknown-linux-gnu release peaks around 185MB in TMP_DIR + # (~52MB archive + ~133MB extracted); 300MB keeps headroom for growth + # without over-requiring on small-tmpfs hosts that install fine today. check_disk_space "$BIN_DIR" + check_disk_space "$TMP_DIR" 300 PLATFORM=$(detect_platform) ARCH=$(detect_arch) diff --git a/arcup/test_arcup.sh b/arcup/test_arcup.sh index 49021191..c1999f81 100755 --- a/arcup/test_arcup.sh +++ b/arcup/test_arcup.sh @@ -810,6 +810,67 @@ test_install_binary_rejects_symlink() { pass "install_binary rejects symlink" } +test_check_disk_space_rejects_insufficient() { + if ( check_disk_space "$TEST_TMP" 999999999 ) >"$TEST_TMP/disk-space.out" 2>&1; then + cat "$TEST_TMP/disk-space.out" >&2 + fail "check_disk_space rejects insufficient space" + fi + + grep -q "Insufficient disk space" "$TEST_TMP/disk-space.out" || { + cat "$TEST_TMP/disk-space.out" >&2 + fail "check_disk_space rejects insufficient space" + } + pass "check_disk_space rejects insufficient space" +} + +# Regression test for: check_disk_space was only ever called on BIN_DIR, +# even though the archive is downloaded and extracted into TMP_DIR first +# (mktemp -d, usually a different filesystem than BIN_DIR, e.g. a small +# tmpfs in containers). A full disk there produced a raw curl/tar failure +# instead of the friendly "Insufficient disk space" error. This drives +# TMP_DIR (via TMPDIR) onto a fake-df'd path with plenty of space for +# BIN_DIR but almost none for TMP_DIR, and asserts main() catches it. +test_main_checks_tmp_dir_disk_space() { + local install_dir="$TEST_TMP/disk-space-install" + local scratch_dir="$TEST_TMP/disk-space-scratch" + mkdir -p "$install_dir" "$scratch_dir" + + local fakebin="$TEST_TMP/disk-space-fakebin" + mkdir -p "$fakebin" + cat > "$fakebin/df" <"$TEST_TMP/disk-space-main.out" 2>&1; then + cat "$TEST_TMP/disk-space-main.out" >&2 + fail "main rejects insufficient TMP_DIR disk space" + fi + + grep -q "Insufficient disk space" "$TEST_TMP/disk-space-main.out" || { + cat "$TEST_TMP/disk-space-main.out" >&2 + fail "main rejects insufficient TMP_DIR disk space" + } + pass "main rejects insufficient TMP_DIR disk space" +} + test_version_normalization test_version_comparison test_target_mapping @@ -827,3 +888,5 @@ test_fixture_install_matrix test_archive_path_traversal_fails test_archive_link_entries_fail test_install_binary_rejects_symlink +test_check_disk_space_rejects_insufficient +test_main_checks_tmp_dir_disk_space