3
3
# proper distribution package, but changes should be made to suit the needs of
4
4
# the package.
5
5
6
- %define debug_package %{nil}
6
+ %bcond_without check
7
+
8
+ %global has_go_rpm_macros (0%{?fedora})
7
9
%define source_date_epoch_from_changelog 0
8
10
9
- Name: rhc
11
+ # must be before %%gometa
10
12
Version: @VERSION@
11
- Release: 0%{?dist}
13
+
14
+ # https://github.com/redhatinsights/rhc
15
+ %global goipath github.com/redhatinsights/rhc
16
+ %global commit @COMMIT@
17
+ %global shortcommit %(c=%{commit}; echo ${c:0:7})
18
+ %global date %(date "+%Y%m%d")
19
+ %global archivename rhc-%{version}
20
+
21
+ %if %{has_go_rpm_macros}
22
+ %gometa %{?fedora:-f}
23
+ %else
24
+ %global gourl https://github.com/RedHatInsights/%{name}
25
+ %global gomodulesmode GO111MODULES=off
26
+ %global gosource %{gourl}/releases/download/%{version}/rhc-%{version}.tar.gz
27
+ %global gocompilerflags "-buildmode pie -compiler gc"
28
+ %global scm git
29
+ %forgemeta
30
+ %endif
31
+
32
+ # Manually redefine %%dist to work around an issue in COPR where the build root
33
+ # that creates the srpm does not define a value for %%dist. This should *NOT* be
34
+ # carried in downstream; this is strictly an upstream/COPR/CI workaround.
35
+ %if "%{dist}" == ""
36
+ %global dist %{distprefix}.fc%{fedora}
37
+ %endif
38
+
39
+ %if 0%{?fedora}
40
+ %global setup_flags -Dvendor=False
41
+ %else
42
+ %endif
43
+ %global setup_flags -Dvendor=True
44
+
45
+ %global common_description %{expand:
46
+ rhc is a client that registers a system with RHSM and activates the Red Hat yggd
47
+ MQTT client.}
48
+
49
+ %global golicenses LICENSE
50
+ %global godocs CONTRIBUTING.md README.md
51
+
52
+ Name: rhc
53
+ Release: 99%{?dist}
12
54
Epoch: 1
13
55
Summary: Client for registering Red Hat Enterprise Linux systems
14
- License: GPL-3.0-only
15
- URL: https://github.com/redhatinsights/rhc
16
-
17
- Source0: %{name}-%{version}.tar.gz
18
56
19
- ExclusiveArch: %{go_arches}
57
+ License: GPL-3.0-only
58
+ URL: %{gourl}
59
+ Source0: %{gosource}
20
60
21
61
Requires: insights-client
22
62
Requires: yggdrasil >= 0.4
23
63
Requires: yggdrasil-worker-package-manager
24
64
Requires: subscription-manager
25
65
26
- BuildRequires: bash-completion
27
- BuildRequires: golang
28
- BuildRequires: dbus-devel
29
- BuildRequires: meson
30
- BuildRequires: systemd-devel
31
- BuildRequires: systemd
66
+ BuildRequires: systemd-rpm-macros
67
+ BuildRequires: meson
68
+ BuildRequires: pkgconfig(systemd)
69
+ BuildRequires: pkgconfig(bash-completion)
70
+ BuildRequires: golang >= 1.18
32
71
33
72
34
- %description
35
- rhc is a client that registers a system with RHSM and activates the Red Hat yggd
36
- MQTT client.
73
+ %description %{common_description}
37
74
38
75
%package compat
39
76
Summary: Transition package to support migrating from rhcd to yggd
@@ -44,22 +81,47 @@ Recommends: rhc
44
81
%description compat
45
82
Transition package to support migrating from rhcd to yggd.
46
83
84
+ %if %{has_go_rpm_macros}
85
+ %gopkg
86
+ %endif
87
+
47
88
%prep
89
+ %if 0%{?fedora}
90
+ %goprep
91
+ %else
48
92
%autosetup
93
+ %endif
49
94
95
+ %if 0%{?fedora}
96
+ %generate_buildrequires
97
+ %go_generate_buildrequires
98
+ %endif
50
99
51
100
%build
52
- %meson
101
+ %undefine _auto_set_build_flags
102
+ export %gomodulesmode
103
+ %{?gobuilddir:export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"}
104
+ ls
105
+ pwd
106
+ %meson %setup_flags "-Dgobuildflags=[%(echo %{expand:%gocompilerflags} | sed -e s/"^"/"'"/ -e s/" "/"', '"/g -e s/"$"/"'"/), '-tags', '"rpm_crashtraceback\ ${BUILDTAGS:-}"', '-a', '-v', '-x']" -Dgoldflags='%{?currentgoldflags} -B 0x%(head -c20 /dev/urandom|od -An -tx1|tr -d " \n") -compressdwarf=false -linkmode=external -extldflags "%{build_ldflags} %{?__golang_extldflags}"'
53
107
%meson_build
54
108
55
-
56
109
%install
57
110
%meson_install
58
111
install --directory %{buildroot}%{_unitdir}
59
112
install --directory %{buildroot}%{_sysconfdir}/rhc
60
113
ln -sf yggdrasil.service %{buildroot}%{_unitdir}/rhcd.service
61
114
ln -sf ../yggdrasil/config.toml %{buildroot}%{_sysconfdir}/rhc/config.toml
62
115
116
+ %if %{with check}
117
+ %check
118
+ %if 0%{?fedora}
119
+ %gocheck
120
+ %else
121
+ %meson_test
122
+ %endif
123
+ %endif
124
+
63
125
%post
64
126
%systemd_post rhc-canonical-facts.timer
65
127
if [ $1 -eq 1 ]; then
@@ -77,7 +139,8 @@ if [ $1 -eq 0 ]; then
77
139
fi
78
140
79
141
%files
80
- %doc README.md
142
+ %license LICENSE
143
+ %doc CONTRIBUTING.md README.md
81
144
%{_bindir}/*
82
145
%{_datadir}/bash-completion/completions/*
83
146
%{_mandir}/man1/*
0 commit comments