diff --git a/rust/src/sysroot_upgrade.rs b/rust/src/sysroot_upgrade.rs index c27c1ac64d..bb343395fd 100644 --- a/rust/src/sysroot_upgrade.rs +++ b/rust/src/sysroot_upgrade.rs @@ -248,12 +248,8 @@ pub async fn get_container_manifest_diff( sigverify, imgref: new_imgref, }; - let (manifest, _) = if let r = ostree_ext::container::fetch_manifest(&container).await? { - r - } else { - return Ok("".to_string()) - }; + let (manifest, _) = ostree_ext::container::fetch_manifest(&container).await?; let diff = ManifestDiff::new(&previous_state.manifest, &manifest); Ok(diff.export_as_string()) diff --git a/src/app/rpmostree-builtin-upgrade.cxx b/src/app/rpmostree-builtin-upgrade.cxx index a0fa3f9e63..ac45053f2b 100644 --- a/src/app/rpmostree-builtin-upgrade.cxx +++ b/src/app/rpmostree-builtin-upgrade.cxx @@ -205,9 +205,8 @@ rpmostree_builtin_upgrade (int argc, char **argv, RpmOstreeCommandInvocation *in g_print ("Note: --check and --preview may be unreliable. See " "https://github.com/coreos/rpm-ostree/issues/1579\n"); g_autoptr (GVariant) cached_update = NULL; - if (rpmostree_os_get_has_cached_update_rpm_diff (os_proxy)) { + if (rpmostree_os_get_has_cached_update_rpm_diff (os_proxy)) cached_update = rpmostree_os_dup_cached_update (os_proxy); - } if (!cached_update) { @@ -218,8 +217,8 @@ rpmostree_builtin_upgrade (int argc, char **argv, RpmOstreeCommandInvocation *in { /* preview --> verbose (i.e. we want the diff) */ if (!rpmostree_print_cached_update (cached_update, opt_preview, FALSE, cancellable, - error)) - return FALSE; + error)) + return FALSE; } } else if (!opt_reboot) diff --git a/src/daemon/rpmostree-sysroot-upgrader.cxx b/src/daemon/rpmostree-sysroot-upgrader.cxx index ac666b0b03..0ea7de959d 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.cxx +++ b/src/daemon/rpmostree-sysroot-upgrader.cxx @@ -401,170 +401,6 @@ rpmostree_sysroot_upgrader_get_sack (RpmOstreeSysrootUpgrader *self, GError **er return self->rpmmd_sack; } -// #include -// #include -// #include - -// gboolean -// rpm_ostree_db_diff_ext_container (gchar* manifest_diff, GVariant **total, -// GVariant **total_size, GVariant **total_removed, -// GVariant **removed_size, GVariant **total_added, -// GVariant **added_size, GError **error) -// { -// char *end_str; -// char *outer_token = strtok_r(manifest_diff, ",", &end_str); - -// while (outer_token != NULL) { -// char *end_token; -// char *inner_token = strtok_r(outer_token, ":", &end_token); - -// while (inner_token != NULL) { - -// if (!strcmp(inner_token, "total")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *total = g_variant_new("s", inner_token); -// } -// else if (!strcmp(inner_token, "total_size")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *total_size = g_variant_new("s", inner_token); -// } -// else if (!strcmp(inner_token, "total_removed")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *total_removed = g_variant_new("s", inner_token); -// } -// else if (!strcmp(inner_token, "removed_size")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *removed_size = g_variant_new("s", inner_token); -// } -// else if (!strcmp(inner_token, "total_added")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *total_added = g_variant_new("s", inner_token); -// } -// else if (!strcmp(inner_token, "added_size")) { -// inner_token = strtok_r(NULL, ":", &end_token); -// *added_size = g_variant_new("s", inner_token); -// } -// inner_token = strtok_r(NULL, ":", &end_token); -// } -// outer_token = strtok_r(NULL, ",", &end_str); -// } - -// if (*total == NULL || *total_size == NULL || *total_removed == NULL || *removed_size == NULL || *total_added == NULL || *added_size == NULL) { -// return FALSE; -// } -// return TRUE; -// } - -// static gboolean -// manifest_diff_add_db_diff (std::string manifest_diff, GCancellable *cancellable, GError **error) -// { - -// g_autoptr (GVariant) total = NULL; -// g_autoptr (GVariant) total_size = NULL; -// g_autoptr (GVariant) total_removed = NULL; -// g_autoptr (GVariant) removed_size = NULL; -// g_autoptr (GVariant) total_added = NULL; -// g_autoptr (GVariant) added_size = NULL; - -// rpmostree_output_message ("Before copy"); -// gchar *converted_manifest_diff = strcpy(new char[manifest_diff.length() + 1], manifest_diff.c_str()); -// // manifest_diff = "total:51,total_size:714.8 MB,total_removed:0,removed_size:0 bytes,total_added:0,added_size:0 bytes"; -// rpmostree_output_message ("Before pop"); -// if (!rpm_ostree_db_diff_ext_container (converted_manifest_diff, &total, &total_size, -// &total_removed, &removed_size, &total_added, &added_size, error)) -// return FALSE; - -// rpmostree_output_message ("After pop"); - -// const gchar *tmp1; -// const gchar *tmp2; -// const gchar *tmp3; -// const gchar *tmp4; -// const gchar *tmp5; -// const gchar *tmp6; - - -// g_variant_get (total, "s", &tmp1); -// rpmostree_output_message ("%s", tmp1); -// g_variant_get (total_size, "s", &tmp2); -// rpmostree_output_message ("%s", tmp2); -// g_variant_get (total_removed, "s", &tmp3); -// rpmostree_output_message ("%s", tmp3); -// g_variant_get (removed_size, "s", &tmp4); -// rpmostree_output_message ("%s", tmp4); -// g_variant_get (total_added, "s", &tmp5); -// rpmostree_output_message ("%s", tmp5); -// g_variant_get (added_size, "s", &tmp6); -// rpmostree_output_message ("%s", tmp6); - -// rpmostree_output_message ("Before dict pop"); -// g_auto (GVariantDict) manifest_dict; -// g_variant_dict_init (&manifest_dict, NULL); -// g_variant_dict_insert (&manifest_dict, "total", "s", tmp1); -// g_variant_dict_insert (&manifest_dict, "total_size", "s", tmp2); -// g_variant_dict_insert (&manifest_dict, "total_removed", "s", tmp3); -// g_variant_dict_insert (&manifest_dict, "removed_size", "s", tmp4); -// g_variant_dict_insert (&manifest_dict, "total_added", "s", tmp5); -// g_variant_dict_insert (&manifest_dict, "added_size", "s", tmp6); - -// rpmostree_output_message ("After dict pop"); - - -// // rpmostree_output_message ("Empty dict initialized"); -// // g_auto (GVariantBuilder) manifest_diff_dict; -// // g_variant_builder_init (&manifest_diff_dict, G_VARIANT_TYPE ("{sv}")); - -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "total", total); -// // rpmostree_output_message ("Add total to builder"); -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "total_size", total_size); -// // rpmostree_output_message ("Add total_size to builder"); -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "total_removed", total_removed); -// // rpmostree_output_message ("Add total_removed to builder"); -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "removed_size", removed_size); -// // rpmostree_output_message ("Add removed_size to builder"); -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "total_added", total_added); -// // rpmostree_output_message ("Add total_added to builder"); -// // g_variant_builder_add (&manifest_diff_dict, "{sv}", "added_size", added_size); -// // rpmostree_output_message ("Add added_size to builder"); -// // rpmostree_output_message ("Dict created"); -// // g_variant_builder_unref(manifest_diff_dict); - -// g_auto (GVariantDict) dict; -// g_variant_dict_init (&dict, NULL); -// g_variant_dict_insert (&dict, "manifest-diff", "@a{sv}", g_variant_dict_end (&manifest_dict)); - -// g_autoptr (GVariant) update = NULL; -// update = g_variant_ref_sink (g_variant_dict_end (&dict)); - -// if (update != NULL) -// { -// rpmostree_output_message ("Update not NULL"); -// if (!glnx_file_replace_contents_at (AT_FDCWD, RPMOSTREE_AUTOUPDATES_CACHE_FILE, -// static_cast (g_variant_get_data (update)), -// g_variant_get_size (update), -// static_cast (0), cancellable, -// error)) -// return FALSE; -// } - -// rpmostree_output_message ("before file check"); -// std::ifstream infile("/var/cache/rpm-ostree/cached-update.gv"); -// rpmostree_output_message ("%d", infile.good()); -// // rpmoZ -// // g_variant_builder_unref(manifest_diff_dict); - -// rpmostree_output_message ("Cache file updated"); -// // diff->total = total; -// // diff->total_size = total_size; -// // diff->total_removed = total_removed; -// // diff->removed_size = removed_size; -// // diff->total_added = total_added; -// // diff->added_size = added_size; -// return TRUE; -// } - - - /* * Like ostree_sysroot_upgrader_pull(), but also handles the `baserefspec` we * use when doing layered packages. @@ -600,36 +436,7 @@ rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self, const char if (check) { - // the use of this function might just be a red hearing, because it might have only - // been introduced to output the error message. Potential next step, just update - // all the cached update (existing and with the new manifest-diff) and the `check` - // part will just be on the builtin-upgrade side - g_autofree char *origin_remote = NULL; - g_autofree char *origin_ref = NULL; - if (!ostree_parse_refspec (r.refspec.c_str (), &origin_remote, &origin_ref, error)) - return FALSE; - - CXX_TRY_VAR ( - res, - rpmostreecxx::compare_local_to_remote_container ( - *self->repo, *cancellable, r.refspec.c_str (), origin_remote, origin_ref), - error); - - rpmostree_output_message ("%s", res.c_str ()); - // manifest_diff_add_db_diff (res.c_str (), cancellable, error); - - // rpmostree_output_message ("%s", self->osname); - - // auto obj = (RpmostreedOS *)g_object_new (RPMOSTREED_TYPE_OS, "name", self->osname, NULL); - // g_autoptr (GError) local_error = NULL; - // if (!refresh_cached_update (obj, &local_error)) - // { - // sd_journal_print (LOG_WARNING, "Failed to refresh CachedUpdate property: %s", - // local_error->message); - - // } - - *out_changed = TRUE; + *out_changed = FALSE; return TRUE; } else diff --git a/src/daemon/rpmostreed-deployment-utils.cxx b/src/daemon/rpmostreed-deployment-utils.cxx index 50ba789297..0a61e1724e 100644 --- a/src/daemon/rpmostreed-deployment-utils.cxx +++ b/src/daemon/rpmostreed-deployment-utils.cxx @@ -514,21 +514,13 @@ rpm_diff_add_db_diff (RpmDiff *diff, OstreeRepo *repo, RpmOstreePkgTypes type, return TRUE; } -#include -#include - static gboolean manifest_diff_add_db_diff (ManifestDiff *diff, std::string manifest_diff, GCancellable *cancellable, GError **error) { - rpmostree_output_message ("Before copy"); gchar *converted_manifest_diff = strcpy(new char[manifest_diff.length() + 1], manifest_diff.c_str()); - // manifest_diff = "total:51,total_size:714.8 MB,total_removed:0,removed_size:0 bytes,total_added:0,added_size:0 bytes"; - rpmostree_output_message ("Before pop"); if (!rpm_ostree_db_diff_ext_container (converted_manifest_diff, &diff->total, &diff->total_size, &diff->total_removed, &diff->removed_size, &diff->total_added, &diff->added_size, error)) return FALSE; - - rpmostree_output_message ("After pop"); return TRUE; } @@ -582,15 +574,12 @@ static gboolean manifest_diff_is_empty (ManifestDiff *diff) { g_assert (diff->initialized); + const gchar *added; const gchar *removed; g_variant_get (diff->total_removed, "s", &removed); g_variant_get (diff->total_added, "s", &added); - rpmostree_output_message ("%s", removed); - rpmostree_output_message ("%s", added); - if (!strcmp(removed, "0") && !strcmp(added, "0")) { - rpmostree_output_message ("hello"); return TRUE; } @@ -620,34 +609,28 @@ rpm_diff_variant_new (RpmDiff *diff) static GVariant * manifest_diff_variant_new (ManifestDiff *diff) { - const gchar *tmp1; - const gchar *tmp2; - const gchar *tmp3; - const gchar *tmp4; - const gchar *tmp5; - const gchar *tmp6; - - g_variant_get (diff->total, "s", &tmp1); - rpmostree_output_message ("%s", tmp1); - g_variant_get (diff->total_size, "s", &tmp2); - rpmostree_output_message ("%s", tmp2); - g_variant_get (diff->total_removed, "s", &tmp3); - rpmostree_output_message ("%s", tmp3); - g_variant_get (diff->removed_size, "s", &tmp4); - rpmostree_output_message ("%s", tmp4); - g_variant_get (diff->total_added, "s", &tmp5); - rpmostree_output_message ("%s", tmp5); - g_variant_get (diff->added_size, "s", &tmp6); - rpmostree_output_message ("%s", tmp6); + const gchar *total_str; + const gchar *total_size_str; + const gchar *total_removed_str; + const gchar *removed_size_str; + const gchar *total_added_str; + const gchar *added_size_str; + + g_variant_get (diff->total, "s", &total_str); + g_variant_get (diff->total_size, "s", &total_size_str); + g_variant_get (diff->total_removed, "s", &total_removed_str); + g_variant_get (diff->removed_size, "s", &removed_size_str); + g_variant_get (diff->total_added, "s", &total_added_str); + g_variant_get (diff->added_size, "s", &added_size_str); g_auto (GVariantDict) manifest_dict; g_variant_dict_init (&manifest_dict, NULL); - g_variant_dict_insert (&manifest_dict, "total", "s", tmp1); - g_variant_dict_insert (&manifest_dict, "total_size", "s", tmp2); - g_variant_dict_insert (&manifest_dict, "total_removed", "s", tmp3); - g_variant_dict_insert (&manifest_dict, "removed_size", "s", tmp4); - g_variant_dict_insert (&manifest_dict, "total_added", "s", tmp5); - g_variant_dict_insert (&manifest_dict, "added_size", "s", tmp6); + g_variant_dict_insert (&manifest_dict, "total", "s", total_str); + g_variant_dict_insert (&manifest_dict, "total_size", "s", total_size_str); + g_variant_dict_insert (&manifest_dict, "total_removed", "s", total_removed_str); + g_variant_dict_insert (&manifest_dict, "removed_size", "s", removed_size_str); + g_variant_dict_insert (&manifest_dict, "total_added", "s", total_added_str); + g_variant_dict_insert (&manifest_dict, "added_size", "s", added_size_str); return g_variant_dict_end (&manifest_dict); } @@ -779,8 +762,7 @@ rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment, /* let's start with the ostree side of things */ - const char *current_checksum = ostree_deployment_get_csum (booted_deployment); - rpmostree_output_message("Current check sum: %s", current_checksum); + const char *current_checksum = ostree_deployment_get_csum (booted_deployment);\ g_autofree char *current_base_checksum_owned = NULL; if (!rpmostree_deployment_get_base_layer (repo, booted_deployment, ¤t_base_checksum_owned, error)) @@ -801,32 +783,13 @@ rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment, } else { - // resolve refspec does not work for containers, so in this case, we need to make our own function to return the new_base_checksum - rpmostree_output_message("Not staged"); if (!ostree_repo_resolve_rev_ext (repo, r.refspec.c_str (), TRUE, static_cast (0), &new_base_checksum_owned, error)) { - rpmostree_output_message("No ostree checksum"); return FALSE; } - - // if (new_base_checksum == NULL) { - // const OstreeRepo &tmp_repo = *repo; - // const GCancellable &tmp_cancellable = *cancellable; - // CXX_TRY_VAR ( - // import, - // rpmostreecxx::pull_container (tmp_repo, tmp_cancellable, r.refspec.c_str ()), - // error); - - // rpmostree_output_message("Before container checksum"); - // new_base_checksum_owned = g_strdup (import->merge_commit.c_str ()); - // rpmostree_output_message("new_base_checksum_owned: %s", new_base_checksum_owned); - // } - - // rpmostree_output_message("Exit ostree checksum"); new_base_checksum = new_base_checksum_owned; - /* just assume that the hypothetical new deployment would also be layered if we are */ is_new_layered = (current_base_checksum_owned != NULL); } @@ -886,17 +849,13 @@ rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment, gboolean rpm_diff_fail = FALSE; if (is_new_checksum) { - rpmostree_output_message("is_new_checksum"); - if (!rpm_diff_add_db_diff (&rpm_diff, repo, RPM_OSTREE_PKG_TYPE_BASE, current_base_checksum, new_base_checksum, &ostree_modified_new, cancellable, error)) { - rpmostree_output_message("rpm diff failed"); rpm_diff_fail = TRUE; } } - rpmostree_output_message("exit new checksum check"); const OstreeRepo &tmp_repo = *repo; const GCancellable &tmp_cancellable = *cancellable; @@ -912,19 +871,13 @@ rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment, tmp_repo, tmp_cancellable, r.refspec.c_str (), origin_remote, origin_ref), error); - rpmostree_output_message("%s", origin_remote); - rpmostree_output_message("%s", origin_ref); - rpmostree_output_message("%s", res.c_str()); - gboolean manifest_diff_fail = FALSE; if (!manifest_diff_add_db_diff (&manifest_diff, res.c_str (), cancellable, error)) { - rpmostree_output_message("manifest diff failed"); manifest_diff_fail = TRUE; } if (rpm_diff_fail && manifest_diff_fail) { - rpmostree_output_message("both updates failed"); return FALSE; }