From 2187ef0f4504589d7a019af8c6fba6b44bcc79d9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 11 Mar 2021 22:07:21 +0000 Subject: [PATCH] live: Don't output "services restart" for pure package additions If all we're doing is layering new packages, no need to tell the admin that things may need restarting. --- rust/src/builtins/apply_live.rs | 14 +++++++++----- tests/kolainst/destructive/apply-live | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rust/src/builtins/apply_live.rs b/rust/src/builtins/apply_live.rs index 2f8e5467..2dd803da 100644 --- a/rust/src/builtins/apply_live.rs +++ b/rust/src/builtins/apply_live.rs @@ -52,12 +52,12 @@ fn get_args_variant(sysroot: &ostree::Sysroot, opts: &Opts) -> Result) -> Result<()> { - let opts = Opts::from_iter(args.iter()); + let opts = &Opts::from_iter(args.iter()); let client = &mut crate::client::ClientConnection::new()?; let sysroot = &ostree::Sysroot::new_default(); sysroot.load(gio::NONE_CANCELLABLE)?; - let args = get_args_variant(sysroot, &opts)?; + let args = get_args_variant(sysroot, opts)?; let params = crate::variant_utils::new_variant_tuple(&[args]); let reply = &client.get_os_ex_proxy().call_sync( @@ -97,8 +97,12 @@ fn finish(sysroot: &ostree::Sysroot) -> Result<()> { }; pkgdiff.print(); - crate::ffi::output_message( - "Successfully updated running filesystem tree; some services may need to be restarted.", - ); + if pkgdiff.n_removed() == 0 && pkgdiff.n_modified() == 0 { + crate::ffi::output_message("Successfully updated running filesystem tree."); + } else { + crate::ffi::output_message( + "Successfully updated running filesystem tree; some services may need to be restarted.", + ); + } Ok(()) } diff --git a/tests/kolainst/destructive/apply-live b/tests/kolainst/destructive/apply-live index 5522e187..33ee94b0 100755 --- a/tests/kolainst/destructive/apply-live +++ b/tests/kolainst/destructive/apply-live @@ -96,7 +96,8 @@ rm -rf /etc/testpkg-etc \ echo myconfig > /etc/testpkg-etc-other.conf grep myconfig /etc/testpkg-etc-other.conf -rpm-ostree install -A testpkg-etc testdaemon +rpm-ostree install -A testpkg-etc testdaemon | tee out.txt +assert_file_has_content_literal out.txt 'Successfully updated running filesystem tree.' rpm -q bar test{pkg-etc,daemon} > rpmq.txt assert_file_has_content rpmq.txt bar-1.0-1 test{pkg-etc,daemon}-1.0-1 cat /etc/testpkg-etc.conf > testpkg-etc.conf