@@ -33,6 +33,18 @@ the purposes of CI/CD tasks.
33
33
%bcond_with python3
34
34
%endif
35
35
36
+ # Modern distributions (using RPM v4.19+; for example, Fedora 39+) do not
37
+ # require the %%pre scriptlet for creating users/groups because the sysusers
38
+ # feature is now built directly into RPM. Simply including the sysusers
39
+ # `mock.conf` file in a package payload is sufficient to leverage this feature.
40
+ # However, for older distributions that lack this capability, we still define
41
+ # the %%pre scriptlet.
42
+ %if (0%{ ?rhel} && 0%{ ?rhel} < 10) || (0%{ ?mageia} && 0%{ ?mageia} < 10) || (0%{ ?suse_version} && 0%{ ?suse_version} < 1660)
43
+ %bcond_without sysusers_compat
44
+ %else
45
+ %bcond_with sysusers_compat
46
+ %endif
47
+
36
48
%global default_python %{ ?with_python3:python3} %{ ! ?with_python3:python2}
37
49
%global default_sitelib %{ ?with_python3:% python3_sitelib} %{ ! ?with_python3:% python_sitelib}
38
50
@@ -82,6 +94,10 @@ BuildRequires: python-yaml
82
94
83
95
Requires: %default_python-%srcname = %version-%release
84
96
97
+ %if %{ with sysusers_compat}
98
+ Requires(pre): shadow-utils
99
+ %endif
100
+
85
101
Source0: https://github.com/praiskup/%name/releases/download/v%version/%name-@
[email protected]
86
102
Source1: resalloc.service
87
103
Source5: resalloc-agent-spawner.service
@@ -116,7 +132,6 @@ Requires: python-sqlalchemy
116
132
Requires: python-yaml
117
133
%endif
118
134
119
- Requires(pre): /usr/sbin/useradd
120
135
%description server
121
136
%desc
122
137
@@ -156,7 +171,6 @@ it shows page with information about resalloc resources.
156
171
%package agent-spawner
157
172
Summary: %sum - daemon starting agent-like resources
158
173
159
- Requires(pre): /usr/sbin/useradd
160
174
Requires: python3-copr-common >= 0.23
161
175
Requires: python3-daemon
162
176
Requires: python3-redis
@@ -219,6 +233,16 @@ restorecon -R %_var/www/cgi-%{name} || :
219
233
rm -r resalloc_agent_spawner
220
234
%endif
221
235
236
+ # Create sysusers.d config files
237
+ cat >resalloc.sysusers.conf <<EOF
238
+ u resalloc - ' %sysuser service user' %_homedir /bin /bash
239
+ m resalloc %sysgroup
240
+ EOF
241
+ cat >resalloc-agent-spawner.sysusers.conf <<EOF
242
+ u resalloc-agent-spawner - ' %agent_user service user' - -
243
+ m resalloc-agent-spawner %agent_group
244
+ EOF
245
+
222
246
223
247
%build
224
248
%if %{with python2}
@@ -266,6 +290,9 @@ rm %buildroot%_bindir/%name-agent-*
266
290
rm %buildroot%_sysconfdir/resalloc-agent-spawner/config.yaml
267
291
%endif
268
292
293
+ install -m0644 -D resalloc.sysusers.conf %{ buildroot} %{ _sysusersdir} /resalloc.conf
294
+ install -m0644 -D resalloc-agent-spawner.sysusers.conf %{ buildroot} %{ _sysusersdir} /resalloc-agent-spawner.conf
295
+
269
296
270
297
%if %{ with check}
271
298
%check
@@ -281,8 +308,10 @@ make check TEST_PYTHONS="python3"
281
308
ln -s "%{ default_sitelib} /%{ name} server" %buildroot%_homedir/project
282
309
283
310
311
+ %if %{ with sysusers_compat}
284
312
%pre server
285
313
%create_user_group %sysuser %sysgroup /bin/bash %_homedir
314
+ %endif
286
315
287
316
%post server
288
317
%systemd_post resalloc.service
@@ -292,8 +321,10 @@ ln -s "%{default_sitelib}/%{name}server" %buildroot%_homedir/project
292
321
293
322
294
323
%if %{ with python3}
324
+ %if %{ with sysusers_compat}
295
325
%pre agent-spawner
296
326
%create_user_group %agent_user %agent_group /bin/false /
327
+ %endif
297
328
298
329
%post agent-spawner
299
330
%systemd_post resalloc-agent-spawner.service
@@ -346,6 +377,7 @@ ln -s "%{default_sitelib}/%{name}server" %buildroot%_homedir/project
346
377
%config %_sysconfdir/logrotate.d/resalloc-server
347
378
%_libexecdir/resalloc-merge-hook-logs
348
379
%config %attr(0755, root, root) %{ _sysconfdir} /cron.hourly/resalloc
380
+ %{ _sysusersdir} /resalloc.conf
349
381
350
382
351
383
%files helpers
@@ -361,6 +393,7 @@ ln -s "%{default_sitelib}/%{name}server" %buildroot%_homedir/project
361
393
%{ default_sitelib} /%{ name} _agent_spawner
362
394
%_unitdir/resalloc-agent-spawner.service
363
395
%config(noreplace) %_sysconfdir/resalloc-agent-spawner
396
+ %{ _sysusersdir} /resalloc-agent-spawner.conf
364
397
365
398
%files webui
366
399
%doc %doc_files
0 commit comments