diff --git a/macros.systemd b/macros.systemd new file mode 100644 index 0000000..766c1f8 --- /dev/null +++ b/macros.systemd @@ -0,0 +1,105 @@ +# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */ +# +# This file is part of systemd. +# +# Copyright 2012 Lennart Poettering +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see . + +# RPM macros for packages installing systemd unit files + +%_unitdir /usr/lib/systemd/system +%_userunitdir /usr/lib/systemd/user +%_presetdir /usr/lib/systemd/system-preset +%_udevhwdbdir /usr/lib/udev/hwdb.d +%_udevrulesdir /usr/lib/udev/rules.d +%_journalcatalogdir /usr/lib/systemd/catalog +%_tmpfilesdir /usr/lib/tmpfiles.d +%_sysusersdir /usr/lib/sysusers.d +%_sysctldir /usr/lib/sysctl.d +%_binfmtdir /usr/lib/binfmt.d + +%systemd_requires \ +Requires(post): systemd \ +Requires(preun): systemd \ +Requires(postun): systemd \ +%{nil} + +%systemd_post() \ +if [ $1 -eq 1 ] ; then \ + # Initial installation \ + systemctl --no-reload preset %{?*} >/dev/null 2>&1 || : \ +fi \ +%{nil} + +%systemd_user_post() %systemd_post --user --global %{?*} + +%systemd_preun() \ +if [ $1 -eq 0 ] ; then \ + # Package removal, not upgrade \ + systemctl --no-reload disable --now %{?*} > /dev/null 2>&1 || : \ +fi \ +%{nil} + +%systemd_user_preun() \ +if [ $1 -eq 0 ] ; then \ + # Package removal, not upgrade \ + systemctl --no-reload --user --global disable %{?*} > /dev/null 2>&1 || : \ +fi \ +%{nil} + +%systemd_postun() %{nil} + +%systemd_user_postun() %{nil} + +%systemd_postun_with_restart() \ +if [ $1 -ge 1 ] ; then \ + # Package upgrade, not uninstall \ + systemctl try-restart %{?*} >/dev/null 2>&1 || : \ +fi \ +%{nil} + +%systemd_user_postun_with_restart() %{nil} + +%udev_hwdb_update() \ +udevadm hwdb --update >/dev/null 2>&1 || : \ +%{nil} + +%udev_rules_update() \ +udevadm control --reload >/dev/null 2>&1 || : \ +%{nil} + +%journal_catalog_update() \ +journalctl --update-catalog >/dev/null 2>&1 || : \ +%{nil} + +%tmpfiles_create() \ +systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \ +%{nil} + +%sysusers_create() \ +systemd-sysusers %{?*} >/dev/null 2>&1 || : \ +%{nil} + +%sysusers_create_inline() \ +echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \ +%{nil} + +%sysctl_apply() \ +/usr/lib/systemd/systemd-sysctl %{?*} >/dev/null 2>&1 || : \ +%{nil} + +%binfmt_apply() \ +/usr/lib/systemd/systemd-binfmt %{?*} >/dev/null 2>&1 || : \ +%{nil} diff --git a/systemd.spec b/systemd.spec index 711a865..00fec4f 100644 --- a/systemd.spec +++ b/systemd.spec @@ -34,6 +34,8 @@ Source7: systemd-journal-remote.xml Source8: systemd-journal-gatewayd.xml Source9: 20-yama-ptrace.conf +Source10: macros.systemd + # kernel-install patch for grubby, drop if grubby is obsolete Patch1000: kernel-install-grubby.patch @@ -369,6 +371,8 @@ install -Dm0644 %{SOURCE8} %{buildroot}/usr/lib/firewalld/services/ # https://bugzilla.redhat.com/show_bug.cgi?id=1234951 install -Dm0644 %{SOURCE9} %{buildroot}%{_pkgdocdir}/ +install -Dm0644 %{SOURCE10} %{buildroot}%{_rpmconfigdir}/macros.d/macros.systemd + %find_lang %{name} %check @@ -377,6 +381,14 @@ make check VERBOSE=1 # Check for botched translations (https://bugzilla.redhat.com/show_bug.cgi?id=1226566) test -z "$(grep -L xml:lang %{buildroot}%{_datadir}/polkit-1/actions/org.freedesktop.*.policy)" +############################################################################################# + +%transfiletriggerin -- /usr/lib/systemd/system /etc/systemd/system +systemctl daemon-reload &>/dev/null || : + +%transfiletriggerun -- /usr/lib/systemd/system /etc/systemd/system +systemctl daemon-reload &>/dev/null || : + %pre getent group cdrom >/dev/null 2>&1 || groupadd -r -g 11 cdrom >/dev/null 2>&1 || : getent group utmp >/dev/null 2>&1 || groupadd -r -g 22 utmp >/dev/null 2>&1 || : @@ -476,11 +488,6 @@ fi # remove obsolete systemd-readahead file rm -f /.readahead > /dev/null 2>&1 || : -%postun -if [ $1 -ge 1 ] ; then - systemctl daemon-reload > /dev/null 2>&1 || : -fi - %preun if [ $1 -eq 0 ] ; then systemctl disable \