From 353c12a33cd971ca352b628ee413f568d197945d Mon Sep 17 00:00:00 2001 From: Jiri Kyjovsky Date: Sun, 28 Apr 2024 17:14:13 +0200 Subject: [PATCH] Enable RPM sysusers integration Provide users/groups via `/usr/lib/sysusers.d`. This is going to be handled by RPM as described in https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/#_dynamic_allocation and https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/NEFOV236FJYS2RED2SEOV5YHDFLDX7DK/#KB6KS3U7RO4AYANGSUNVSG7UF5AW52Q2 Relates to https://github.com/fedora-copr/copr/issues/2789 --- mock-core-configs/mock-core-configs.spec | 2 -- {mock-core-configs => mock}/mock.conf | 0 mock/mock.spec | 13 ++++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) rename {mock-core-configs => mock}/mock.conf (100%) diff --git a/mock-core-configs/mock-core-configs.spec b/mock-core-configs/mock-core-configs.spec index 420c5e8c9..869562f8f 100644 --- a/mock-core-configs/mock-core-configs.spec +++ b/mock-core-configs/mock-core-configs.spec @@ -50,8 +50,6 @@ Rocky Linux and various other specific or combined chroots. %install -mkdir -p %{buildroot}%{_sysusersdir} - mkdir -p %{buildroot}%{_sysconfdir}/mock/eol/templates mkdir -p %{buildroot}%{_sysconfdir}/mock/templates cp -a etc/mock/*.cfg %{buildroot}%{_sysconfdir}/mock diff --git a/mock-core-configs/mock.conf b/mock/mock.conf similarity index 100% rename from mock-core-configs/mock.conf rename to mock/mock.conf diff --git a/mock/mock.spec b/mock/mock.spec index fed1bae4a..27ac1ab02 100644 --- a/mock/mock.spec +++ b/mock/mock.spec @@ -1,8 +1,7 @@ %bcond_with lint %bcond_without tests -# mock group id allocate for Fedora -%global mockgid 135 +%global mock_conf %{_builddir}/%{name}-%{version}/mock.conf %global __python %{__python3} %global python_sitelib %{python3_sitelib} @@ -67,6 +66,7 @@ BuildRequires: python%{python3_pkgversion}-pylint %endif BuildRequires: python%{python3_pkgversion}-rpm BuildRequires: python%{python3_pkgversion}-rpmautospec-core +BuildRequires: systemd-rpm-macros %if 0%{?fedora} >= 38 # DNF5 stack @@ -107,6 +107,7 @@ Requires: coreutils Requires: procps-ng Requires: shadow-utils +%{?sysusers_requires_compat} %description Mock takes an SRPM and builds it in a chroot. @@ -213,13 +214,14 @@ install -d %{buildroot}/var/cache/mock mkdir -p %{buildroot}%{_pkgdocdir} install -p -m 0644 docs/site-defaults.cfg %{buildroot}%{_pkgdocdir} +mkdir -p %{buildroot}%{_sysusersdir} +install -p -D -m 0644 mock.conf %{buildroot}%{_sysusersdir} + sed -i 's/^_MOCK_NVR = None$/_MOCK_NVR = "%name-%version-%release"/' \ %{buildroot}%{_libexecdir}/mock/mock %pre filesystem -# check for existence of mock group, create it if not found -getent group mock > /dev/null || groupadd -f -g %mockgid -r mock -exit 0 +%sysusers_create_compat %mock_conf %check %if %{with lint} @@ -257,6 +259,7 @@ pylint-3 py/mockbuild/ py/*.py py/mockbuild/plugins/* || : %config(noreplace) %{_sysconfdir}/%{name}/*.ini %config(noreplace) %{_sysconfdir}/pam.d/%{name} %config(noreplace) %{_sysconfdir}/security/console.apps/%{name} +%{_sysusersdir}/mock.conf # directory for personal gpg keys %dir %{_sysconfdir}/pki/mock