├── schedule-system-update ├── perform-system-update ├── LICENSE ├── system-update-pacman.service └── README.md /schedule-system-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | > /system-update 3 | [ -e /system-update ] && echo "A system update has been scheduled for the next reboot." 4 | -------------------------------------------------------------------------------- /perform-system-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Remove /system-update first, to avoid reboot loops. 4 | /usr/bin/rm -fv /system-update 5 | 6 | # Perform the system update using Pacman. 7 | /usr/bin/pacman -Su --noconfirm --color=auto > /dev/tty1 2>&1 8 | 9 | # Reboot the system. 10 | /usr/bin/systemctl reboot 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Francis Gagné 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /system-update-pacman.service: -------------------------------------------------------------------------------- 1 | # Some of the configuration in this unit was copied from: 2 | # 3 | # https://github.com/rpm-software-management/dnf-plugins-extras/blob/master/etc/systemd/dnf-system-upgrade.service 4 | 5 | [Unit] 6 | Description=Install system updates using pacman 7 | DefaultDependencies=no 8 | 9 | Requires=sysinit.target 10 | After=sysinit.target systemd-journald.socket 11 | Before=shutdown.target system-update.target 12 | 13 | # `system-update.target` wants `system-update-cleanup.service`. 14 | # `system-update-cleanup.service` removes `/system-update` 15 | # and reboots the system. 16 | # `system-update-cleanup.service` was added in systemd 233. 17 | # 18 | # Since we're not running as a oneshot service (see below), 19 | # that service would start before the system update is complete. 20 | # Fortunately, the dependency is a `Wants`, not a `Requires`, 21 | # so we can use a `Conflicts` here 22 | # to prevent `system-update-cleanup.service` from running. 23 | Conflicts=system-update-cleanup.service 24 | 25 | [Service] 26 | # This unit is set up as a `simple` service. 27 | # If it was set up as a `oneshot` service, 28 | # then systemd would output "A start job is running for ..." messages 29 | # through pacman's output. 30 | Type=simple 31 | 32 | # The command that performs the actual system update. 33 | ExecStart=/usr/lib/systemd-system-update-pacman/perform-system-update 34 | 35 | # Remove the symlink if it's still there, to protect against reboot loops. 36 | ExecStopPost=/usr/bin/rm -fv /system-update 37 | 38 | # If anything goes wrong, reboot back to the normal system. 39 | FailureAction=reboot 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # systemd-system-update-pacman 2 | 3 | This is a couple of scripts 4 | that enable the use of [pacman][pacman] 5 | to perform system updates 6 | using [systemd][systemd]'s system update mechanism. 7 | This means that in order to use these scripts, 8 | you must be using a Linux-based distribution 9 | using pacman as a package manager 10 | and systemd running as init (PID 1). 11 | 12 | [pacman]: https://www.archlinux.org/pacman/ 13 | [systemd]: https://www.freedesktop.org/wiki/Software/systemd/ 14 | 15 | ## Usage 16 | 17 | Typical usage looks like this: 18 | 19 | * Synchronize pacman's database: `sudo pacman -Sy` 20 | * Optionally, download the updated packages in advance: `sudo pacman -Suw` 21 | * Schedule a system update: `sudo schedule-system-update` 22 | * Reboot 23 | 24 | ## Installation 25 | 26 | Install the package from the [AUR][our-aur-package]. 27 | 28 | [our-aur-package]: https://aur.archlinux.org/packages/systemd-system-update-pacman/ 29 | 30 | ## Files 31 | 32 | The first script is `schedule-system-update`. 33 | Run this script as root (e.g. with `sudo`) 34 | to schedule a system update for the next reboot. 35 | All this does is create the file `/system-update`. 36 | On your next reboot, 37 | systemd will see this file 38 | and perform the system update 39 | instead of performing a normal system boot. 40 | 41 | The second script is `perform-system-update`. 42 | This is referenced by `system-update-pacman.service`, 43 | a systemd service unit that will be started to perform the system update. 44 | You do not run this script manually. 45 | It removes `/system-update` 46 | (otherwise, systemd will keep launching system updates on each boot), 47 | then runs `pacman -Su --no-confirm` to update the system. 48 | Note that this does *not* pass the `-y` flag to sync the database. 49 | You should sync the database and review the updates 50 | before performing a system update. 51 | --------------------------------------------------------------------------------