diff --git a/docs/lorax.rst b/docs/lorax.rst index 5ee56cdc..bbbf4143 100644 --- a/docs/lorax.rst +++ b/docs/lorax.rst @@ -54,6 +54,40 @@ 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. + +Variants +~~~~~~~~ + +If a ``variant`` is passed to lorax it will select a ``system-release`` package that +ends with the variant name. eg. Passing ``--variant workstation`` will select the +``fedora-release-workstation`` package if it exists. It will select a logo package +the same way it does for non-variants. eg. ``fedora-logos``. + +If there is no package ending with the variant name it will fall back to using the +first non-generic package providing ``system-release``. + +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 f3e73c3a..781dfd33 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -183,7 +183,8 @@ class Lorax(BaseLoraxClass): add_arch_template_vars=None, verify=True, user_dracut_args=None, - squashfs_only=False): + squashfs_only=False, + skip_branding=False): assert self._configured @@ -263,7 +264,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 652ffbbd..59e851d3 100644 --- a/src/pylorax/cmdline.py +++ b/src/pylorax/cmdline.py @@ -111,6 +111,8 @@ def lorax_parser(dracut_default=""): help="Enable a DNF plugin by name/glob, or * to enable all of them.") optional.add_argument("--squashfs-only", action="store_true", default=False, help="Use a plain squashfs filesystem for the runtime.") + 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: (default: %s)" % dracut_default) diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 5045d3b3..7f951b55 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -71,7 +71,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() @@ -87,6 +88,7 @@ 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 @@ -96,6 +98,9 @@ class RuntimeBuilder(object): - If variant is set look for a package ending with lower(variant) and use that - 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 a4cc3bfa..5f8fb882 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -213,7 +213,8 @@ def main(): add_arch_template_vars=parsed_add_arch_template_vars, remove_temp=True, verify=opts.verify, user_dracut_args=user_dracut_args, - squashfs_only=opts.squashfs_only) + squashfs_only=opts.squashfs_only, + skip_branding=opts.skip_branding) # Release the lock on the tempdir os.close(dir_fd) diff --git a/tests/pylorax/test_treebuilder.py b/tests/pylorax/test_treebuilder.py index e9550289..710773df 100644 --- a/tests/pylorax/test_treebuilder.py +++ b/tests/pylorax/test_treebuilder.py @@ -62,7 +62,7 @@ def makeFakeRPM(repo_dir, name, epoch, version, release, files=None, provides=No class InstallBrandingTestCase(unittest.TestCase): - def install_branding(self, repo_dir, variant=None): + def install_branding(self, repo_dir, variant=None, skip_branding=False): """Run the _install_branding and return the names of the installed packages""" with tempfile.TemporaryDirectory(prefix="lorax.test.") as root_dir: dbo = get_dnf_base_object(root_dir, ["file://"+repo_dir], enablerepos=[], disablerepos=[]) @@ -71,7 +71,7 @@ class InstallBrandingTestCase(unittest.TestCase): product = DataHolder(name="Fedora", version="33", release="33", variant=variant, bugurl="http://none", isfinal=True) arch = ArchData(os.uname().machine) - rb = RuntimeBuilder(product, arch, dbo) + rb = RuntimeBuilder(product, arch, dbo, skip_branding=skip_branding) rb._install_branding() dbo.resolve() self.assertTrue(dbo.transaction is not None) @@ -134,3 +134,13 @@ class InstallBrandingTestCase(unittest.TestCase): # Test with a variant set, but not available pkgs = self.install_branding(repo_dir, variant="server") self.assertEqual(pkgs, ["fedora-logos", "fedora-release"]) + + def test_skip_branding(self): + """Test disabled branding""" + with tempfile.TemporaryDirectory(prefix="lorax.test.repo.") as repo_dir: + makeFakeRPM(repo_dir, "fedora-release", 0, "33", "1", ["/etc/system-release"], ["system-release"]) + makeFakeRPM(repo_dir, "fedora-logos", 0, "33", "1") + os.system("createrepo_c " + repo_dir) + + pkgs = self.install_branding(repo_dir, skip_branding=True) + self.assertEqual(pkgs, [])