From 4f36c07f1a777d053474c75368e4c8bb961e70cf Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 11 Jun 2023 15:54:40 +0100 Subject: locmaint: don't do some other parts of sysmaint during suite upgrade --- bin/locmaint | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'bin/locmaint') diff --git a/bin/locmaint b/bin/locmaint index 523dd5a0..9cb01bce 100755 --- a/bin/locmaint +++ b/bin/locmaint @@ -225,7 +225,8 @@ sub main { close $sources_out; say_spaced_bullet("Host's /etc/apt/sources.list updated as shown."); get_ack(); - do_sysmaint(); + do_apt_update(); + do_apt_upgrade(); say_bold("Update host's suite in consfig and deploy, before reboot."); get_ack(); do_maybe_reboot(); @@ -537,9 +538,7 @@ sub do_sysmaint { "Clean up some files if host does not have enough disc space"); get_ack(); - script_status("updating apt indices"); - system as_root("apt-get update"); - die "apt-get update failed" unless $? == 0; + do_apt_update(); unless (@rc_packages == 0) { say_bold("Conf-files packages:"); print " rc $_\n" for @rc_packages; @@ -580,27 +579,7 @@ sub do_sysmaint { system as_root("apt-get -y purge @obsolete_packages") if prompt_yn("Purge these?"); } - # the first apt-get call is equivalent to `apt upgrade` (at the - # time of writing) and has the advantage over plain `apt-get - # upgrade` that new Recommends won't be missed, which is possible - # with plain `apt-get upgrade`. (Arguably plain `apt-get upgrade` - # should never be used and its semantics were a poor design - # choice.) - script_status("doing apt upgrade"); - interactive_ensure_subroutine_success( - sub { system_pty_capture(as_root("apt-get --with-new-pkgs upgrade")) } - ); - interactive_ensure_subroutine_success( - sub { system_pty_capture(as_root("apt-get dist-upgrade")) } - ); - script_status("doing apt autoremove"); - interactive_ensure_subroutine_success( - sub { system_pty_capture(as_root("apt-get -y autoremove")) } - ); - script_status("autocleaning apt's cache"); - interactive_ensure_subroutine_success( - sub { system_pty_capture(as_root("apt-get autoclean")) } - ); + do_apt_upgrade(); my $mailq = executable_find "mailq"; if (-x $mailq and -x executable_find "dpkg-query") { @@ -675,8 +654,34 @@ sub do_sysmaint { } } +sub do_apt_update { + script_status("updating apt indices"); + system as_root("apt-get update"); + die "apt-get update failed" unless $? == 0; +} + +sub do_apt_upgrade { + # The first apt-get call is equivalent to `apt upgrade` (at the time of + # writing) and has the advantage over plain `apt-get upgrade` that new + # Recommends won't be missed, which is possible with plain `apt-get + # upgrade`. (Arguably plain `apt-get upgrade` should never be used and + # its semantics were a poor design choice.) + script_status("doing apt upgrade"); + interactive_ensure_subroutine_success( + sub { system_pty_capture(as_root("apt-get --with-new-pkgs upgrade")) } + ); + interactive_ensure_subroutine_success( + sub { system_pty_capture(as_root("apt-get dist-upgrade")) }); + script_status("doing apt autoremove"); + interactive_ensure_subroutine_success( + sub { system_pty_capture(as_root("apt-get -y autoremove")) }); + script_status("autocleaning apt's cache"); + interactive_ensure_subroutine_success( + sub { system_pty_capture(as_root("apt-get autoclean")) }); +} + sub do_maybe_reboot { - if (($suite ne STABLE || -e "/var/run/reboot-required") + if (($suite && $suite ne STABLE || -e "/var/run/reboot-required") && prompt_yn("Should reboot; do it now?")) { exec as_root("reboot"); } -- cgit v1.2.3