From 235813212f42708f6a1162ad3817eaa7aba3f744 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 14 Mar 2019 09:45:40 -0700 Subject: [PATCH] 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. --- share/templates.d/99-generic/live/aarch64.tmpl | 4 ++-- .../99-generic/live/config_files/aarch64/grub2-efi.cfg | 6 +++--- .../99-generic/live/config_files/ppc/grub.cfg.in | 4 ++-- .../99-generic/live/config_files/s390/generic.prm | 2 +- .../templates.d/99-generic/live/config_files/x86/grub.conf | 4 ++-- .../99-generic/live/config_files/x86/grub2-efi.cfg | 6 +++--- .../99-generic/live/config_files/x86/isolinux.cfg | 6 +++--- share/templates.d/99-generic/live/efi.tmpl | 3 ++- share/templates.d/99-generic/live/ppc64le.tmpl | 3 ++- share/templates.d/99-generic/live/s390.tmpl | 3 ++- share/templates.d/99-generic/live/x86.tmpl | 5 +++-- src/pylorax/cmdline.py | 3 +++ src/pylorax/creator.py | 3 ++- src/pylorax/treebuilder.py | 6 ++++-- 14 files changed, 34 insertions(+), 24 deletions(-) diff --git a/share/templates.d/99-generic/live/aarch64.tmpl b/share/templates.d/99-generic/live/aarch64.tmpl index 9a134022..be81eed9 100644 --- a/share/templates.d/99-generic/live/aarch64.tmpl +++ b/share/templates.d/99-generic/live/aarch64.tmpl @@ -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" PXEBOOTDIR="images/pxeboot" @@ -45,7 +45,7 @@ mkdir ${KERNELDIR} %> treeinfo images-${basearch} ${img|basename} ${img} %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 # Create optional product.img and updates.img diff --git a/share/templates.d/99-generic/live/config_files/aarch64/grub2-efi.cfg b/share/templates.d/99-generic/live/config_files/aarch64/grub2-efi.cfg index c6a3d686..d0799243 100644 --- a/share/templates.d/99-generic/live/config_files/aarch64/grub2-efi.cfg +++ b/share/templates.d/99-generic/live/config_files/aarch64/grub2-efi.cfg @@ -27,16 +27,16 @@ search --no-floppy --set=root -l '@ISOLABEL@' ### BEGIN /etc/grub.d/10_linux ### 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@ } 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@ } submenu 'Troubleshooting -->' { 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@ } } diff --git a/share/templates.d/99-generic/live/config_files/ppc/grub.cfg.in b/share/templates.d/99-generic/live/config_files/ppc/grub.cfg.in index bbdcfe6c..630b3769 100644 --- a/share/templates.d/99-generic/live/config_files/ppc/grub.cfg.in +++ b/share/templates.d/99-generic/live/config_files/ppc/grub.cfg.in @@ -6,12 +6,12 @@ echo -e "\nWelcome to the @PRODUCT@ @VERSION@ installer!\n\n" for BITS in 32 64; do if [ -d "/ppc/ppc${BITS}" ]; then 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 } 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 } fi diff --git a/share/templates.d/99-generic/live/config_files/s390/generic.prm b/share/templates.d/99-generic/live/config_files/s390/generic.prm index e1dc3977..4f9ba388 100644 --- a/share/templates.d/99-generic/live/config_files/s390/generic.prm +++ b/share/templates.d/99-generic/live/config_files/s390/generic.prm @@ -1 +1 @@ -ro ramdisk_size=40000 cio_ignore=all,!condev +ro ramdisk_size=40000 cio_ignore=all,!condev @EXTRA@ diff --git a/share/templates.d/99-generic/live/config_files/x86/grub.conf b/share/templates.d/99-generic/live/config_files/x86/grub.conf index 2a4b808e..6c4a51f3 100644 --- a/share/templates.d/99-generic/live/config_files/x86/grub.conf +++ b/share/templates.d/99-generic/live/config_files/x86/grub.conf @@ -5,9 +5,9 @@ timeout 60 hiddenmenu title Start @PRODUCT@ @VERSION@ findiso - kernel @KERNELPATH@ @ROOT@ rd.live.image quiet + kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet initrd @INITRDPATH@ title Test this media & start @PRODUCT@ @VERSION@ findiso - kernel @KERNELPATH@ @ROOT@ rd.live.image rd.live.check quiet + kernel @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet initrd @INITRDPATH@ diff --git a/share/templates.d/99-generic/live/config_files/x86/grub2-efi.cfg b/share/templates.d/99-generic/live/config_files/x86/grub2-efi.cfg index 3f8ca1e0..2e24b15f 100644 --- a/share/templates.d/99-generic/live/config_files/x86/grub2-efi.cfg +++ b/share/templates.d/99-generic/live/config_files/x86/grub2-efi.cfg @@ -21,16 +21,16 @@ search --no-floppy --set=root -l '@ISOLABEL@' ### BEGIN /etc/grub.d/10_linux ### 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@ } 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@ } submenu 'Troubleshooting -->' { 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@ } } diff --git a/share/templates.d/99-generic/live/config_files/x86/isolinux.cfg b/share/templates.d/99-generic/live/config_files/x86/isolinux.cfg index 475f8ff2..bc36bb9c 100644 --- a/share/templates.d/99-generic/live/config_files/x86/isolinux.cfg +++ b/share/templates.d/99-generic/live/config_files/x86/isolinux.cfg @@ -61,13 +61,13 @@ menu separator # insert an empty line label linux menu label ^Start @PRODUCT@ @VERSION@ kernel vmlinuz - append initrd=initrd.img @ROOT@ rd.live.image quiet + append initrd=initrd.img @ROOT@ @EXTRA@ rd.live.image quiet label check menu label Test this ^media & start @PRODUCT@ @VERSION@ menu default 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 @@ -83,7 +83,7 @@ label vesa @PRODUCT@ @VERSION@. endtext 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 menu label Run a ^memory test diff --git a/share/templates.d/99-generic/live/efi.tmpl b/share/templates.d/99-generic/live/efi.tmpl index 5eb2962c..572e07d2 100644 --- a/share/templates.d/99-generic/live/efi.tmpl +++ b/share/templates.d/99-generic/live/efi.tmpl @@ -1,4 +1,4 @@ -<%page args="configdir, KERNELDIR, efiarch32, efiarch64, isolabel"/> +<%page args="configdir, KERNELDIR, efiarch32, efiarch64, isolabel, extra_boot_args"/> <% EFIBOOTDIR="EFI/BOOT" 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 @INITRDPATH@ /${kdir}/initrd.img ${eficonf} replace @ISOLABEL@ '${isolabel}' ${eficonf} + replace @EXTRA@ '${extra_boot_args}' ${eficonf} %if disk: replace @ROOT@ root=live:LABEL=ANACONDA ${eficonf} %else: diff --git a/share/templates.d/99-generic/live/ppc64le.tmpl b/share/templates.d/99-generic/live/ppc64le.tmpl index 361a3fd3..c24c0e76 100644 --- a/share/templates.d/99-generic/live/ppc64le.tmpl +++ b/share/templates.d/99-generic/live/ppc64le.tmpl @@ -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" BOOTDIR="ppc" @@ -38,6 +38,7 @@ install ${configdir}/grub.cfg.in ${GRUBDIR}/grub.cfg replace @PRODUCT@ '${product.name}' ${GRUBDIR}/grub.cfg replace @VERSION@ ${product.version} ${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) %for kernel in kernels: diff --git a/share/templates.d/99-generic/live/s390.tmpl b/share/templates.d/99-generic/live/s390.tmpl index bd6f8ff7..7db02f0f 100644 --- a/share/templates.d/99-generic/live/s390.tmpl +++ b/share/templates.d/99-generic/live/s390.tmpl @@ -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" BOOTDIR="images" @@ -22,6 +22,7 @@ install ${configdir}/generic.ins . ## configure bootloader replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins +replace @EXTRA@ ${extra_boot_args} generic.prm ## install kernel installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img diff --git a/share/templates.d/99-generic/live/x86.tmpl b/share/templates.d/99-generic/live/x86.tmpl index fae44bcc..51ba70fc 100644 --- a/share/templates.d/99-generic/live/x86.tmpl +++ b/share/templates.d/99-generic/live/x86.tmpl @@ -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" SYSLINUXDIR="usr/share/syslinux" @@ -38,6 +38,7 @@ install boot/memtest* ${BOOTDIR}/memtest 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 @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${BOOTDIR}/isolinux.cfg +replace @EXTRA@ '${extra_boot_args}' ${BOOTDIR}/isolinux.cfg ## install kernels mkdir ${KERNELDIR} @@ -80,7 +81,7 @@ hardlink ${KERNELDIR}/initrd.img ${BOOTDIR} %> treeinfo images-${basearch} ${img|basename} ${img} %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 # Create optional product.img and updates.img diff --git a/src/pylorax/cmdline.py b/src/pylorax/cmdline.py index 95b20841..163af0a1 100644 --- a/src/pylorax/cmdline.py +++ b/src/pylorax/cmdline.py @@ -203,6 +203,9 @@ def lmc_parser(dracut_default=""): parser.add_argument("--nomacboot", action="store_false", 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.add_argument("--disk-image", type=os.path.abspath, help="Path to existing disk image to use for creating final image.") diff --git a/src/pylorax/creator.py b/src/pylorax/creator.py index 00e80aa6..eda6fea0 100644 --- a/src/pylorax/creator.py +++ b/src/pylorax/creator.py @@ -355,7 +355,8 @@ def make_livecd(opts, mount_dir, work_dir): tb = TreeBuilder(product=product, arch=arch, domacboot=opts.domacboot, inroot=mount_dir, outroot=work_dir, 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") if not opts.dracut_args: dracut_args = DRACUT_DEFAULT diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 1b52bab2..c02d0ea6 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -245,7 +245,8 @@ class RuntimeBuilder(object): class TreeBuilder(object): '''Builds the arch-specific boot images. 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 # clobber some mako internal variables - hence "runtime_img". @@ -254,7 +255,8 @@ class TreeBuilder(object): inroot=inroot, outroot=outroot, basearch=arch.basearch, libdir=arch.libdir, 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.defaults = self.vars self.add_templates = add_templates or []