From 3613c12464e1291aee76e737118348ac3041e1ac Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 3 Mar 2020 17:10:31 -0800 Subject: [PATCH] lorax: Update how the release package is chosen Previously the release package was chosen by picking the first package that provides 'system-release' that isn't named generic. This can cause branding issues with repos containing multiple system-release packages. This patch changes _install_branding so that it will give preference to a system-release package that ends with lowercase --variant name. If there isn't one it will fall back to the previous behavior. Resolves: rhbz#1826479 --- src/pylorax/treebuilder.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index a93018b2..19e39cfb 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -96,6 +96,7 @@ class RuntimeBuilder(object): 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 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: @@ -104,18 +105,20 @@ class RuntimeBuilder(object): release = None q = self.dbo.sack.query() a = q.available() - for pkg in a.filter(provides='system-release'): - logger.debug("Found release package %s", pkg) - if pkg.name.startswith('generic'): - continue - else: - release = pkg.name - break - - if not release: - logger.error('could not get the release') + pkgs = sorted([p.name for p in a.filter(provides='system-release') + if not p.name.startswith("generic")]) + if not pkgs: + logger.error("No system-release packages found, could not get the release") return + logger.debug("system-release packages: %s", pkgs) + if self.vars.product.variant: + variant = [p for p in pkgs if p.endswith("-"+self.vars.product.variant.lower())] + if variant: + release = variant[0] + if not release: + release = pkgs[0] + # release logger.info('got release: %s', release) self._runner.installpkg(release)