Skip to content

Commit 096e7b2

Browse files
committed
fix: use forge macros
Create NVR information using forge macros
1 parent d0cad0c commit 096e7b2

File tree

2 files changed

+84
-20
lines changed

2 files changed

+84
-20
lines changed

.packit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ srpm_build_deps:
1010
- "pkgconfig(bash-completion)"
1111
- "pkgconfig(dbus-1)"
1212
- "pkgconfig(systemd)"
13+
- "rpm_macro(forgemeta)"
1314
- rpm-build
1415

1516
actions:

dist/srpm/rhc.spec.in

Lines changed: 83 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,74 @@
33
# proper distribution package, but changes should be made to suit the needs of
44
# the package.
55

6-
%define debug_package %{nil}
6+
%bcond_without check
7+
8+
%global has_go_rpm_macros (0%{?fedora})
79
%define source_date_epoch_from_changelog 0
810

9-
Name: rhc
11+
# must be before %%gometa
1012
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}
1254
Epoch: 1
1355
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
1856

19-
ExclusiveArch: %{go_arches}
57+
License: GPL-3.0-only
58+
URL: %{gourl}
59+
Source0: %{gosource}
2060

2161
Requires: insights-client
2262
Requires: yggdrasil >= 0.4
2363
Requires: yggdrasil-worker-package-manager
2464
Requires: subscription-manager
2565

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
3271

3372

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}
3774

3875
%package compat
3976
Summary: Transition package to support migrating from rhcd to yggd
@@ -44,22 +81,47 @@ Recommends: rhc
4481
%description compat
4582
Transition package to support migrating from rhcd to yggd.
4683

84+
%if %{has_go_rpm_macros}
85+
%gopkg
86+
%endif
87+
4788
%prep
89+
%if 0%{?fedora}
90+
%goprep
91+
%else
4892
%autosetup
93+
%endif
4994

95+
%if 0%{?fedora}
96+
%generate_buildrequires
97+
%go_generate_buildrequires
98+
%endif
5099

51100
%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}"'
53107
%meson_build
54108

55-
56109
%install
57110
%meson_install
58111
install --directory %{buildroot}%{_unitdir}
59112
install --directory %{buildroot}%{_sysconfdir}/rhc
60113
ln -sf yggdrasil.service %{buildroot}%{_unitdir}/rhcd.service
61114
ln -sf ../yggdrasil/config.toml %{buildroot}%{_sysconfdir}/rhc/config.toml
62115

116+
%if %{with check}
117+
%check
118+
%if 0%{?fedora}
119+
%gocheck
120+
%else
121+
%meson_test
122+
%endif
123+
%endif
124+
63125
%post
64126
%systemd_post rhc-canonical-facts.timer
65127
if [ $1 -eq 1 ]; then
@@ -77,7 +139,8 @@ if [ $1 -eq 0 ]; then
77139
fi
78140

79141
%files
80-
%doc README.md
142+
%license LICENSE
143+
%doc CONTRIBUTING.md README.md
81144
%{_bindir}/*
82145
%{_datadir}/bash-completion/completions/*
83146
%{_mandir}/man1/*

0 commit comments

Comments
 (0)