Skip to content

Commit

Permalink
mock: avoid the %pre scriptlet if possible
Browse files Browse the repository at this point in the history
The script for generating the %pre scriptlet is non-existing on new
distributions (like Mageia now, but Fedora will drop that sooner or
later, too).  The build of Mock on Mageia previously relied on
sysusers.generate-pre.sh, and failed.

The sysusers feature is an RPM built-in anyway (on modern systems), so
there's no reason to duplicate the logic in %pre.  Generate the %pre
scriptlet only for older distributions.

Complements: #1367
Relates: #289
Relates: fedora-copr/copr#2789
  • Loading branch information
praiskup committed Nov 1, 2024
1 parent 66444e7 commit 3c6751d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mock/mock.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
%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, the %%sysusers_requires_compat macro is typically
# used. This macro isn't ideal for Mock's packaging style (tito) because it
# requires mock.conf to be an additional SourceN file rather than within
# `Source0` tarball. Instead of using that macro, we manually generate the
# scriptlet content for older distributions using the `sysusers.generate-pre.sh`
# script (which is the `%%sysusers_requires_compat` "internal").
%if 0%{?rhel} && 0%{?rhel} <= 9
%bcond_without sysusers_compat
%else
%bcond_with sysusers_compat
%endif

%global __python %{__python3}
%global python_sitelib %{python3_sitelib}

Expand Down Expand Up @@ -171,8 +187,9 @@ done

./precompile-bash-completion "mock.complete"

# this is what %%sysusers_create_compat will expand to
%if %{with sysusers_compat}
%{_rpmconfigdir}/sysusers.generate-pre.sh mock.conf > sysusers_script
%endif

argparse-manpage --pyfile ./py/mock-hermetic-repo.py --function _argparser > mock-hermetic-repo.1

Expand Down Expand Up @@ -230,7 +247,9 @@ sed -i 's/^_MOCK_NVR = None$/_MOCK_NVR = "%name-%version-%release"/' \
%{buildroot}%{_libexecdir}/mock/mock


%if %{with sysusers_compat}
%pre filesystem -f sysusers_script
%endif


%check
Expand Down
2 changes: 2 additions & 0 deletions releng/release-notes-next/sysusers-on-mageia.bugfix
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit 3c6751d

Please sign in to comment.