From 9369c6a4df0b5ae6fc86eabe4cf488a7dc39d596 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 19 Oct 2021 11:47:14 -0400 Subject: [PATCH] pkglist: Canonicalize "no packages" to "no database found" It can happen that we successfully query zero packages. For example, when rpm-ostree on RHEL8 (assuming bdb database) is trying to parse an ostree commit generated from fedora (sqlite rpmdb), librpm will just give us nothing. Eventually perhaps we may need to fall back to actually running the target commit as a container just to get this data for cases like that. Specifically, I hit this doing `rpm-ostree rebase --experimental ostree-unverified-image:registry:quay.io/cgwalters/fcos-derivation-example` on RHCOS8. --- src/app/rpmostree-builtin-shlib-backend.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/rpmostree-builtin-shlib-backend.cxx b/src/app/rpmostree-builtin-shlib-backend.cxx index 808d76f26a..d3494b23ae 100644 --- a/src/app/rpmostree-builtin-shlib-backend.cxx +++ b/src/app/rpmostree-builtin-shlib-backend.cxx @@ -76,6 +76,13 @@ impl_packagelist_from_commit (OstreeRepo *repo, const char *commit, GError **err } g_autoptr(GVariant) pkgs = rpmostree_variant_pkgs_from_sack (rsack); + // It can happen that we successfully query zero packages. For example, + // when rpm-ostree on RHEL8 (assuming bdb database) is trying to parse an + // ostree commit generated from fedora (sqlite rpmdb), librpm will just give us + // nothing. Eventually perhaps we may need to fall back to actually running + // the target commit as a container just to get this data for cases like that. + if (g_variant_n_children (pkgs) == 0) + return g_variant_new_maybe ((GVariantType*) RPMOSTREE_SHLIB_IPC_PKGLIST, NULL); return g_variant_ref_sink (g_variant_new_maybe ((GVariantType*) RPMOSTREE_SHLIB_IPC_PKGLIST, pkgs)); }