Add extra boot args to the livemedia-creator iso templates

This adds a new livemedia-creator argument, --extra-boot-args, which can
be used to add arguments to the kernel command-line in the templates.

(cherry picked from commit 235813212f)
(cherry picked from commit 48548722b3)
This commit is contained in:
Brian C. Lane 2019-03-14 09:45:40 -07:00
parent afa68df873
commit 6aa0a3fdf6
14 changed files with 62 additions and 52 deletions

View File

@ -1,4 +1,4 @@
<%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel"/> <%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel, extra_boot_args"/>
<% <%
configdir="tmp/config_files/aarch64" configdir="tmp/config_files/aarch64"
PXEBOOTDIR="images/pxeboot" PXEBOOTDIR="images/pxeboot"
@ -55,7 +55,7 @@ mkdir ${KERNELDIR}
%> %>
treeinfo images-${basearch} ${img|basename} ${img} treeinfo images-${basearch} ${img|basename} ${img}
%endfor %endfor
<%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel"/> <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel, extra_boot_args=extra_boot_args"/>
%endif %endif
# Create optional product.img and updates.img # Create optional product.img and updates.img

View File

@ -27,16 +27,16 @@ search --no-floppy --set=root -l '@ISOLABEL@'
### BEGIN /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os { menuentry 'Start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ rd.live.image quiet linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet
initrd @INITRDPATH@ initrd @INITRDPATH@
} }
menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os { menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ rd.live.image rd.live.check quiet linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
initrd @INITRDPATH@ initrd @INITRDPATH@
} }
submenu 'Troubleshooting -->' { submenu 'Troubleshooting -->' {
menuentry 'Install @PRODUCT@ @VERSION@ in basic graphics mode' --class red --class gnu-linux --class gnu --class os { menuentry 'Install @PRODUCT@ @VERSION@ in basic graphics mode' --class red --class gnu-linux --class gnu --class os {
linux @KERNELPATH@ @ROOT@ rd.live.image nomodeset quiet linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image nomodeset quiet
initrd @INITRDPATH@ initrd @INITRDPATH@
} }
} }

View File

@ -6,12 +6,12 @@ echo -e "\nWelcome to the @PRODUCT@ @VERSION@ installer!\n\n"
for BITS in 32 64; do for BITS in 32 64; do
if [ -d "/ppc/ppc${BITS}" ]; then if [ -d "/ppc/ppc${BITS}" ]; then
menuentry "Start @PRODUCT@ @VERSION@ (${BITS}-bit kernel)" $BITS --class fedora --class gnu-linux --class gnu --class os { menuentry "Start @PRODUCT@ @VERSION@ (${BITS}-bit kernel)" $BITS --class fedora --class gnu-linux --class gnu --class os {
linux /ppc/ppc${2}/vmlinuz @ROOT@ ro rd.live.image quiet linux /ppc/ppc${2}/vmlinuz @ROOT@ @EXTRA@ ro rd.live.image quiet
initrd /ppc/ppc${2}/initrd.img initrd /ppc/ppc${2}/initrd.img
} }
menuentry "Test this media & start @PRODUCT@ @VERSION@ (${BITS}-bit kernel)" $BITS --class fedora --class gnu-linux --class gnu --class os { menuentry "Test this media & start @PRODUCT@ @VERSION@ (${BITS}-bit kernel)" $BITS --class fedora --class gnu-linux --class gnu --class os {
linux /ppc/ppc${2}/vmlinuz @ROOT@ rd.live.image rd.live.check ro quiet linux /ppc/ppc${2}/vmlinuz @ROOT@ @EXTRA@ rd.live.image rd.live.check ro quiet
initrd /ppc/ppc${2}/initrd.img initrd /ppc/ppc${2}/initrd.img
} }
fi fi

View File

@ -1 +1 @@
ro ramdisk_size=40000 cio_ignore=all,!condev ro ramdisk_size=40000 cio_ignore=all,!condev @EXTRA@

View File

@ -5,9 +5,9 @@ timeout 60
hiddenmenu hiddenmenu
title Start @PRODUCT@ @VERSION@ title Start @PRODUCT@ @VERSION@
findiso findiso
kernel @KERNELPATH@ @ROOT@ rd.live.image quiet kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet
initrd @INITRDPATH@ initrd @INITRDPATH@
title Test this media & start @PRODUCT@ @VERSION@ title Test this media & start @PRODUCT@ @VERSION@
findiso findiso
kernel @KERNELPATH@ @ROOT@ rd.live.image rd.live.check quiet kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
initrd @INITRDPATH@ initrd @INITRDPATH@

View File

@ -21,16 +21,16 @@ search --no-floppy --set=root -l '@ISOLABEL@'
### BEGIN /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os { menuentry 'Start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os {
linuxefi @KERNELPATH@ @ROOT@ rd.live.image quiet linuxefi @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet
initrdefi @INITRDPATH@ initrdefi @INITRDPATH@
} }
menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os { menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class fedora --class gnu-linux --class gnu --class os {
linuxefi @KERNELPATH@ @ROOT@ rd.live.image rd.live.check quiet linuxefi @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
initrdefi @INITRDPATH@ initrdefi @INITRDPATH@
} }
submenu 'Troubleshooting -->' { submenu 'Troubleshooting -->' {
menuentry 'Start @PRODUCT@ @VERSION@ in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os { menuentry 'Start @PRODUCT@ @VERSION@ in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
linuxefi @KERNELPATH@ @ROOT@ rd.live.image nomodeset quiet linuxefi @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image nomodeset quiet
initrdefi @INITRDPATH@ initrdefi @INITRDPATH@
} }
} }

View File

@ -61,13 +61,13 @@ menu separator # insert an empty line
label linux label linux
menu label ^Start @PRODUCT@ @VERSION@ menu label ^Start @PRODUCT@ @VERSION@
kernel vmlinuz kernel vmlinuz
append initrd=initrd.img @ROOT@ rd.live.image quiet append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image quiet
label check label check
menu label Test this ^media & start @PRODUCT@ @VERSION@ menu label Test this ^media & start @PRODUCT@ @VERSION@
menu default menu default
kernel vmlinuz kernel vmlinuz
append initrd=initrd.img @ROOT@ rd.live.image rd.live.check quiet append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
menu separator # insert an empty line menu separator # insert an empty line
@ -83,7 +83,7 @@ label vesa
@PRODUCT@ @VERSION@. @PRODUCT@ @VERSION@.
endtext endtext
kernel vmlinuz kernel vmlinuz
append initrd=initrd.img @ROOT@ rd.live.image nomodeset quiet append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image nomodeset quiet
label memtest label memtest
menu label Run a ^memory test menu label Run a ^memory test

View File

@ -1,4 +1,4 @@
<%page args="configdir, KERNELDIR, efiarch32, efiarch64, isolabel"/> <%page args="configdir, KERNELDIR, efiarch32, efiarch64, isolabel, extra_boot_args"/>
<% <%
EFIBOOTDIR="EFI/BOOT" EFIBOOTDIR="EFI/BOOT"
APPLE_EFI_ICON=inroot+"/usr/share/pixmaps/bootloader/fedora.icns" APPLE_EFI_ICON=inroot+"/usr/share/pixmaps/bootloader/fedora.icns"
@ -45,6 +45,7 @@ ${make_efiboot("images/efiboot.img")}
replace @KERNELPATH@ /${kdir}/vmlinuz ${eficonf} replace @KERNELPATH@ /${kdir}/vmlinuz ${eficonf}
replace @INITRDPATH@ /${kdir}/initrd.img ${eficonf} replace @INITRDPATH@ /${kdir}/initrd.img ${eficonf}
replace @ISOLABEL@ '${isolabel}' ${eficonf} replace @ISOLABEL@ '${isolabel}' ${eficonf}
replace @EXTRA@ '${extra_boot_args}' ${eficonf}
%if disk: %if disk:
replace @ROOT@ root=live:LABEL=ANACONDA ${eficonf} replace @ROOT@ root=live:LABEL=ANACONDA ${eficonf}
%else: %else:

View File

@ -1,4 +1,4 @@
<%page args="kernels, runtime_img, basearch, libdir, inroot, outroot, product, isolabel"/> <%page args="kernels, runtime_img, basearch, libdir, inroot, outroot, product, isolabel, extra_boot_args"/>
<% <%
configdir="tmp/config_files/ppc" configdir="tmp/config_files/ppc"
BOOTDIR="ppc" BOOTDIR="ppc"
@ -38,6 +38,7 @@ install ${configdir}/grub.cfg.in ${GRUBDIR}/grub.cfg
replace @PRODUCT@ '${product.name}' ${GRUBDIR}/grub.cfg replace @PRODUCT@ '${product.name}' ${GRUBDIR}/grub.cfg
replace @VERSION@ ${product.version} ${GRUBDIR}/grub.cfg replace @VERSION@ ${product.version} ${GRUBDIR}/grub.cfg
replace @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${GRUBDIR}/grub.cfg replace @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${GRUBDIR}/grub.cfg
replace @EXTRA@ '${extra_boot_args}' ${GRUBDIR}/grub.cfg
## Install kernel and bootloader config (in separate places for each arch) ## Install kernel and bootloader config (in separate places for each arch)
%for kernel in kernels: %for kernel in kernels:

View File

@ -1,4 +1,4 @@
<%page args="kernels, runtime_img, runtime_base, basearch, outroot"/> <%page args="kernels, runtime_img, runtime_base, basearch, outroot, extra_boot_args"/>
<% <%
configdir="tmp/config_files/s390" configdir="tmp/config_files/s390"
BOOTDIR="images" BOOTDIR="images"
@ -22,6 +22,7 @@ install ${configdir}/generic.ins .
## configure bootloader ## configure bootloader
replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins
replace @EXTRA@ ${extra_boot_args} generic.prm
## install kernel ## install kernel
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img

View File

@ -1,4 +1,4 @@
<%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel"/> <%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel, extra_boot_args"/>
<% <%
configdir="tmp/config_files/x86" configdir="tmp/config_files/x86"
SYSLINUXDIR="usr/share/syslinux" SYSLINUXDIR="usr/share/syslinux"
@ -10,7 +10,7 @@ LORAXDIR="usr/share/lorax/"
## Don't allow spaces or escape characters in the iso label ## Don't allow spaces or escape characters in the iso label
def valid_label(ch): def valid_label(ch):
return ch.isalnum() or ch == '_' return ch.isalnum() or ch == '_'
isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel) isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
@ -19,12 +19,12 @@ from os.path import basename
## Test ${runtime_img} to see if udf is needed ## Test ${runtime_img} to see if udf is needed
<% <%
import os import os
from pylorax.sysutils import joinpaths from pylorax.sysutils import joinpaths
if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3: if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
udfargs = "-allow-limited-size" udfargs = "-allow-limited-size"
else: else:
udfargs = "" udfargs = ""
%> %>
mkdir ${LIVEDIR} mkdir ${LIVEDIR}
@ -48,48 +48,49 @@ install boot/memtest* ${BOOTDIR}/memtest
replace @VERSION@ ${product.version} ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg replace @VERSION@ ${product.version} ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg
replace @PRODUCT@ '${product.name}' ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg replace @PRODUCT@ '${product.name}' ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg
replace @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${BOOTDIR}/isolinux.cfg replace @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${BOOTDIR}/isolinux.cfg
replace @EXTRA@ '${extra_boot_args}' ${BOOTDIR}/isolinux.cfg
## install kernels ## install kernels
mkdir ${KERNELDIR} mkdir ${KERNELDIR}
%for kernel in kernels: %for kernel in kernels:
%if kernel.flavor: %if kernel.flavor:
installkernel images-xen ${kernel.path} ${KERNELDIR}/vmlinuz-${kernel.flavor} installkernel images-xen ${kernel.path} ${KERNELDIR}/vmlinuz-${kernel.flavor}
installinitrd images-xen ${kernel.initrd.path} ${KERNELDIR}/initrd-${kernel.flavor}.img installinitrd images-xen ${kernel.initrd.path} ${KERNELDIR}/initrd-${kernel.flavor}.img
%else: %else:
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%endif %endif
%endfor %endfor
hardlink ${KERNELDIR}/vmlinuz ${BOOTDIR} hardlink ${KERNELDIR}/vmlinuz ${BOOTDIR}
hardlink ${KERNELDIR}/initrd.img ${BOOTDIR} hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
%if basearch == 'x86_64': %if basearch == 'x86_64':
treeinfo images-xen kernel ${KERNELDIR}/vmlinuz treeinfo images-xen kernel ${KERNELDIR}/vmlinuz
treeinfo images-xen initrd ${KERNELDIR}/initrd.img treeinfo images-xen initrd ${KERNELDIR}/initrd.img
%endif %endif
## WHeeeeeeee, EFI. ## WHeeeeeeee, EFI.
<% efiargs=""; efigraft=""; efihybrid=""; efiarch32=None; efiarch64=None %> <% efiargs=""; efigraft=""; efihybrid=""; efiarch32=None; efiarch64=None %>
%if exists("boot/efi/EFI/*/gcdia32.efi"): %if exists("boot/efi/EFI/*/gcdia32.efi"):
<% efiarch32 = 'IA32' %> <% efiarch32 = 'IA32' %>
%endif %endif
%if exists("boot/efi/EFI/*/gcdx64.efi"): %if exists("boot/efi/EFI/*/gcdx64.efi"):
<% efiarch64 = 'X64' %> <% efiarch64 = 'X64' %>
%endif %endif
%if (efiarch32 or efiarch64) and basearch != 'i386': %if (efiarch32 or efiarch64) and basearch != 'i386':
<%
efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
images = ["images/efiboot.img"]
if domacboot:
images.append("images/macboot.img")
%>
%for img in images:
<% <%
efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot) efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot".format(img)
images = ["images/efiboot.img"] efigraft += " {0}={1}/{0}".format(img,outroot)
if domacboot:
images.append("images/macboot.img")
%> %>
%for img in images: treeinfo images-${basearch} ${img|basename} ${img}
<% %endfor
efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot".format(img)
efigraft += " {0}={1}/{0}".format(img,outroot)
%>
treeinfo images-${basearch} ${img|basename} ${img}
%endfor
<% efihybrid = "--uefi --mac" if domacboot else "--uefi" %> <% efihybrid = "--uefi --mac" if domacboot else "--uefi" %>
<%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel"/> <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel"/>
%endif %endif

View File

@ -203,6 +203,9 @@ def lmc_parser(dracut_default=""):
parser.add_argument("--nomacboot", action="store_false", parser.add_argument("--nomacboot", action="store_false",
dest="domacboot") dest="domacboot")
parser.add_argument("--extra-boot-args", default="", dest="extra_boot_args",
help="Extra arguments to add to the bootloader kernel cmdline in the templates")
image_group = parser.add_argument_group("disk/fs image arguments") image_group = parser.add_argument_group("disk/fs image arguments")
image_group.add_argument("--disk-image", type=os.path.abspath, image_group.add_argument("--disk-image", type=os.path.abspath,
help="Path to existing disk image to use for creating final image.") help="Path to existing disk image to use for creating final image.")

View File

@ -355,7 +355,8 @@ def make_livecd(opts, mount_dir, work_dir):
tb = TreeBuilder(product=product, arch=arch, domacboot=opts.domacboot, tb = TreeBuilder(product=product, arch=arch, domacboot=opts.domacboot,
inroot=mount_dir, outroot=work_dir, inroot=mount_dir, outroot=work_dir,
runtime=RUNTIME, isolabel=isolabel, runtime=RUNTIME, isolabel=isolabel,
templatedir=joinpaths(opts.lorax_templates,"live/")) templatedir=joinpaths(opts.lorax_templates,"live/"),
extra_boot_args=opts.extra_boot_args)
log.info("Rebuilding initrds") log.info("Rebuilding initrds")
if not opts.dracut_args: if not opts.dracut_args:
dracut_args = DRACUT_DEFAULT dracut_args = DRACUT_DEFAULT

View File

@ -247,7 +247,8 @@ class RuntimeBuilder(object):
class TreeBuilder(object): class TreeBuilder(object):
'''Builds the arch-specific boot images. '''Builds the arch-specific boot images.
inroot should be the installtree root (the newly-built runtime dir)''' inroot should be the installtree root (the newly-built runtime dir)'''
def __init__(self, product, arch, inroot, outroot, runtime, isolabel, domacboot=True, doupgrade=True, templatedir=None, add_templates=None, add_template_vars=None, workdir=None): def __init__(self, product, arch, inroot, outroot, runtime, isolabel, domacboot=True, doupgrade=True,
templatedir=None, add_templates=None, add_template_vars=None, workdir=None, extra_boot_args=""):
# NOTE: if you pass an arg named "runtime" to a mako template it'll # NOTE: if you pass an arg named "runtime" to a mako template it'll
# clobber some mako internal variables - hence "runtime_img". # clobber some mako internal variables - hence "runtime_img".
@ -256,7 +257,8 @@ class TreeBuilder(object):
inroot=inroot, outroot=outroot, inroot=inroot, outroot=outroot,
basearch=arch.basearch, libdir=arch.libdir, basearch=arch.basearch, libdir=arch.libdir,
isolabel=isolabel, udev=udev_escape, domacboot=domacboot, doupgrade=doupgrade, isolabel=isolabel, udev=udev_escape, domacboot=domacboot, doupgrade=doupgrade,
workdir=workdir, lower=string_lower) workdir=workdir, lower=string_lower,
extra_boot_args=extra_boot_args)
self._runner = LoraxTemplateRunner(inroot, outroot, templatedir=templatedir) self._runner = LoraxTemplateRunner(inroot, outroot, templatedir=templatedir)
self._runner.defaults = self.vars self._runner.defaults = self.vars
self.add_templates = add_templates or [] self.add_templates = add_templates or []