diff --git a/src/daemon/rpmostree-sysroot-core.c b/src/daemon/rpmostree-sysroot-core.c index b4a2e1d21f..c1bf411fe0 100644 --- a/src/daemon/rpmostree-sysroot-core.c +++ b/src/daemon/rpmostree-sysroot-core.c @@ -404,8 +404,10 @@ rpmostree_syscore_filter_deployments (OstreeSysroot *sysroot, continue; } - /* Is this deployment for a different osname? Keep it. */ - if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0) + const gboolean osname_matches = + strcmp (ostree_deployment_get_osname (deployment), osname) == 0; + /* Retain deployments for other osnames, as well as pinned ones */ + if (!osname_matches || ostree_deployment_is_pinned (deployment)) { g_ptr_array_add (new_deployments, g_object_ref (deployment)); continue; diff --git a/tests/vmcheck/test-basic.sh b/tests/vmcheck/test-basic.sh index b8874210fd..4d4f4d4b79 100755 --- a/tests/vmcheck/test-basic.sh +++ b/tests/vmcheck/test-basic.sh @@ -125,6 +125,16 @@ vm_rpmostree status > status.txt assert_not_file_has_content status.txt "Pinned: yes" echo "ok pinning" +vm_cmd ostree admin pin 0 +vm_rpmostree reload # Try to avoid reload races +vm_rpmostree cleanup -p +vm_assert_status_jq ".deployments|length == 2" +vm_cmd ostree admin pin -u 0 +vm_rpmostree reload # Try to avoid reload races +vm_rpmostree cleanup -p +vm_assert_status_jq ".deployments|length == 1" +echo "ok pinned retained" + # https://github.com/ostreedev/ostree/pull/1055 vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck --timestamp=\"October 25 1985\" if vm_rpmostree upgrade 2>err.txt; then