3
0

- Unlike systemd-tmpfiles call in %tmpfiles_create_package(), systemd-sysusers

must always be called by %sysusers_create_package() even on transactional
  systems since it's part of the macro contract. Writing to /etc is not
  recommended on such systems but it has to work anyways.

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=98
This commit is contained in:
Franck Bui 2023-06-20 15:01:29 +00:00 committed by Git OBS Bridge
parent 695ae9a4b5
commit ff6965c5cb
2 changed files with 29 additions and 9 deletions

View File

@ -217,13 +217,16 @@ 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.
#
# Since we moved to file triggers the 2 following macros are deprecated. If 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.
#
%tmpfiles_create() \
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# tmpfiles_create}} \
[ -z "${TRANSACTIONAL_UPDATE}" ] && [ -x /usr/bin/systemd-tmpfiles ] && \
@ -232,13 +235,19 @@ fi \
%sysusers_create() \
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysusers_create}} \
[ -x /usr/bin/systemd-sysusers ] && /usr/bin/systemd-sysusers %{?*} || : \
[ -z "${TRANSACTIONAL_UPDATE}" ] && [ -x /usr/bin/systemd-sysusers ] && \
/usr/bin/systemd-sysusers %{?*} || : \
%{nil}
# This may be used by package installation scripts to create files according to
# their tmpfiles configuration from a package installation script, even before
# the files of that package are installed on disk.
#
# FIXME: this macro should be removed because it cannot work on transactional
# systems since directories that systemd-tmpfiles usually operates on (i.e.
# /var, /etc) are not available during (transactional) updates. So packages
# can't rely on the behavior this macro is supposed to provide.
#
# Example:
# Source1: %{name}-tmpfiles.conf
# ...
@ -251,7 +260,7 @@ fi \
#
%tmpfiles_create_package() \
%{expand:%%{?!__systemd_twoargs_%#:%%{error:The %%%%tmpfiles_create_package macro requires two arguments}}} \
[ -d /run/systemd/system ] && \
[ -d /run/systemd/system ] && [ -x /usr/bin/systemd-tmpfiles ] && \
/usr/bin/systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - <<SYSTEMD_INLINE_EOF || : \
%(cat %2) \
SYSTEMD_INLINE_EOF\
@ -271,10 +280,13 @@ SYSTEMD_INLINE_EOF\
# %files
# %{_sysusersdir}/%{name}.conf
#
# Note: writing to /etc is not recommended on transactional systems but the
# sysusers must be created now since by calling this macro the package explicitly
# requests that.
#
%sysusers_create_package() \
%{expand:%%{?!__systemd_twoargs_%#:%%{error:The %%%%sysusers_create_package macro requires two arguments}}} \
[ -z "${TRANSACTIONAL_UPDATE}" ] && [ -x /usr/bin/systemd-tmpfiles ] && \
/usr/bin/systemd-sysusers --replace=%_sysusersdir/%1.conf - <<SYSTEMD_INLINE_EOF || : \
[ -x /usr/bin/systemd-sysusers ] && /usr/bin/systemd-sysusers --replace=%_sysusersdir/%1.conf - <<SYSTEMD_INLINE_EOF || : \
%(cat %2) \
SYSTEMD_INLINE_EOF\
%{nil}

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Jun 20 14:58:35 UTC 2023 - Franck Bui <fbui@suse.com>
- Unlike systemd-tmpfiles call in %tmpfiles_create_package(), systemd-sysusers
must always be called by %sysusers_create_package() even on transactional
systems since it's part of the macro contract. Writing to /etc is not
recommended on such systems but it has to work anyways.
-------------------------------------------------------------------
Fri Jun 16 13:11:34 UTC 2023 - Franck Bui <fbui@suse.com>