status: always include the packages entries

Pull #646 introduced a subtle regression: we went from always including
a "packages" entry to only including it if there are packages present.
Albeit it's easy to guard against, though to be nice, let's make it
easier for consumers by always including it.

Reported-by: Micah Abbott <miabbott@redhat.com>

Closes: #670
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2017-03-09 16:39:03 -05:00 committed by Atomic Bot
parent 14a9135ea0
commit 49cbdb739a
2 changed files with 15 additions and 6 deletions

View File

@ -236,15 +236,18 @@ rpmostreed_deployment_generate_variant (OstreeDeployment *deployment,
} }
g_variant_dict_insert (&dict, "origin", "s", refspec); g_variant_dict_insert (&dict, "origin", "s", refspec);
if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0)
{ g_autofree char **requested_pkgs =
g_autofree char **pkgs =
(char**)g_hash_table_get_keys_as_array (rpmostree_origin_get_packages (origin), NULL); (char**)g_hash_table_get_keys_as_array (rpmostree_origin_get_packages (origin), NULL);
g_variant_dict_insert (&dict, "requested-packages", "^as", pkgs); g_variant_dict_insert (&dict, "requested-packages", "^as", requested_pkgs);
}
if (is_layered && g_strv_length (layered_pkgs) > 0) if (is_layered && g_strv_length (layered_pkgs) > 0)
g_variant_dict_insert (&dict, "packages", "^as", layered_pkgs); g_variant_dict_insert (&dict, "packages", "^as", layered_pkgs);
else
{
const char *const p[] = { NULL };
g_variant_dict_insert (&dict, "packages", "^as", p);
}
if (sigs != NULL) if (sigs != NULL)
g_variant_dict_insert_value (&dict, "signatures", sigs); g_variant_dict_insert_value (&dict, "signatures", sigs);

View File

@ -37,6 +37,12 @@ vm_assert_status_jq \
'.deployments[0]["base-checksum"]|not' \ '.deployments[0]["base-checksum"]|not' \
'.deployments[0]["pending-base-checksum"]|not' '.deployments[0]["pending-base-checksum"]|not'
# make sure that package-related entries are always present,
# even when they're empty
vm_assert_status_jq \
'.deployments[0]["packages"]' \
'.deployments[0]["requested-packages"]'
# Be sure an unprivileged user exists # Be sure an unprivileged user exists
vm_cmd getent passwd bin vm_cmd getent passwd bin
if vm_cmd "runuser -u bin rpm-ostree pkg-add foo-1.0"; then if vm_cmd "runuser -u bin rpm-ostree pkg-add foo-1.0"; then