aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--README.md58
-rwxr-xr-xbin/pacman-offline66
-rw-r--r--config/offline-include.conf2
-rw-r--r--config/offline.conf2
-rw-r--r--desktop/pacman-offline.desktop11
-rw-r--r--hook/99-pacman-offline.hook2
-rwxr-xr-xsystemd/pacman-offline51
-rw-r--r--systemd/pacman-offline-done-poweroff.service22
-rw-r--r--systemd/pacman-offline-done-reboot.service22
-rw-r--r--systemd/pacman-offline-prepare.service6
-rw-r--r--systemd/pacman-offline-prepare.timer3
-rw-r--r--systemd/pacman-offline-reboot.service14
-rw-r--r--systemd/pacman-offline-reboot.timer4
-rw-r--r--systemd/pacman-offline.service14
15 files changed, 207 insertions, 77 deletions
diff --git a/Makefile b/Makefile
index 3f9ffb8..4a25222 100644
--- a/Makefile
+++ b/Makefile
@@ -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.8
all: README.html
@@ -20,13 +20,16 @@ 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 desktop/pacman-offline.desktop $(DESTDIR)/usr/share/applications/pacman-offline.desktop
$(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
diff --git a/README.md b/README.md
index 6beb1a7..3a510fa 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,35 @@
pacman-offline
==============
+[![GitHub stars](https://img.shields.io/github/stars/eworm-de/pacman-offline?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/pacman-offline/stargazers)
+[![GitHub forks](https://img.shields.io/github/forks/eworm-de/pacman-offline?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/pacman-offline/network)
+[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/pacman-offline?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/pacman-offline/watchers)
+
**Run offline system update with pacman.**
The offline system update with pacman is achieved by integrating into
-[offline updates in systemd](https://www.freedesktop.org/software/systemd/man/systemd.offline-updates.html).
+[offline updates in systemd ↗️](https://www.freedesktop.org/software/systemd/man/systemd.offline-updates.html).
In fact only two scripts and a number of systemd unit files are used to
glue `systemd` and `pacman`.
+*Use at your own risk*, pay attention to
+[license and warranty](#license-and-warranty), and
+[disclaimer on external links](#disclaimer-on-external-links)!
+
Requirements
------------
There are the runtime dependencies:
-* [pacman](https://archlinux.org/pacman/)
-* [systemd](https://www.github.com/systemd/systemd)
+* [pacman ↗️](https://archlinux.org/pacman/)
+* [systemd ↗️](https://www.github.com/systemd/systemd)
And there's an optional dependency to support elevating privileges:
-* [polkit](https://github.com/polkit-org/polkit)
+* [polkit ↗️](https://github.com/polkit-org/polkit)
Optional basic support for
-[plymouth](https://www.freedesktop.org/wiki/Software/Plymouth/) is
+[plymouth ↗️](https://www.freedesktop.org/wiki/Software/Plymouth/) is
integrated.
Usage
@@ -67,19 +75,29 @@ You can enable a timer for nightly reboot:
This will trigger at night, if updates are pending and prepared.
+### Desktop environment
+
+A *desktop file* is installed to allow preparing from a desktop
+environment. Have a look at your application menu...
+
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
+
+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.
-It will cause `pacman` to ignore linux packages and prevent breaking module
-loading. These packages are not ignored on offline update.
+The second one has the opposite effect, it is included on offline action
+only.
-Modify `/etc/pacman.d/offline.conf` to your needs by changing or adding
-packages.
+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
--------------------
@@ -94,6 +112,21 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[GNU General Public License](COPYING.md) for more details.
+Disclaimer on external links
+----------------------------
+
+Our website contains links to the websites of third parties ("external
+links"). As the content of these websites is not under our control, we
+cannot assume any liability for such external content. In all cases, the
+provider of information of the linked websites is liable for the content
+and accuracy of the information provided. At the point in time when the
+links were placed, no infringements of the law were recognisable to us.
+As soon as an infringement of the law becomes known to us, we will
+immediately remove the link in question.
+
+> 💡️ **Hint**: All external links are marked with an arrow pointing
+> diagonally in an up-right (or north-east) direction (↗️).
+
### Upstream
URL:
@@ -102,3 +135,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..73723af 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
@@ -10,16 +10,18 @@
set -e
function help() {
- echo "usage: ${0} [OPTIONS]"
- echo
- echo ' -a abort pending system-update'
- echo ' -c clean before download'
- echo ' -f force if other system-update is pending'
- echo ' -h this help'
- echo ' -p reboot, install and poweroff immediately'
- echo ' -r reboot and install immediately'
- echo ' -t start timer for nightly reboot'
- echo ' -y update sync databases'
+ cat <<-EOM
+ usage: ${0} [OPTIONS]
+
+ -a abort pending system-update
+ -c clean before download
+ -f force if other system-update is pending
+ -h this help
+ -p reboot, install and poweroff immediately
+ -r reboot and install immediately
+ -t start timer for nightly reboot
+ -y update sync databases
+ EOM
}
CLEAN=0
@@ -107,14 +109,17 @@ 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
# check for available updates
if [ "$(pacman --config /run/pacman.conf --sync --sysupgrade --print | wc -l)" -eq 0 ]; then
- echo "No updates available."
+ echo 'No updates available.'
exit 0
fi
@@ -129,32 +134,39 @@ 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
+echo 'Updates will be installed on next reboot.'
+
# start timer if requested
if [ ${TIMER} -eq 1 ]; then
systemctl start pacman-offline-reboot.timer
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/desktop/pacman-offline.desktop b/desktop/pacman-offline.desktop
new file mode 100644
index 0000000..2228c55
--- /dev/null
+++ b/desktop/pacman-offline.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Version=1.0
+Name=pacman-offline
+GenericName=Offline System Update
+Comment=Download and prepare Offline System Update
+Icon=system-software-update
+Exec=sh -c 'pacman-offline -cy; echo Press ENTER to close.; read'
+Terminal=true
+Categories=System;PackageManager
+Keywords=system;PackageManager
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