Blame SPECS/host-metering.spec

048fb3
%bcond_without check
048fb3
048fb3
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && ! 0%{?centos}
048fb3
%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 %{?**};
048fb3
%endif
048fb3
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && 0%{?centos}
048fb3
048fb3
%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 %{?**};
048fb3
%endif
048fb3
048fb3
%global goipath         github.com/RedHatInsights/host-metering
048fb3
%global forgeurl        https://github.com/RedHatInsights/host-metering/
048fb3
%global autorelease     4
048fb3
%global gomodulesmode   GO111MODULE=on
048fb3
%global godocs          README.md
048fb3
%global go_arches       x86_64 s390x ppc64le
048fb3
048fb3
# macros needed by SELinux
048fb3
%global selinuxtype     targeted
048fb3
%global moduletype      contrib
048fb3
%global modulename      host-metering
048fb3
048fb3
Name:           host-metering
048fb3
Version:        1.2.0
048fb3
Release:        %{autorelease}%{?dist}
048fb3
Summary:        None
048fb3
048fb3
License:        Apache-2.0
048fb3
URL:            https://github.com/RedHatInsights/host-metering/
048fb3
ExclusiveArch: %{go_arches}
048fb3
048fb3
Source:         https://github.com/RedHatInsights/host-metering/releases/download/v%{version}/host-metering-%{version}.tar.gz
048fb3
048fb3
# RHEL specific patches
048fb3
Patch0001:      0001-use-production-write-url.patch
048fb3
Patch0002:      0002-feat-enable-host-metering.service-on-rpm-installatio.patch
048fb3
048fb3
%if 0%{?rhel} <= 7 && ! 0%{?fedora} && ! 0%{?centos}
048fb3
BuildRequires: go-toolset-1.19
048fb3
%else
048fb3
BuildRequires: golang >= 1.19
048fb3
BuildRequires: systemd-rpm-macros
048fb3
%endif
048fb3
BuildRequires: git
048fb3
BuildRequires: policycoreutils
048fb3
BuildRequires: selinux-policy
048fb3
BuildRequires: selinux-policy-devel
048fb3
Requires:      %{name}-selinux = %{version}-%{release}
048fb3
048fb3
%description
048fb3
Host metering service
048fb3
048fb3
%package selinux
048fb3
Summary:       SELinux policy module for host-metering
048fb3
BuildArch:     noarch
048fb3
%{?selinux_requires}
048fb3
Requires:      %{name} = %{version}-%{release}
048fb3
048fb3
%description selinux
048fb3
This package installs and sets up the SELinux policy security module for host-metering.
048fb3
048fb3
%prep
048fb3
%setup -q -b 0
048fb3
048fb3
# for possible downstream patches
048fb3
%autopatch -p1
048fb3
048fb3
%build
048fb3
pwd
048fb3
%gobuild -o $(pwd)/bin/host-metering %{goipath}
048fb3
make build-selinux
048fb3
048fb3
%pre selinux
048fb3
%selinux_relabel_pre -s %{selinuxtype}
048fb3
048fb3
%install
048fb3
install -m 0755 -vd                     %{buildroot}%{_bindir}
048fb3
install -m 0755 -vp $(pwd)/bin/*        %{buildroot}%{_bindir}/
048fb3
install -m 0755 -vd                     %{buildroot}%{_unitdir}
048fb3
install -m 644 contrib/systemd/host-metering.service %{buildroot}%{_unitdir}/%{name}.service
048fb3
install -m 0755 -vd                     %{buildroot}%{_presetdir}
048fb3
install -m 644 contrib/systemd/80-host-metering.preset %{buildroot}%{_presetdir}/80-%{name}.preset
048fb3
install -m 0755 -vd                     %{buildroot}%{_mandir}/man1
048fb3
install -m 644 contrib/man/host-metering.1 %{buildroot}%{_mandir}/man1/host-metering.1
048fb3
install -m 0755 -vd                     %{buildroot}%{_mandir}/man5
048fb3
install -m 644 contrib/man/host-metering.conf.5 %{buildroot}%{_mandir}/man5/host-metering.conf.5
048fb3
048fb3
install -D -m 0644 contrib/selinux/%{modulename}.pp %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp
048fb3
install -D -p -m 644 contrib/selinux/%{modulename}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{modulename}.if
048fb3
048fb3
%if %{with check}
048fb3
%check
048fb3
%endif
048fb3
048fb3
%post
048fb3
%systemd_post %{name}.service
048fb3
048fb3
%post selinux
048fb3
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp
048fb3
%selinux_relabel_post -s %{selinuxtype}
048fb3
048fb3
if [ "$1" -le "1" ]; then # First install
048fb3
   # the daemon needs to be restarted for the custom label to be applied
048fb3
   %systemd_postun_with_restart %{modulename}.service
048fb3
fi
048fb3
048fb3
%preun
048fb3
%systemd_preun %{name}.service
048fb3
048fb3
%postun
048fb3
%systemd_postun_with_restart %{name}.service
048fb3
048fb3
%postun selinux
048fb3
if [ $1 -eq 0 ]; then
048fb3
    %selinux_modules_uninstall -s %{selinuxtype} %{modulename}
048fb3
    %selinux_relabel_post -s %{selinuxtype}
048fb3
fi
048fb3
048fb3
%files
048fb3
%doc README.md
048fb3
%{_bindir}/*
048fb3
%attr(644,root,root) %{_unitdir}/%{name}.service
048fb3
%{_mandir}/man1/host-metering.1*
048fb3
%{_mandir}/man5/host-metering.conf.5*
048fb3
%{_presetdir}/*.preset
048fb3
048fb3
%files selinux
048fb3
%{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp
048fb3
%{_datadir}/selinux/devel/include/distributed/%{modulename}.if
048fb3
%ghost %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{modulename}
048fb3
048fb3
048fb3
%changelog
048fb3
* Fri Jan 12 2024 Vobornik Petr <pvoborni@redhat.com> - 1.2.0-4
048fb3
- Removal of automatic start if host-metering.service on rpm installation
048fb3
048fb3
* Tue Jan 9 2024 Vobornik Petr <pvoborni@redhat.com> - 1.2.0-3
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7
048fb3
- Enable and start host-metering.service on rpm installation
048fb3
048fb3
* Fri Jan 5 2024 Vobornik Petr <pvoborni@redhat.com> - 1.2.0-2
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7
048fb3
- Fixed default writeUrl
048fb3
048fb3
* Tue Dec 19 2023 Vobornik Petr <pvoborni@redhat.com> - 1.2.0-1
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7
048fb3
- Rebasing to upstream release v1.2.0
048fb3
048fb3
* Wed Dec 13 2023 Vobornik Petr <pvoborni@redhat.com> - 1.1.0-1
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7
048fb3
- Rebasing to upstream release v1.1.0
048fb3
048fb3
* Fri Dec 8 2023 Vobornik Petr <pvoborni@redhat.com> - 1.0.0-2
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7
048fb3
- Change custom log file permission to 0600
048fb3
048fb3
* Tue Nov 7 2023 Vobornik Petr <pvoborni@redhat.com> - 1.0.0-1
048fb3
- Resolves: RHEL-12368 [RFE] Add host-metering package to RHEL 7