commit b7a3ddd7830f891d0eff4faa5ae9968142f20b34
parent 41a2b6e78fef062764d234c84f7601861dead00f
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Wed, 12 Aug 2020 18:35:02 +0200
syslinux/efilinux code unification
Diffstat:
M | install.sh | | | 77 | ++++++++++++++++++++++++++++++++--------------------------------------------- |
1 file changed, 32 insertions(+), 45 deletions(-)
diff --git a/install.sh b/install.sh
@@ -33,41 +33,10 @@ success()
echo "\e[32m$@\e[0m"
}
-inst_efilinux()
-{
- part_type="${1:?"part_type not provided"}"
- shift
- part="${1:?"partition not provided"}"
- shift
- fs="${1:?"fs not provided"}"
- shift
- disk="${1:?"disk not provided"}"
- shift
- src="${1:?"src folder not provided"}"
- shift
- rootfs="${1:?"rootfs folder not provided"}"
- shift
-
- if test "$part_type" != "gpt"
- then
- error "EFIlinux only supports gpt partition type"
- return
- fi
- mkfs.$fs $part
- dd if=/usr/lib/SYSLINUX/gptmbr.bin of="$disk"
-
- mkdir /tmp/efiboot
- mount $part /tmp/efiboot
- mkdir -p /tmp/efiboot/EFI/BOOT
- cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /tmp/efiboot/EFI/BOOT/bootx64.efi
- cp -r --no-preserve=all "$src"/* /tmp/efiboot/EFI/BOOT
- # this is probably a bad idea, since it prevent user's customisations
- cp "$rootfs/vmlinuz" "$rootfs/initrd.img" /tmp/efiboot/EFI/BOOT
- umount /tmp/efiboot
-}
-
inst_syslinux()
{
+ flavor="${1:?"flavor not provided"}"
+ shift
part_type="${1:?"part_type not provided"}"
shift
part="${1:?"partition not provided"}"
@@ -81,8 +50,7 @@ inst_syslinux()
rootfs="${1:?"rootfs folder not provided"}"
shift
- #TODO support extlinux (should be trivial changes)
-
+ ## common stuff
mkfs.$fs $part
case "$part_type" in
mbr)
@@ -92,16 +60,38 @@ inst_syslinux()
mbr="gptmbr.bin"
;;
*)
- die "unknow partition type: $part_type"
+ error "unknow partition type: $part_type"
+ return
esac
dd if=/usr/lib/SYSLINUX/$mbr of="$disk"
-
- syslinux -i $part
mkdir /tmp/syslinux
mount $part /tmp/syslinux
- cp -r --no-preserve=all "$src"/* /tmp/syslinux/
+ DEST_DIR=/tmp/syslinux
+
+ case "$flavor" in
+ syslinux)
+ syslinux -i $part
+ ;;
+
+ efilinux)
+ if test "$part_type" != "gpt"
+ then
+ error "EFIlinux only supports gpt partition type"
+ return
+ fi
+
+ DEST_DIR="$DEST_DIR/EFI/BOOT"
+ mkdir -p "$DEST_DIR"
+ cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi "$DEST_DIR"/bootx64.efi
+ ;;
+ *)
+ error "flavor $flavor not supported"
+ ;;
+ esac
+
+ cp -r --no-preserve=all "$src"/* "$DEST_DIR"
# this is probably a bad idea, since it prevent user's customisations
- cp "$rootfs/vmlinuz" "$rootfs/initrd.img" /tmp/syslinux
+ cp "$rootfs/vmlinuz" "$rootfs/initrd.img" "$DEST_DIR"
umount /tmp/syslinux
}
@@ -278,11 +268,8 @@ then
then
case "$BOOTLOADER" in
#TODO: pxe/iso/ext variants
- efilinux)
- inst_efilinux $part_type $part_boot $FS_BOOT $TARGET "$SOURCE/syslinux" "$cp_target"
- ;;
- syslinux)
- inst_syslinux $part_type $part_boot $FS_BOOT $TARGET "$SOURCE/syslinux" "$cp_target"
+ efilinux|syslinux)
+ inst_syslinux $BOOTLOADER $part_type $part_boot $FS_BOOT $TARGET "$SOURCE/syslinux" "$cp_target"
;;
*)
error "unsupported BOOTLOADER value ($BOOTLOADER)"