Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions installer/functions
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,61 @@ 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
local size_gb="$((${size}/1000))GB"
echo -n "WARNING: Your CHROOTS partition is rather small" 1>&2
echo " (${size_gb})." 1>&2
echo "WARNING: Usually $((${1}/1000))GB or more is recommended." 1>&2
return 1
elif [ "$avail" -lt "$2" ]; then
local avail_gb="$((${avail}/1000))GB"
echo -n "WARNING: Your available space for CHROOTS is rather" 1>&2
echo " small (${avail_gb})." 1>&2
echo "WARNING: Usually $((${2}/1000))GB or more is recommended." 1>&2
return 2
else
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}")"
if [ "$dualboot_size" -gt 1 ]; then
echo "WARNING: Partiton 7, normally used for dual-boot installs, has been resized" 1>&2
local tmp="`mktemp -d --tmpdir=/tmp 'check-dualboot.XXX'`"
local unmount="umount -l '$tmp' 2>/dev/null && rmdir '$tmp'"
addtrap "$unmount"
if ! mount -o ro "$dualboot_part" "$tmp" 2>/dev/null; then
mount "$dualboot_part" "$tmp" 2>/dev/null
fi
df -m "$tmp" | awk 'FNR == 2 {print $2,$4}' | {
read -r size avail
local dualboot_size_gb="$((${size}/1000))GB"
local dualboot_avail_gb="$((${avail}/1000))GB"
echo "WARNING: to ${dualboot_size_gb} with ${dualboot_avail_gb} free." 1>&2
}
distrib="$(awk -F= '/DISTRIB_DESCRIPTION=/ {print $2}' < \
"$tmp/etc/lsb-release" 2>/dev/null)"
if [ -n "$distrib" ]; then
echo "WARNING: (It appears to have $distrib installed.)" 1>&2
fi
undotrap
eval "$unmount"
return 1
else
return 0
fi
}
10 changes: 10 additions & 0 deletions installer/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=''
Expand Down Expand Up @@ -366,6 +368,14 @@ 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
check_dualboot || true
echo "Press Ctrl-C to abort; installation will continue in 5 seconds." 1>&2
sleep 5
fi

if [ -z "$RESTOREBIN" ]; then
# Fix NAME if it was not specified.
CHROOT="$CHROOTS/${NAME:="${RELEASE:-"$DEFAULTRELEASE"}"}"
Expand Down