From d7dec89091ee4a456ff64ad7ce675ae6813668f1 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Tue, 25 May 2021 16:25:30 -0400 Subject: [PATCH 1/2] guix: Remove dest if OUTDIR mv fails --- contrib/guix/libexec/build.sh | 4 +++- contrib/guix/libexec/codesign.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 00cb494963..2894a9a695 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -448,4 +448,6 @@ mkdir -p "$DISTSRC" esac ) # $DISTSRC -mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" +rm -rf "$ACTUAL_OUTDIR" +mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \ + || ( rm -rf "$ACTUAL_OUTDIR" && exit 1 ) diff --git a/contrib/guix/libexec/codesign.sh b/contrib/guix/libexec/codesign.sh index 46b42a5712..1822da7ca4 100755 --- a/contrib/guix/libexec/codesign.sh +++ b/contrib/guix/libexec/codesign.sh @@ -100,4 +100,6 @@ mkdir -p "$DISTSRC" esac ) # $DISTSRC -mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" +rm -rf "$ACTUAL_OUTDIR" +mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \ + || ( rm -rf "$ACTUAL_OUTDIR" && exit 1 ) From 108a6be92adc1e80839d90b552e72b8142140f6c Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Tue, 25 May 2021 22:27:37 -0400 Subject: [PATCH 2/2] guix: Check for disk space availability before building --- contrib/guix/guix-build | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 69c244a6fa..29d6701b25 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -138,6 +138,28 @@ for host in $HOSTS; do esac done +################ +# VERSION_BASE should have enough space +################ + +avail_KiB="$(df -Pk "$VERSION_BASE" | sed 1d | tr -s ' ' | cut -d' ' -f4)" +total_required_KiB=0 +for host in $HOSTS; do + case "$host" in + *darwin*) required_KiB=440000 ;; + *mingw*) required_KiB=7600000 ;; + *) required_KiB=6400000 ;; + esac + total_required_KiB=$((total_required_KiB+required_KiB)) +done + +if (( total_required_KiB > avail_KiB )); then + total_required_GiB=$((total_required_KiB / 1048576)) + avail_GiB=$((avail_KiB / 1048576)) + echo "Performing a Bitcoin Core Guix build for the selected HOSTS requires ${total_required_GiB} GiB, however, only ${avail_GiB} GiB is available. Please free up some disk space before performing the build." + exit 1 +fi + ################ # Check that we can connect to the guix-daemon ################