diff --git a/macros.systemd b/macros.systemd index 0b90a34..d2225e5 100644 --- a/macros.systemd +++ b/macros.systemd @@ -1,10 +1,9 @@ -# -*- Mode: rpm-spec; indent-tabs-mode: t -*- +# -*- mode: shell-script; indent-tabs-mode: t -*- # RPM macros for packages installing systemd unit files # ### # -# When a package install systemd unit files, it should use the -# following macros: +# When a package install systemd unit files, it should use the following macros: # # add %systemd_requires in the specfile # @@ -21,10 +20,10 @@ # %service_del_postun demo.service # %service_del_postun_without_restart demo.service # -# Note: the upstream variants are also available and are aliases to -# their SUSE counterparts. However for consistency the SUSE macros -# should be preferred unless the package is intended to be portable -# across multiple distributions based on RPM. +# Note: the upstream variants are also available and are aliases to their SUSE +# counterparts. However for consistency the SUSE macros should be preferred +# unless the package is intended to be portable across multiple distributions +# based on RPM. %_systemd_util_dir /usr/lib/systemd %_unitdir /usr/lib/systemd/system @@ -175,7 +174,7 @@ fi \ %systemd_user_preun() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_preun}} \ if [ $1 -eq 0 ] && [ -x /usr/lib/systemd/systemd-update-helper ]; then \ - # Package removal, not upgrade \ + # Package removal, not upgrade \ /usr/lib/systemd/systemd-update-helper remove-user-units %{?*} || : \ fi \ %{nil} @@ -188,25 +187,24 @@ fi \ %systemd_user_postun_with_restart() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_postun_with_restart}} \ if [ $1 -ge 1 ] && [ -x /usr/lib/systemd/systemd-update-helper ]; then \ - # Package upgrade, not uninstall \ - /usr/lib/systemd/systemd-update-helper mark-restart-user-units %{?*} || : \ + # Package upgrade, not uninstall \ + /usr/lib/systemd/systemd-update-helper mark-restart-user-units %{?*} || : \ fi \ %{nil} # -# The following macros are empty as we have file triggers in place for hwdb, -# journal catalog, udev rules, binfmt and sysctl. +# The following macros are empty as systemd trans-file-triggers are in place for +# hwdb, journal catalog, udev rules, binfmt and sysctl. +# +# Note: 'sysctl_apply' and 'binfmt_apply' don't have any users that rely on +# their immediate effect. # - %udev_hwdb_update() :%{nil} %udev_rules_update() :%{nil} %journal_catalog_update() :%{nil} -# Currently the 2 following macros don't have any interesting users. Leave them -# empty until a specific need appears. - %sysctl_apply() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysctl_apply}} \ : \ @@ -217,26 +215,42 @@ fi \ : \ %{nil} -# For cases where the sysusers or tmpfiles data need to be created in advance -# (when a system user needs to be installed in %%pre so proper ownership are -# used when package's files are installed for example) then use the -# '*_create_package()' variants. # -# FIXME: these macros could be converted to NOPs since we moved to file -# triggers. However some packages might assume that the macros effects are -# effective as soon as the macros return. This reason is actually moot since -# this can't work on transactional systems anyway. +# This should be used when a package needs to execute the shipped udev rules +# during its installation. It automatically triggers a reload of the rule files, +# as this step is often overlooked by packages. # +# Note1: The version of this macro shipped with SLE < 16 only supports a limited +# subset of options, due to the older RPM versions (< 4.17), which lacks support +# for disabling option processing. +# +# Note2: This is suboptimal when multiple events need to be triggered, as it +# results in multiple reloads of the rule files. +# +%udev_trigger_with_reload(-) \ +if [ -e /run/udev/control ]; then \ + /usr/bin/udevadm control --reload && /usr/bin/udevadm trigger %{?*} || : \ +fi \ +%{nil} + +# The 2 following macros have also been converted into NOPs since we moved to +# file triggers. Some packages might have assumed that their effects were +# effective as soon as the macros return. However such assumption on tmpfiles +# can't work on transactional systems anyways where changes must take place on +# reboot. +# +# When a system user/group needs to be created in %%pre, so proper ownership are +# used when package's files are installed, "sysusers_create_package()" should be +# used. + %tmpfiles_create() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# tmpfiles_create}} \ -[ -z "${TRANSACTIONAL_UPDATE}" ] && [ -x /usr/bin/systemd-tmpfiles ] && \ - /usr/bin/systemd-tmpfiles --create %{?*} || : \ +: \ %{nil} %sysusers_create() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysusers_create}} \ -[ -z "${TRANSACTIONAL_UPDATE}" ] && [ -x /usr/bin/systemd-sysusers ] && \ - /usr/bin/systemd-sysusers %{?*} || : \ +: \ %{nil} # This should be used by package installation scripts which require users or diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 33b47bc..1b265f6 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,35 @@ +------------------------------------------------------------------- +Tue Jul 8 12:58:05 UTC 2025 - Franck Bui + +- Bump version to 26 + +------------------------------------------------------------------- +Mon Jul 7 15:56:08 UTC 2025 - Franck Bui + +- Introduce %udev_trigger_with_reload() for packages that need to trigger events + in theirs scriplets. The new macro automatically triggers a reload of the udev + rule files as this step is often overlooked by packages (bsc#1237143). + +------------------------------------------------------------------- +Sat Jun 24 08:41:48 UTC 2023 - Franck Bui + +- Bump to version 25 + +------------------------------------------------------------------- +Sat Jun 24 08:40:00 UTC 2023 - Franck Bui + +- Turn %tmpfiles_create/%sysusers_create into NOPs + + The 2 following macros have also been converted into NOPs since we moved to + file triggers. Some packages might have assumed that their effects were + effective as soon as the macros return. However such assumption on tmpfiles + can't work on transactional systems anyways where changes must take place on + reboot. + + When a system user/group needs to be created in %%pre, so proper ownership are + used when package's files are installed, "sysusers_create_package()" should be + used. + ------------------------------------------------------------------- Tue Jun 20 16:08:47 UTC 2023 - Franck Bui diff --git a/systemd-rpm-macros.spec b/systemd-rpm-macros.spec index 62abdae..2021f11 100644 --- a/systemd-rpm-macros.spec +++ b/systemd-rpm-macros.spec @@ -1,7 +1,7 @@ # # spec file for package systemd-rpm-macros # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2025 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: systemd-rpm-macros -Version: 24 +Version: 26 Release: 0 Summary: RPM macros for systemd License: LGPL-2.1-or-later