summaryrefslogtreecommitdiff
path: root/bin/locmaint
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-06-11 15:54:40 +0100
committerSean Whitton <spwhitton@spwhitton.name>2023-06-11 15:55:19 +0100
commit4f36c07f1a777d053474c75368e4c8bb961e70cf (patch)
treee3308b69fc0396e200c0719c4580bb4c663bca46 /bin/locmaint
parent7c207bdd598d8b9911ad96ee449bdfdafe4020c5 (diff)
downloaddotfiles-4f36c07f1a777d053474c75368e4c8bb961e70cf.tar.gz
locmaint: don't do some other parts of sysmaint during suite upgrade
Diffstat (limited to 'bin/locmaint')
-rwxr-xr-xbin/locmaint57
1 files changed, 31 insertions, 26 deletions
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");
}