Skip to content

Commit

Permalink
fixup! WIP: read lockfile for RPM versions
Browse files Browse the repository at this point in the history
Correctly parse data from gvariant
  • Loading branch information
r4f4 committed May 9, 2019
1 parent 6489f2c commit 1230849
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/app/rpmostree-composeutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,34 +592,43 @@ rpmostree_composeutil_get_vlockmap (JsonParser *parser,
GError **error)
{
g_autoptr(GHashTable) name_to_nevra =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

/* lockfile = {sa{sa(ss)}} */
JsonNode *metarootval = json_parser_get_root (parser);
g_autoptr(GVariant) jsonmetav = json_gvariant_deserialize (metarootval, "{sa{sa(ss)}}", error);
if (!jsonmetav)
return NULL;

g_autoptr(GVariant) repometav =
g_variant_lookup_value (jsonmetav, "packages", G_VARIANT_TYPE ("a{sa(ss)}"));
g_assert (repometav != NULL);
const char *pkgkey;
g_autoptr(GVariant) repometav = NULL;
g_variant_get (jsonmetav, "{&s@a{sa(ss)}}", &pkgkey, &repometav);
if (strcmp (pkgkey, "packages") != 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"Failed to find \"packages\" section in lock file");
return NULL;
}

if (!repometav)
return NULL;

char *repo;
GVariant *value;
GVariantIter viter;
g_variant_iter_init (&viter, repometav);
while (g_variant_iter_loop (&viter, "{sa(ss)}", &repo, &value))
while (g_variant_iter_loop (&viter, "{&s@a(ss)}", &repo, &value))
{
GVariantIter piter;
g_variant_iter_init (&piter, value);
char *nevra, *repochksum;
while (g_variant_iter_loop (&piter, "a(ss)", &nevra, &repochksum))
while (g_variant_iter_loop (&piter, "(s&s)", &nevra, &repochksum))
{
g_autofree char *name = NULL;
char *name = NULL;
if (!rpmostree_decompose_nevra (nevra, &name, NULL, NULL, NULL, NULL, error))
return FALSE;
return NULL;
g_hash_table_insert (name_to_nevra, name, g_strdup (nevra));
/* FIXME: how to return repochksum info? */
g_hash_table_insert (name_to_nevra, g_steal_pointer (&name), (gpointer)nevra);
}
}

Expand Down

0 comments on commit 1230849

Please sign in to comment.