#1077 Introduce %sysusers_create
Closed 2 years ago by mmarkk. Opened 2 years ago by mmarkk.
mmarkk/packaging-committee master  into  master

@@ -137,32 +137,66 @@ 

  

  To create users and groups in packages using dynamic allocation, do the following:

  

- Create a `<package-name>.sysusers` file with the user definition and add it to the specfile as a source.

+ Create a `<package-name>-sysusers.conf` file with the user definition and add it to the specfile as a source.

  For example for the `munge` package, this file contains:

  ```

  #Type Name   ID  GECOS                        Home directory  Shell

  u     munge  -   "Runs Uid 'N' Gid Emporium"  /run/munge      /sbin/nologin

  ```

  

- In the specfile, add a BuildRequires for systemd-rpm-macros, install the sysusers file,

-  and use the `%sysusers_create_compat` macro to consume it in the `%pre` section

- (in this example the sysusers config file is `Source3` of the specfile):

+ For different Fedora version, different macroses are recommended. Use the following hints:

+ 

+ For Fedora 32 and lower:

  ```

+ Source3: %{name}-sysusers.conf

  [...]

  BuildRequires:  systemd-rpm-macros

- 

+ %sysusers_requires_compat

  [...]

  %install

- install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/munge.conf

- 

+ install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf

  [...]

  %pre

  %sysusers_create_compat %{SOURCE3}

+ [...]

+ %files

+ %{_sysusersdir}/%{name}.conf

+ ```

  

+ For Fedora 33:

+ ```

+ Source3: %{name}-sysusers.conf

+ [...]

+ BuildRequires: systemd-rpm-macros

+ [...]

+ Requires(pre): /usr/bin/systemd-sysusers

+ [...]

+ %install

+ install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf

+ [...]

+ %pre

+ %sysusers_create %{SOURCE3}

  [...]

  %files

- %{_sysusersdir}/munge.conf

+ %{_sysusersdir}/%{name}.conf

+ ```

+ 

+ Fedora 34 and higher:

+ ```

+ Source3: %{name}-sysusers.conf

+ [...]

+ BuildRequires: systemd-rpm-macros

+ [...]

+ Requires(pre): /usr/bin/systemd-sysusers

  [...]

+ %install

+ install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf

+ [...]

+ %pre

+ %sysusers_create_package %{name} %{SOURCE3}

+ [...]

+ %files

+ %{_sysusersdir}/%{name}.conf

  ```

  

  === Soft static allocation

no initial comment

Metadata Update from @tibbs:
- Pull-request tagged with: meeting

2 years ago

-> Starting from Fedora 33 the following new macros shall be used

No,
1. Requires(pre): /usr/bin/systemd-sysusers
is missing.
2. sysusers_create_compat instead of sysusers_create

We are not using systemd-sysusers yet right now.

What stops from? even in Fedora 35/36 ?

See https://fedoraproject.org/wiki/Changes/Adopting_sysusers.d_format for the current status. Changing this would require creating and submitting a Fedora Change request.

from /usr/lib/rpm/macros.d/macros.systemd of F33 line 105

# Deprecated. Use %sysusers_create_package instead
%sysusers_create() \
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysusers_create}} \
[ -x /usr/bin/systemd-sysusers ] && /usr/bin/systemd-sysusers %{?*} || : \
%{nil}

1 new commit added

  • Update guidelines/modules/ROOT/pages/UsersAndGroups.adoc
2 years ago

Pull-Request has been closed by mmarkk

2 years ago