overrides: Allow resetting inactive overrides

This fixes a small regression from #852 which prevented inactive
overrides to be reset. Which is funny, because that's exactly the most
likely time when you would want to reset an override.

Basically, the `!is_layered --> no overrides` doesn't make sense for
inactive overrides. I suspect most people worked around this by just
using `reset --all`.

Closes: #1323
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-04-03 14:00:07 -04:00 committed by Atomic Bot
parent cb99fb44b2
commit bb07a29bc2
3 changed files with 36 additions and 13 deletions

View File

@ -916,16 +916,12 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
OstreeDeployment *merge_deployment =
rpmostree_sysroot_upgrader_get_merge_deployment (upgrader);
gboolean is_layered;
g_autoptr(GVariant) removed = NULL;
g_autoptr(GVariant) replaced = NULL;
if (!rpmostree_deployment_get_layered_info (repo, merge_deployment, &is_layered, NULL,
NULL, &removed, &replaced, error))
if (!rpmostree_deployment_get_layered_info (repo, merge_deployment, NULL, NULL, NULL,
&removed, &replaced, error))
return FALSE;
if (!is_layered)
return glnx_throw (error, "No overrides currently applied");
g_autoptr(GHashTable) nevra_to_name = g_hash_table_new (g_str_hash, g_str_equal);
g_autoptr(GHashTable) name_to_nevra = g_hash_table_new (g_str_hash, g_str_equal);
@ -959,7 +955,11 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
const char *nevra = g_hash_table_lookup (name_to_nevra, name_or_nevra);
if (name == NULL && nevra == NULL)
return glnx_throw (error, "No overrides for package '%s'", name_or_nevra);
{
/* it might be an inactive override; just try it both ways */
name = name_or_nevra;
nevra = name_or_nevra;
}
else if (name == NULL)
name = name_or_nevra;
else if (nevra == NULL)
@ -979,8 +979,7 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
RPMOSTREE_ORIGIN_OVERRIDE_REPLACE_LOCAL))
continue; /* override found; move on to the next one */
/* if a mapping was found, then it must be an override */
g_assert_not_reached ();
return glnx_throw (error, "No overrides for package '%s'", name_or_nevra);
}
changed = TRUE;

View File

@ -162,6 +162,19 @@ vm_assert_status_jq \
assert_replaced_local_pkg bar-1.0-1.x86_64 bar-0.9-1.x86_64
echo "ok active -> inactive -> active override replace"
# make sure we can reset it while it's inactive
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/without_foo_and_bar
vm_rpmostree upgrade
vm_assert_status_jq \
'.deployments[0]["base-local-replacements"]|length == 0' \
'.deployments[0]["requested-base-local-replacements"]|length == 1' \
'.deployments[0]["requested-base-local-replacements"]|index("bar-0.9-1.x86_64") >= 0'
vm_rpmostree override reset bar-0.9-1.x86_64
vm_assert_status_jq \
'.deployments[0]["base-local-replacements"]|length == 0' \
'.deployments[0]["requested-base-local-replacements"]|length == 0'
echo "ok reset inactive override replace"
vm_rpmostree cleanup -p
# try both local package layering and local replacements to make sure fd sending

View File

@ -150,9 +150,6 @@ vm_assert_status_jq \
'.deployments[0]["base-removals"]|length == 0' \
'.deployments[0]["requested-base-removals"]|length == 1' \
'.deployments[0]["requested-base-removals"]|index("foo") >= 0'
echo "ok override remove requested but not applied"
# check that upgrading again to a base with foo turns the override back on
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo_and_bar
vm_rpmostree upgrade --cache-only
vm_assert_status_jq \
@ -160,7 +157,21 @@ vm_assert_status_jq \
'[.deployments[0]["base-removals"][][.0]]|index("foo-1.0-1.x86_64") >= 0' \
'.deployments[0]["requested-base-removals"]|length == 1' \
'.deployments[0]["requested-base-removals"]|index("foo") >= 0'
echo "ok override remove re-applied"
echo "ok active -> inactive -> active override remove"
# make sure we can reset it while it's inactive
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/without_foo_and_bar
vm_rpmostree upgrade --cache-only
vm_assert_status_jq \
'.deployments[0]["base-removals"]|length == 0' \
'.deployments[0]["requested-base-removals"]|length == 1' \
'.deployments[0]["requested-base-removals"]|index("foo") >= 0'
vm_rpmostree override reset foo
vm_assert_status_jq \
'.deployments[0]["base-removals"]|length == 0' \
'.deployments[0]["requested-base-removals"]|length == 0'
echo "ok reset inactive override remove"
vm_rpmostree cleanup -p
# Restore the local yum repo.