-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rpm spec and Makefile targets to install and run host-metering from RPM. The Makefile targets allow to build it directly on current host (rpm) or via mock in several build targets. Signed-off-by: Petr Vobornik <[email protected]>
- Loading branch information
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Build / Release | ||
dist/ | ||
vendor/ | ||
contrib/rpm/host-metering.spec | ||
|
||
# Coverage | ||
coverage.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
%bcond_without check | ||
|
||
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && ! 0%{?centos} | ||
%define gobuild(o:) scl enable go-toolset-1.19 -- go build -mod vendor -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${GO_LDFLAGS:-} ${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'" -a -v %{?**}; | ||
%endif | ||
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && 0%{?centos} | ||
|
||
%define gobuild(o:) go build -mod vendor -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${GO_LDFLAGS:-} ${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'" -a -v %{?**}; | ||
%endif | ||
|
||
%global goipath github.com/RedHatInsights/host-metering | ||
%global forgeurl https://github.com/RedHatInsights/host-metering/ | ||
%global autorelease #AUTORELEASE# | ||
%global gomodulesmode GO111MODULE=on | ||
|
||
|
||
%global godocs README.md | ||
|
||
Name: host-metering | ||
Version: #VERSION# | ||
Release: %{autorelease}%{?dist} | ||
Summary: None | ||
|
||
License: Apache-2.0 | ||
ExcludeArch: %{ix86} s390 ppc ppc64 | ||
URL: %{gourl} | ||
|
||
Source: %{name}-%{version}.tar.gz | ||
|
||
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && ! 0%{?centos} | ||
BuildRequires: go-toolset-1.19 | ||
%else | ||
BuildRequires: golang >= 1.19 | ||
BuildRequires: systemd-rpm-macros | ||
%endif | ||
BuildRequires: git | ||
|
||
%description | ||
Host metering service | ||
|
||
%gopkg | ||
|
||
%prep | ||
%setup -q -b 0 | ||
|
||
# for possible downstream patches | ||
%autopatch -p1 | ||
|
||
%build | ||
pwd | ||
%gobuild -o $(pwd)/bin/host-metering %{goipath} | ||
|
||
%install | ||
install -m 0755 -vd %{buildroot}%{_bindir} | ||
install -m 0755 -vp $(pwd)/bin/* %{buildroot}%{_bindir}/ | ||
install -m 0755 -vd %{buildroot}%{_unitdir} | ||
install -m 644 contrib/systemd/host-metering.service %{buildroot}%{_unitdir}/%{name}.service | ||
|
||
%if %{with check} | ||
%check | ||
%endif | ||
|
||
%files | ||
%doc README.md | ||
%{_bindir}/* | ||
%attr(644,root,root) %{_unitdir}/%{name}.service | ||
|
||
|
||
%changelog | ||
* Mon Oct 2 2023 Vobornik Petr <[email protected]> - #VERSION#-#AUTORELEASE# | ||
- No changelog. The history is kept in Git, downstreams have own logs. |