diff --git a/src/daemon/rpmostreed-transaction-types.cxx b/src/daemon/rpmostreed-transaction-types.cxx index 033a97a4bc..9067b0a02b 100644 --- a/src/daemon/rpmostreed-transaction-types.cxx +++ b/src/daemon/rpmostreed-transaction-types.cxx @@ -2708,7 +2708,8 @@ kernel_arg_apply_patching (KernelArgTransaction *self, RpmOstreeSysrootUpgrader for (char **iter = append_if_missing; iter && *iter; iter++) { const char *arg = *iter; - if (!g_strv_contains (existing_kargs, arg)) + g_auto (GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs); + if (!g_strv_contains (kargs_strv, arg)) { ostree_kernel_args_append (kargs, arg); changed = TRUE; diff --git a/tests/vmcheck/test-kernel-args.sh b/tests/vmcheck/test-kernel-args.sh index aa952022c1..f64b95b5d5 100755 --- a/tests/vmcheck/test-kernel-args.sh +++ b/tests/vmcheck/test-kernel-args.sh @@ -187,7 +187,18 @@ vm_rpmostree kargs > kargs.txt assert_file_has_content_literal kargs.txt 'PACKAGE3=NEWTEST' rpm-ostree kargs --delete-if-present=PACKAGE3=TEST || rc=$? assert_streq $rc 0 -vm_rpmostree kargs --delete-if-present=PACKAGE3=TEST3 +echo "ok for append-if-missing and delete-if-present if existing key" + +# Test corner case for append and append-if-missing with the same value +vm_rpmostree kargs --append=foo --append-if-missing=foo +vm_rpmostree kargs > kargs.txt +assert_not_file_has_content_literal kargs.txt 'foo foo' +assert_file_has_content_literal kargs.txt 'foo' +vm_rpmostree kargs --append-if-missing=PACKAGE4=TEST4 --append-if-missing=PACKAGE4=TEST4 +vm_rpmostree kargs > kargs.txt +assert_not_file_has_content_literal kargs.txt 'PACKAGE4=TEST4 PACKAGE4=TEST4' +assert_file_has_content_literal kargs.txt 'PACKAGE4=TEST4' +echo "ok for append and append-if-missing with the same value" # Test for 'rpm-ostree kargs --editor'. vm_rpmostree kargs > kargs.txt