From 792196615be4349c8349fac40aedad2c6e9036c5 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 27 Mar 2026 14:00:33 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20select=20bio=C3=B6d=20correct=20variant?= =?UTF-8?q?=20if=20variant=20has=20been=20passed=20on=20cmd=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ Pmodules/modbuild.in | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce9ed7..6fa20f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ (#1401) * Use patchelf 0.14.5 and Lmod 9.1.1 (#1391, #1393) +* Bugfix: test whether a variant has to be build or not fixed + (#1377) * Bugfix: Selecting the variant to build on the cmd-line did not work. (#1371) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index 874a41a..cf522af 100644 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -1277,19 +1277,23 @@ build_modules_yaml_v1(){ } check_variant(){ + # if a variant is neither passed as argument nor a default, + # is defined, therefore let's build this variant. local -- build_variant="${opt_variant:-${config['default_variant']}}" - # don't build if a variant has be specified on the command line or - # a default variant has been set in the config file, but no - # variant name is defined here - [[ -n ${build_variant} && -z ${config['variant']} ]] && return 1 + [[ -z "${build_variant}" ]] && return 0 + + # a variant has been passed as argument or a default variant is + # defined. If this variant is not named, we don't build it. [[ -z ${config['variant']} ]] && return 1 + set -o noglob - local -a items=( "${config['variant'],,}" ) + local -a variants=( "${config['variant'],,}" ) set +o noglob - local item='' - for item in "${items[@]}"; do - [[ "${opt_variant}" == "${item}" ]] && return 0 + local variant='' + for variant in "${variants[@]}"; do + [[ "${build_variant}" == "${variant}" ]] && return 0 done + return 1 } check_kernel module_config || return 1