Update grub install

This commit is contained in:
natemaia 2018-12-15 21:18:34 -08:00
parent 83743ec8c8
commit 84ed8947ae
4 changed files with 81 additions and 50 deletions

View File

@ -10,7 +10,7 @@
# immutable globals
readonly VER="1.7.37" # Installer version
readonly VER="1.7.39" # Installer version
readonly DIST="ArchLabs" # Linux distributor
readonly MNT="/mnt" # Install mountpoint
readonly ERR="/tmp/errlog" # Built-in error log

View File

@ -8,12 +8,11 @@
# sourcing this file in a non bash shell is not advised
# command used to install each bootloader
declare -Ag BCMDS=(
[UEFI-syslinux]='efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST'
[BIOS-syslinux]='syslinux-install_update -iam'
[UEFI-grub]='grub-install --recheck --force --bootloader-id=$DIST && grub-mkconfig -o /boot/grub/grub.cfg'
[BIOS-grub]='grub-install --recheck --force --bootloader-id=$DIST --target=i386-pc $BOOT_DEVICE && grub-mkconfig -o /boot/grub/grub.cfg'
[systemd-boot]='bootctl --path=/boot install'
[syslinux]="syslinux-install_update -iam"
[grub]="grub-install --recheck --force"
[systemd-boot]="bootctl --path=/boot install"
)
# boot partition mount points for each bootloader
@ -31,29 +30,66 @@ declare -Ag BOOTLDRS=(
[UEFI]="systemd-boot ${BMNTS[UEFI-systemd-boot]} grub ${BMNTS[UEFI-grub]} syslinux ${BMNTS[UEFI-syslinux]}"
)
pre_grub()
select_bootloader()
{
tput civis
if ! BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then
return 1
fi
[[ $BOOT_PART ]] && setup_boot_device
post_menu_${BOOTLDR} || return 1
}
post_menu_grub()
{
FILES[9]="/etc/default/grub"
if [[ $SYS == 'BIOS' && $BOOT_DEVICE == "" ]]; then
select_device 'boot' || return 1
elif [[ $SYS == 'UEFI' && $ROOT_PART =~ /dev/mapper && ! $LVM && ! $LUKS_PASS ]]; then
luks_pass "$_LuksOpen" "$ROOT_PART" || return 1
if [[ $SYS == 'BIOS' ]]; then
if [[ $BOOT_DEVICE == "" ]]; then
select_device 'boot' || return 1
fi
BCMDS[grub]+=" --target=i386-pc $BOOT_DEVICE"
else
if [[ $ROOT_PART =~ /dev/mapper && ! $LVM && ! $LUKS_PASS ]]; then
luks_pass "$_LuksOpen" "$ROOT_PART" || return 1
fi
if [[ $IS_64BIT == true ]]; then
local ttype='x86_64-efi'
else
local ttype="i386-efi"
fi
# all the mount mess is needed to work properly in the chroot
BCMDS[grub]="mkdir -p /run/udev &&
mkdir -p /run/lvm &&
mount --bind /hostrun/udev /run/udev &&
mount --bind /hostrun/lvm /run/lvm &&
${BCMDS[grub]} --target=$ttype --efi-directory=${BMNTS[UEFI-grub]} --bootloader-id=$DIST &&
umount /run/udev &&
umount /run/lvm"
fi
return 0
}
pre_syslinux()
post_menu_syslinux()
{
if [[ $SYS == 'BIOS' ]]; then
FILES[9]="/boot/syslinux/syslinux.cfg"
if ! BCMDS[syslinux]="$(menubox "$_InstSysTitle" "$_InstSysBody" 0 0 0 \
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
"syslinux-install_update -i" "Install to root partition (/)")"; then
return 1
fi
else
FILES[9]="/boot/EFI/syslinux/syslinux.cfg"
BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
fi
}
pre_systemd-boot()
post_menu_systemd-boot()
{
FILES[9]="/boot/loader/entries/$DIST.conf"
}
@ -74,16 +110,12 @@ prerun_grub()
fi
# needed for os-prober module to work properly in the chroot
if [[ $SYS == 'UEFI' ]]; then
# mkdir -p /run/lvm $MNT/hostrun/lvm
# mount --bind /run/lvm $MNT/hostrun/lvm
mkdir -p /run/udev $MNT/hostrun/udev
mount --bind /run/udev $MNT/hostrun/udev
BCMDS[grub]="mkdir -p /run/udev &&
mount --bind /hostrun/udev /run/udev &&
${BCMDS[grub]} &&
umount /run/udev"
fi
mkdir -p /run/lvm
mkdir -p /run/udev
mkdir -p $MNT/hostrun/lvm
mkdir -p $MNT/hostrun/udev
mount --bind /run/lvm $MNT/hostrun/lvm
mount --bind /run/udev $MNT/hostrun/udev
return 0
}
@ -177,18 +209,21 @@ install_bootloader()
fi
prerun_$BOOTLDR
printf "\nInstalling and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n\n"
chrun "${BCMDS[$BOOTLDR]}" #2>$ERR
echeck "${BCMDS[$BOOTLDR]}"
chrun "eval ${BCMDS[$SYS-$BOOTLDR]}"
if [[ -d $MNT/hostrun/udev ]]; then
umount $MNT/hostrun/udev
rm -rf $MNT/hostrun
if [[ -d $MNT/hostrun ]]; then
umount $MNT/hostrun/udev >/dev/null 2>&1
umount $MNT/hostrun/lvm >/dev/null 2>&1
rm -rf $MNT/hostrun >/dev/null 2>&1
fi
# copy efi stub to generic catch all
[[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]] && uefi_boot_fallback
if [[ $SYS == 'UEFI' && ($BOOTLDR == 'grub' || $BOOTLDR == 'syslinux') ]]; then
uefi_boot_fallback
fi
return 0
}
@ -202,8 +237,7 @@ uefi_boot_fallback()
local default="boot"
default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 \
-name '[Bb][oO][oO][tT]' -type d)"
[[ $default ]] && default="$(basename $default)"
default="$(basename $default)"
if [[ -d $esp/EFI/$default ]]; then
rm -rf $esp/EFI/$default/*
@ -215,9 +249,17 @@ uefi_boot_fallback()
cp -rf $esp/EFI/syslinux/* $esp/EFI/$default/
cp -f $esp/EFI/syslinux/syslinux.efi $esp/EFI/$default/bootx64.efi
elif [[ $BOOTLDR == 'grub' && $IS_64BIT == true ]]; then
cp -f $esp/EFI/$DIST/grubx64.efi $esp/EFI/$default/bootx64.efi
if [[ -d $esp/EFI/$DIST ]]; then
cp -f $esp/EFI/$DIST/grubx64.efi $esp/EFI/$default/bootx64.efi
else
cp -f $esp/EFI/grub/grubx64.efi $esp/EFI/$default/bootx64.efi
fi
elif [[ $BOOTLDR == 'grub' ]]; then
cp -f $esp/EFI/$DIST/grubia32.efi $esp/EFI/$default/bootia32.efi
if [[ -d $esp/EFI/$DIST ]]; then
cp -f $esp/EFI/$DIST/grubia32.efi $esp/EFI/$default/bootia32.efi
else
cp -f $esp/EFI/grub/grubia32.efi $esp/EFI/$default/bootia32.efi
fi
fi
return 0

View File

@ -38,7 +38,7 @@ declare -g MYSHELL=""
declare -g MKINIT_HOOKS="shutdown"
# match the wm name with the actual session name used for xinit
declare -gA WM_SESSIONS=(
declare -Ag WM_SESSIONS=(
[dwm]='dwm'
[i3-gaps]='i3'
[bspwm]='bspwm'
@ -49,7 +49,7 @@ declare -gA WM_SESSIONS=(
)
# additional packages installed for each wm/de
declare -gA WM_EXT=(
declare -Ag WM_EXT=(
[gnome]="gnome-extra"
[bspwm]="sxhkd archlabs-skel-bspwm rofi archlabs-polybar"
[xfce4]="xfce4-goodies xfce4-pulseaudio-plugin archlabs-skel-xfce4"
@ -58,7 +58,7 @@ declare -gA WM_EXT=(
)
# files the user can edit during the final stage of install
declare -gA EDIT_FILES=(
declare -Ag EDIT_FILES=(
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
[3]="/etc/locale.conf /etc/default/locale"
[4]="/etc/hostname /etc/hosts"
@ -66,7 +66,7 @@ declare -gA EDIT_FILES=(
[6]="/etc/mkinitcpio.conf"
[7]="/etc/fstab"
[8]="/etc/crypttab"
[9]="/etc/default/grub"
[9]="/boot/loader/entries/$DIST.conf"
[10]="/etc/pacman.conf"
[11]="" # login files.. Populated later once login method is chosen
)
@ -76,7 +76,7 @@ declare -gA EDIT_FILES=(
show_cfg()
{
local cmd mnt pkgs
cmd="$(eval echo ${BCMDS[$SYS-$BOOTLDR]})"
cmd="${BCMDS[$SYS-$BOOTLDR]}"
mnt="${BMNTS[$SYS-$BOOTLDR]}"
msgbox "$_PrepTitle" "

View File

@ -104,17 +104,6 @@ select_mountpoint()
return 0
}
select_bootloader()
{
tput civis
if ! BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then
return 1
fi
[[ $BOOT_PART ]] && setup_boot_device
pre_${BOOTLDR} || return 1
}
select_mount_opts()
{
local part="$1"