summaryrefslogtreecommitdiff
path: root/functions.sh
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2021-03-31 13:19:32 +0800
committerIru Cai <mytbk920423@gmail.com>2021-03-31 13:19:32 +0800
commit1e643b9aa7851b22994f28925e4775173198e5a0 (patch)
tree362b9d1535276149f81d8e99519af3bfa501df50 /functions.sh
parent6622de751b60f0474d1a69be9b5592e82c1ba556 (diff)
parenta5092b29f5e60e6ee9a4bd537747d53bfd6c491c (diff)
downloadliveusb-builder-1e643b9aa7851b22994f28925e4775173198e5a0.tar.xz
Merge branch 'metaiso'
Diffstat (limited to 'functions.sh')
-rw-r--r--functions.sh85
1 files changed, 82 insertions, 3 deletions
diff --git a/functions.sh b/functions.sh
index a3b3a8d..8f9db5f 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,50 @@ gen_grubcfg() {
fi
for entry in "${allentries[@]}"
do
- UUID="$UUID" ISOFILE="$ISOFILE" ./mkgrubcfg.sh "$entry"
+ unset INITRD # because it can be an array or just a string
+
+ 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
+ unset INITRD # because it can be an array or just a string
+
+ "$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
+ unset INITRD # because it can be an array or just a string
+
+ "$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 +159,11 @@ gen_syslinux() {
count=0
for entry in "${allentries[@]}"
do
- UUID="$UUID" ISOFILE="$ISOFILE" LABEL="$name$count" \
- ./mksyslinux.sh "$entry"
+ unset INITRD # because it can be an array or just a string
+
+ source "$entry"
+ UUID="$UUID" ISOFILE="$ISOFILE" LABEL="${name}_${count}" \
+ output_syslinux_entry
count=$(($count+1))
done
}