diff --git a/mock/mock.spec b/mock/mock.spec index a884110fd..23686c642 100644 --- a/mock/mock.spec +++ b/mock/mock.spec @@ -1,6 +1,19 @@ %bcond_with lint %bcond_without tests +# In modern distributions with RPM v4.19+ (e.g., Fedora 39+), the %%pre +# scriptlet for creating users/groups is no longer necessary due to the built-in +# sysusers feature. To enable it, we simply include the `mock.conf` file in the +# package payload so that RPM knows what actions to take. For older +# distributions, however, %%pre is needed. On some of those older distros the +# %%sysusers_*_compat macros could help (but not everywhere), so turns out it is +# just way easier and to expand those macros and hardcode them in this specfile. +%if 0%{?fedora} || 0%{?rhel} >= 10 +%bcond_with sysusers_compat +%else +%bcond_without sysusers_compat +%endif + %global __python %{__python3} %global python_sitelib %{python3_sitelib} @@ -147,7 +160,9 @@ Summary: Mock filesystem layout Requires(pre): shadow-utils BuildRequires: systemd-rpm-macros -%{?sysusers_requires_compat} +%if %{with sysusers_compat} +Requires(pre): shadow-utils +%endif %description filesystem Filesystem layout and group for Mock. @@ -171,9 +186,6 @@ done ./precompile-bash-completion "mock.complete" -# this is what %%sysusers_create_compat will expand to -%{_rpmconfigdir}/sysusers.generate-pre.sh mock.conf > sysusers_script - argparse-manpage --pyfile ./py/mock-hermetic-repo.py --function _argparser > mock-hermetic-repo.1 @@ -230,7 +242,10 @@ sed -i 's/^_MOCK_NVR = None$/_MOCK_NVR = "%name-%version-%release"/' \ %{buildroot}%{_libexecdir}/mock/mock -%pre filesystem -f sysusers_script +%if %{with sysusers_compat} +%pre filesystem +getent group 'mock' >/dev/null || groupadd -f -g '135' -r 'mock' || : +%endif %check diff --git a/releng/release-notes-next/sysusers-on-mageia.bugfix b/releng/release-notes-next/sysusers-on-mageia.bugfix new file mode 100644 index 000000000..10583fabd --- /dev/null +++ b/releng/release-notes-next/sysusers-on-mageia.bugfix @@ -0,0 +1,2 @@ +The %pre scriptlet is not generated for modern distributions like Fedora 39+ or +Mageia (group/user additions are handled by an RPM built-in feature).