From e4c22e3973083a0fc10807130ea9906501cd7713 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 Jul 2022 17:28:37 +0200 Subject: [PATCH] ITL: apt: render vars.apt_[dist_]upgrade=true as --[dist-]upgrade, not --[dist-]upgrade=true but preserve vars.apt_[dist_]upgrade=-s as --[dist-]upgrade=-s. --- itl/command-plugins.conf | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/itl/command-plugins.conf b/itl/command-plugins.conf index 2999e41e1..e64e80d84 100644 --- a/itl/command-plugins.conf +++ b/itl/command-plugins.conf @@ -1923,20 +1923,43 @@ object CheckCommand "apt" { command = [ PluginDir + "/check_apt" ] arguments = { - "--extra-opts" = { - value = "$apt_extra_opts$" - description = "Read options from an ini file." - } + // apt-get takes only options starting with "-" (like "-sqq") before + // the upgrade command, so passing e.g. "foobar" as "--upgrade=foobar" + // makes no sense. This allows to easily decide between "-x=-y" + // (strings starting with "-") and "-x" (everything else). "--upgrade" = { - value = "$apt_upgrade$" - separator = "=" + set_if = {{ + var v = macro("$apt_upgrade$") + return match("-*", string(v).trim()) ? false : v + }} description = "[Default] Perform an upgrade. If an optional OPTS argument is provided, apt-get will be run with these command line options instead of the default." } "--dist-upgrade" = { - value = "$apt_dist_upgrade$" - separator = "=" + set_if = {{ + var v = macro("$apt_dist_upgrade$") + return match("-*", string(v).trim()) ? false : v + }} description = "Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS can be provided to override the default options." } + "--upgrade=OPTS" = { + set_if = {{ match("-*", string(macro("$apt_upgrade$")).trim()) }} + key = "--upgrade" + separator = "=" + value = "$apt_upgrade$" + description = "[Default] Perform an upgrade. If an optional OPTS argument is provided, apt-get will be run with these command line options instead of the default." + } + "--dist-upgrade=OPTS" = { + set_if = {{ match("-*", string(macro("$apt_dist_upgrade$")).trim()) }} + key = "--dist-upgrade" + separator = "=" + value = "$apt_dist_upgrade$" + description = "Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS can be provided to override the default options." + } + + "--extra-opts" = { + value = "$apt_extra_opts$" + description = "Read options from an ini file." + } "--include" = { value = "$apt_include$" description = "Include only packages matching REGEXP. Can be specified multiple times the values will be combined together."