mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
merge syslinux and extlinux
This commit is contained in:
parent
aba05f72cb
commit
7616922b44
1 changed files with 45 additions and 65 deletions
|
@ -3157,20 +3157,35 @@ prepare_syslinux () {
|
||||||
common_syslinux () {
|
common_syslinux () {
|
||||||
DEVS="$(findbootloaderdisks _)"
|
DEVS="$(findbootloaderdisks _)"
|
||||||
DEVS="$DEVS $(findbootloaderpartitions _)"
|
DEVS="$DEVS $(findbootloaderpartitions _)"
|
||||||
|
|
||||||
if [[ "$DEVS" = "" ]]; then
|
if [[ "$DEVS" = "" ]]; then
|
||||||
DIALOG --msgbox "No hard drives were found" 0 0
|
DIALOG --msgbox "No hard drives were found" 0 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DIALOG --menu "Select the boot device where the $SYSLINUX bootloader will be installed (usually the MBR)" 14 55 7 $DEVS 2>$ANSWER || return 1
|
DIALOG --menu "Select the boot device where the $SYSLINUX bootloader will be installed (usually the MBR)" 14 55 7 $DEVS 2>$ANSWER || return 1
|
||||||
ROOTDEV=$(cat $ANSWER)
|
ROOTDEV=$(cat $ANSWER)
|
||||||
|
|
||||||
# generate config file
|
# generate config file
|
||||||
TEMPDIR=/tmp
|
TEMPDIR=/tmp
|
||||||
MBR=$DESTDIR/usr/lib/syslinux/mbr.bin
|
|
||||||
GPTMBR=$DESTDIR/usr/lib/syslinux/gptmbr.bin
|
|
||||||
# check if GPT/GUID is used
|
# check if GPT/GUID is used
|
||||||
GUID_DETECTED=
|
GUID_DETECTED=''
|
||||||
[[ "$(parted -s $ROOTDEV print | grep "Partition Table: gpt")" ]] && GUID_DETECTED=1
|
[[ "$(parted -s $ROOTDEV print | grep "Partition Table: gpt")" ]] && GUID_DETECTED=1
|
||||||
|
|
||||||
|
PARTITION_NUMBER=$(echo $bootdev | sed -e 's#.*[a-z]##g')
|
||||||
|
if [[ "$GUID_DETECTED" = '1' ]]; then
|
||||||
|
# Set Legacy BIOS Bootable GPT Partition Attribute using sgdisk
|
||||||
|
if ! [[ "$(sgdisk -i $PARTITION_NUMBER $ROOTDEV | grep '^Attribute' | grep '4$')" ]]; then
|
||||||
|
sgdisk $ROOTDEV --attributes=$PARTITION_NUMBER:set:2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# mark the partition with /boot as active in MBR
|
||||||
|
parted -s $ROOTDEV set $PARTITION_NUMBER boot on >$LOG
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -e $TEMPDIR/$SYSLINUX_CONF ]] && rm $TEMPDIR/$SYSLINUX_CONF
|
[[ -e $TEMPDIR/$SYSLINUX_CONF ]] && rm $TEMPDIR/$SYSLINUX_CONF
|
||||||
|
|
||||||
cat << EOF > $TEMPDIR/$SYSLINUX_CONF
|
cat << EOF > $TEMPDIR/$SYSLINUX_CONF
|
||||||
DEFAULT vesamenu.c32
|
DEFAULT vesamenu.c32
|
||||||
PROMPT 0
|
PROMPT 0
|
||||||
|
@ -3225,42 +3240,43 @@ EOF
|
||||||
else
|
else
|
||||||
echo "append initrd=$subdir/$KERNELPKG-fallback.img root=$PART_ROOT rootflags=$ROOTFLAGS rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> $TEMPDIR/$SYSLINUX_CONF
|
echo "append initrd=$subdir/$KERNELPKG-fallback.img root=$PART_ROOT rootflags=$ROOTFLAGS rootfstype=$ROOTFS $RAIDARRAYS $CRYPTSETUP" | sed -e 's# # #g' >> $TEMPDIR/$SYSLINUX_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# edit config file
|
# edit config file
|
||||||
DIALOG --msgbox "Before installing $SYSLINUX, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, $SYSLINUX will be installed." 0 0
|
DIALOG --msgbox "Before installing $SYSLINUX, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, $SYSLINUX will be installed." 0 0
|
||||||
geteditor || return 1
|
geteditor || return 1
|
||||||
$EDITOR $TEMPDIR/$SYSLINUX_CONF
|
$EDITOR $TEMPDIR/$SYSLINUX_CONF
|
||||||
|
|
||||||
# install syslinux
|
# install syslinux
|
||||||
DIALOG --infobox "Installing the $SYSLINUX bootloader..." 0 0
|
DIALOG --infobox "Installing the $SYSLINUX bootloader..." 0 0
|
||||||
! [[ -d $DESTDIR/boot/$SYSLINUX_DIR ]] && mkdir -p $DESTDIR/boot/$SYSLINUX_DIR
|
! [[ -d $DESTDIR/boot/$SYSLINUX_DIR ]] && mkdir -p $DESTDIR/boot/$SYSLINUX_DIR
|
||||||
cp $TEMPDIR/$SYSLINUX_CONF $DESTDIR/boot/$SYSLINUX_DIR/$SYSLINUX_CONF
|
cp $TEMPDIR/$SYSLINUX_CONF $DESTDIR/boot/$SYSLINUX_DIR/$SYSLINUX_CONF
|
||||||
cp $DESTDIR/usr/lib/syslinux/*.c32 $DESTDIR/boot/$SYSLINUX_DIR
|
cp $DESTDIR/usr/lib/syslinux/*.c32 $DESTDIR/boot/$SYSLINUX_DIR
|
||||||
if [[ "$GUID_DETECTED" = "" ]]; then
|
|
||||||
cat $MBR > $ROOTDEV
|
|
||||||
else
|
|
||||||
cat $GPTMBR > $ROOTDEV
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# finish_syslinux
|
# finish_syslinux
|
||||||
finish_syslinux () {
|
finish_syslinux () {
|
||||||
|
MBR=$DESTDIR/usr/lib/syslinux/mbr.bin
|
||||||
|
GPTMBR=$DESTDIR/usr/lib/syslinux/gptmbr.bin
|
||||||
|
|
||||||
|
# check if GPT/GUID is used
|
||||||
|
GUID_DETECTED=''
|
||||||
|
[[ "$(parted -s $ROOTDEV print | grep "Partition Table: gpt")" ]] && GUID_DETECTED=1
|
||||||
|
|
||||||
|
if [[ "$GUID_DETECTED" = '1' ]]; then
|
||||||
|
cat $GPTMBR > $ROOTDEV
|
||||||
|
else
|
||||||
|
cat $MBR > $ROOTDEV
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
chroot_umount
|
chroot_umount
|
||||||
DIALOG --msgbox "Error installing $SYSLINUX. (see $LOG for output)" 0 0
|
DIALOG --msgbox "Error installing $SYSLINUX. (see $LOG for output)" 0 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f "/src/boot/syslinux/splash.png" ]] && cp /src/boot/syslinux/splash.png $DESTDIR/boot/$SYSLINUX_DIR
|
[[ -f "/src/boot/syslinux/splash.png" ]] && cp /src/boot/syslinux/splash.png $DESTDIR/boot/$SYSLINUX_DIR
|
||||||
chroot_umount
|
chroot_umount
|
||||||
|
|
||||||
# make partition with /boot active!
|
|
||||||
PARTITION_NUMBER=$(echo $bootdev | sed -e 's#.*[a-z]##g')
|
|
||||||
if [[ "$GUID_DETECTED" = "" ]]; then
|
|
||||||
parted -s $ROOTDEV set $PARTITION_NUMBER boot on >$LOG
|
|
||||||
else
|
|
||||||
# change flag to bios legacy booting
|
|
||||||
if ! [[ "$(sgdisk -i $PARTITION_NUMBER $ROOTDEV | grep '^Attribute' | grep '4$')" ]]; then
|
|
||||||
sgdisk $ROOTDEV --attributes=$PARTITION_NUMBER:set:2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
DIALOG --msgbox "$SYSLINUX was successfully installed." 0 0
|
DIALOG --msgbox "$SYSLINUX was successfully installed." 0 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3270,16 +3286,16 @@ doextlinux () {
|
||||||
SYSLINUX_PACKAGES="syslinux"
|
SYSLINUX_PACKAGES="syslinux"
|
||||||
SYSLINUX=EXTLINUX
|
SYSLINUX=EXTLINUX
|
||||||
SYSLINUX_PROGRAM=extlinux
|
SYSLINUX_PROGRAM=extlinux
|
||||||
SYSLINUX_DIR=extlinux
|
SYSLINUX_DIR=syslinux
|
||||||
SYSLINUX_CONF=extlinux.conf
|
SYSLINUX_CONF=syslinux.cfg
|
||||||
SYSLINUX_OPTS=""
|
SYSLINUX_OPTS=""
|
||||||
prepare_syslinux
|
prepare_syslinux
|
||||||
check_bootpart
|
check_bootpart
|
||||||
abort_nilfs_bootpart || return 1
|
abort_nilfs_bootpart || return 1
|
||||||
# extlinux only can boot from ext2/3/4 and btrfs partitions!
|
# extlinux only can boot from ext2/3/4 and btrfs partitions!
|
||||||
FSTYPE="$(blkid -c /dev/null $bootdev -o value -s TYPE)"
|
FSTYPE="$(blkid -c /dev/null $bootdev -o value -s TYPE)"
|
||||||
if ! [[ "$FSTYPE" = "ext2" || "$FSTYPE" = "ext3" || "$FSTYPE" = "ext4" || "$FSTYPE" = "btrfs" ]]; then
|
if ! [[ "$FSTYPE" = "ext2" || "$FSTYPE" = "ext3" || "$FSTYPE" = "ext4" || "$FSTYPE" = "btrfs" || "$FSTYPE" = "vfat" ]]; then
|
||||||
DIALOG --msgbox "Error:\nCouldn't find ext2/3/4 or btrfs partition with /boot on it." 0 0
|
DIALOG --msgbox "Error:\nCouldn't find ext2/3/4 , btrfs or vfat partition with /boot on it." 0 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# extlinux cannot boot from any raid partition, encrypted and dmraid device
|
# extlinux cannot boot from any raid partition, encrypted and dmraid device
|
||||||
|
@ -3290,7 +3306,7 @@ doextlinux () {
|
||||||
# check if raid1 device is used, else fail.
|
# check if raid1 device is used, else fail.
|
||||||
if [[ "$(echo $bootdev | grep /dev/md)" ]]; then
|
if [[ "$(echo $bootdev | grep /dev/md)" ]]; then
|
||||||
if ! [[ "$(mdadm --detail $bootdev | grep Level | sed -e 's#.*:\ ##g')" = "raid1" ]]; then
|
if ! [[ "$(mdadm --detail $bootdev | grep Level | sed -e 's#.*:\ ##g')" = "raid1" ]]; then
|
||||||
DIALOG --msgbox "Error:\n$SYSLINUX cannot boot from none raid1 devices." 0 0
|
DIALOG --msgbox "Error:\n$SYSLINUX cannot boot from non raid1 devices." 0 0
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
SYSLINUX_OPTS="--raid"
|
SYSLINUX_OPTS="--raid"
|
||||||
|
@ -3314,40 +3330,6 @@ doextlinux () {
|
||||||
finish_syslinux
|
finish_syslinux
|
||||||
}
|
}
|
||||||
|
|
||||||
### TODO: Merge extlinux and syslinux into one function!
|
|
||||||
# install syslinux bootloader
|
|
||||||
dosyslinux() {
|
|
||||||
bootdev=""
|
|
||||||
subdir=""
|
|
||||||
SYSLINUX_PACKAGES="syslinux mtools"
|
|
||||||
SYSLINUX=SYSLINUX
|
|
||||||
SYSLINUX_DIR=syslinux
|
|
||||||
SYSLINUX_CONF=syslinux.cfg
|
|
||||||
SYSLINUX_PROGRAM=syslinux
|
|
||||||
prepare_syslinux
|
|
||||||
# look for a separately-mounted /boot partition
|
|
||||||
bootdev=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
|
|
||||||
if [[ "$bootdev" = "" ]]; then
|
|
||||||
DIALOG --msgbox "Error:\nCouldn't find separate /boot partition." 0 0
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# syslinux only can boot from vfat partitions!
|
|
||||||
FSTYPE="$(blkid -c /dev/null $bootdev -o value -s TYPE)"
|
|
||||||
if ! [[ "$FSTYPE" = "vfat" ]]; then
|
|
||||||
DIALOG --msgbox "Error:\nCouldn't find vfat /boot partition." 0 0
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# syslinux cannot boot from any raid, raid partition, encrypted and dmraid device
|
|
||||||
if [[ "$(echo $bootdev | grep /dev/md)" || "$(echo $bootdev | grep /dev/mapper)" ]]; then
|
|
||||||
DIALOG --msgbox "Error:\n$SYSLINUX cannot boot from any raid, raid partition, encrypted or dmraid device." 0 0
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
common_syslinux || return 1
|
|
||||||
chroot_mount
|
|
||||||
chroot $DESTDIR $SYSLINUX_PROGRAM $bootdev >$LOG 2>&1
|
|
||||||
finish_syslinux
|
|
||||||
}
|
|
||||||
|
|
||||||
dolilo() {
|
dolilo() {
|
||||||
if [[ ! -f $DESTDIR/etc/lilo.conf ]]; then
|
if [[ ! -f $DESTDIR/etc/lilo.conf ]]; then
|
||||||
DIALOG --msgbox "Couldn't find $DESTDIR/etc/lilo.conf, installing lilo now ..." 0 0
|
DIALOG --msgbox "Couldn't find $DESTDIR/etc/lilo.conf, installing lilo now ..." 0 0
|
||||||
|
@ -4541,22 +4523,20 @@ install_bootloader()
|
||||||
[[ "$EFI_x86_64" = "1" ]] && DIALOG --yesno "Setup detected that you are using x86_64 (64-bit) (U)EFI ...\nDo you want to install grub2-efi-x86_64 as the bootloader?" 0 0 && dogrub2_efi_x86_64
|
[[ "$EFI_x86_64" = "1" ]] && DIALOG --yesno "Setup detected that you are using x86_64 (64-bit) (U)EFI ...\nDo you want to install grub2-efi-x86_64 as the bootloader?" 0 0 && dogrub2_efi_x86_64
|
||||||
[[ "$EFI_i386" = "1" ]] && DIALOG --yesno "Setup detected that you are using i386 (32-bit) (U)EFI ...\nDo you want to install grub2-efi-i386 as the bootloader?" 0 0 && dogrub2_efi_i386
|
[[ "$EFI_i386" = "1" ]] && DIALOG --yesno "Setup detected that you are using i386 (32-bit) (U)EFI ...\nDo you want to install grub2-efi-i386 as the bootloader?" 0 0 && dogrub2_efi_i386
|
||||||
|
|
||||||
DIALOG --menu "Which bootloader would you like to use?" 12 55 7 \
|
DIALOG --menu "Which bootloader would you like to use?" 12 55 6 \
|
||||||
"GRUB_LEGACY" "Use the GRUB LEGACY bootloader (default)" \
|
"EXTLINUX" "Use the EXTLINUX aka SYSLINUX BIOS bootloader" \
|
||||||
"GRUB2_BIOS" "Use the GRUB2 BIOS bootloader (experimental)" \
|
"GRUB2_BIOS" "Use the GRUB2 BIOS bootloader (experimental)" \
|
||||||
"GRUB2_EFI_x86_64" "Use the GRUB2 64-bit UEFI bootloader (experimental)" \
|
"GRUB2_EFI_x86_64" "Use the GRUB2 64-bit UEFI bootloader (experimental)" \
|
||||||
"GRUB2_EFI_i386" "Use the GRUB2 32-bit UEFI bootloader (experimental)" \
|
"GRUB2_EFI_i386" "Use the GRUB2 32-bit UEFI bootloader (experimental)" \
|
||||||
"LILO" "Use the LILO bootloader (not recommended)" \
|
"GRUB_LEGACY" "Use the GRUB LEGACY BIOS bootloader (unmaintained)" \
|
||||||
"EXTLINUX" "Use the EXTLINUX bootloader" \
|
"LILO" "Use the LILO BIOS bootloader (not recommended)" 2>$ANSWER || CANCEL=1
|
||||||
"SYSLINUX" "Use the SYSLINUX bootloader" 2>$ANSWER || CANCEL=1
|
|
||||||
case $(cat $ANSWER) in
|
case $(cat $ANSWER) in
|
||||||
"GRUB_LEGACY") dogrub ;;
|
"EXTLINUX") doextlinux ;;
|
||||||
"GRUB2_BIOS") dogrub2_bios ;;
|
"GRUB2_BIOS") dogrub2_bios ;;
|
||||||
"GRUB2_EFI_x86_64") dogrub2_efi_x86_64 ;;
|
"GRUB2_EFI_x86_64") dogrub2_efi_x86_64 ;;
|
||||||
"GRUB2_EFI_i386") dogrub2_efi_i386 ;;
|
"GRUB2_EFI_i386") dogrub2_efi_i386 ;;
|
||||||
|
"GRUB_LEGACY") dogrub ;;
|
||||||
"LILO") dolilo ;;
|
"LILO") dolilo ;;
|
||||||
"EXTLINUX") doextlinux ;;
|
|
||||||
"SYSLINUX") dosyslinux ;;
|
|
||||||
esac
|
esac
|
||||||
if [[ "$CANCEL" = "1" ]]; then
|
if [[ "$CANCEL" = "1" ]]; then
|
||||||
NEXTITEM="7"
|
NEXTITEM="7"
|
||||||
|
|
Loading…
Reference in a new issue