From 433e9cbddbe7694d76d6f21ea4adf0aa8277e761 Mon Sep 17 00:00:00 2001 From: DennisL Date: Sun, 1 Nov 2015 20:22:49 -0500 Subject: [PATCH 01/13] calls to check_space and check_chrubuntu functions Add routine to check space on CHROOTS partiton and ChrUbuntu partitions --- installer/main.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/installer/main.sh b/installer/main.sh index 86ef1afbc..051533331 100755 --- a/installer/main.sh +++ b/installer/main.sh @@ -366,6 +366,17 @@ addtrap "stty echo 2>/dev/null" BIN="$PREFIX/bin" CHROOTS="$PREFIX/chroots" +# Check if space requirements have been met +# if not, check for chrubuntu + PART_AVAIL_MIN=2000 # in MB + PART_SIZE_MIN=4000 # in MB + #PART_AVAIL_MIN=200000 # in MB !!! TEST VALUE + #PART_SIZE_MIN=400000 # in MB !!! TEST VALUE + if ! check_space "$PART_SIZE_MIN" "$PART_AVAIL_MIN"; then + check_chrubuntu + # exit 1 # Don't exit, just spit out out warnings + fi + if [ -z "$RESTOREBIN" ]; then # Fix NAME if it was not specified. CHROOT="$CHROOTS/${NAME:="${RELEASE:-"$DEFAULTRELEASE"}"}" From 551013f52a22dcd0e2a9d6eadd980a10819d7670 Mon Sep 17 00:00:00 2001 From: DennisL Date: Sun, 1 Nov 2015 20:24:53 -0500 Subject: [PATCH 02/13] add functions: check_space and check_chrubuntu check_space checks that the minimum partition size and free space is met. check_ubuntu checks if partition 7 is being used and reports it's sizes and configuration --- installer/functions | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/installer/functions b/installer/functions index 14451973d..eb1988815 100644 --- a/installer/functions +++ b/installer/functions @@ -239,3 +239,58 @@ 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,$6}' |\ + while read -r size avail mp; do + if [ "$size" -lt "$1" ]; then + local size_gb="$((${size}/1000))GB" + echo "WARNING: Your CHROOTS partition is rather small (${size_gb})." + echo "WARNING: Usually $((${1}/1000))GB or more is needed. " + # error 1 "ERROR: Choose another partition then try again..." + 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 needed. " + # error 1 "ERROR: Free up more space then try again..." + return 2 + else + # echo "Your space requirements for CHROOTS have been met." + return 0 + fi + done +} + +# Check if partition 7 / ROOT-C (ChrUbuntu) has been resized +# normally called when space requirements on the CHROOTS partiton aren't met +check_chrubuntu() { + local disk=$(rootdev -s -d) + local chrubuntu_part=$(rootdev -s | sed 's/.$/7/') + local chrubuntu_size=$(cgpt show -i7 -s ${disk}) + if [ "$chrubuntu_size" -gt 1 ]; then + echo "WARNING: Partiton 7, normally used for ChrUbuntu, has been resized" + local tmp="`mktemp -d --tmpdir=/tmp 'check-chrubuntu.XXX'`" + local unmount="umount -l '$tmp' && rmdir '$tmp'" + # addtrap "$unmount" + mount $chrubuntu_part "$tmp" 2>/dev/null + df -m $chrubuntu_part | awk 'FNR == 2 {print $2,$3,$4}' |\ + while read -r size used avail; do + local chrubuntu_size_gb="$((${size}/1000))GB" + local chrubuntu_used_gb="$((${used}/1000))GB" + local chrubuntu_avail_gb="$((${avail}/1000))GB" + echo "WARNING: to ${chrubuntu_size_gb}, it's using ${chrubuntu_used_gb}, and ${chrubuntu_avail_gb} is available for your use..." + done + distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null | cut -d= -f2)" + if [ -n "$distrib" ]; then + echo "WARNING: Also, it has $distrib installed." + fi + # undotrap + eval "$unmount" + fi + return 0 +} From 800dd586cec1dd17a325423063079fe76a364f10 Mon Sep 17 00:00:00 2001 From: DennisL Date: Sun, 1 Nov 2015 23:35:01 -0500 Subject: [PATCH 03/13] added return values for check_chrubuntu Added return values for check_chrubuntu in case we decide to use them. --- installer/functions | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/installer/functions b/installer/functions index eb1988815..5f93d9829 100644 --- a/installer/functions +++ b/installer/functions @@ -291,6 +291,8 @@ check_chrubuntu() { fi # undotrap eval "$unmount" + return 1 + else + return 0 fi - return 0 } From d57703cae26773888016d459adb4421bf27ce30a Mon Sep 17 00:00:00 2001 From: DennisL Date: Thu, 5 Nov 2015 15:27:37 -0500 Subject: [PATCH 04/13] updated 'df' command in check_chrubuntu to use mountpoint 'df' command in check_chrubuntu changed to use mountpoint instead of partition. --- installer/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/functions b/installer/functions index 5f93d9829..166931c72 100644 --- a/installer/functions +++ b/installer/functions @@ -278,7 +278,7 @@ check_chrubuntu() { local unmount="umount -l '$tmp' && rmdir '$tmp'" # addtrap "$unmount" mount $chrubuntu_part "$tmp" 2>/dev/null - df -m $chrubuntu_part | awk 'FNR == 2 {print $2,$3,$4}' |\ + df -m "$tmp" | awk 'FNR == 2 {print $2,$3,$4}' |\ while read -r size used avail; do local chrubuntu_size_gb="$((${size}/1000))GB" local chrubuntu_used_gb="$((${used}/1000))GB" From 152e56c2611979d0401105c97dc03703a51eff35 Mon Sep 17 00:00:00 2001 From: DennisL Date: Thu, 5 Nov 2015 15:53:26 -0500 Subject: [PATCH 05/13] moved check_space variable declarations Moved check_space variable declarations to top of file with the others. --- installer/main.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/installer/main.sh b/installer/main.sh index 051533331..fdda0430f 100755 --- a/installer/main.sh +++ b/installer/main.sh @@ -14,6 +14,8 @@ INSTALLERDIR="$SCRIPTDIR/installer" HOSTBINDIR="$SCRIPTDIR/host-bin" TARGETSDIR="$SCRIPTDIR/targets" SRCDIR="$SCRIPTDIR/src" +PART_AVAIL_MIN=2000 # in MB +PART_SIZE_MIN=4000 # in MB ARCH='' BOOTSTRAP_RELEASE='' @@ -368,14 +370,12 @@ CHROOTS="$PREFIX/chroots" # Check if space requirements have been met # if not, check for chrubuntu - PART_AVAIL_MIN=2000 # in MB - PART_SIZE_MIN=4000 # in MB - #PART_AVAIL_MIN=200000 # in MB !!! TEST VALUE - #PART_SIZE_MIN=400000 # in MB !!! TEST VALUE - if ! check_space "$PART_SIZE_MIN" "$PART_AVAIL_MIN"; then - check_chrubuntu - # exit 1 # Don't exit, just spit out out warnings - fi +#PART_AVAIL_MIN=200000 # in MB !!! TEST VALUE +#PART_SIZE_MIN=400000 # in MB !!! TEST VALUE +if ! check_space "$PART_SIZE_MIN" "$PART_AVAIL_MIN"; then + check_chrubuntu +# exit 1 # Don't exit, just spit out out warnings +fi if [ -z "$RESTOREBIN" ]; then # Fix NAME if it was not specified. From 9e7a6fbd014e5314c571e6adbd8f4600217d6441 Mon Sep 17 00:00:00 2001 From: DennisL Date: Wed, 30 Dec 2015 00:12:41 -0500 Subject: [PATCH 06/13] updated per line notes Updated to incorporate changes per line notes from @dnschneid --- installer/functions | 54 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/installer/functions b/installer/functions index 166931c72..04e7ce3ca 100644 --- a/installer/functions +++ b/installer/functions @@ -244,52 +244,50 @@ websocketcommand() { # $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,$6}' |\ - while read -r size avail mp; do + 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 "WARNING: Your CHROOTS partition is rather small (${size_gb})." - echo "WARNING: Usually $((${1}/1000))GB or more is needed. " - # error 1 "ERROR: Choose another partition then try again..." + echo "WARNING: Usually $((${1}/1000))GB or more is recommended. " 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 needed. " - # error 1 "ERROR: Free up more space then try again..." return 2 else - # echo "Your space requirements for CHROOTS have been met." + echo "Your space requirements for CHROOTS have been met." return 0 fi - done + } } -# Check if partition 7 / ROOT-C (ChrUbuntu) has been resized +# 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_chrubuntu() { - local disk=$(rootdev -s -d) - local chrubuntu_part=$(rootdev -s | sed 's/.$/7/') - local chrubuntu_size=$(cgpt show -i7 -s ${disk}) - if [ "$chrubuntu_size" -gt 1 ]; then - echo "WARNING: Partiton 7, normally used for ChrUbuntu, has been resized" - local tmp="`mktemp -d --tmpdir=/tmp 'check-chrubuntu.XXX'`" - local unmount="umount -l '$tmp' && rmdir '$tmp'" - # addtrap "$unmount" - mount $chrubuntu_part "$tmp" 2>/dev/null - df -m "$tmp" | awk 'FNR == 2 {print $2,$3,$4}' |\ - while read -r size used avail; do - local chrubuntu_size_gb="$((${size}/1000))GB" - local chrubuntu_used_gb="$((${used}/1000))GB" - local chrubuntu_avail_gb="$((${avail}/1000))GB" - echo "WARNING: to ${chrubuntu_size_gb}, it's using ${chrubuntu_used_gb}, and ${chrubuntu_avail_gb} is available for your use..." - done +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" + local tmp="`mktemp -d --tmpdir=/tmp 'check-dualboot.XXX'`" + local unmount="umount -l '$tmp' 2>/dev/null && rmdir '$tmp'" + addtrap "$unmount" + mount $dualboot_part "$tmp" 2>/dev/null + df -m "$tmp" | awk 'FNR == 2 {print $2,$3,$4}' | { + read -r size used avail + local dualboot_size_gb="$((${size}/1000))GB" + local dualboot_used_gb="$((${used}/1000))GB" + 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)" if [ -n "$distrib" ]; then - echo "WARNING: Also, it has $distrib installed." + echo "WARNING: (It appears to have $distrib installed.)" fi - # undotrap + undotrap eval "$unmount" return 1 else From c6ed677001997173685804ab6cb29e63fb7178a9 Mon Sep 17 00:00:00 2001 From: DennisL Date: Wed, 30 Dec 2015 00:26:46 -0500 Subject: [PATCH 07/13] updated per line notes Updated to incorporate changes per line notes from @dnschneid --- installer/main.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/installer/main.sh b/installer/main.sh index fdda0430f..6de13906b 100755 --- a/installer/main.sh +++ b/installer/main.sh @@ -14,8 +14,8 @@ INSTALLERDIR="$SCRIPTDIR/installer" HOSTBINDIR="$SCRIPTDIR/host-bin" TARGETSDIR="$SCRIPTDIR/targets" SRCDIR="$SCRIPTDIR/src" -PART_AVAIL_MIN=2000 # in MB -PART_SIZE_MIN=4000 # in MB +AVAILMIN=2000 # in MB +SIZEMIN=4000 # in MB ARCH='' BOOTSTRAP_RELEASE='' @@ -369,12 +369,12 @@ BIN="$PREFIX/bin" CHROOTS="$PREFIX/chroots" # Check if space requirements have been met -# if not, check for chrubuntu -#PART_AVAIL_MIN=200000 # in MB !!! TEST VALUE -#PART_SIZE_MIN=400000 # in MB !!! TEST VALUE -if ! check_space "$PART_SIZE_MIN" "$PART_AVAIL_MIN"; then - check_chrubuntu -# exit 1 # Don't exit, just spit out out warnings +# if not, check for dualboot +if ! check_space "$SIZEMIN" "$AVAILMIN"; then + sleep 3 + if ! check_dualboot; then + sleep 2 + fi fi if [ -z "$RESTOREBIN" ]; then From e648ecccb86c9121a8e6a906fabc8b1c9778ab7e Mon Sep 17 00:00:00 2001 From: DennisL Date: Thu, 31 Dec 2015 14:42:12 -0500 Subject: [PATCH 08/13] installer/functions updated per line notes Updated to incorporate changes per line notes from @dnschneid on 12/30/15. --- installer/functions | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/installer/functions b/installer/functions index 04e7ce3ca..49101c381 100644 --- a/installer/functions +++ b/installer/functions @@ -246,21 +246,21 @@ websocketcommand() { 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 "WARNING: Your CHROOTS partition is rather small (${size_gb})." - echo "WARNING: Usually $((${1}/1000))GB or more is recommended. " - 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 needed. " - return 2 - else - echo "Your space requirements for CHROOTS have been met." - return 0 - fi + read -r size avail + if [ "$size" -lt "$1" ]; then + local size_gb="$((${size}/1000))GB" + echo "WARNING: Your CHROOTS partition is rather small (${size_gb})." + echo "WARNING: Usually $((${1}/1000))GB or more is recommended. " + 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." + return 0 + fi } } @@ -275,13 +275,12 @@ check_dualboot() { local tmp="`mktemp -d --tmpdir=/tmp 'check-dualboot.XXX'`" local unmount="umount -l '$tmp' 2>/dev/null && rmdir '$tmp'" addtrap "$unmount" - mount $dualboot_part "$tmp" 2>/dev/null - df -m "$tmp" | awk 'FNR == 2 {print $2,$3,$4}' | { - read -r size used avail - local dualboot_size_gb="$((${size}/1000))GB" - local dualboot_used_gb="$((${used}/1000))GB" - local dualboot_avail_gb="$((${avail}/1000))GB" - echo "WARNING: to ${dualboot_size_gb}, with ${dualboot_avail_gb} free." + mount -o ro "$dualboot_part" "$tmp" 2>/dev/null + df -m "$tmp" | awk 'FNR == 2 {print $2,$4}' | { + read -r size used 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." } distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null | cut -d= -f2)" if [ -n "$distrib" ]; then From d4f23a4a86e914e24fdf82427b17760e97bc58fc Mon Sep 17 00:00:00 2001 From: DennisL Date: Thu, 31 Dec 2015 15:04:13 -0500 Subject: [PATCH 09/13] installer/functions updated to remove 'used'. Updated to remove remnant of 'used' on line 280. --- installer/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/functions b/installer/functions index 49101c381..65ba70dc3 100644 --- a/installer/functions +++ b/installer/functions @@ -277,7 +277,7 @@ check_dualboot() { addtrap "$unmount" mount -o ro "$dualboot_part" "$tmp" 2>/dev/null df -m "$tmp" | awk 'FNR == 2 {print $2,$4}' | { - read -r size used avail + 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." From b1b1ec75eb64d9d45719bfc2180d5f98ea5db82c Mon Sep 17 00:00:00 2001 From: DennisL Date: Sat, 2 Jan 2016 16:32:30 -0500 Subject: [PATCH 10/13] installer/main.sh updated per line notes Updated to incorporate changes per line notes from @dnschneid on 1/1/16. Removed multiple delays and added message that installation will continue after 5s. --- installer/main.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/installer/main.sh b/installer/main.sh index 6de13906b..5c3c8a231 100755 --- a/installer/main.sh +++ b/installer/main.sh @@ -368,13 +368,12 @@ addtrap "stty echo 2>/dev/null" BIN="$PREFIX/bin" CHROOTS="$PREFIX/chroots" -# Check if space requirements have been met -# if not, check for dualboot +# Check if space requirements have been met. +# If not, check for dualboot. if ! check_space "$SIZEMIN" "$AVAILMIN"; then - sleep 3 - if ! check_dualboot; then - sleep 2 - fi + if ! check_dualboot; then true; fi + echo "Press Ctrl-C to abort; installation will continue in 5 seconds." 1>&2 + sleep 5 fi if [ -z "$RESTOREBIN" ]; then From 2b28dfeb61310934a488b4bb3afbf4a5cf2aa1e1 Mon Sep 17 00:00:00 2001 From: DennisL Date: Sat, 2 Jan 2016 16:51:23 -0500 Subject: [PATCH 11/13] installer//functions updated per line notes Updated to incorporate changes per line notes from @dnschneid on 1/1/16. Added missing quotes, fixed indentation, insured lines <=80 chars, sent warnings to stderr. Also reworked logic to check for existing mounts do to 'ro' mount failing if already mounted. --- installer/functions | 61 ++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/installer/functions b/installer/functions index 65ba70dc3..e3bac2b2a 100644 --- a/installer/functions +++ b/installer/functions @@ -245,22 +245,23 @@ websocketcommand() { # $2: the partition's minimum available space threshold check_space() { local part="${CHROOTS:-/usr/local}" - df -m $part | awk 'FNR == 2 {print $2,$4}' | { + 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 "WARNING: Your CHROOTS partition is rather small (${size_gb})." - echo "WARNING: Usually $((${1}/1000))GB or more is recommended. " - 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." - return 0 - fi + 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 } } @@ -269,22 +270,30 @@ check_space() { check_dualboot() { local disk="$(rootdev -s -d)" local dualboot_part="$(rootdev -s | sed 's/.$/7/')" - local dualboot_size="$(cgpt show -i7 -s ${disk})" + 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" - 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 + echo -n "WARNING: Partiton 7, normally used for dual-boot installs" 1>&2 + echo ", has been resized" 1>&2 + if grep -q "${dualboot_part}" /proc/mounts; then + tmp="$(grep "${dualboot_part}" /proc/mounts | cut -d' ' -f2)" + unmount="true" + else + 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 + 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." + local dualboot_size_gb="$((${size}/1000))GB" + local dualboot_avail_gb="$((${avail}/1000))GB" + echo -n "WARNING: to ${dualboot_size_gb}, with" 1>&2 + echo " ${dualboot_avail_gb} free." 1>&2 } - distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null | cut -d= -f2)" + distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null |\ + cut -d= -f2)" if [ -n "$distrib" ]; then - echo "WARNING: (It appears to have $distrib installed.)" + echo "WARNING: (It appears to have $distrib installed.)" 1>&2 fi undotrap eval "$unmount" From f6daf613833e5ab90c8cc9fae46e97e0357672fa Mon Sep 17 00:00:00 2001 From: DennisL Date: Tue, 5 Jan 2016 15:44:16 -0500 Subject: [PATCH 12/13] installer/main.sh updated per line notes on 1/4/2015 Simplified logic for invoking check_dualboot function. --- installer/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/main.sh b/installer/main.sh index 5c3c8a231..ddbdc46b8 100755 --- a/installer/main.sh +++ b/installer/main.sh @@ -371,7 +371,7 @@ CHROOTS="$PREFIX/chroots" # Check if space requirements have been met. # If not, check for dualboot. if ! check_space "$SIZEMIN" "$AVAILMIN"; then - if ! check_dualboot; then true; fi + check_dualboot || true echo "Press Ctrl-C to abort; installation will continue in 5 seconds." 1>&2 sleep 5 fi From 81400a15af05403a0bb7e63cbf09a5a33a33b192 Mon Sep 17 00:00:00 2001 From: DennisL Date: Tue, 5 Jan 2016 16:39:12 -0500 Subject: [PATCH 13/13] installer/functions updated per line notes: 1/4/2015 un-split warning messages. removed `proc/mounts` lookup and redid mount logic for mounted and unmounted partition. 'grep' and 'cut' replaced with 'awk'. --- installer/functions | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/installer/functions b/installer/functions index e3bac2b2a..c4a00a5b5 100644 --- a/installer/functions +++ b/installer/functions @@ -272,26 +272,21 @@ check_dualboot() { local dualboot_part="$(rootdev -s | sed 's/.$/7/')" local dualboot_size="$(cgpt show -i7 -s "${disk}")" if [ "$dualboot_size" -gt 1 ]; then - echo -n "WARNING: Partiton 7, normally used for dual-boot installs" 1>&2 - echo ", has been resized" 1>&2 - if grep -q "${dualboot_part}" /proc/mounts; then - tmp="$(grep "${dualboot_part}" /proc/mounts | cut -d' ' -f2)" - unmount="true" - else - 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 + 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 -n "WARNING: to ${dualboot_size_gb}, with" 1>&2 - echo " ${dualboot_avail_gb} free." 1>&2 + echo "WARNING: to ${dualboot_size_gb} with ${dualboot_avail_gb} free." 1>&2 } - distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null |\ - cut -d= -f2)" + 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