Testing btrfs changes
This commit is contained in:
parent
c57cc058fb
commit
43a31435be
@ -1365,6 +1365,7 @@ select_root()
|
||||
if (( BTRFS == 2 )); then
|
||||
btrfs_subvols "$ROOT" || return 1
|
||||
fi
|
||||
BTRFS=0
|
||||
return 0
|
||||
fi
|
||||
# should never reach here unless an error occurred
|
||||
@ -1432,24 +1433,25 @@ select_extra()
|
||||
done <<< "$PARTS"
|
||||
fi
|
||||
|
||||
while (( PART_COUNT )); do
|
||||
part=''
|
||||
dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break
|
||||
if [[ $part == 'done' ]]; then
|
||||
break
|
||||
elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT" $BTRFS; then
|
||||
if (( BTRFS == 2 )); then
|
||||
btrfs_subvols "$part" "$EXMNT" || return 1
|
||||
fi
|
||||
EXMNTS+="$part: $EXMNT "
|
||||
[[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
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
|
||||
part=''
|
||||
dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break
|
||||
if [[ $part == 'done' ]]; then
|
||||
break
|
||||
elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT" $BTRFS; then
|
||||
if (( BTRFS == 2 )); then
|
||||
btrfs_subvols "$part" "$EXMNT" || return 1
|
||||
fi
|
||||
EXMNTS+="$part: $EXMNT "
|
||||
[[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr"
|
||||
BTRFS=0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -2383,16 +2385,16 @@ prerun_systemd-boot()
|
||||
btrfs_name()
|
||||
{
|
||||
local txt="$1"
|
||||
local default="$2"
|
||||
local def="$2"
|
||||
local match="$3"
|
||||
|
||||
SUBVOL=''
|
||||
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
|
||||
return 1
|
||||
elif [[ $SUBVOL =~ \ |\' || $match == *"$SUBVOL"* || $SUBVOL == "$MVOL" ]]; then
|
||||
msg "Btrfs Subvolume Name Error" "$_btrfserrname"
|
||||
msg "Subvolume Name Error" "$_btrfserrname"
|
||||
SUBVOL=''
|
||||
fi
|
||||
done
|
||||
@ -2403,29 +2405,18 @@ btrfs_subvols()
|
||||
{
|
||||
local part="$1"
|
||||
local mntp="$2"
|
||||
local list=""
|
||||
local opts=''
|
||||
local n=1
|
||||
local list='' opts='' s="${mntp//\//_}" n=1
|
||||
local txt="\nEnter a name for the initial subvolume.\n\nOnce mounted other subvolumes created for"
|
||||
|
||||
MVOL=""
|
||||
btrfs_name "$txt ${mntp:-/} will branch from it." "root" || return 1
|
||||
btrfs_name "$txt $MNT${mntp} will branch from it." "subvol${s:-_root}" || return 1
|
||||
MVOL="$SUBVOL"
|
||||
|
||||
if [[ $mntp ]]; then
|
||||
mkdir -p "${MNT}$mntpt" || return 1
|
||||
cd "$MNT${mntp}" 2> "$ERR"
|
||||
errshow 0 "cd $MNT${mntp}" || return 1
|
||||
else
|
||||
BTRFS_MNT="rootflags=subvol=$MVOL"
|
||||
fi
|
||||
mkdir -p "$MNT${mntp}" || return 1
|
||||
[[ -z $mntp ]] && BTRFS_MNT="rootflags=subvol=$MVOL"
|
||||
|
||||
# create the main subvolume
|
||||
btrfs subvolume create "$MVOL" > /dev/null 2> "$ERR"
|
||||
errshow 0 "btrfs subvolume create $MVOL" || return 1
|
||||
|
||||
cd 2> "$ERR"
|
||||
errshow 0 "cd" || return 1
|
||||
btrfs subvolume create "$MNT${mntp}/$MVOL" > /dev/null 2> "$ERR"
|
||||
errshow 0 "btrfs subvolume create $MNT${mntp}/$MVOL" || return 1
|
||||
umount "$part" 2> "$ERR"
|
||||
errshow 0 "umount $part" || return 1
|
||||
|
||||
@ -2435,36 +2426,23 @@ btrfs_subvols()
|
||||
opts="subvol=${MVOL}"
|
||||
fi
|
||||
|
||||
if [[ $mntp ]]; then
|
||||
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
|
||||
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
|
||||
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
|
||||
mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR"
|
||||
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; }
|
||||
msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT${mntp}\n" 1
|
||||
|
||||
# create the subvolume(s)
|
||||
SUBVOL=''
|
||||
until [[ $SUBVOL == '*' ]]; do
|
||||
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."
|
||||
btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "subvol$n" "$list" || return 1
|
||||
btrfs subvolume create $SUBVOL > /dev/null 2> "$ERR"
|
||||
errshow 0 "btrfs subvolume create $SUBVOL" || return 1
|
||||
btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "subvol_$n" "$list" || return 1
|
||||
btrfs subvolume create "$MNT${mntp}/$MVOL/$SUBVOL" > /dev/null 2> "$ERR"
|
||||
errshow 0 "btrfs subvolume create $MNT${mntp}/$MVOL/$SUBVOL" || return 1
|
||||
(( n++ ))
|
||||
list+="$SUBVOL "
|
||||
done
|
||||
|
||||
msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls)"
|
||||
cd 2> "$ERR"
|
||||
errshow 0 "cd" || return 1
|
||||
msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls -R "$MNT${mntp}/$MVOL")"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
@ -2835,8 +2813,9 @@ ofn()
|
||||
|
||||
die()
|
||||
{
|
||||
# cleanup and exit the installer cleanly with exit code $1
|
||||
local e="${1:-$?}" # when e is 127 unmount /run/archiso/bootmnt and reboot
|
||||
# exit cleanly with exit code $1 or the last command's exit code
|
||||
# when $1 == 127 we unmount and reboot
|
||||
local e="${1:-$?}"
|
||||
|
||||
trap - INT
|
||||
tput cnorm
|
||||
@ -2967,12 +2946,14 @@ live()
|
||||
usage()
|
||||
{
|
||||
cat <<- EOF
|
||||
usage: $1 [-hdn] [-rb DEVICE] [-l SESSION]
|
||||
usage: $1 [-hDn] [-r ROOT] [-b BOOT] [-l SESSION] [-d DISTRO] [-m MOUNTPOINT]
|
||||
|
||||
options:
|
||||
-h print this message and exit
|
||||
-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)
|
||||
-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
|
||||
@ -2993,24 +2974,6 @@ usage()
|
||||
plasma - A kde software project currently comprising a full desktop environment
|
||||
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
|
||||
exit 0
|
||||
}
|
||||
@ -3052,7 +3015,7 @@ errmsg()
|
||||
local 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"
|
||||
}
|
||||
|
||||
@ -3127,7 +3090,7 @@ prechecks()
|
||||
{
|
||||
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
|
||||
SEL=4 i=0
|
||||
elif [[ $1 -ge 1 && -z $BOOTLDR ]]; then
|
||||
@ -3137,7 +3100,7 @@ prechecks()
|
||||
msg "No User" "\nA user must be created first.\n" 2
|
||||
SEL=6 i=0
|
||||
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
|
||||
fi
|
||||
(( i )) # return code
|
||||
@ -3147,7 +3110,7 @@ umount_dir()
|
||||
{
|
||||
mount | grep -q 'swap' && swapoff -a
|
||||
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
|
||||
sleep 0.5
|
||||
umount -f "$dir" 2> /dev/null || umount -l "$dir"
|
||||
@ -3235,10 +3198,10 @@ system_identify()
|
||||
modprobe -q efivarfs > /dev/null 2>&1
|
||||
|
||||
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
|
||||
else
|
||||
export SYS="BIOS"
|
||||
SYS="BIOS"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -3265,45 +3228,23 @@ trap 'printf "\n^C\n" && die 1' INT
|
||||
|
||||
while getopts ":htl:Dnr:b:m:d:" OPT; do
|
||||
case "$OPT" in
|
||||
n)
|
||||
NOMOUNT=true
|
||||
;;
|
||||
m)
|
||||
MNT="$OPTARG"
|
||||
;;
|
||||
d)
|
||||
DIST="$OPTARG"
|
||||
;;
|
||||
D)
|
||||
debug
|
||||
;;
|
||||
h)
|
||||
usage "$0"
|
||||
;;
|
||||
t)
|
||||
TEARFREE=true
|
||||
;;
|
||||
D) debug ;;
|
||||
h) usage "$0" ;;
|
||||
n) NOMOUNT=true ;;
|
||||
t) TEARFREE=true ;;
|
||||
m) MNT="$OPTARG" ;;
|
||||
d) DIST="$OPTARG" ;;
|
||||
r)
|
||||
if [[ ! -b $OPTARG ]]; then
|
||||
msg "Invalid Root" "\nThe installer expects a full path to a block device for root.\n\nExiting..\n" 2
|
||||
die 1
|
||||
fi
|
||||
[[ -b $OPTARG ]] || { msg "Invalid Root" "\nThe installer expects a full path to a block device for root.\n\nExiting..\n" 2; die 1; }
|
||||
ROOT="$OPTARG"
|
||||
;;
|
||||
b)
|
||||
if [[ ! -b $OPTARG ]]; then
|
||||
msg "Invalid Boot" "\nThe installer expects a full path to a block device for boot.\n\nExiting..\n" 2
|
||||
die 1
|
||||
fi
|
||||
[[ -b $OPTARG ]] || { msg "Invalid Boot" "\nThe installer expects a full path to a block device for boot.\n\nExiting..\n" 2; die 1; }
|
||||
BOOT="$OPTARG"
|
||||
;;
|
||||
l)
|
||||
if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then
|
||||
live "$OPTARG"
|
||||
else
|
||||
echo "error: invalid session for -l, see -h for help"
|
||||
die 1
|
||||
fi
|
||||
[[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]] || { echo "error: invalid session for -l, see -h for help"; die 1; }
|
||||
live "$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
echo "invalid option: $OPTARG"
|
||||
@ -3312,6 +3253,7 @@ while getopts ":htl:Dnr:b:m:d:" OPT; do
|
||||
esac
|
||||
done
|
||||
|
||||
# verify mountpoint and distro name
|
||||
if [[ ! -d $MNT ]]; then
|
||||
msg "Invalid Mountpoint" "\nThe installer expects an existing directory for mounting.\n\nExiting..\n" 2
|
||||
die 1
|
||||
@ -3323,6 +3265,7 @@ fi
|
||||
system_identify
|
||||
system_devices
|
||||
|
||||
# verify partitions for self mounted installs
|
||||
if [[ $NOMOUNT ]]; then
|
||||
if [[ -z $ROOT || ($SYS == 'UEFI' && -z $BOOT) ]]; then
|
||||
msg "Invalid Partitions" "$_errpart" 0
|
||||
@ -3334,26 +3277,30 @@ if [[ $NOMOUNT ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $TERM == 'linux' && -f /tmp/hassetfont ]]; then
|
||||
FONT="$(< /tmp/hassetfont)"
|
||||
setfont "$FONT"
|
||||
else
|
||||
fontsize=16
|
||||
FONT="ter-i${fontsize}n"
|
||||
while [[ $TERM == 'linux' && ! -f /tmp/hassetfont ]]; do
|
||||
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" \
|
||||
20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \
|
||||
32 "setfont ter-i32n" || break
|
||||
FONT="ter-i${fontsize}n"
|
||||
# linux console font setup
|
||||
if [[ $TERM == 'linux' ]]; then
|
||||
if [[ -f /tmp/font ]]; then
|
||||
FONT="$(< /tmp/font)"
|
||||
setfont "$FONT"
|
||||
yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/hassetfont
|
||||
done
|
||||
else
|
||||
fontsize=16
|
||||
while [[ $TERM == 'linux' && ! -f /tmp/font ]]; do
|
||||
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" \
|
||||
20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \
|
||||
32 "setfont ter-i32n" || break
|
||||
|
||||
FONT="ter-i${fontsize}n"
|
||||
setfont "$FONT"
|
||||
yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/font
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f /tmp/welcomed ]]; then
|
||||
# welcome once
|
||||
if [[ ! -f /tmp/weld ]]; then
|
||||
msg "Welcome to the $DIST Installer" "$_welcome"
|
||||
touch /tmp/welcomed
|
||||
touch /tmp/weld
|
||||
fi
|
||||
|
||||
if ! select_keymap; then
|
||||
@ -3364,8 +3311,9 @@ elif ! net_connect; then
|
||||
die 1
|
||||
fi
|
||||
|
||||
# check for update once
|
||||
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 (( $(vercmp "$(awk -F= '/^VER=/ {print $2}' /tmp/archlabs-installer)" "$VER") > 0 )); then
|
||||
cp /tmp/new /usr/bin/archlabs-installer && exec archlabs-installer "$@"
|
||||
@ -3376,6 +3324,7 @@ if [[ ! -f /tmp/new ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# warn before starting the background process
|
||||
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"
|
||||
yesno "Data Warning" "$wrn\nProceed?\n" || die 0
|
||||
|
Reference in New Issue
Block a user