app: Split upgrade --check-diff into separate options

rpm-ostree upgrade --preview   - Just preview package differences,
                                 like deploy --preview
rpm-ostree upgrade --check     - Just check if an upgrade is available

In both cases, the exit codes are 0 (upgrade available), 77 (no upgrade
available) and 1 (error).

The --check-diff option still works but is deprecated and not shown in
the --help option listing.
This commit is contained in:
Matthew Barnes 2015-11-02 20:15:34 -05:00
parent 1c01141e0c
commit 6114255b8e
2 changed files with 27 additions and 9 deletions

View File

@ -115,7 +115,9 @@ Boston, MA 02111-1307, USA.
<para><command>--allow-downgrade</command> to permit deployment of chronologically older trees.</para>
<para><option>--check-diff</option> to download only /usr/share/rpm in order to do a package-level diff between the two versions.</para>
<para><option>--preview</option> to download only /usr/share/rpm in order to do a package-level diff between the two versions.</para>
<para><option>--check</option> to just check if an upgrade is available, without downloading it or performing a package-level diff.</para>
</listitem>
</varlistentry>

View File

@ -35,13 +35,17 @@
static char *opt_osname;
static gboolean opt_reboot;
static gboolean opt_allow_downgrade;
static gboolean opt_check_diff;
static gboolean opt_preview;
static gboolean opt_check;
/* "check-diff" is deprecated, replaced by "preview" */
static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after an upgrade is prepared", NULL },
{ "allow-downgrade", 0, 0, G_OPTION_ARG_NONE, &opt_allow_downgrade, "Permit deployment of chronologically older trees", NULL },
{ "check-diff", 0, 0, G_OPTION_ARG_NONE, &opt_check_diff, "Check for upgrades and print package diff only", NULL },
{ "check-diff", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_preview, "Check for upgrades and print package diff only", NULL },
{ "preview", 0, 0, G_OPTION_ARG_NONE, &opt_preview, "Just preview package differences", NULL },
{ "check", 0, 0, G_OPTION_ARG_NONE, &opt_check, "Just check if an upgrade is available", NULL },
{ NULL }
};
@ -89,18 +93,29 @@ rpmostree_builtin_upgrade (int argc,
error))
goto out;
if (opt_check_diff && opt_reboot)
if (opt_reboot && opt_preview)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"cannot specify both --reboot and --check-diff");
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Cannot specify both --reboot and --preview");
goto out;
}
if (opt_reboot && opt_check)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Cannot specify both --reboot and --check");
goto out;
}
/* If both --check and --preview were passed, --preview overrides. */
if (opt_preview)
opt_check = FALSE;
if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname,
cancellable, &os_proxy, error))
goto out;
if (opt_check_diff)
if (opt_preview || opt_check)
{
if (!rpmostree_os_call_download_update_rpm_diff_sync (os_proxy,
&transaction_address,
@ -128,7 +143,7 @@ rpmostree_builtin_upgrade (int argc,
error))
goto out;
if (opt_check_diff)
if (opt_preview || opt_check)
{
g_autoptr(GVariant) result = NULL;
g_autoptr(GVariant) details = NULL;
@ -147,7 +162,8 @@ rpmostree_builtin_upgrade (int argc,
goto out;
}
rpmostree_print_package_diffs (result);
if (!opt_check)
rpmostree_print_package_diffs (result);
}
else if (!opt_reboot)
{