forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuyuni-tools.spec
More file actions
561 lines (458 loc) · 15.8 KB
/
Copy pathuyuni-tools.spec
File metadata and controls
561 lines (458 loc) · 15.8 KB
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#
# spec file for package uyuni-tools
#
# Copyright (c) 2026 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}
%{!?productprettyname: %global productprettyname Uyuni}
%global namespace registry.opensuse.org/uyuni
%if "%{productprettyname}" == "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
%else
%if 0%{?suse_version} >= 1600 || 0%{?sle_version} >= 150400
%define adm_build 1
%else
%define adm_build 0
%endif
%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
# debian || ubuntu
Name: %{project}
Version: 5.2.9
Release: 0
Summary: Tools for managing %{productprettyname} container
License: Apache-2.0
Group: System/Management
URL: https://%{provider_prefix}
#!CreateArchive: uyuni-tools
Source0: %{name}-%{version}.tar.gz
#!CreateArchive: vendor
Source1: vendor.tar.gz
BuildRequires: bash-completion
BuildRequires: coreutils
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires: gettext
%endif
# debian || ubuntu
%if 0%{?is_opensuse} || 0%{?fedora} || 0%{?debian} || 0%{?ubuntu}
BuildRequires: fish
%endif
# is_opensuse || fedora || debian || ubuntu
BuildRequires: zsh
# Get the proper Go version on different distros
%if 0%{?suse_version}
BuildRequires: golang(API) >= 1.25
%endif
# suse_version
%if 0%{?ubuntu}
%define go_version 1.22
# On Ubuntu 22.04, the metapackage golang is too old (1.18) and
# we must use the versioned package name specifically for this OS version.
%if 0%{?ubuntu} == 2204
BuildRequires: golang-%{go_version}-go
%else
BuildRequires: golang >= %{go_version}
%endif
%endif
# ubuntu
%if 0%{?debian}
BuildRequires: golang >= 1.19
%endif
# debian
%if 0%{?fedora} || 0%{?rhel}
BuildRequires: golang >= 1.21
%endif
# fedora || rhel
%description
Tools for managing %{productprettyname} container.
%if %{adm_build}
%package -n %{name_adm}
Summary: Command line tool to install and update %{productprettyname}
%if 0%{?suse_version}
Requires: (aardvark-dns if podman)
Requires: (netavark if podman)
%endif
# 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 %{productprettyname} components as containers running
either on Podman or a Kubernetes cluster.
%package -n %{name_pxy}
Summary: Command line tool to install and update %{productprettyname} proxy
Obsoletes: uyuni-proxy-systemd-services
%if 0%{?suse_version}
Requires: (aardvark-dns if podman)
Requires: (netavark if podman)
%endif
# suse_version
%description -n %{name_pxy}
%{name_pxy} is a convenient tool to install and update %{productprettyname} 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} >= 1500
Supplements: (%{name_adm} and bash-completion)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_adm} and zsh)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_pxy} and bash-completion)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_pxy} and zsh)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_adm} and fish)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_pxy} and fish)
%endif
# suse_version >= 1500
%description -n %{name_pxy}-fish-completion
Fish command line completion support for %{name_pxy}.
%endif
# is_opensuse || fedora || debian || ubuntu
%endif
# adm_build
%package -n %{name_ctl}
Summary: Command line tool to perform day-to-day operations on %{productprettyname}
%description -n %{name_ctl}
%{name_ctl} is a tool helping with daily tasks on %{productprettyname} 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} >= 1500
Supplements: (%{name_ctl} and bash-completion)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_ctl} and zsh)
%endif
# suse_version >= 1500
%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} >= 1500
Supplements: (%{name_ctl} and fish)
%endif
# suse_version >= 1500
%description -n %{name_ctl}-fish-completion
Fish command line completion support for %{name_ctl}.
%endif
# is_opensuse || fedora || debian || 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
# suse_version || sle_version
%prep
%autosetup
tar -zxf %{SOURCE1}
%build
%ifarch i386
%if 0%{?debian}
# Disable CGO build for debian 32 bits to avoid cross-compilation
export CGO_ENABLED=0
%endif
%endif
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_namespace=%{namespace}
%if "%{?_default_namespace}" != ""
namespace='%{_default_namespace}'
%endif
%if "%{?_default_helm_registry}" != ""
helm_namespace='%{_default_helm_registry}'
%endif
go_tags=""
%if "%{?_uyuni_tools_tags}" != ""
go_tags="-tags %{_uyuni_tools_tags}"
%endif
# "_uyuni_tools_tags" != ""
go_path=""
%if 0%{?ubuntu}
# Pinpoint the highest binary
go_path=$(find /usr/lib/go-*/bin/go 2>/dev/null | sort | tail -n 1)
[ -z "$go_path" ] && go_path="/usr/bin/go"
if [ -x "$go_path" ]; then
# Query GOVERSION
v_str=$("$go_path" env GOVERSION 2>/dev/null)
# Strip the leading 'go' prefix
v_str="${v_str#go}"
# Parse required and found versions
echo "%{go_version}" | { IFS="." read -r req_major req_minor req_patch;
echo "$v_str" | { IFS="." read -r max_major max_minor max_patch;
# Fallbacks to guarantee whole integers if trailing elements are empty
[ -z "$max_patch" ] && max_patch=0
[ -z "$max_minor" ] && max_minor=0
if [ "$max_major" -lt "$req_major" ] || { [ "$max_major" -eq "$req_major" ] && [ "$max_minor" -lt "$req_minor" ]; }; then
echo "ERROR: Found Go version ${v_str} at ${go_path}, but version >= %{go_version} is required."
exit 1
fi
}; }
# Format the path variable suffix for the rest of the spec compilation steps
go_path="${go_path%go}"
else
echo "ERROR: No Go compiler found at ${go_path} or /usr/bin/go"
exit 1
fi
%else
%if "%{?_go_bin}" != ""
go_path='%{_go_bin}/'
%endif
%endif
# ubuntu
registry="${namespace%%%%/*}"
imageprefix="${namespace#*/}"
# --- same for helm_registry ---
helmregistry="${helm_namespace%%%%/*}"
helmimageprefix="${helm_namespace#*/}"
GOLD_FLAGS="-X '${UTILS_PATH}.Version=%{version} for ${tag} image (%{version_details}) (compilation tag: %{_uyuni_tools_tags})' -X ${UTILS_PATH}.LocaleRoot=%{_datadir}/locale"
if test -n "${namespace}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultRegistry=${registry}"
fi
if test -n "${helmregistry}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultHelmRegistry=${helmregistry}"
fi
if test -n "${imageprefix}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultImagePrefix=${imageprefix}"
fi
if test -n "${helmimageprefix}"; then
GOLD_FLAGS="${GOLD_FLAGS} -X ${UTILS_PATH}.DefaultHelmImagePrefix=${helmimageprefix}"
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
# rhel >= 8 || 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
# 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
# is_opensuse || fedora || debian || 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
# is_opensuse || fedora || debian || 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
# suse_version || 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
# is_opensuse || fedora || debian || 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
# suse_version || 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
# is_opensuse || fedora || debian || 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
# suse_version || 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
# is_opensuse || fedora || debian || ubuntu
%changelog