diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 20 | ||||
-rwxr-xr-x | bin/pacman-offline | 40 | ||||
-rw-r--r-- | config/offline-include.conf | 2 | ||||
-rw-r--r-- | config/offline.conf | 2 | ||||
-rw-r--r-- | hook/99-pacman-offline.hook | 2 | ||||
-rwxr-xr-x | systemd/pacman-offline | 51 | ||||
-rw-r--r-- | systemd/pacman-offline-done-poweroff.service | 22 | ||||
-rw-r--r-- | systemd/pacman-offline-done-reboot.service | 22 | ||||
-rw-r--r-- | systemd/pacman-offline-prepare.service | 6 | ||||
-rw-r--r-- | systemd/pacman-offline-prepare.timer | 3 | ||||
-rw-r--r-- | systemd/pacman-offline-reboot.service | 14 | ||||
-rw-r--r-- | systemd/pacman-offline-reboot.timer | 4 | ||||
-rw-r--r-- | systemd/pacman-offline.service | 14 |
14 files changed, 147 insertions, 61 deletions
@@ -7,7 +7,7 @@ SED := sed # this is just a fallback in case you do not # use git but downloaded a release tarball... -VERSION := 0.3.2 +VERSION := 0.3.7 all: README.html @@ -20,13 +20,15 @@ install: install-bin install-doc install-bin: $(INSTALL) -D -m0755 bin/pacman-offline $(DESTDIR)/usr/bin/pacman-offline $(INSTALL) -D -m0644 config/offline.conf $(DESTDIR)/etc/pacman.d/offline.conf + $(INSTALL) -D -m0644 config/offline-include.conf $(DESTDIR)/etc/pacman.d/offline-include.conf $(INSTALL) -D -m0644 hook/99-pacman-offline.hook $(DESTDIR)/usr/share/libalpm/hooks/99-pacman-offline.hook $(INSTALL) -D -m0644 polkit/pacman-offline.rules $(DESTDIR)/usr/share/polkit-1/rules.d/pacman-offline.rules $(INSTALL) -D -m0644 systemd/pacman-offline.service $(DESTDIR)/usr/lib/systemd/system/pacman-offline.service $(INSTALL) -D -m0755 systemd/pacman-offline $(DESTDIR)/usr/lib/systemd/scripts/pacman-offline + $(INSTALL) -D -m0644 systemd/pacman-offline-done-poweroff.service $(DESTDIR)/usr/lib/systemd/system/pacman-offline-done-poweroff.service + $(INSTALL) -D -m0644 systemd/pacman-offline-done-reboot.service $(DESTDIR)/usr/lib/systemd/system/pacman-offline-done-reboot.service $(INSTALL) -D -m0644 systemd/pacman-offline-prepare.service $(DESTDIR)/usr/lib/systemd/system/pacman-offline-prepare.service $(INSTALL) -D -m0644 systemd/pacman-offline-prepare.timer $(DESTDIR)/usr/lib/systemd/system/pacman-offline-prepare.timer - $(INSTALL) -D -m0644 systemd/pacman-offline-reboot.service $(DESTDIR)/usr/lib/systemd/system/pacman-offline-reboot.service $(INSTALL) -D -m0644 systemd/pacman-offline-reboot.timer $(DESTDIR)/usr/lib/systemd/system/pacman-offline-reboot.timer $(INSTALL) -d -m0755 $(DESTDIR)/usr/lib/systemd/system/system-update.target.wants/ $(LN) -s ../pacman-offline.service $(DESTDIR)/usr/lib/systemd/system/system-update.target.wants/pacman-offline.service @@ -70,16 +70,21 @@ This will trigger at night, if updates are pending and prepared. Configuration ------------- -A sinppet for inclusion in `/etc/pacman.conf` is shipped. To make use of -it add this line: +Two snippets for inclusion in `/etc/pacman.conf` are shipped. To make use of +them add these line: Include = /etc/pacman.d/offline.conf + #Include = /etc/pacman.d/offline-include.conf -It will cause `pacman` to ignore linux packages and prevent breaking module -loading. These packages are not ignored on offline update. +The first one will cause `pacman` to ignore linux packages and prevent +breaking module loading and hibernation. These packages are not ignored +on offline update. -Modify `/etc/pacman.d/offline.conf` to your needs by changing or adding -packages. +The second one has the opposite effect, it is included on offline action +only. + +Modify `/etc/pacman.d/offline.conf` and `/etc/pacman.d/offline-include.conf` +to your needs by changing or adding packages, or adding new directives. License and warranty -------------------- @@ -102,3 +107,6 @@ URL: Mirror: [eworm.de](https://git.eworm.de/cgit.cgi/pacman-offline/) [GitLab.com](https://gitlab.com/eworm-de/pacman-offline#pacman-offline) + +--- +[⬆️ Go back to top](#top) diff --git a/bin/pacman-offline b/bin/pacman-offline index cb46cb4..181aa74 100755 --- a/bin/pacman-offline +++ b/bin/pacman-offline @@ -1,6 +1,6 @@ #!/bin/sh -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -107,7 +107,10 @@ fi # exclude /etc/pacman.d/offline.conf function finish { rm -f /run/pacman.conf; } trap finish EXIT -sed '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' < /etc/pacman.conf > /run/pacman.conf +sed \ + -e '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' \ + -e '/^#Include *= *\/etc\/pacman\.d\/offline-include\.conf$/s|^#||' \ + < /etc/pacman.conf > /run/pacman.conf # remove the symlink for now, will be recreated it later rm -f /system-update @@ -129,26 +132,29 @@ pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade --downloadonly # enable system update ln -sf /var/cache/pacman/pkg /system-update if [ ${POWEROFF} -eq 1 ]; then - touch /run/system-update-poweroff + touch /run/pacman-offline-poweroff fi -# (soft-)reboot if requested -if [ ${REBOOT} -eq 1 ]; then - echo "Soft-rebooting for update." - systemctl soft-reboot -else - # force a soft-reboot on (manual) reboot ... - ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service /run/systemd/system/systemd-reboot.service +# force a soft-reboot on (manual) reboot ... +ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service \ + /run/systemd/system/systemd-reboot.service - # ... and also on poweroff, but prepare poweroff - cp /usr/lib/systemd/system/systemd-soft-reboot.service /run/systemd/system/systemd-poweroff.service - cat >> /run/systemd/system/systemd-poweroff.service <<-EOF +# ... and also on poweroff, but prepare poweroff +cp /usr/lib/systemd/system/systemd-soft-reboot.service \ + /run/systemd/system/systemd-poweroff.service +cat >> /run/systemd/system/systemd-poweroff.service <<-EOF [Service] - ExecStart=/usr/bin/touch /run/system-update-poweroff + ExecStart=/usr/bin/touch /run/pacman-offline-poweroff EOF - systemctl daemon-reload +# reload for service changes +systemctl daemon-reload + +# (soft-)reboot if requested +if [ ${REBOOT} -eq 1 ]; then + echo 'Rebooting for update.' + exec systemctl reboot fi # start timer if requested @@ -157,4 +163,6 @@ if [ ${TIMER} -eq 1 ]; then fi # show the timer (if active) -systemctl --quiet --no-pager list-timers pacman-offline-prepare.timer pacman-offline-reboot.timer +systemctl --quiet --no-pager list-timers \ + pacman-offline-prepare.timer \ + pacman-offline-reboot.timer diff --git a/config/offline-include.conf b/config/offline-include.conf new file mode 100644 index 0000000..879919e --- /dev/null +++ b/config/offline-include.conf @@ -0,0 +1,2 @@ +# Add this file as commented include, and it will be included on +# offline action. diff --git a/config/offline.conf b/config/offline.conf index 56f8b76..97e78e3 100644 --- a/config/offline.conf +++ b/config/offline.conf @@ -1,4 +1,4 @@ -# Ingore linux packages and prevent breaking module loading. The include of +# Ignore linux packages and prevent breaking module loading. The include of # this configuration file is removed on offline action. IgnorePkg = linux linux-headers linux-docs IgnorePkg = linux-lts linux-lts-headers linux-lts-docs diff --git a/hook/99-pacman-offline.hook b/hook/99-pacman-offline.hook index 0586d6a..12da360 100644 --- a/hook/99-pacman-offline.hook +++ b/hook/99-pacman-offline.hook @@ -7,5 +7,5 @@ Target = * [Action] Description = Aborting pending pacman offline system-update... -When = PostTransaction +When = PreTransaction Exec = /usr/bin/pacman-offline -a diff --git a/systemd/pacman-offline b/systemd/pacman-offline index 9bae2ee..f7ba48a 100755 --- a/systemd/pacman-offline +++ b/systemd/pacman-offline @@ -1,6 +1,6 @@ #!/bin/sh -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,16 +14,29 @@ if [ "$(readlink '/system-update')" != '/var/cache/pacman/pkg' ]; then exit 0 fi -# exclude /etc/pacman.d/offline.conf -function finish { rm -f /run/pacman.conf; } -trap finish EXIT -sed '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' < /etc/pacman.conf > /run/pacman.conf - -# remove triggering symlink and reboot & poweroff override +# force the proper action on failure, ... +if [ -e '/run/pacman-offline-poweroff' ]; then + ln -sf ../../../usr/lib/systemd/system/poweroff.target \ + /run/systemd/system/pacman-offline-failure.target +else + ln -sf ../../../usr/lib/systemd/system/reboot.target \ + /run/systemd/system/pacman-offline-failure.target +fi +# ... remove triggering symlink and reboot & poweroff override, ... rm --force \ /system-update \ /run/systemd/system/systemd-poweroff.service \ /run/systemd/system/systemd-reboot.service +# ... and reload +systemctl daemon-reload + +# exclude /etc/pacman.d/offline.conf +function finish { rm -f /run/pacman.conf; } +trap finish EXIT +sed \ + -e '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' \ + -e '/^#Include *= *\/etc\/pacman\.d\/offline-include\.conf$/s|^#||' \ + < /etc/pacman.conf > /run/pacman.conf # install updates if [ "$(pacman --sync --print --needed archlinux-keyring | wc -l)" -gt 0 ]; then @@ -31,14 +44,24 @@ if [ "$(pacman --sync --print --needed archlinux-keyring | wc -l)" -gt 0 ]; then fi pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade +# clean up config file, drop trap +rm -f /run/pacman.conf +trap - EXIT + # clean up package cache pacman --sync --noconfirm --clean -# poweroff or (soft-)reboot -if [ -e '/run/system-update-poweroff' ]; then - systemctl poweroff -elif [ -s "/usr/lib/modules/$(uname -r)/pkgbase" ]; then - systemctl soft-reboot -else - systemctl reboot +# sync the storage +sync + +# prepare for soft-reboot via override when applicable +if [ ! -e '/run/pacman-offline-poweroff' -a \ + -s "/usr/lib/modules/$(uname -r)/pkgbase" ]; then + ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service \ + /run/systemd/system/systemd-reboot.service + systemctl daemon-reload fi + +# All done, just touch a status file and exit successfully! +# (Soft-)Reboot or Poweroff is done by specific units. +touch /run/pacman-offline-done diff --git a/systemd/pacman-offline-done-poweroff.service b/systemd/pacman-offline-done-poweroff.service new file mode 100644 index 0000000..441daa9 --- /dev/null +++ b/systemd/pacman-offline-done-poweroff.service @@ -0,0 +1,22 @@ +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + + +[Unit] +Description=Offline system update with pacman - Poweroff +Documentation=https://pacman-offline.eworm.de/ +After=pacman-offline.service +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target system-update.target +ConditionPathExists=/run/pacman-offline-done +ConditionPathExists=/run/pacman-offline-poweroff +SuccessAction=poweroff + +[Service] +Type=oneshot +ExecStart=/usr/bin/rm --force /run/pacman-offline-done /run/pacman-offline-poweroff diff --git a/systemd/pacman-offline-done-reboot.service b/systemd/pacman-offline-done-reboot.service new file mode 100644 index 0000000..b4e7b48 --- /dev/null +++ b/systemd/pacman-offline-done-reboot.service @@ -0,0 +1,22 @@ +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + + +[Unit] +Description=Offline system update with pacman - Reboot +Documentation=https://pacman-offline.eworm.de/ +After=pacman-offline.service +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target system-update.target +ConditionPathExists=/run/pacman-offline-done +ConditionPathExists=!/run/pacman-offline-poweroff +SuccessAction=reboot + +[Service] +Type=oneshot +ExecStart=/usr/bin/rm --force /run/pacman-offline-done /run/systemd/system/systemd-reboot.service diff --git a/systemd/pacman-offline-prepare.service b/systemd/pacman-offline-prepare.service index c9b5ba5..deb746b 100644 --- a/systemd/pacman-offline-prepare.service +++ b/systemd/pacman-offline-prepare.service @@ -1,4 +1,4 @@ -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -7,7 +7,11 @@ [Unit] Description=Prepare pacman offline system-update +Documentation=https://pacman-offline.eworm.de/ ConditionPathExists=!/var/lib/pacman/db.lck +# Synchronizing databases needs network, see https://systemd.io/NETWORK_ONLINE/ +After=network-online.target +Wants=network-online.target [Service] Type=oneshot diff --git a/systemd/pacman-offline-prepare.timer b/systemd/pacman-offline-prepare.timer index 598b387..c4a2cdf 100644 --- a/systemd/pacman-offline-prepare.timer +++ b/systemd/pacman-offline-prepare.timer @@ -1,4 +1,4 @@ -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -7,6 +7,7 @@ [Unit] Description=Prepare pacman offline system-update +Documentation=https://pacman-offline.eworm.de/ [Timer] OnBootSec=5min diff --git a/systemd/pacman-offline-reboot.service b/systemd/pacman-offline-reboot.service deleted file mode 100644 index c131d70..0000000 --- a/systemd/pacman-offline-reboot.service +++ /dev/null @@ -1,14 +0,0 @@ -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -[Unit] -Description=Soft-reboot for pacman offline system-update -ConditionPathExists=/system-update - -[Service] -Type=oneshot -ExecStart=/usr/bin/systemctl soft-reboot diff --git a/systemd/pacman-offline-reboot.timer b/systemd/pacman-offline-reboot.timer index b6852a9..024c9da 100644 --- a/systemd/pacman-offline-reboot.timer +++ b/systemd/pacman-offline-reboot.timer @@ -1,4 +1,4 @@ -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -7,10 +7,12 @@ [Unit] Description=Reboot for pacman offline system-update +Documentation=https://pacman-offline.eworm.de/ [Timer] OnCalendar=03:00:00 RandomizedDelaySec=2hours +Unit=systemd-reboot.service [Install] WantedBy=timers.target diff --git a/systemd/pacman-offline.service b/systemd/pacman-offline.service index 516acae..9ce6639 100644 --- a/systemd/pacman-offline.service +++ b/systemd/pacman-offline.service @@ -1,4 +1,4 @@ -# (C) 2017-2024 by Christian Hesse <mail@eworm.de> +# (C) 2017-2025 by Christian Hesse <mail@eworm.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -7,17 +7,23 @@ [Unit] Description=Offline system update with pacman +Documentation=https://pacman-offline.eworm.de/ ConditionPathIsSymbolicLink=/system-update DefaultDependencies=false Requires=sysinit.target dbus.socket -After=sysinit.target dbus.socket -Before=shutdown.target system-update.target -OnFailure=reboot.target +Wants=pacman-offline-done-poweroff.service pacman-offline-done-reboot.service +After=sysinit.target system-update-pre.target dbus.socket +Before=pacman-offline-done-poweroff.service pacman-offline-done-reboot.service system-update.target +OnFailure=pacman-offline-failure.target [Service] Type=oneshot +# Pretty print to tty... StandardOutput=tty StandardError=tty +# ... or use this for debugging - less pretty, but with output in journal. +#StandardOutput=journal+console +#StandardError=journal+console ExecStartPre=-/usr/bin/plymouth change-mode --updates ExecStartPre=-/usr/bin/plymouth system-update --progress=20 ExecStart=/usr/lib/systemd/scripts/pacman-offline |