Blob Blame History Raw
%define debug_package %{nil}
%global buildflags -buildmode pie -compiler gc -a -v -x
%global goldflags %{expand:-linkmode=external -compressdwarf=false -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags'}

%global go_arches x86_64 s390x ppc64le

%global yggdrasil_ver   0.2.2
%global ygg_pkg_mgr_ver 0.1.0

Name:    rhc
Version: 0.2.4
Release: 1%{?dist}
Epoch:   1
Summary: rhc connects the system to Red Hat hosted services
License: GPLv3
URL:     https://github.com/RedHatInsights/rhc

Source0: https://github.com/RedHatInsights/rhc/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1: config.toml
Source2: https://github.com/RedHatInsights/yggdrasil/releases/download/%{yggdrasil_ver}/yggdrasil-%{yggdrasil_ver}.tar.gz
Source3: https://github.com/RedHatInsights/yggdrasil-worker-package-manager/releases/download/%{ygg_pkg_mgr_ver}/yggdrasil-worker-package-manager-%{ygg_pkg_mgr_ver}.tar.gz
Source4: rhc-package-manager.toml

# Remove Makefile preamble and use gzip -c instead of -k
Patch0:  yggdrasil-patch-Makefile.patch
Patch1:  rhc-patch-Makefile.patch
Patch2:  0001-feat-default-config-file-location.patch
Patch3:  0001-revert-drop-enable_content-option.patch

ExclusiveArch: %{go_arches}

Requires:      insights-client

%global go_toolset_version 1.19
BuildRequires: git
BuildRequires: go-toolset-%{go_toolset_version}-golang
BuildRequires: dbus-devel
BuildRequires: systemd-devel


%define _description %{expand:%{name} is a client tool and daemon that connects
the system to Red Hat hosted services enabling system and subscription
management.}

%description
%{_description}

%global makeflags %{expand:PREFIX=%{_prefix} \\
     SYSCONFDIR=%{_sysconfdir} \\
     LOCALSTATEDIR=%{_localstatedir} \\
     SHORTNAME=%{name} \\
     LONGNAME=%{name} \\
     PKGNAME=%{name} \\
     'BRANDNAME=Remote Host Configuration' \\
     TOPICPREFIX=redhat/insights \\
     VERSION=%{version} \\
     DATAHOST=cert.cloud.redhat.com \\
     'PROVIDER=Red Hat'}


%prep
%setup -q -T -D -c -n %{name} -a 0
%setup -q -T -D -c -n %{name} -a 2
%setup -q -T -D -c -n %{name} -a 3
sed -i -e "s/LDFLAGS :=/LDFLAGS ?=/" %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}/Makefile
sed -i -e "s/LDFLAGS :=/LDFLAGS ?=/" %{_builddir}/%{name}/%{name}-%{version}/Makefile
cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
%patch -P 0 -p1
cd %{_builddir}/%{name}/%{name}-%{version}
%patch -P 1 -p1
%patch -P 3 -p1
cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
%patch -P 2 -p0

%build
export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all"
export BUILDFLAGS="%{buildflags}"
export LDFLAGS="%{goldflags}"
cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
scl enable go-toolset-%{go_toolset_version} -- \
make %{makeflags}

cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
scl enable go-toolset-%{go_toolset_version} -- \
go build %{buildflags} -ldflags="%{goldflags}" -o rhc-package-manager-worker -mod=vendor .

cd %{_builddir}/%{name}/%{name}-%{version}
scl enable go-toolset-%{go_toolset_version} -- \
make %{makeflags}


%install
export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all"
export BUILDFLAGS="%{buildflags}"
export LDFLAGS="%{goldflags}"
cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
scl enable go-toolset-%{go_toolset_version} -- \
make %{makeflags} \
     DESTDIR=%{buildroot} \
     install

%{__install} -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}/

cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
%{__install} -D -m 755 rhc-package-manager-worker %{buildroot}%{_libexecdir}/%{name}/
%{__install} -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/%{name}/workers/rhc-package-manager.toml

cd %{_builddir}/%{name}/%{name}-%{version}
make %{makeflags} \
     DESTDIR=%{buildroot} \
     install


%files
%doc %{name}-%{version}/README.md yggdrasil-%{yggdrasil_ver}/doc/tags.toml
%{_bindir}/%{name}
%{_sbindir}/%{name}d
%config(noreplace) %{_sysconfdir}/%{name}/config.toml
%config(noreplace) %{_sysconfdir}/%{name}/workers/rhc-package-manager.toml
%{_unitdir}/%{name}d.service
%{_datadir}/bash-completion/completions/*
%{_mandir}/man1/*
%{_prefix}/share/pkgconfig/%{name}.pc
%{_libexecdir}/%{name}


%changelog
* Wed Aug 30 2023 Link Dupont <link@redhat.com> - 0.2.4-1
- Update rhc to 0.2.4 (RHBZ#2227142)
- Update yggdrasion to 0.2.2 (RHBZ#2227142)
- Include rhc-worker-package-manager
- Rebuild with Go 1.19

* Mon Oct 24 2022 Link Dupont <link@redhat.com> - 0.2.0-3
- Rebuild with Go 1.16 (RHBZ#2028560)

* Wed Aug 25 2021 Link Dupont <link@redhat.com> - 0.2.0-2
- Rebuild for new build target

* Mon Jun 28 2021 Link Dupont <link@redhat.com> - 0.2.0-1
- New upstream release
- Mark config file as a noreplace config file

* Fri Apr  9 2021 Link Dupont <link@redhat.com> - 0.1.4-1
- New upstream release

* Fri Feb 19 2021 Link Dupont <link@redhat.com> - 0.1.2-2
- Update default broker URI
- Set Epoch to 1

* Thu Feb 18 2021 Link Dupont <link@redhat.com> - 0.1.2-1
- New upstream release

* Wed Feb 17 2021 Link Dupont <link@redhat.com> - 0.1.1-1
- New upstream release

* Fri Feb 12 2021 Link Dupont <link@redhat.com> - 0.1-1
- Initial release