-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Size tests #2240
base: master
Are you sure you want to change the base?
Size tests #2240
Changes from 10 commits
9908ce4
433e9cb
551013f
800dd58
d57703c
152e56c
9e7a6fb
c6ed677
e648ecc
d4f23a4
b1b1ec7
2b28dfe
f6daf61
81400a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,3 +239,57 @@ websocketcommand() { | |
echo "EError timeout" | ||
fi | ||
} | ||
|
||
# Check space requirements on CHROOTS partition | ||
# $1: the partition's minimum size threshold | ||
# $2: the partition's minimum available space threshold | ||
check_space() { | ||
local part="${CHROOTS:-/usr/local}" | ||
df -m $part | awk 'FNR == 2 {print $2,$4}' | { | ||
read -r size avail | ||
if [ "$size" -lt "$1" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoa, too much indentation :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed indentation. |
||
local size_gb="$((${size}/1000))GB" | ||
echo "WARNING: Your CHROOTS partition is rather small (${size_gb})." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we've been outputting warnings like these out to stderr, but might want to check for consistency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warnings sent to stderr. |
||
echo "WARNING: Usually $((${1}/1000))GB or more is recommended. " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space at end of string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
return 1 | ||
elif [ "$avail" -lt "$2" ]; then | ||
local avail_gb="$((${avail}/1000))GB" | ||
echo "WARNING: Your available space for CHROOTS is rather small (${avail_gb})." | ||
echo "WARNING: Usually $((${2}/1000))GB or more is recommended. " | ||
return 2 | ||
else | ||
echo "Your space requirements for CHROOTS have been met." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output isn't really necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed superfluous message. |
||
return 0 | ||
fi | ||
} | ||
} | ||
|
||
# Check if partition 7 / ROOT-C (dual-boot installs) has been resized | ||
# normally called when space requirements on the CHROOTS partiton aren't met | ||
check_dualboot() { | ||
local disk="$(rootdev -s -d)" | ||
local dualboot_part="$(rootdev -s | sed 's/.$/7/')" | ||
local dualboot_size="$(cgpt show -i7 -s ${disk})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably should quote $disk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quoted. |
||
if [ "$dualboot_size" -gt 1 ]; then | ||
echo "WARNING: Partiton 7, normally used for dual-boot installs, has been resized" | ||
local tmp="`mktemp -d --tmpdir=/tmp 'check-dualboot.XXX'`" | ||
local unmount="umount -l '$tmp' 2>/dev/null && rmdir '$tmp'" | ||
addtrap "$unmount" | ||
mount -o ro "$dualboot_part" "$tmp" 2>/dev/null | ||
df -m "$tmp" | awk 'FNR == 2 {print $2,$4}' | { | ||
read -r size avail | ||
local dualboot_size_gb="$((${size}/1000))GB" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same indentation issue here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed indentation. |
||
local dualboot_avail_gb="$((${avail}/1000))GB" | ||
echo "WARNING: to ${dualboot_size_gb}, with ${dualboot_avail_gb} free." | ||
} | ||
distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null | cut -d= -f2)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. once you fix the indentation, please make sure all lines are <80 chars wide There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adjusted line lengths to <80chars 'ish... |
||
if [ -n "$distrib" ]; then | ||
echo "WARNING: (It appears to have $distrib installed.)" | ||
fi | ||
undotrap | ||
eval "$unmount" | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ INSTALLERDIR="$SCRIPTDIR/installer" | |
HOSTBINDIR="$SCRIPTDIR/host-bin" | ||
TARGETSDIR="$SCRIPTDIR/targets" | ||
SRCDIR="$SCRIPTDIR/src" | ||
AVAILMIN=2000 # in MB | ||
SIZEMIN=4000 # in MB | ||
|
||
ARCH='' | ||
BOOTSTRAP_RELEASE='' | ||
|
@@ -366,6 +368,15 @@ addtrap "stty echo 2>/dev/null" | |
BIN="$PREFIX/bin" | ||
CHROOTS="$PREFIX/chroots" | ||
|
||
# Check if space requirements have been met | ||
# if not, check for dualboot | ||
if ! check_space "$SIZEMIN" "$AVAILMIN"; then | ||
sleep 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably don't want output, delay, more output, more delay. the other instances we do this, we have extra text that says something like "installation will continue in 5 seconds, or hit ctrl-c to cancel"...copy that text? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed multiple delays and added message that installation will continue after 5s. |
||
if ! check_dualboot; then | ||
sleep 2 | ||
fi | ||
fi | ||
|
||
if [ -z "$RESTOREBIN" ]; then | ||
# Fix NAME if it was not specified. | ||
CHROOT="$CHROOTS/${NAME:="${RELEASE:-"$DEFAULTRELEASE"}"}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quote $part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quoted.