Skip to content

Commit

Permalink
workaround implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarmtemp committed Jul 17, 2023
1 parent 5484ee2 commit 7ed27b8
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 1 deletion.
54 changes: 53 additions & 1 deletion src/app/rpmostree-builtin-upgrade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "rpmostree-rpm-util.h"

#include <libglnx.h>
#include <rpmostree-sysroot-upgrader.cxx>

static char *opt_osname;
static gboolean opt_reboot;
Expand Down Expand Up @@ -207,6 +208,12 @@ rpmostree_builtin_upgrade (int argc, char **argv, RpmOstreeCommandInvocation *in
if (rpmostree_os_get_has_cached_update_rpm_diff (os_proxy))
cached_update = rpmostree_os_dup_cached_update (os_proxy);

gboolean manifest_diff = FALSE;
// if (rpmostree_os_get_has_cached_update_manifest_diff (os_proxy)) {
manifest_diff = TRUE;
cached_update = rpmostree_os_dup_cached_update (os_proxy);
// }

if (!cached_update)
{
g_print ("No updates available.\n");
Expand All @@ -215,9 +222,54 @@ rpmostree_builtin_upgrade (int argc, char **argv, RpmOstreeCommandInvocation *in
else
{
/* preview --> verbose (i.e. we want the diff) */
if (!rpmostree_print_cached_update (cached_update, opt_preview, FALSE, cancellable,
if (!manifest_diff) {
if (!rpmostree_print_cached_update (cached_update, opt_preview, FALSE, cancellable,
error))
return FALSE;
}
else {
std::string test = "total:51,total_size:714.8 MB,total_removed:0,removed_size:0 bytes,total_added:0,added_size:0 bytes";
manifest_diff_add_db_diff (test, cancellable, error);



glnx_autofd int fd = -1;
g_autoptr (GError) local_error = NULL;
if (!glnx_openat_rdonly (AT_FDCWD, RPMOSTREE_AUTOUPDATES_CACHE_FILE, TRUE, &fd, &local_error))
{
if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
return g_propagate_error (error, util::move_nullify (local_error)), FALSE;
return TRUE; /* Note early return */
}

/* sanity check there isn't something fishy going on before even reading it in */
struct stat stbuf;
if (!glnx_fstat (fd, &stbuf, error))
return FALSE;

if (!rpmostree_check_size_within_limit (stbuf.st_size, OSTREE_MAX_METADATA_SIZE,
RPMOSTREE_AUTOUPDATES_CACHE_FILE, error))
return FALSE;

g_autoptr (GBytes) data = glnx_fd_readall_bytes (fd, NULL, error);
if (!data)
return FALSE;

cached_update
= g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE_VARDICT, data, FALSE));




// cached_update = rpmostree_os_dup_cached_update (os_proxy);
if (!rpmostree_print_cached_update_container (cached_update, opt_preview, FALSE, cancellable,
error))
{
return FALSE;
}

}

}
}
else if (!opt_reboot)
Expand Down
118 changes: 118 additions & 0 deletions src/app/rpmostree-clientlib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,124 @@ rpmostree_print_cached_update (GVariant *cached_update, gboolean verbose,
return TRUE;
}

gboolean
rpmostree_print_cached_update_container (GVariant *cached_update, gboolean verbose,
gboolean verbose_advisories, GCancellable *cancellable,
GError **error)
{
GLNX_AUTO_PREFIX_ERROR ("Retrieving cached update", error);
g_print("Enter Print Func\n");

g_auto (GVariantDict) dict;
g_variant_dict_init (&dict, cached_update);
if (cached_update == NULL)
g_print("Failure\n");
g_print("Not failure\n");

/* let's just extract 📤 all the info ahead of time */

// const char *total;
// if (!g_variant_dict_lookup (&dict, "total", "&s", &total))
// return glnx_throw (error, "Missing \"total\" key");

if (!g_variant_dict_lookup_value (&dict, "manifest-diff", G_VARIANT_TYPE ("a{sv}")))
return glnx_throw (error, "Missing \"manifest-diff\" key");

g_autoptr (GVariant) mainfest_diff
= g_variant_dict_lookup_value (&dict, "manifest-diff", G_VARIANT_TYPE ("a{sv}"));

g_auto (GVariantDict) manifest_diff_dict;
g_variant_dict_init (&manifest_diff_dict, mainfest_diff);

g_autoptr (GVariant) total
= g_variant_dict_lookup_value (&manifest_diff_dict, "total", G_VARIANT_TYPE ("s"));
if (!total)
return FALSE;

const gchar *tmp1;
g_variant_get (total, "s", &tmp1);
g_print("%s\n", tmp1);

// g_auto (GVariantDict) dict;
// g_variant_dict_init (&dict, cached_update);

// /* let's just extract 📤 all the info ahead of time */

// g_autoptr (GVariant) manifest_diff
// = g_variant_dict_lookup_value (&dict, "manifest-diff", G_VARIANT_TYPE ("a{sv}"));

// g_autoptr (GVariantIter) iter1 = NULL;
// g_variant_get (manifest_diff, "a{sv}", &iter1);

// if (!manifest_diff)
// g_print("WE Failed");

// const gchar *key;
// const gchar *value;
// while (g_variant_iter_loop (iter1, "{sv}", &key, &value))
// {
// g_print("%s", key);
// }

// g_auto (GVariantDict) rpm_diff_dict;
// g_variant_dict_init (&rpm_diff_dict, rpm_diff);

// g_autoptr (GVariant) total
// = g_variant_dict_lookup_value (manifest_diff, "total", G_VARIANT_TYPE ("s"));
// if (!total) {
// g_print("WE Failed");
// return FALSE;
// }

// g_autoptr (GVariant) total_size = _rpmostree_vardict_lookup_value_required (
// &rpm_diff_dict, "total_size", RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT, error);
// if (!total_size)
// return FALSE;

// g_autoptr (GVariant) total_removed = _rpmostree_vardict_lookup_value_required (
// &rpm_diff_dict, "total_removed", RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT, error);
// if (!total_removed)
// return FALSE;

// g_autoptr (GVariant) removed_size = _rpmostree_vardict_lookup_value_required (
// &rpm_diff_dict, "removed_size", RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT, error);
// if (!removed_size)
// return FALSE;

// g_autoptr (GVariant) total_added = _rpmostree_vardict_lookup_value_required (
// &rpm_diff_dict, "total_added", RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT, error);
// if (!total_added)
// return FALSE;

// g_autoptr (GVariant) added_size = _rpmostree_vardict_lookup_value_required (
// &rpm_diff_dict, "added_size", RPMOSTREE_DIFF_MODIFIED_GVARIANT_FORMAT, error);
// if (!added_size)
// return FALSE;

// const gchar *tmp1;
// const gchar *tmp2;
// const gchar *tmp3;
// const gchar *tmp4;
// const gchar *tmp5;
// const gchar *tmp6;

// g_variant_get (total, "s", &tmp1);
// g_variant_get (total_size, "s", &tmp2);
// g_variant_get (total_removed, "s", &tmp3);
// g_variant_get (removed_size, "s", &tmp4);
// g_variant_get (total_added, "s", &tmp5);
// g_variant_get (added_size, "s", &tmp6);

// g_print("%s", tmp1);
// g_print("%s", tmp2);
// g_print("%s", tmp3);
// g_print("%s", tmp4);
// g_print("%s", tmp5);
// g_print("%s", tmp6);

return TRUE;
}

/* Query systemd for systemd unit's object path using method_name provided with
* parameters. The reply_type of method_name must be G_VARIANT_TYPE_TUPLE. */
gboolean
Expand Down
4 changes: 4 additions & 0 deletions src/app/rpmostree-clientlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ gboolean rpmostree_print_cached_update (GVariant *cached_update, gboolean verbos
gboolean verbose_advisories, GCancellable *cancellable,
GError **error);

gboolean rpmostree_print_cached_update_container (GVariant *cached_update, gboolean verbose,
gboolean verbose_advisories, GCancellable *cancellable,
GError **error);

void rpmostree_print_advisories (GVariant *advisories, gboolean verbose, guint max_key_len);

gboolean get_sd_unit_objpath (GDBusConnection *connection, const char *method_name,
Expand Down
1 change: 1 addition & 0 deletions src/daemon/org.projectatomic.rpmostree1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
</property>
<property name="HasCachedUpdateRpmDiff" type="b" access="read"/>
<property name="HasCachedUpdateManifestDiff" type="b" access="read"/>

<!-- Available options:
"mode" (type 's')
Expand Down
Loading

0 comments on commit 7ed27b8

Please sign in to comment.