int rpmostree_builtin_rebase (int argc, char **argv, GCancellable *cancellable, GError **error) { int exit_status = EXIT_FAILURE; const char *new_provided_refspec; const char *revision = NULL; /* forced blank for now */ const char *packages[] = { NULL }; g_autoptr(GOptionContext) context = g_option_context_new ("REFSPEC [REVISION] - Switch to a different tree"); glnx_unref_object RPMOSTreeOS *os_proxy = NULL; glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL; g_autofree char *transaction_address = NULL; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, RPM_OSTREE_BUILTIN_FLAG_NONE, cancellable, &sysroot_proxy, error)) goto out; if (argc < 2 || argc > 3) { rpmostree_usage_error (context, "Too few or too many arguments", error); goto out; } new_provided_refspec = argv[1]; if (argc == 3) revision = argv[2]; if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname, cancellable, &os_proxy, error)) goto out; if (!rpmostree_os_call_rebase_sync (os_proxy, get_args_variant (revision), new_provided_refspec, packages, &transaction_address, cancellable, error)) goto out; if (!rpmostree_transaction_get_response_sync (sysroot_proxy, transaction_address, cancellable, error)) goto out; if (!opt_reboot) { const char *sysroot_path; sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy); /* By request, doing this without dbus */ if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path, cancellable, error)) goto out; g_print ("Run \"systemctl reboot\" to start a reboot\n"); } exit_status = EXIT_SUCCESS; out: /* Does nothing if using the message bus. */ rpmostree_cleanup_peer (); return exit_status; }
gboolean rpmostree_builtin_rebase (int argc, char **argv, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; const char *new_provided_refspec; /* forced blank for now */ const char *packages[] = { NULL }; GOptionContext *context = g_option_context_new ("REFSPEC - Switch to a different tree"); glnx_unref_object RPMOSTreeOS *os_proxy = NULL; glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL; g_autofree char *transaction_address = NULL; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, RPM_OSTREE_BUILTIN_FLAG_NONE, cancellable, &sysroot_proxy, error)) goto out; if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname, cancellable, &os_proxy, error)) goto out; new_provided_refspec = argv[1]; if (!rpmostree_os_call_rebase_sync (os_proxy, get_args_variant (), new_provided_refspec, packages, &transaction_address, cancellable, error)) goto out; if (!rpmostree_transaction_get_response_sync (sysroot_proxy, transaction_address, cancellable, error)) goto out; if (!opt_reboot) { const char *sysroot_path; sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy); /* By request, doing this without dbus */ if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path, cancellable, error)) goto out; g_print ("Run \"systemctl reboot\" to start a reboot\n"); } ret = TRUE; out: /* Does nothing if using the message bus. */ rpmostree_cleanup_peer (); return ret; }