From 2b2a560aca6b8eb454388b5006283f78f88b3909 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 11 Apr 2024 14:59:58 +0200 Subject: [PATCH] tools/osbuild-depsolve-dnf(5): require releasever Originally, I made releasever required only when root_dir was set. This was initially done to maintain backwards compatibility but we broke that already and osbuild/images will always include releasever in the request. --- tools/osbuild-depsolve-dnf | 19 ++++++------------- tools/osbuild-depsolve-dnf5 | 16 +++++----------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/tools/osbuild-depsolve-dnf b/tools/osbuild-depsolve-dnf index 18592b72..dbffdb59 100755 --- a/tools/osbuild-depsolve-dnf +++ b/tools/osbuild-depsolve-dnf @@ -63,8 +63,7 @@ class Solver(): self.base.conf.cachedir = cache_dir self.base.conf.substitutions['arch'] = arch self.base.conf.substitutions['basearch'] = dnf.rpm.basearch(arch) - if releasever: - self.base.conf.substitutions['releasever'] = releasever + self.base.conf.substitutions['releasever'] = releasever if proxy: self.base.conf.proxy = proxy @@ -445,7 +444,11 @@ def validate_request(request): "kind": "InvalidRequest", "reason": "no 'module_platform_id' specified" } - + if not request.get("releasever"): + return { + "kind": "InvalidRequest", + "reason": "no 'module_platform_id' specified" + } arguments = request.get("arguments") if not arguments: return { @@ -459,16 +462,6 @@ def validate_request(request): "reason": "no 'repos' or 'root_dir' specified" } - # if root_dir is used, we also need releasever - # pylint: disable=fixme - # TODO: Make releasever mandatory in all cases. - # We temporarily keep it tied to root_dir for short-term backwards compatibility - if arguments.get("root_dir") and not request.get("releasever"): - return { - "kind": "InvalidRequest", - "reason": "'root_dir' requires setting 'releasever'" - } - return None diff --git a/tools/osbuild-depsolve-dnf5 b/tools/osbuild-depsolve-dnf5 index 252c2a15..afac612e 100755 --- a/tools/osbuild-depsolve-dnf5 +++ b/tools/osbuild-depsolve-dnf5 @@ -570,7 +570,11 @@ def validate_request(request): "kind": "InvalidRequest", "reason": "no 'module_platform_id' specified" } - + if not request.get("releasever"): + return { + "kind": "InvalidRequest", + "reason": "no 'module_platform_id' specified" + } arguments = request.get("arguments") if not arguments: return { @@ -584,16 +588,6 @@ def validate_request(request): "reason": "no 'repos' or 'root_dir' specified" } - # if root_dir is used, we also need releasever - # pylint: disable=fixme - # TODO: Make releasever mandatory in all cases. - # We temporarily keep it tied to root_dir for short-term backwards compatibility - if arguments.get("root_dir") and not request.get("releasever"): - return { - "kind": "InvalidRequest", - "reason": "'root_dir' requires setting 'releasever'" - } - return None