Testing btrfs changes

This commit is contained in:
natemaia 2020-05-16 16:05:01 -07:00
parent c57cc058fb
commit 43a31435be

View File

@ -1365,6 +1365,7 @@ select_root()
if (( BTRFS == 2 )); then if (( BTRFS == 2 )); then
btrfs_subvols "$ROOT" || return 1 btrfs_subvols "$ROOT" || return 1
fi fi
BTRFS=0
return 0 return 0
fi fi
# should never reach here unless an error occurred # should never reach here unless an error occurred
@ -1432,6 +1433,9 @@ select_extra()
done <<< "$PARTS" done <<< "$PARTS"
fi fi
if (( PART_COUNT == 0 )); then
msg "Mount Extra" "\nMounting Finished\n\nNo more partitions to mount, returning to main menu.\n" 2
else
while (( PART_COUNT )); do while (( PART_COUNT )); do
part='' part=''
dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break
@ -1443,13 +1447,11 @@ select_extra()
fi fi
EXMNTS+="$part: $EXMNT " EXMNTS+="$part: $EXMNT "
[[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr" [[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr"
BTRFS=0
else else
return 1 return 1
fi fi
done done
if (( PART_COUNT == 0 )); then
msg "Mount Extra" "\nMounting Finished\n\nNo more partitions to mount, returning to main menu.\n" 2
fi fi
return 0 return 0
} }
@ -2383,16 +2385,16 @@ prerun_systemd-boot()
btrfs_name() btrfs_name()
{ {
local txt="$1" local txt="$1"
local default="$2" local def="$2"
local match="$3" local match="$3"
SUBVOL='' SUBVOL=''
until [[ $SUBVOL ]]; do until [[ $SUBVOL ]]; do
dlg SUBVOL input "Btrfs Subvolume Name" "$txt" "$default" || return 1 dlg SUBVOL input "Subvolume Name" "$txt" "$def" || return 1
if [[ -z $SUBVOL ]]; then if [[ -z $SUBVOL ]]; then
return 1 return 1
elif [[ $SUBVOL =~ \ |\' || $match == *"$SUBVOL"* || $SUBVOL == "$MVOL" ]]; then elif [[ $SUBVOL =~ \ |\' || $match == *"$SUBVOL"* || $SUBVOL == "$MVOL" ]]; then
msg "Btrfs Subvolume Name Error" "$_btrfserrname" msg "Subvolume Name Error" "$_btrfserrname"
SUBVOL='' SUBVOL=''
fi fi
done done
@ -2403,29 +2405,18 @@ btrfs_subvols()
{ {
local part="$1" local part="$1"
local mntp="$2" local mntp="$2"
local list="" local list='' opts='' s="${mntp//\//_}" n=1
local opts=''
local n=1
local txt="\nEnter a name for the initial subvolume.\n\nOnce mounted other subvolumes created for" local txt="\nEnter a name for the initial subvolume.\n\nOnce mounted other subvolumes created for"
MVOL="" btrfs_name "$txt $MNT${mntp} will branch from it." "subvol${s:-_root}" || return 1
btrfs_name "$txt ${mntp:-/} will branch from it." "root" || return 1
MVOL="$SUBVOL" MVOL="$SUBVOL"
if [[ $mntp ]]; then mkdir -p "$MNT${mntp}" || return 1
mkdir -p "${MNT}$mntpt" || return 1 [[ -z $mntp ]] && BTRFS_MNT="rootflags=subvol=$MVOL"
cd "$MNT${mntp}" 2> "$ERR"
errshow 0 "cd $MNT${mntp}" || return 1
else
BTRFS_MNT="rootflags=subvol=$MVOL"
fi
# create the main subvolume # create the main subvolume
btrfs subvolume create "$MVOL" > /dev/null 2> "$ERR" btrfs subvolume create "$MNT${mntp}/$MVOL" > /dev/null 2> "$ERR"
errshow 0 "btrfs subvolume create $MVOL" || return 1 errshow 0 "btrfs subvolume create $MNT${mntp}/$MVOL" || return 1
cd 2> "$ERR"
errshow 0 "cd" || return 1
umount "$part" 2> "$ERR" umount "$part" 2> "$ERR"
errshow 0 "umount $part" || return 1 errshow 0 "umount $part" || return 1
@ -2435,36 +2426,23 @@ btrfs_subvols()
opts="subvol=${MVOL}" opts="subvol=${MVOL}"
fi fi
if [[ $mntp ]]; then mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR"
mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR" || mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR"
errshow 0 "mount -o $opts $part $MNT${mntp}" || return 1 errshow 0 "mount -o $opts $part $MNT${mntp}" || return 1
grep -q "$MNT${mntp}" /proc/mounts || { msg "Mount Failed" "\nUnable to mount $part at $MNT${mntp}\n" 2; return 1; } grep -q "$MNT${mntp}" /proc/mounts || { msg "Mount Failed" "\nUnable to mount $part at $MNT${mntp}\n" 2; return 1; }
msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT${mntp}\n" 1 msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT${mntp}\n" 1
else
mount -o $opts "$part" "$MNT" 2> "$ERR" || mount -o $opts "$part" "$MNT" 2> "$ERR"
errshow 0 "mount -o $opts $part $MNT" || return 1
grep -q "$MNT" /proc/mounts || { msg "Mount Failed" "\nUnable to mount $part at $MNT\n" 2; return 1; }
msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT\n" 1
fi
cd "$MNT${mntp}" 2> "$ERR"
errshow 0 "cd $MNT${mntp}" || return 1
# create the subvolume(s) # create the subvolume(s)
SUBVOL=''
until [[ $SUBVOL == '*' ]]; do until [[ $SUBVOL == '*' ]]; do
local txt="\nEnter a name for subvolume $n within '$MVOL' subvolume." local txt="\nEnter a name for subvolume $n within '$MVOL' subvolume."
txt+="\n\nThis process will be repeated until an asterisk (*) is entered as the subvolume name." txt+="\n\nThis process will be repeated until an asterisk (*) is entered as the subvolume name."
btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "subvol$n" "$list" || return 1 btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "subvol_$n" "$list" || return 1
btrfs subvolume create $SUBVOL > /dev/null 2> "$ERR" btrfs subvolume create "$MNT${mntp}/$MVOL/$SUBVOL" > /dev/null 2> "$ERR"
errshow 0 "btrfs subvolume create $SUBVOL" || return 1 errshow 0 "btrfs subvolume create $MNT${mntp}/$MVOL/$SUBVOL" || return 1
(( n++ )) (( n++ ))
list+="$SUBVOL " list+="$SUBVOL "
done done
msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls)" msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls -R "$MNT${mntp}/$MVOL")"
cd 2> "$ERR"
errshow 0 "cd" || return 1
} }
############################################################################### ###############################################################################
@ -2835,8 +2813,9 @@ ofn()
die() die()
{ {
# cleanup and exit the installer cleanly with exit code $1 # exit cleanly with exit code $1 or the last command's exit code
local e="${1:-$?}" # when e is 127 unmount /run/archiso/bootmnt and reboot # when $1 == 127 we unmount and reboot
local e="${1:-$?}"
trap - INT trap - INT
tput cnorm tput cnorm
@ -2967,12 +2946,14 @@ live()
usage() usage()
{ {
cat <<- EOF cat <<- EOF
usage: $1 [-hdn] [-rb DEVICE] [-l SESSION] usage: $1 [-hDn] [-r ROOT] [-b BOOT] [-l SESSION] [-d DISTRO] [-m MOUNTPOINT]
options: options:
-h print this message and exit -h print this message and exit
-l install and setup a live session -l install and setup a live session
-d enable xtrace and log output to $DBG -D enable xtrace and log output to $DBG
-m set the mountpoint used for the new installation
-d set the distribution name for the installed system
-n no partitioning, mounting, or formatting (self mount) -n no partitioning, mounting, or formatting (self mount)
-r root partition to use for install, required when using -n -r root partition to use for install, required when using -n
-b boot partition to use for install, required on UEFI systems when using -n -b boot partition to use for install, required on UEFI systems when using -n
@ -2993,24 +2974,6 @@ usage()
plasma - A kde software project currently comprising a full desktop environment plasma - A kde software project currently comprising a full desktop environment
xfce4 - A lightweight and modular desktop environment based on gtk+2/3 xfce4 - A lightweight and modular desktop environment based on gtk+2/3
distro name:
set the DIST environment variable before launching the installer eg.
DIST='MyDistro' $1
root/boot partition:
set the ROOT and/or BOOT environment variables before launching the installer eg.
ROOT='/dev/sda2' BOOT='/dev/sda1' $1
editor used:
set the EDITOR environment variable before launching the installer eg.
EDITOR='nano' $1
EOF EOF
exit 0 exit 0
} }
@ -3052,7 +3015,7 @@ errmsg()
local err="" local err=""
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")" err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
[[ -z $err ]] && err="no error message was found" [[ -z $err ]] && err="no error message was output"
printf "%s" "$err" printf "%s" "$err"
} }
@ -3127,7 +3090,7 @@ prechecks()
{ {
local i=1 local i=1
if (( $1 >= 0 )) && ! grep -qw "$MNT" /proc/mounts; then if (( $1 >= 0 )) && ! grep -q " $MNT " /proc/mounts; then
msg "Not Mounted" "\nPartition(s) must be mounted first.\n" 2 msg "Not Mounted" "\nPartition(s) must be mounted first.\n" 2
SEL=4 i=0 SEL=4 i=0
elif [[ $1 -ge 1 && -z $BOOTLDR ]]; then elif [[ $1 -ge 1 && -z $BOOTLDR ]]; then
@ -3137,7 +3100,7 @@ prechecks()
msg "No User" "\nA user must be created first.\n" 2 msg "No User" "\nA user must be created first.\n" 2
SEL=6 i=0 SEL=6 i=0
elif [[ $1 -ge 3 && -z $CONFIG_DONE ]]; then elif [[ $1 -ge 3 && -z $CONFIG_DONE ]]; then
msg "Not Configured" "\nSystem configuration must be done first.\n" 2 msg "No Config" "\nSystem configuration must be done first.\n" 2
SEL=7 i=0 SEL=7 i=0
fi fi
(( i )) # return code (( i )) # return code
@ -3147,7 +3110,7 @@ umount_dir()
{ {
mount | grep -q 'swap' && swapoff -a mount | grep -q 'swap' && swapoff -a
for dir; do for dir; do
if [[ -d $dir ]] && mount | grep -q "on $dir "; then if [[ -d $dir ]] && grep -q " $dir " /proc/mounts; then
if ! umount "$dir" 2> /dev/null; then if ! umount "$dir" 2> /dev/null; then
sleep 0.5 sleep 0.5
umount -f "$dir" 2> /dev/null || umount -l "$dir" umount -f "$dir" 2> /dev/null || umount -l "$dir"
@ -3235,10 +3198,10 @@ system_identify()
modprobe -q efivarfs > /dev/null 2>&1 modprobe -q efivarfs > /dev/null 2>&1
if [[ -d /sys/firmware/efi/efivars ]]; then if [[ -d /sys/firmware/efi/efivars ]]; then
export SYS="UEFI" SYS="UEFI"
grep -q /sys/firmware/efi/efivars /proc/mounts || mount -t efivarfs efivarfs /sys/firmware/efi/efivars grep -q /sys/firmware/efi/efivars /proc/mounts || mount -t efivarfs efivarfs /sys/firmware/efi/efivars
else else
export SYS="BIOS" SYS="BIOS"
fi fi
} }
@ -3265,45 +3228,23 @@ trap 'printf "\n^C\n" && die 1' INT
while getopts ":htl:Dnr:b:m:d:" OPT; do while getopts ":htl:Dnr:b:m:d:" OPT; do
case "$OPT" in case "$OPT" in
n) D) debug ;;
NOMOUNT=true h) usage "$0" ;;
;; n) NOMOUNT=true ;;
m) t) TEARFREE=true ;;
MNT="$OPTARG" m) MNT="$OPTARG" ;;
;; d) DIST="$OPTARG" ;;
d)
DIST="$OPTARG"
;;
D)
debug
;;
h)
usage "$0"
;;
t)
TEARFREE=true
;;
r) r)
if [[ ! -b $OPTARG ]]; then [[ -b $OPTARG ]] || { msg "Invalid Root" "\nThe installer expects a full path to a block device for root.\n\nExiting..\n" 2; die 1; }
msg "Invalid Root" "\nThe installer expects a full path to a block device for root.\n\nExiting..\n" 2
die 1
fi
ROOT="$OPTARG" ROOT="$OPTARG"
;; ;;
b) b)
if [[ ! -b $OPTARG ]]; then [[ -b $OPTARG ]] || { msg "Invalid Boot" "\nThe installer expects a full path to a block device for boot.\n\nExiting..\n" 2; die 1; }
msg "Invalid Boot" "\nThe installer expects a full path to a block device for boot.\n\nExiting..\n" 2
die 1
fi
BOOT="$OPTARG" BOOT="$OPTARG"
;; ;;
l) l)
if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]] || { echo "error: invalid session for -l, see -h for help"; die 1; }
live "$OPTARG" live "$OPTARG"
else
echo "error: invalid session for -l, see -h for help"
die 1
fi
;; ;;
\?) \?)
echo "invalid option: $OPTARG" echo "invalid option: $OPTARG"
@ -3312,6 +3253,7 @@ while getopts ":htl:Dnr:b:m:d:" OPT; do
esac esac
done done
# verify mountpoint and distro name
if [[ ! -d $MNT ]]; then if [[ ! -d $MNT ]]; then
msg "Invalid Mountpoint" "\nThe installer expects an existing directory for mounting.\n\nExiting..\n" 2 msg "Invalid Mountpoint" "\nThe installer expects an existing directory for mounting.\n\nExiting..\n" 2
die 1 die 1
@ -3323,6 +3265,7 @@ fi
system_identify system_identify
system_devices system_devices
# verify partitions for self mounted installs
if [[ $NOMOUNT ]]; then if [[ $NOMOUNT ]]; then
if [[ -z $ROOT || ($SYS == 'UEFI' && -z $BOOT) ]]; then if [[ -z $ROOT || ($SYS == 'UEFI' && -z $BOOT) ]]; then
msg "Invalid Partitions" "$_errpart" 0 msg "Invalid Partitions" "$_errpart" 0
@ -3334,26 +3277,30 @@ if [[ $NOMOUNT ]]; then
fi fi
fi fi
if [[ $TERM == 'linux' && -f /tmp/hassetfont ]]; then # linux console font setup
FONT="$(< /tmp/hassetfont)" if [[ $TERM == 'linux' ]]; then
if [[ -f /tmp/font ]]; then
FONT="$(< /tmp/font)"
setfont "$FONT" setfont "$FONT"
else else
fontsize=16 fontsize=16
FONT="ter-i${fontsize}n" while [[ $TERM == 'linux' && ! -f /tmp/font ]]; do
while [[ $TERM == 'linux' && ! -f /tmp/hassetfont ]]; do
dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \ dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \
12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \ 12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \
20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \ 20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \
32 "setfont ter-i32n" || break 32 "setfont ter-i32n" || break
FONT="ter-i${fontsize}n" FONT="ter-i${fontsize}n"
setfont "$FONT" setfont "$FONT"
yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/hassetfont yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/font
done done
fi
fi fi
if [[ ! -f /tmp/welcomed ]]; then # welcome once
if [[ ! -f /tmp/weld ]]; then
msg "Welcome to the $DIST Installer" "$_welcome" msg "Welcome to the $DIST Installer" "$_welcome"
touch /tmp/welcomed touch /tmp/weld
fi fi
if ! select_keymap; then if ! select_keymap; then
@ -3364,8 +3311,9 @@ elif ! net_connect; then
die 1 die 1
fi fi
# check for update once
if [[ ! -f /tmp/new ]]; then if [[ ! -f /tmp/new ]]; then
msg "Installer Update" "\nChecking that the installer version is the newest.\n" 0 msg "Installer Update" "\nChecking for newer installer versions.\n" 1
if curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/archlabs-installer -o /tmp/new; then if curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/archlabs-installer -o /tmp/new; then
if (( $(vercmp "$(awk -F= '/^VER=/ {print $2}' /tmp/archlabs-installer)" "$VER") > 0 )); then if (( $(vercmp "$(awk -F= '/^VER=/ {print $2}' /tmp/archlabs-installer)" "$VER") > 0 )); then
cp /tmp/new /usr/bin/archlabs-installer && exec archlabs-installer "$@" cp /tmp/new /usr/bin/archlabs-installer && exec archlabs-installer "$@"
@ -3376,6 +3324,7 @@ if [[ ! -f /tmp/new ]]; then
fi fi
fi fi
# warn before starting the background process
if [[ $NOMOUNT ]]; then if [[ $NOMOUNT ]]; then
wrn="\nA background install process will begin early when using -n flag\n\nSome files may be overwritten during the process\n" wrn="\nA background install process will begin early when using -n flag\n\nSome files may be overwritten during the process\n"
yesno "Data Warning" "$wrn\nProceed?\n" || die 0 yesno "Data Warning" "$wrn\nProceed?\n" || die 0