# This RPM spec file exists primarily to enable CI/CD pipelines and automatic
# testing of built RPMs. This RPM can be used as a suitable baseline for a
# proper distribution package, but changes should be made to suit the needs of
# the package.

%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'}

Name:    yggdrasil
Version: 0.2.99
Release: 0.86.git.3eb009b
Summary: Message dispatch agent for cloud-connected systems
License: GPLv3
URL: https://github.com/redhatinsights/yggdrasil

Source: %{name}-%{version}-%{release}.tar.gz

ExclusiveArch: %{go_arches}

BuildRequires: git
BuildRequires: golang
BuildRequires: dbus-devel
BuildRequires: systemd-devel


%description
yggdrasil is pair of utilities that register systems with RHSM and establishes
a receiving queue for instructions to be sent to the system via a broker.

%prep
%autosetup -n %{name}-%{version}-%{release}


%build
%set_build_flags
export BUILDFLAGS="%{buildflags}"
export LDFLAGS="%{goldflags}"
make PREFIX=%{_prefix} \
     SYSCONFDIR=%{_sysconfdir} \
     LOCALSTATEDIR=%{_localstatedir} \
     LIBEXECDIR=%{_libexecdir} \
     SHORTNAME=yggdrasil \
     LONGNAME=yggdrasil \
     PKGNAME=yggdrasil \
     BRANDNAME=yggdrasil \
     TOPICPREFIX=yggdrasil \
     VERSION=%{version} \
     DATAHOST="" \
     'PROVIDER='


%install
%set_build_flags
export BUILDFLAGS="%{buildflags}"
export LDFLAGS="%{goldflags}"
make PREFIX=%{_prefix} \
     SYSCONFDIR=%{_sysconfdir} \
     LOCALSTATEDIR=%{_localstatedir} \
     LIBEXECDIR=%{_libexecdir} \
     DESTDIR=%{buildroot} \
     SHORTNAME=yggdrasil \
     LONGNAME=yggdrasil \
     PKGNAME=yggdrasil \
     BRANDNAME=yggdrasil \
     TOPICPREFIX=yggdrasil \
     VERSION=%{version} \
     DATAHOST="" \
     'PROVIDER=' \
     install


%files
%doc README.md doc/tags.toml
%{_sbindir}/yggdrasild
%config(noreplace) %{_sysconfdir}/yggdrasil/config.toml
%{_unitdir}/yggdrasild.service
%{_datadir}/bash-completion/completions/*
%{_mandir}/man1/*
%{_prefix}/share/pkgconfig/yggdrasil.pc
%{_libexecdir}/yggdrasil


%changelog