Skip to content

Commit 7cac262

Browse files
committed
Merge bitcoin/bitcoin#22075: guix: Misc leftover usability improvements
108a6be guix: Check for disk space availability before building (Carl Dong) d7dec89 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 108a6be achow101: ACK 108a6be Tree-SHA512: cf6438317da40bf55714cd2d8cce859b3d435cc66cabefe8d4a53552d7880966acfe84ffe8fadf1c80e368ae6b037992258a6d409df85ffc6ce8bf780e98e2e5
2 parents 82bc7fa + 108a6be commit 7cac262

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

contrib/guix/guix-build

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ for host in $HOSTS; do
138138
esac
139139
done
140140

141+
################
142+
# VERSION_BASE should have enough space
143+
################
144+
145+
avail_KiB="$(df -Pk "$VERSION_BASE" | sed 1d | tr -s ' ' | cut -d' ' -f4)"
146+
total_required_KiB=0
147+
for host in $HOSTS; do
148+
case "$host" in
149+
*darwin*) required_KiB=440000 ;;
150+
*mingw*) required_KiB=7600000 ;;
151+
*) required_KiB=6400000 ;;
152+
esac
153+
total_required_KiB=$((total_required_KiB+required_KiB))
154+
done
155+
156+
if (( total_required_KiB > avail_KiB )); then
157+
total_required_GiB=$((total_required_KiB / 1048576))
158+
avail_GiB=$((avail_KiB / 1048576))
159+
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."
160+
exit 1
161+
fi
162+
141163
################
142164
# Check that we can connect to the guix-daemon
143165
################

contrib/guix/libexec/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,6 @@ mkdir -p "$DISTSRC"
447447
esac
448448
) # $DISTSRC
449449

450-
mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR"
450+
rm -rf "$ACTUAL_OUTDIR"
451+
mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \
452+
|| ( rm -rf "$ACTUAL_OUTDIR" && exit 1 )

contrib/guix/libexec/codesign.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ mkdir -p "$DISTSRC"
100100
esac
101101
) # $DISTSRC
102102

103-
mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR"
103+
rm -rf "$ACTUAL_OUTDIR"
104+
mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \
105+
|| ( rm -rf "$ACTUAL_OUTDIR" && exit 1 )

0 commit comments

Comments
 (0)