Regularize yumpkg option separators

Add logging and convert to formatted string literal.

Other Yum options uses equal sign as separator but setopt separator is
irregular using space as separator.

Fix: https://github.com/saltstack/salt/issues/66970
This commit is contained in:
Ben Grande 2024-10-15 11:19:51 +02:00 committed by Daniel Wozniak
parent 28662c490b
commit e3f25965af
2 changed files with 12 additions and 21 deletions

View file

@ -315,7 +315,8 @@ def _get_options(**kwargs):
ret.append(f"--branch={branch}")
for item in setopt:
ret.extend(["--setopt", str(item)])
log.info("Adding configuration option '%s'", item)
ret.extend([f"--setopt={item}"])
if get_extra_options:
# sorting here to make order uniform, makes unit testing more reliable

View file

@ -1423,10 +1423,8 @@ def test_install_with_options():
"--disablerepo=*",
"--enablerepo=good",
"--branch=foo",
"--setopt",
"obsoletes=0",
"--setopt",
"plugins=0",
"--setopt=obsoletes=0",
"--setopt=plugins=0",
"install",
"foo",
],
@ -1454,10 +1452,8 @@ def test_install_with_options():
"--disablerepo=bad",
"--enablerepo=good",
"--branch=foo",
"--setopt",
"obsoletes=0",
"--setopt",
"plugins=0",
"--setopt=obsoletes=0",
"--setopt=plugins=0",
"install",
"foo",
],
@ -1852,10 +1848,8 @@ def test_upgrade_with_options():
"--disablerepo=*",
"--enablerepo=good",
"--branch=foo",
"--setopt",
"obsoletes=0",
"--setopt",
"plugins=0",
"--setopt=obsoletes=0",
"--setopt=plugins=0",
"--exclude=kernel*",
"--nogpgcheck",
"upgrade",
@ -1897,10 +1891,8 @@ def test_upgrade_with_options():
"--disablerepo=bad",
"--enablerepo=good",
"--branch=foo",
"--setopt",
"obsoletes=0",
"--setopt",
"plugins=0",
"--setopt=obsoletes=0",
"--setopt=plugins=0",
"--exclude=kernel*",
"upgrade",
],
@ -3046,10 +3038,8 @@ def test_pkg_update_dnf():
"dnf",
"--quiet",
"-y",
"--setopt",
"plugins=0",
"--setopt",
"obsoletes=False",
"--setopt=plugins=0",
"--setopt=obsoletes=False",
"upgrade",
"foo",
],