From 43bcccb694f0273ef95f0de9d98ca85d866359e8 Mon Sep 17 00:00:00 2001 From: jbtrystram Date: Tue, 3 Sep 2024 09:34:18 +0200 Subject: [PATCH] packaging: add a systemd unit to run every boot This enables bootloader updates automatically on boot. Note that the service is intentionally not enabled by default, it should be up to the distribution to add a systemd preset if auto-update for the bootloader is desired. Right now RAID setups are not supported but see [1] for an example in coreos. [1] https://github.com/coreos/fedora-coreos-config/pull/3042 --- Makefile | 3 +++ contrib/packaging/bootupctl-update.service | 13 +++++++++++++ contrib/packaging/bootupd.spec | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 contrib/packaging/bootupctl-update.service diff --git a/Makefile b/Makefile index f5292a4c..512f77a0 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ install-grub-static: install -m 644 -D -t ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static src/grub2/*.cfg install -m 755 -d ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static/configs.d +install-systemd-unit: + install -m 644 -D -t "${DESTDIR}$(PREFIX)/lib/systemd/system/" contrib/packaging/bootupctl-update.service + bin-archive: rm target/inst -rf $(MAKE) install install-grub-static DESTDIR=$$(pwd)/target/inst diff --git a/contrib/packaging/bootupctl-update.service b/contrib/packaging/bootupctl-update.service new file mode 100644 index 00000000..71fda80f --- /dev/null +++ b/contrib/packaging/bootupctl-update.service @@ -0,0 +1,13 @@ +[Unit] +Description=Update Bootloader on boot +Documentation=https://github.com/coreos/bootupd +ConditionPathExists=/dev/disk/by-label/EFI-SYSTEM + +[Service] +Type=oneshot +ExecStart=/usr/bin/bootupctl update +RemainAfterExit=yes +MountFlags=slave + +[Install] +WantedBy=multi-user.target diff --git a/contrib/packaging/bootupd.spec b/contrib/packaging/bootupd.spec index ebe3c2d3..dbe84247 100644 --- a/contrib/packaging/bootupd.spec +++ b/contrib/packaging/bootupd.spec @@ -21,6 +21,7 @@ BuildRequires: cargo BuildRequires: git BuildRequires: openssl-devel BuildRequires: systemd-devel +BuildRequires: systemd-rpm-macros %description %{summary} @@ -31,6 +32,7 @@ BuildRequires: systemd-devel %{_bindir}/bootupctl %{_libexecdir}/bootupd %{_prefix}/lib/bootupd/grub2-static/ +%{_unitdir}/bootupctl-update.service %prep %autosetup -n %{crate}-%{version} -p1 -Sgit @@ -50,7 +52,8 @@ cargo build --release %install %make_install INSTALL="install -p -c" make install-grub-static DESTDIR=%{?buildroot} INSTALL="%{__install} -p" +make install-systemd-unit DESTDIR=%{?buildroot} INSTALL="%{__install} -p" %changelog * Tue Oct 18 2022 Colin Walters - 0.2.8-3 -- Dummy changelog \ No newline at end of file +- Dummy changelog