#1143 Add back Fedora < 32, EL7 and EL8 instructions
Closed 2 years ago by tibbs. Opened 2 years ago by ekohl.
ekohl/packaging-committee add-legacy-packaging-guidelines  into  master

Add back Fedora < 32, EL7 and EL8 instructions
Ewoud Kohl van Wijngaarden • 2 years ago  
@@ -135,6 +135,8 @@ 

  

  === Dynamic allocation

  

+ ==== Fedora >= 32

+ 

  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.
@@ -165,6 +167,23 @@ 

  [...]

  ```

  

+ ==== Fedora < 32, EL7 and EL8

+ 

+ In older versions the `%sysusers_create_compat` macro is unavailable.

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

+ 

+ ....

+ Requires(pre): shadow-utils

+ [...]

+ 

+ %pre

+ getent group GROUPNAME >/dev/null || groupadd -r GROUPNAME

+ getent passwd USERNAME >/dev/null || \

+     useradd -r -g GROUPNAME -d HOMEDIR -s /sbin/nologin \

+     -c "Useful comment about the purpose of this account" USERNAME

+ exit 0

+ ....

+ 

  === Soft static allocation

  

  To allocate a UID and/or GID,

While Fedora < 32 is not relevant since it's unsupported, EL7 and EL8 are due to EPEL. Ideally speaking the macro would be available there as well, but this fills the gap for now.

I don't think Fedora < 32 should be mentioned here as well. I don't mind including EPEL notes, but the guidelines are not for EPEL.

It's quite common for packagers to use a single spec for both Fedora and EPEL. Should we recommend using macros to use the newer style if available? Something like:

%if !0%{rhel} || 0%{rhel} >= 9
BuildRequires:  systemd-rpm-macros
%endif
%if 0%{rhel} && 0%{rhel} < 9
Requires(pre): shadow-utils
%endif

I think installing the sysusers file can happen unconditionally. Then %pre would become

%pre
%if !0%{rhel} || 0%{rhel} >= 9
%sysusers_create_compat %{SOURCE3}
%endif
%if 0%{rhel} && 0%{rhel} < 9
getent group GROUPNAME >/dev/null || groupadd -r GROUPNAME
getent passwd USERNAME >/dev/null || \
    useradd -r -g GROUPNAME -d HOMEDIR -s /sbin/nologin \
    -c "Useful comment about the purpose of this account" USERNAME
exit 0
%endif

That said, it was pointed out that there's an EPEL guide. I'd be happy to send a PR there that describes this. Once that's merged, this guide can link to it with a warning for EPEL packagers.

Pull-Request has been closed by tibbs

2 years ago
Metadata