From db8f198304dfad5df8ad7de2cf81760febf1a4b2 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 21 Apr 2020 15:31:00 -0700 Subject: [PATCH] lorax: Add --skip-branding cmdline argument Also document how branding currently works. See docs/lorax.rst Resolves: rhbz#1826479 --- docs/lorax.rst | 23 +++++++++++++++++++++++ src/pylorax/__init__.py | 6 ++++-- src/pylorax/cmdline.py | 2 ++ src/pylorax/treebuilder.py | 13 ++++++++++++- src/sbin/lorax | 3 ++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/docs/lorax.rst b/docs/lorax.rst index 65c866bc..f1bed0ad 100644 --- a/docs/lorax.rst +++ b/docs/lorax.rst @@ -54,6 +54,29 @@ Under ``./results/`` will be the release tree files: .discinfo, .treeinfo, every goes onto the boot.iso, the pxeboot directory, and the boot.iso under ``./images/``. +Branding +-------- + +By default lorax will search for the first package that provides ``system-release`` +that doesn't start with ``generic-`` and will install it. It then selects a +corresponding logo package by using the first part of the system-release package and +appending ``-logos`` to it. eg. fedora-release and fedora-logos. + +Custom Branding +~~~~~~~~~~~~~~~ + +If ``--skip-branding`` is passed to lorax it will skip selecting the +``system-release``, and logos packages and leave it up to the user to pass any +branding related packages to lorax using ``--installpkgs``. When using +``skip-branding`` you must make sure that you provide all of the expected files, +otherwise Anaconda may not work as expected. See the contents of ``fedora-release`` +and ``fedora-logos`` for examples of what to include. + +Note that this does not prevent something else in the dependency tree from +causing these packages to be included. Using ``--excludepkgs`` may help if they +are unexpectedly included. + + Running inside of mock ---------------------- diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index acc4e5f4..2ccfb950 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -186,7 +186,8 @@ class Lorax(BaseLoraxClass): add_arch_templates=None, add_arch_template_vars=None, verify=True, - user_dracut_args=None): + user_dracut_args=None, + skip_branding=False): assert self._configured @@ -266,7 +267,8 @@ class Lorax(BaseLoraxClass): installpkgs=installpkgs, excludepkgs=excludepkgs, add_templates=add_templates, - add_template_vars=add_template_vars) + add_template_vars=add_template_vars, + skip_branding=skip_branding) logger.info("installing runtime packages") rb.install() diff --git a/src/pylorax/cmdline.py b/src/pylorax/cmdline.py index 3af1956a..869fc150 100644 --- a/src/pylorax/cmdline.py +++ b/src/pylorax/cmdline.py @@ -107,6 +107,8 @@ def lorax_parser(dracut_default=""): help="Size of root filesystem in GiB. Defaults to 3.") optional.add_argument("--noverifyssl", action="store_true", default=False, help="Do not verify SSL certificates") + optional.add_argument("--skip-branding", action="store_true", default=False, + help="Disable automatic branding package selection. Use --installpkgs to add custom branding.") # dracut arguments dracut_group = parser.add_argument_group("dracut arguments") diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 1055b6a2..a93018b2 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -72,7 +72,8 @@ class RuntimeBuilder(object): def __init__(self, product, arch, dbo, templatedir=None, installpkgs=None, excludepkgs=None, add_templates=None, - add_template_vars=None): + add_template_vars=None, + skip_branding=False): root = dbo.conf.installroot # use a copy of product so we can modify it locally product = product.copy() @@ -88,8 +89,18 @@ class RuntimeBuilder(object): self._excludepkgs = excludepkgs or [] self._runner.defaults = self.vars self.dbo.reset() + self._skip_branding = skip_branding def _install_branding(self): + """Select the branding from the available 'system-release' packages + The *best* way to control this is to have a single package in the repo provide 'system-release' + When there are more than 1 package it will: + - Make a list of the available packages + - If there are one or more non-generic packages, use the first one after sorting + """ + if self._skip_branding: + return + release = None q = self.dbo.sack.query() a = q.available() diff --git a/src/sbin/lorax b/src/sbin/lorax index 8ba77c80..453f2d3e 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -192,7 +192,8 @@ def main(): add_arch_templates=opts.add_arch_templates, add_arch_template_vars=parsed_add_arch_template_vars, remove_temp=True, verify=opts.verify, - user_dracut_args=opts.dracut_args) + user_dracut_args=opts.dracut_args, + skip_branding=opts.skip_branding) # Release the lock on the tempdir os.close(dir_fd)