From ac5acd6d0dd40655335b62ecc33db0937a322f6c Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Mon, 29 Jun 2020 14:30:42 +0800 Subject: initial meta distro support Now we support using an iso file directly other than first downloading it, this is very useful for iso files that update frequently (like openSUSE) or custom iso files. --- functions.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'functions.sh') diff --git a/functions.sh b/functions.sh index a3b3a8d..452cabb 100644 --- a/functions.sh +++ b/functions.sh @@ -61,6 +61,45 @@ process_distro() { # ISOMNT="/media/$ISOFILE" } +# output_grub_entry +# output_syslinux_entry +# usage: first source the entry, then call this +# +# variables in entryfile: +# - UUID: the UUID of the partition +# - ISOFILE: the file name of iso +# +# parameters in entry file: +# - TITLE: GRUB menu entry title +# - KERNEL: path to kernel image +# - INITRD: path to initramfs/initrd image +# - OPTION: kernel command line +# - X64: y/n, indicates whether it's 64-bit +# +output_grub_entry() { + cat << EOF +menuentry '$TITLE' { + linux $KERNEL $OPTION + initrd ${INITRD[@]} +} + +EOF +} + +# we also need $LABEL when calling this +output_syslinux_entry() { + _INITRD=$(echo ${INITRD[*]}|sed 's/ /,/g') + + cat << EOF +LABEL $LABEL +MENU LABEL $TITLE +LINUX $KERNEL +INITRD $_INITRD +APPEND $OPTION + +EOF +} + gen_grubcfg() { local entry allentries allentries=("distro/$1/entry"*) @@ -69,13 +108,44 @@ gen_grubcfg() { fi for entry in "${allentries[@]}" do - UUID="$UUID" ISOFILE="$ISOFILE" ./mkgrubcfg.sh "$entry" + source "$entry" + UUID="$UUID" ISOFILE="$ISOFILE" output_grub_entry done if [ ${#allentries[@]} -gt 1 ]; then echo '}' fi } +meta_gen_grubcfg() { + local entry + source "distro/$1/meta" + if [ ${#entries[@]} -gt 1 ]; then + echo "submenu '$ISONAME' {" + fi + for entry in "${entries[@]}" + do + "$entry" + UUID="$UUID" ISOFILE="$ISOFILE" output_grub_entry + done + if [ ${#entries[@]} -gt 1 ]; then + echo '}' + fi +} + +meta_gen_syslinux() { + local entry count name + source "distro/$1/meta" + name=$(echo $1|sed 's/\//_/g') + count=0 + for entry in "${entries[@]}" + do + "$entry" + UUID="$UUID" ISOFILE="$ISOFILE" LABEL="${name}_${count}" \ + output_syslinux_entry + count=$(($count+1)) + done +} + gen_syslinux() { local entry allentries count name allentries=("distro/$1/entry"*) @@ -83,8 +153,9 @@ gen_syslinux() { count=0 for entry in "${allentries[@]}" do - UUID="$UUID" ISOFILE="$ISOFILE" LABEL="$name$count" \ - ./mksyslinux.sh "$entry" + source "$entry" + UUID="$UUID" ISOFILE="$ISOFILE" LABEL="${name}_${count}" \ + output_syslinux_entry count=$(($count+1)) done } -- cgit v1.2.3