From f212c9ef2c9479824308b3a5378e508d13020b46 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 22 Sep 2017 00:36:39 +0200 Subject: initial commit --- .gitignore | 1 + Makefile | 22 ++++++++++++++++++++++ README.md | 4 ++++ bin/pacman-offline | 9 +++++++++ systemd/pacman-offline | 17 +++++++++++++++++ systemd/pacman-offline.service | 14 ++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100755 bin/pacman-offline create mode 100755 systemd/pacman-offline create mode 100644 systemd/pacman-offline.service diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b84df0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.html \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66c15c7 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +# commands +INSTALL := install +LN := ln +MD := markdown +RM := rm +SED := sed + +all: README.html + +%.html: %.md + $(MD) $< > $@ + $(SED) -i 's/\(README[-[:alnum:]]*\).md/\1.html/g' $@ + +install: + $(INSTALL) -D -m0755 bin/pacman-offline $(DESTDIR)/usr/bin/pacman-offline + $(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 -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 + +clean: + $(RM) -f README.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..f4440aa --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +pacman-offline +============== + +Run offline system update with pacman. diff --git a/bin/pacman-offline b/bin/pacman-offline new file mode 100755 index 0000000..35bff53 --- /dev/null +++ b/bin/pacman-offline @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# download packages +pacman -Suw --noconfirm + +# enable system update +ln -sf /var/cache/pacman/pkg /system-update diff --git a/systemd/pacman-offline b/systemd/pacman-offline new file mode 100755 index 0000000..9764666 --- /dev/null +++ b/systemd/pacman-offline @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +# verify this is for us or exit gracefully +if [ "$(readlink '/system-update')" != '/var/cache/pacman/pkg' ]; then + exit 0 +fi + +# install updates +pacman -Su --noconfirm + +# remove triggering symlink +rm -f /system-update + +# reboot +systemctl reboot diff --git a/systemd/pacman-offline.service b/systemd/pacman-offline.service new file mode 100644 index 0000000..3b698a3 --- /dev/null +++ b/systemd/pacman-offline.service @@ -0,0 +1,14 @@ +[Unit] +Description=Offline system update with pacman +ConditionPathExists=/system-update +DefaultDependencies=false +Requires=sysinit.target dbus.socket +After=sysinit.target dbus.socket +Before=shutdown.target system-update.target +OnFailure=reboot.target + +[Service] +Type=oneshot +StandardOutput=tty +StandardError=tty +ExecStart=/usr/lib/systemd/scripts/pacman-offline -- cgit v1.2.3-54-g00ecf