From 67860c5ece3f07f92ecc0aa179b4748126f740a2 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 30 Jul 2018 17:17:19 -0400 Subject: [PATCH] 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 --- src/app/rpmostree-pkg-builtins.c | 4 +++- tests/vmcheck/test-layering-basic-1.sh | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/rpmostree-pkg-builtins.c b/src/app/rpmostree-pkg-builtins.c index 3367feef..469a9c94 100644 --- a/src/app/rpmostree-pkg-builtins.c +++ b/src/app/rpmostree-pkg-builtins.c @@ -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); diff --git a/tests/vmcheck/test-layering-basic-1.sh b/tests/vmcheck/test-layering-basic-1.sh index 6c890df9..90969f32 100755 --- a/tests/vmcheck/test-layering-basic-1.sh +++ b/tests/vmcheck/test-layering-basic-1.sh @@ -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"