app/pkg-builtins: Add --unchanged-exit-77

This is analogous to `upgrade --upgrade-unchanged-exit-77`, but for
`install`/`uninstall`. This way, one can determine whether the command
truly had an effect on the default deployment or not.

Since this works by comparing against the previous default deployment,
this works correctly even if we already had a pending deployment at the
beginning of the transaction.

Closes: #1478
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-07-30 17:17:19 -04:00 committed by Atomic Bot
parent d35fbb665e
commit 67860c5ece
2 changed files with 8 additions and 2 deletions

View File

@ -39,6 +39,7 @@ static gboolean opt_cache_only;
static gboolean opt_download_only;
static gboolean opt_allow_inactive;
static gboolean opt_uninstall_all;
static gboolean opt_unchanged_exit_77;
static GOptionEntry option_entries[] = {
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
@ -46,6 +47,7 @@ static GOptionEntry option_entries[] = {
{ "dry-run", 'n', 0, G_OPTION_ARG_NONE, &opt_dry_run, "Exit after printing the transaction", NULL },
{ "allow-inactive", 0, 0, G_OPTION_ARG_NONE, &opt_allow_inactive, "Allow inactive package requests", NULL },
{ "idempotent", 0, 0, G_OPTION_ARG_NONE, &opt_idempotent, "Do nothing if package already (un)installed", NULL },
{ "unchanged-exit-77", 0, 0, G_OPTION_ARG_NONE, &opt_unchanged_exit_77, "If no overlays were changed, exit 77", NULL },
{ NULL }
};
@ -133,7 +135,7 @@ pkg_change (RpmOstreeCommandInvocation *invocation,
}
return rpmostree_transaction_client_run (invocation, sysroot_proxy, os_proxy,
options, FALSE,
options, opt_unchanged_exit_77,
transaction_address,
previous_deployment,
cancellable, error);

View File

@ -109,7 +109,10 @@ if vm_rpmostree uninstall foo-1.0 &> out.txt; then
fi
assert_file_has_content_literal out.txt 'not currently requested'
vm_rpmostree uninstall foo-1.0 --idempotent
rc=0
vm_rpmostree uninstall foo-1.0 --idempotent --unchanged-exit-77 || rc=$?
assert_streq $old_pending $(vm_get_pending_csum)
assert_streq $rc 77
echo "ok idempotent uninstall"
# Test `rpm-ostree status --pending-exit-77`
@ -118,7 +121,8 @@ vm_rpmostree status --pending-exit-77 || rc=$?
assert_streq $rc 77
# Test that we don't do progress bars if on a tty (with the client)
vm_rpmostree install foo-1.0 > foo-install.txt
# (And use --unchanged-exit-77 to verify that we *don't* exit 77).
vm_rpmostree install foo-1.0 --unchanged-exit-77 > foo-install.txt
assert_file_has_content_literal foo-install.txt 'Checking out packages (1/1) 100%'
echo "ok install not on a tty"