Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
57 changes: 57 additions & 0 deletions installer/functions
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,60 @@ 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}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quotes added.

df -m $part | awk 'FNR == 2 {print $2,$4,$6}' |\
while read -r size avail mp; do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a while loop, since you always "return" after one round. Just start a { } block after the | on the upper line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while loop changed to { } block.

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. "
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"XGB or more is recommended."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-worded WARNING.

# error 1 "ERROR: Choose another partition then try again..."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the dead lines, please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented lines removed.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing how ChrUbuntu is mostly being superseded by other projects, it's probably worth changing references to just "dual boot"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed function and all variable names from 'chrubuntu' to 'dualboot' and updated comments and messages..

# normally called when space requirements on the CHROOTS partiton aren't met
check_chrubuntu() {
local disk=$(rootdev -s -d)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoting (also lines below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quotes added.

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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"often used for dual-boot installs"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworded and changed 'chrubuntu' to 'dual-boot installs'.

local tmp="`mktemp -d --tmpdir=/tmp 'check-chrubuntu.XXX'`"
local unmount="umount -l '$tmp' && rmdir '$tmp'"
# addtrap "$unmount"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trap added and later undone.

mount $chrubuntu_part "$tmp" 2>/dev/null
df -m "$tmp" | awk 'FNR == 2 {print $2,$3,$4}' |\
while read -r size used avail; do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also could probably just be a { } block

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while loop changed to { } block.

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..."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to ${chrubuntu_size_gb}, with ${chrubuntu_avail_gb} free

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-worded per note.

done
distrib="$(grep 'DISTRIB_DESCRIPTION=' "$tmp/etc/lsb-release" 2>/dev/null | cut -d= -f2)"
Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjusted line lengths to <80chars 'ish...

if [ -n "$distrib" ]; then
echo "WARNING: Also, it has $distrib installed."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It appears to have $distrib installed.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-worded per note.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trap added above and undone here.

fi
# undotrap
eval "$unmount"
return 1
else
return 0
fi
}
11 changes: 11 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"
PART_AVAIL_MIN=2000 # in MB
PART_SIZE_MIN=4000 # in MB

ARCH=''
BOOTSTRAP_RELEASE=''
Expand Down Expand Up @@ -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 chrubuntu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-worded comments

#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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably do the same wait-for-x-seconds thing we do elsewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep X added to both checks.

fi

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