libpriv/core: include pkglist for client commits
The new `rpmdb.pkglist` metadata is a cheap way of retrieving the set of packages in a commit. I'd like to make use of it as much as possible vs. checking out the rpmdb and setting up a DnfSack. Of course, in the case of layered commits, it doesn't matter *as* much, because a layered commit being present in the repo should mean that a deployment is currently using it, and we should learn to reuse the rpmdb checkout of that deployment. Though keeping it consistent across both server and client commits makes implementing `OstreeDeployment`-agnostic things like `db diff` more efficient too. I also plan to use this in the upcoming auto-update code. Closes: #1158 Approved by: cgwalters
This commit is contained in:
parent
97133bd028
commit
d9e870be88
@ -1091,37 +1091,6 @@ impl_install_tree (RpmOstreeTreeComposeContext *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
create_rpmdb_pkglist_variant (int rootfs_dfd,
|
||||
GVariant **out_variant,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GPtrArray) pkglist = NULL;
|
||||
g_autoptr(RpmOstreeRefSack) refsack = NULL;
|
||||
if (!rpmostree_get_pkglist_for_root (rootfs_dfd, ".", &refsack,
|
||||
&pkglist, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
GVariantBuilder pkglist_v_builder;
|
||||
g_variant_builder_init (&pkglist_v_builder, (GVariantType*)"a(stsss)");
|
||||
|
||||
const guint n = pkglist->len;
|
||||
for (guint i = 0; i < n; i++)
|
||||
{
|
||||
DnfPackage *pkg = pkglist->pdata[i];
|
||||
g_variant_builder_add (&pkglist_v_builder, "(stsss)",
|
||||
dnf_package_get_name (pkg),
|
||||
dnf_package_get_epoch (pkg),
|
||||
dnf_package_get_version (pkg),
|
||||
dnf_package_get_release (pkg),
|
||||
dnf_package_get_arch (pkg));
|
||||
}
|
||||
|
||||
*out_variant = g_variant_builder_end (&pkglist_v_builder);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_commit_tree (RpmOstreeTreeComposeContext *self,
|
||||
GCancellable *cancellable,
|
||||
@ -1145,10 +1114,10 @@ impl_commit_tree (RpmOstreeTreeComposeContext *self,
|
||||
* pending updates. once we only support unified core composes, this can easily be much
|
||||
* more readily injected during assembly */
|
||||
g_autoptr(GVariant) rpmdb_v = NULL;
|
||||
if (!create_rpmdb_pkglist_variant (self->rootfs_dfd, &rpmdb_v, cancellable, error))
|
||||
if (!rpmostree_create_rpmdb_pkglist_variant (self->rootfs_dfd, &rpmdb_v,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
g_variant_builder_add (metadata_builder, "{sv}", "rpmostree.rpmdb.pkglist",
|
||||
g_steal_pointer (&rpmdb_v));
|
||||
g_variant_builder_add (metadata_builder, "{sv}", "rpmostree.rpmdb.pkglist", rpmdb_v);
|
||||
|
||||
metadata = g_variant_ref_sink (g_variant_builder_end (metadata_builder));
|
||||
/* Canonicalize to big endian, like OSTree does. Without this, any numbers
|
||||
|
@ -3753,10 +3753,17 @@ rpmostree_context_commit (RpmOstreeContext *self,
|
||||
g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.replaced-base-packages",
|
||||
g_variant_builder_end (&replaced_base_pkgs));
|
||||
|
||||
/* this is used by the db commands, and auto updates to diff against the base */
|
||||
g_autoptr(GVariant) rpmdb = NULL;
|
||||
if (!rpmostree_create_rpmdb_pkglist_variant (self->tmprootfs_dfd, &rpmdb,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.rpmdb.pkglist", rpmdb);
|
||||
|
||||
/* be nice to our future selves */
|
||||
g_variant_builder_add (&metadata_builder, "{sv}",
|
||||
"rpmostree.clientlayer_version",
|
||||
g_variant_new_uint32 (2));
|
||||
g_variant_new_uint32 (3));
|
||||
}
|
||||
else if (assemble_type == RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE)
|
||||
{
|
||||
|
@ -1128,3 +1128,34 @@ rpmostree_sack_get_by_pkgname (DnfSack *sack,
|
||||
*out_pkg = g_steal_pointer (&ret_pkg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
rpmostree_create_rpmdb_pkglist_variant (int rootfs_dfd,
|
||||
GVariant **out_variant,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GPtrArray) pkglist = NULL;
|
||||
g_autoptr(RpmOstreeRefSack) refsack = NULL;
|
||||
if (!rpmostree_get_pkglist_for_root (rootfs_dfd, ".", &refsack,
|
||||
&pkglist, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
GVariantBuilder pkglist_v_builder;
|
||||
g_variant_builder_init (&pkglist_v_builder, (GVariantType*)"a(stsss)");
|
||||
|
||||
const guint n = pkglist->len;
|
||||
for (guint i = 0; i < n; i++)
|
||||
{
|
||||
DnfPackage *pkg = pkglist->pdata[i];
|
||||
g_variant_builder_add (&pkglist_v_builder, "(stsss)",
|
||||
dnf_package_get_name (pkg),
|
||||
dnf_package_get_epoch (pkg),
|
||||
dnf_package_get_version (pkg),
|
||||
dnf_package_get_release (pkg),
|
||||
dnf_package_get_arch (pkg));
|
||||
}
|
||||
|
||||
*out_variant = g_variant_ref_sink (g_variant_builder_end (&pkglist_v_builder));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -181,3 +181,9 @@ rpmostree_sack_get_by_pkgname (DnfSack *sack,
|
||||
const char *pkgname,
|
||||
DnfPackage **out_pkg,
|
||||
GError **error);
|
||||
|
||||
gboolean
|
||||
rpmostree_create_rpmdb_pkglist_variant (int rootfs_dfd,
|
||||
GVariant **out_variant,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
@ -60,5 +60,5 @@ echo "ok no leftover files"
|
||||
ostree --repo=${repobuild} show ${treeref} \
|
||||
--print-metadata-key rpmostree.rpmdb.pkglist > pkglist.txt
|
||||
assert_file_has_content pkglist.txt 'systemd'
|
||||
echo "ok pkglist"
|
||||
echo "ok compose pkglist"
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ vm_assert_status_jq \
|
||||
'.deployments[0]["base-checksum"]' \
|
||||
'.deployments[0]["pending-base-checksum"]|not' \
|
||||
'.deployments[0]["base-commit-meta"]' \
|
||||
'.deployments[0]["layered-commit-meta"]["rpmostree.clientlayer_version"] == 2'
|
||||
'.deployments[0]["layered-commit-meta"]["rpmostree.clientlayer_version"] > 1'
|
||||
|
||||
vm_assert_layered_pkg foo-1.0 present
|
||||
echo "ok pkg foo added"
|
||||
@ -190,3 +190,8 @@ for ref in rpmostree/pkg/test-pkgcache-migrate-pkg{1,2}/1.0-1.x86__64; do
|
||||
done
|
||||
vm_cmd test -L ${OLD_PKGCACHE_DIR}
|
||||
echo "ok migrate pkgcache"
|
||||
|
||||
vm_cmd ostree show --print-metadata-key rpmostree.rpmdb.pkglist \
|
||||
$(vm_get_deployment_info 0 checksum) > pkglist.txt
|
||||
assert_file_has_content pkglist.txt 'test-pkgcache-migrate-pkg'
|
||||
echo "ok layered pkglist"
|
||||
|
Loading…
Reference in New Issue
Block a user