From 6d1c78677da42fc89ff8deba1f37b05f3e5760fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 21 Dec 2024 11:09:53 +0100 Subject: [PATCH] test that the remote system has the cpio command --- src/get-facts.sh | 1 + src/nixos-anywhere.sh | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/get-facts.sh b/src/get-facts.sh index 0820bed6..80434422 100755 --- a/src/get-facts.sh +++ b/src/get-facts.sh @@ -13,6 +13,7 @@ isInstaller=$(if [ "$isNixos" = "y" ] && grep -Eq 'VARIANT_ID="?installer"?' /et isContainer=$(if [ "$(has systemd-detect-virt)" = "y" ]; then systemd-detect-virt --container; else echo "none"; fi) hasIpv6Only=$(if [ "$(has ip)" = "n" ] || ip r g 1 >/dev/null 2>/dev/null || ! ip -6 r g :: >/dev/null 2>/dev/null; then echo "n"; else echo "y"; fi) hasTar=$(has tar) +hasCpio=$(has cpio) hasSudo=$(has sudo) hasDoas=$(has doas) hasWget=$(has wget) diff --git a/src/nixos-anywhere.sh b/src/nixos-anywhere.sh index a698c1f6..54e2d97d 100755 --- a/src/nixos-anywhere.sh +++ b/src/nixos-anywhere.sh @@ -45,6 +45,7 @@ isInstaller= isContainer= hasIpv6Only= hasTar= +hasCpio= hasSudo= hasDoas= hasWget= @@ -434,7 +435,7 @@ importFacts() { # shellcheck disable=SC2046 export $(echo "$filteredFacts" | xargs) - for var in isOs isArch isKexec isInstaller isContainer hasIpv6Only hasTar hasSudo hasDoas hasWget hasCurl hasSetsid; do + for var in isOs isArch isKexec isInstaller isContainer hasIpv6Only hasTar hasCpio hasSudo hasDoas hasWget hasCurl hasSetsid; do if [[ -z ${!var} ]]; then abort "Failed to retrieve fact $var from host" fi @@ -673,6 +674,10 @@ main() { abort "no tar command found, but required to unpack kexec tarball" fi + if [[ ${hasCpio-n} == "n" ]]; then + abort "no cpio command found, but required to build the new initrd" + fi + if [[ ${hasSetsid-n} == "n" ]]; then abort "no setsid command found, but required to run the kexec script under a new session" fi