summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-01-28 11:16:55 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-01-28 11:33:01 +0100
commit65c8e0638b90d619ea8450f37af832af9b657fd1 (patch)
tree5e55944034fa0aca3d89fab12076820a09e616e4
parent54bed85724efa95898610fed877d2eedbe7c23c7 (diff)
downloadpacman-offline-65c8e0638b90d619ea8450f37af832af9b657fd1.tar.gz
pacman-offline-65c8e0638b90d619ea8450f37af832af9b657fd1.tar.zst
act on specific packages on offline action only
This adds a configuration file /etc/pacman.d/offline.conf that can be included to global pacman configuration file /etc/pacman.conf. By default it contains configuration to ignore linux packages. On offline action this include is removed, allowing to update linux packages on offline action only. This prevents from breaking module loading in a running system.
-rw-r--r--Makefile1
-rwxr-xr-xbin/pacman-offline9
-rw-r--r--config/offline.conf6
-rwxr-xr-xsystemd/pacman-offline7
4 files changed, 20 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index e587c7b..37bf3cb 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ all: README.html
install:
$(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 hook/99-pacman-offline.hook $(DESTDIR)/usr/share/libalpm/hooks/99-pacman-offline.hook
$(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
diff --git a/bin/pacman-offline b/bin/pacman-offline
index 534a0a9..0105f54 100755
--- a/bin/pacman-offline
+++ b/bin/pacman-offline
@@ -37,17 +37,22 @@ if [ -e '/system-update' -a "$(readlink '/system-update')" != '/var/cache/pacman
exit 1
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 the symlink for now, will be recreated it later
rm -f /system-update
# check for available updates
-if [ "$(pacman --sync --sysupgrade --print | wc -l)" -eq 0 ]; then
+if [ "$(pacman --config /run/pacman.conf --sync --sysupgrade --print | wc -l)" -eq 0 ]; then
echo "No updates available."
exit 0
fi
# download packages
-pacman --sync --noconfirm --sysupgrade --downloadonly
+pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade --downloadonly
# enable system update
ln -sf /var/cache/pacman/pkg /system-update
diff --git a/config/offline.conf b/config/offline.conf
new file mode 100644
index 0000000..56f8b76
--- /dev/null
+++ b/config/offline.conf
@@ -0,0 +1,6 @@
+# Ingore 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
+IgnorePkg = linux-zen linux-zen-headers linux-zen-docs
+IgnorePkg = linux-hardened linux-hardened-headers linux-hardened-docs
diff --git a/systemd/pacman-offline b/systemd/pacman-offline
index 3e9133b..39ed094 100755
--- a/systemd/pacman-offline
+++ b/systemd/pacman-offline
@@ -7,6 +7,11 @@ 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
rm -f /system-update
@@ -14,7 +19,7 @@ rm -f /system-update
if [ "$(pacman --sync --print --needed archlinux-keyring | wc -l)" -gt 0 ]; then
pacman --sync --noconfirm archlinux-keyring
fi
-pacman --sync --noconfirm --sysupgrade
+pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade
# clean up package cache
pacman --sync --noconfirm --clean