From 370679717b53ca269667f9ed8cd34e1fea59ff9b Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Wed, 10 Jan 2018 16:35:03 +0000 Subject: [PATCH] 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 --- src/lib/rpmostree-package.c | 16 +++------------- src/libpriv/rpmostree-rpm-util.c | 8 +++----- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/lib/rpmostree-package.c b/src/lib/rpmostree-package.c index 11c8f81b..7d6b17c6 100644 --- a/src/lib/rpmostree-package.c +++ b/src/lib/rpmostree-package.c @@ -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 * diff --git a/src/libpriv/rpmostree-rpm-util.c b/src/libpriv/rpmostree-rpm-util.c index 829286d0..fc73e404 100644 --- a/src/libpriv/rpmostree-rpm-util.c +++ b/src/libpriv/rpmostree-rpm-util.c @@ -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)); }