forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uyuni-tools.spec
522 lines (425 loc) · 14.6 KB
/
uyuni-tools.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#
# spec file for package uyuni-tools
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global provider github
%global provider_tld com
%global org uyuni-project
%global project uyuni-tools
%global provider_prefix %{provider}.%{provider_tld}/%{org}/%{project}
%global productname Uyuni
%global namespace registry.opensuse.org/uyuni
%if 0%{?suse_version} >= 1600 || 0%{?sle_version} >= 150400 || 0%{?rhel} >= 8 || 0%{?fedora} >= 37 || 0%{?debian} >= 12 || 0%{?ubuntu} >= 2004
%define adm_build 1
%else
%define adm_build 0
%endif
%define name_adm mgradm
%define name_ctl mgrctl
%define name_pxy mgrpxy
# Completion files
%if 0%{?debian} || 0%{?ubuntu}
%define _zshdir %{_datarootdir}/zsh/vendor-completions
%else
%define _zshdir %{_datarootdir}/zsh/site-functions
%endif
# 0%{?debian} || 0%{?ubuntu}
Name: %{project}
Version: 5.1.2
Release: 0
Summary: Tools for managing %{productname} container
License: Apache-2.0
Group: System/Management
URL: https://%{provider_prefix}
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
BuildRequires: bash-completion
BuildRequires: coreutils
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires: gettext
%endif
# 0%{?debian} || 0%{?ubuntu}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
BuildRequires: fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
BuildRequires: zsh
# Get the proper Go version on different distros
%if 0%{?suse_version}
BuildRequires: golang(API) >= 1.21
%endif
# 0%{?suse_version}
%if 0%{?ubuntu}
%define go_version 1.21
BuildRequires: golang-%{go_version}
%endif
# 0%{?ubuntu}
%if 0%{?debian}
BuildRequires: golang >= 1.21
%endif
# 0%{?debian}
%if 0%{?fedora} || 0%{?rhel}
BuildRequires: golang >= 1.21
%endif
# 0%{?fedora} || 0%{?rhel}
%description
Tools for managing %{productname} container.
%if %{adm_build}
%package -n %{name_adm}
Summary: Command line tool to install and update %{productname}
%if 0%{?suse_version}
Requires: (aardvark-dns if podman)
Requires: (netavark if podman)
%endif
# 0%{?suse_version}
%if "%{_vendor}" != "debbuild"
Requires: (podman >= 4.5.0 if podman)
%endif
%description -n %{name_adm}
%{name_adm} is a convenient tool to install and update %{productname} components as containers running
either on Podman or a Kubernetes cluster.
%package -n %{name_pxy}
Summary: Command line tool to install and update %{productname} proxy
Obsoletes: uyuni-proxy-systemd-services
%if 0%{?suse_version}
Requires: (aardvark-dns if podman)
Requires: (netavark if podman)
%endif
# 0%{?suse_version}
%description -n %{name_pxy}
%{name_pxy} is a convenient tool to install and update %{productname} proxy components as containers
running either on Podman or a Kubernetes cluster.
%package -n %{name_adm}-bash-completion
Summary: Bash Completion for %{name_adm}
Group: System/Shells
Requires: %{name_adm} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_adm} and bash-completion)
%else
Supplements: bash-completion
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_adm}-bash-completion
Bash command line completion support for %{name_adm}.
%package -n %{name_adm}-zsh-completion
Summary: Zsh Completion for %{name_adm}
Group: System/Shells
Requires: %{name_adm} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_adm} and zsh)
%else
Supplements: zsh
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_adm}-zsh-completion
Zsh command line completion support for %{name_adm}.
%package -n %{name_pxy}-bash-completion
Summary: Bash Completion for %{name_pxy}
Group: System/Shells
Requires: %{name_pxy} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_pxy} and bash-completion)
%else
Supplements: bash-completion
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_pxy}-bash-completion
Bash command line completion support for %{name_pxy}.
%package -n %{name_pxy}-zsh-completion
Summary: Zsh Completion for %{name_pxy}
Group: System/Shells
Requires: %{name_pxy} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_pxy} and zsh)
%else
Supplements: zsh
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_pxy}-zsh-completion
Zsh command line completion support for %{name_pxy}.
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%package -n %{name_adm}-fish-completion
Summary: Fish Completion for %{name_adm}
Group: System/Shells
Requires: %{name_adm} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_adm} and fish)
%else
Supplements: fish
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_adm}-fish-completion
Fish command line completion support for %{name_adm}.
%package -n %{name_pxy}-fish-completion
Summary: Fish Completion for %{name_pxy}
Group: System/Shells
Requires: %{name_pxy} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_pxy} and fish)
%else
Supplements: fish
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_pxy}-fish-completion
Fish command line completion support for %{name_pxy}.
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%endif
# %{adm_build}
%package -n %{name_ctl}
Summary: Command line tool to perform day-to-day operations on %{productname}
%description -n %{name_ctl}
%{name_ctl} is a tool helping with dayly tasks on %{productname} components running as containers
either on Podman or a Kubernetes cluster.
%package -n %{name_ctl}-bash-completion
Summary: Bash Completion for %{name_ctl}
Group: System/Shells
Requires: %{name_ctl} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_ctl} and bash-completion)
%else
Supplements: bash-completion
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_ctl}-bash-completion
Bash command line completion support for %{name_ctl}.
%package -n %{name_ctl}-zsh-completion
Summary: Zsh Completion for %{name_ctl}
Group: System/Shells
Requires: %{name_ctl} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_ctl} and zsh)
%else
Supplements: zsh
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_ctl}-zsh-completion
Zsh command line completion support for %{name_ctl}.
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%package -n %{name_ctl}-fish-completion
Summary: Fish Completion for %{name_ctl}
Group: System/Shells
Requires: %{name_ctl} = %{version}
BuildArch: noarch
%if 0%{?suse_version} >= 150000
Supplements: (%{name_ctl} and fish)
%else
Supplements: fish
%endif
# 0%{?suse_version} >= 150000
%description -n %{name_ctl}-fish-completion
Fish command line completion support for %{name_ctl}.
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
# Only SUSE distros have a -lang packages, for the others they
# will all be in the correspdonding tool package.
%if 0%{?suse_version} || 0%{?sle_version}
%lang_package -n %{name_ctl}
%lang_package -n %{name_pxy}
%if %{adm_build}
%lang_package -n %{name_adm}
%endif
# %{adm_build}
%endif
# 0%{?suse_version} || 0%{?sle_version}
%prep
%autosetup
tar -zxf %{SOURCE1}
%build
export GOFLAGS=-mod=vendor
mkdir -p bin
UTILS_PATH="%{provider_prefix}/shared/utils"
tag=%{!?_default_tag:latest}
%if "%{?_default_tag}" != ""
tag='%{_default_tag}'
%endif
# "%{?_default_tag}" != ""
pull_policy=%{!?_default_pull_policy:Always}
%if "%{?_default_pull_policy}" != ""
pull_policy='%{_default_pull_policy}'
%endif
# "%{?_default_pull_policy}" != ""
namespace=%{namespace}
helm_registry=%{namespace}
%if "%{?_default_namespace}" != ""
# Set both container and helm chart namespaces as this can be the same value
namespace='%{_default_namespace}'
helm_registry='%{_default_namespace}'
%endif
# "%{?_default_namespace}" != ""
# We may have additional config for helm registry as the path is different in OBS devel projects
%if "%{?_default_helm_registry}" != ""
helm_registry='%{_default_helm_registry}'
%endif
# "%{?_default_helm_registry}" != ""
go_tags=""
%if "%{?_uyuni_tools_tags}" != ""
go_tags="-tags %{_uyuni_tools_tags}"
%endif
# "%{?_uyuni_tools_tags}" != ""
go_path=""
%if 0%{?ubuntu}
go_path=/usr/lib/go-%{go_version}/bin/
%else
%if "%{?_go_bin}" != ""
go_path='%{_go_bin}/'
%endif
# "%{?_go_bin}" != ""
%endif
# 0%{?ubuntu}
GOLD_FLAGS="-X '${UTILS_PATH}.Version=%{version} (%{version_details})' -X ${UTILS_PATH}.LocaleRoot=%{_datadir}/locale"
if test -n "${namespace}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultRegistry=${namespace}"
fi
if test -n "${helm_registry}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultHelmRegistry=${helm_registry}"
fi
if test -n "${tag}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultTag=${tag}"
fi
if test -n "${pull_policy}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultPullPolicy=${pull_policy}"
fi
# Workaround for rpm on Fedora and EL clones not able to handle go's compressed debug symbols
# Found compressed .debug_aranges section, not attempting dwz compression
%if 0%{?rhel} >= 8 || 0%{?fedora} >= 38
GOLD_FLAGS="-compressdwarf=false ${GOLD_FLAGS}"
%endif
# 0%{?rhel} >= 8 || 0%{?fedora} >= 38
# Workaround for missing build-id on Fedora
# error: Missing build-id in [...]
%if 0%{?fedora} >= 38
GOLD_FLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') ${GOLD_FLAGS}"
%endif
# 0%{?fedora} >= 38
${go_path}go build ${go_tags} -ldflags "${GOLD_FLAGS}" -o ./bin ./...
%if ! %{adm_build}
rm ./bin/%{name_adm}
rm ./bin/%{name_pxy}
%endif
# ! %{adm_build}
%install
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp ./bin/* %{buildroot}%{_bindir}/
# Generate the machine object files for localizations
./locale/build.sh %{buildroot}%{_datadir}/locale/
%find_lang %{name_ctl}
%if %{adm_build}
%find_lang %{name_adm}
%find_lang %{name_pxy}
%else
rm %{buildroot}%{_datadir}/locale/*/LC_MESSAGES/%{name_adm}.mo
rm %{buildroot}%{_datadir}/locale/*/LC_MESSAGES/%{name_pxy}.mo
%endif
# %{adm_build}
# Completion files
mkdir -p %{buildroot}%{_datarootdir}/bash-completion/completions/
mkdir -p %{buildroot}%{_zshdir}
%{buildroot}/%{_bindir}/%{name_ctl} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{name_ctl}
%{buildroot}/%{_bindir}/%{name_ctl} completion zsh > %{buildroot}%{_zshdir}/_%{name_ctl}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
mkdir -p %{buildroot}%{_datarootdir}/fish/vendor_completions.d/
%{buildroot}/%{_bindir}/%{name_ctl} completion fish > %{buildroot}%{_datarootdir}/fish/vendor_completions.d/%{name_ctl}.fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%if %{adm_build}
%{buildroot}/%{_bindir}/%{name_adm} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{name_adm}
%{buildroot}/%{_bindir}/%{name_adm} completion zsh > %{buildroot}%{_zshdir}/_%{name_adm}
%{buildroot}/%{_bindir}/%{name_pxy} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{name_pxy}
%{buildroot}/%{_bindir}/%{name_pxy} completion zsh > %{buildroot}%{_zshdir}/_%{name_pxy}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%{buildroot}/%{_bindir}/%{name_adm} completion fish > %{buildroot}%{_datarootdir}/fish/vendor_completions.d/%{name_adm}.fish
%{buildroot}/%{_bindir}/%{name_pxy} completion fish > %{buildroot}%{_datarootdir}/fish/vendor_completions.d/%{name_pxy}.fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%endif
# %{adm_build}
%if %{adm_build}
# mgradm packages files
# Only SUSE distros have a -lang package
%if 0%{?suse_version} || 0%{?sle_version}
%files -n %{name_adm}-lang -f %{name_adm}.lang
%files -n %{name_adm}
%else
%files -n %{name_adm} -f %{name_adm}.lang
%endif
# 0%{?suse_version} || 0%{?sle_version}
%defattr(-,root,root)
%doc README.md
%license LICENSE
%{_bindir}/%{name_adm}
%files -n %{name_adm}-bash-completion
%{_datarootdir}/bash-completion/completions/%{name_adm}
%files -n %{name_adm}-zsh-completion
%{_zshdir}/_%{name_adm}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%files -n %{name_adm}-fish-completion
%{_datarootdir}/fish/vendor_completions.d/%{name_adm}.fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
# mgrpxy packages files
# Only SUSE distros have a -lang package
%if 0%{?suse_version} || 0%{?sle_version}
%files -n %{name_pxy}-lang -f %{name_pxy}.lang
%files -n %{name_pxy}
%else
%files -n %{name_pxy} -f %{name_pxy}.lang
%endif
# 0%{?suse_version} || 0%{?sle_version}
%defattr(-,root,root)
%doc README.md
%license LICENSE
%{_bindir}/%{name_pxy}
%files -n %{name_pxy}-bash-completion
%{_datarootdir}/bash-completion/completions/%{name_pxy}
%files -n %{name_pxy}-zsh-completion
%{_zshdir}/_%{name_pxy}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%files -n %{name_pxy}-fish-completion
%{_datarootdir}/fish/vendor_completions.d/%{name_pxy}.fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%endif
# %{adm_build}
# mgrctl packages files
# Only SUSE distros have a -lang package
%if 0%{?suse_version} || 0%{?sle_version}
%files -n %{name_ctl}-lang -f %{name_ctl}.lang
%files -n %{name_ctl}
%else
%files -n %{name_ctl} -f %{name_ctl}.lang
%endif
# 0%{?suse_version} || 0%{?sle_version}
%defattr(-,root,root)
%doc README.md
%license LICENSE
%{_bindir}/%{name_ctl}
%files -n %{name_ctl}-bash-completion
%{_datarootdir}/bash-completion/completions/%{name_ctl}
%files -n %{name_ctl}-zsh-completion
%{_zshdir}/_%{name_ctl}
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%files -n %{name_ctl}-fish-completion
%{_datarootdir}/fish/vendor_completions.d/%{name_ctl}.fish
%endif
# 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
%changelog