Name: snapper-sdboot Version: 1.0.0 Release: 1%{?dist} Summary: Boot entries for snapper snapshots in systemd-boot License: MIT URL: https://codeberg.org/chf/%{name} Source0: https://codeberg.org/chf/%{name}/archive/v%{version}.tar.gz BuildRequires: cargo BuildRequires: systemd-rpm-macros Requires: snapper Requires: systemd-boot-unsigned %description Generates Boot Loader Specification entries for snapper snapshots on the ESP, so systemd-boot can boot them, the systemd-boot counterpart of grub-btrfs. %prep %autosetup -n %{name} %build cargo build --release %install install -Dm755 target/release/%{name} %{buildroot}%{_bindir}/%{name} install -Dm644 dist/%{name}.service %{buildroot}%{_unitdir}/%{name}.service install -Dm644 dist/%{name}.path %{buildroot}%{_unitdir}/%{name}.path install -Dm755 dist/95-%{name}.install %{buildroot}%{_prefix}/lib/kernel/install.d/95-%{name}.install install -Dm644 dist/90-%{name}.conf %{buildroot}%{_prefix}/lib/dracut/dracut.conf.d/90-%{name}.conf install -Dm755 dist/dracut/module-setup.sh %{buildroot}%{_prefix}/lib/dracut/modules.d/90%{name}/module-setup.sh install -Dm755 dist/dracut/%{name}-overlay.sh %{buildroot}%{_prefix}/lib/dracut/modules.d/90%{name}/%{name}-overlay.sh install -Dm644 dist/%{name}.toml %{buildroot}%{_sysconfdir}/%{name}.toml install -dm755 %{buildroot}%{_sharedstatedir}/%{name} %post %systemd_post %{name}.path %{name}.service # enable on first install, the package is useless without the triggers if [ $1 -eq 1 ] && [ -d /run/systemd/system ]; then systemctl enable %{name}.path %{name}.service >/dev/null 2>&1 || : fi %preun %systemd_preun %{name}.path %{name}.service if [ $1 -eq 0 ]; then %{_bindir}/%{name} clean >/dev/null 2>&1 || : fi %postun %systemd_postun %{name}.path %{name}.service %posttrans # rebuild initrds when the overlay module is new or changed state=%{_sharedstatedir}/%{name}/dracut.sha256 sum=$(cat %{_prefix}/lib/dracut/modules.d/90%{name}/* %{_prefix}/lib/dracut/dracut.conf.d/90-%{name}.conf | sha256sum) if [ "$sum" != "$(cat "$state" 2>/dev/null)" ]; then dracut --force --regenerate-all >/dev/null 2>&1 && echo "$sum" > "$state" || : fi # regenerate the entries with the binary just installed if [ -d /run/systemd/system ] && systemctl -q is-enabled %{name}.service 2>/dev/null; then systemctl start --no-block %{name}.path %{name}.service || : fi %files %license LICENSE %doc docs/README.md %{_bindir}/%{name} %{_unitdir}/%{name}.service %{_unitdir}/%{name}.path %{_prefix}/lib/kernel/install.d/95-%{name}.install %{_prefix}/lib/dracut/dracut.conf.d/90-%{name}.conf %{_prefix}/lib/dracut/modules.d/90%{name}/ %config(noreplace) %{_sysconfdir}/%{name}.toml %dir %{_sharedstatedir}/%{name} %ghost %{_sharedstatedir}/%{name}/dracut.sha256