libpriv/rpm-util: just encode evr in pkglist
I initially wanted to include all of `epoch`, `version`, and `release` separately in the rpmdb.pkglist metadata in case we needed them separately. Thinking more on this, I can't think of a really good reason to have them, so since we're not public yet, let's just encode the `evr` as a single string. The reason I'm revisiting this is because it took me a while to hunt down issues when handling epoch, which turned out to be the fact that we weren't consistently committing as big endian (i.e. we did so in the `compose tree` case, but not the layering case), and neither were we consistently converting back from big endian. It's doable of course, but the added gymnastics doesn't feel justified for the gains here. This also nicely cleans up the `RpmOstreePackage` implementation to be leaner and faster. Closes: #1190 Approved by: cgwalters
This commit is contained in:
parent
b1c92a6a1d
commit
370679717b
@ -53,7 +53,6 @@ struct RpmOstreePackage
|
||||
char *nevra;
|
||||
const char *name;
|
||||
const char *evr;
|
||||
char *evr_owned;
|
||||
const char *arch;
|
||||
};
|
||||
|
||||
@ -68,7 +67,6 @@ rpm_ostree_package_finalize (GObject *object)
|
||||
g_clear_pointer (&pkg->gv_nevra, g_variant_unref);
|
||||
|
||||
g_clear_pointer (&pkg->nevra, g_free);
|
||||
g_clear_pointer (&pkg->evr_owned, g_free);
|
||||
|
||||
G_OBJECT_CLASS (rpm_ostree_package_parent_class)->finalize (object);
|
||||
}
|
||||
@ -196,16 +194,8 @@ _rpm_ostree_package_new_from_variant (GVariant *gv_nevra)
|
||||
|
||||
/* we deconstruct now to make accessors simpler */
|
||||
|
||||
uint64_t epoch;
|
||||
const char *version;
|
||||
const char *release;
|
||||
|
||||
g_variant_get (p->gv_nevra, "(&st&s&s&s)", &p->name, &epoch, &version, &release, &p->arch);
|
||||
p->nevra = rpmostree_custom_nevra_strdup (p->name, epoch, version, release, p->arch,
|
||||
PKG_NEVRA_FLAGS_NEVRA);
|
||||
p->evr_owned = rpmostree_custom_nevra_strdup (NULL, epoch, version, release, NULL,
|
||||
PKG_NEVRA_FLAGS_EVR);
|
||||
p->evr = p->evr_owned;
|
||||
g_variant_get (p->gv_nevra, "(&s&s&s)", &p->name, &p->evr, &p->arch);
|
||||
p->nevra = g_strdup_printf ("%s-%s.%s", p->name, p->evr, p->arch);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -215,7 +205,7 @@ get_commit_rpmdb_pkglist (GVariant *commit)
|
||||
g_autoptr(GVariant) meta = g_variant_get_child_value (commit, 0);
|
||||
g_autoptr(GVariantDict) meta_dict = g_variant_dict_new (meta);
|
||||
return g_variant_dict_lookup_value (meta_dict, "rpmostree.rpmdb.pkglist",
|
||||
G_VARIANT_TYPE ("a(stsss)"));
|
||||
G_VARIANT_TYPE ("a(sss)"));
|
||||
}
|
||||
|
||||
static GPtrArray *
|
||||
|
@ -1129,17 +1129,15 @@ rpmostree_create_rpmdb_pkglist_variant (int rootfs_dfd,
|
||||
g_autoptr(GPtrArray) pkglist = rpmostree_sack_get_sorted_packages (refsack->sack);
|
||||
|
||||
GVariantBuilder pkglist_v_builder;
|
||||
g_variant_builder_init (&pkglist_v_builder, (GVariantType*)"a(stsss)");
|
||||
g_variant_builder_init (&pkglist_v_builder, (GVariantType*)"a(sss)");
|
||||
|
||||
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)",
|
||||
g_variant_builder_add (&pkglist_v_builder, "(sss)",
|
||||
dnf_package_get_name (pkg),
|
||||
dnf_package_get_epoch (pkg),
|
||||
dnf_package_get_version (pkg),
|
||||
dnf_package_get_release (pkg),
|
||||
dnf_package_get_evr (pkg),
|
||||
dnf_package_get_arch (pkg));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user