aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-06-09 09:08:32 +0800
committerfanquake <fanquake@gmail.com>2021-06-09 09:09:38 +0800
commit7cac26246a23b2843cb368fe8a68c54dde04d5d8 (patch)
tree73609c61111f49afd9ce94965082edd91f9b82c4
parent82bc7faec8079b50f248655a97950087948f065d (diff)
parent108a6be92adc1e80839d90b552e72b8142140f6c (diff)
downloadbitcoin-7cac26246a23b2843cb368fe8a68c54dde04d5d8.tar.xz
Merge bitcoin/bitcoin#22075: guix: Misc leftover usability improvements
108a6be92adc1e80839d90b552e72b8142140f6c guix: Check for disk space availability before building (Carl Dong) d7dec89091ee4a456ff64ad7ce675ae6813668f1 guix: Remove dest if OUTDIR mv fails (Carl Dong) Pull request description: There seems to be some corner cases that can be hit when guix scripts unexpectedly fail in the middle of operation, see: https://gnusha.org/bitcoin-builds/2021-05-24.log - Perform an early disk space check for `guix-build` - Overwrite existing output directory after a successful build (the existing one might be malformed), and cleanup output directory if the `mv` somehow fails ACKs for top commit: laanwj: Tested ACK 108a6be92adc1e80839d90b552e72b8142140f6c achow101: ACK 108a6be92adc1e80839d90b552e72b8142140f6c Tree-SHA512: cf6438317da40bf55714cd2d8cce859b3d435cc66cabefe8d4a53552d7880966acfe84ffe8fadf1c80e368ae6b037992258a6d409df85ffc6ce8bf780e98e2e5
-rwxr-xr-xcontrib/guix/guix-build22
-rwxr-xr-xcontrib/guix/libexec/build.sh4
-rwxr-xr-xcontrib/guix/libexec/codesign.sh4
3 files changed, 28 insertions, 2 deletions
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
@@ -139,6 +139,28 @@ for host in $HOSTS; do
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
################
diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh
index 46bfa29b74..3073b41baf 100755
--- a/contrib/guix/libexec/build.sh
+++ b/contrib/guix/libexec/build.sh
@@ -447,4 +447,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 )