%bcond_without check %global has_go_rpm_macros (0%{?fedora}) # https://github.com/redhatinsights/yggdrasil-worker-package-manager %global goipath github.com/redhatinsights/yggdrasil-worker-package-manager Version: 0.2.3 %global commit 4db1b94c7f23a515511ccbec2eb7501c1cb29743 %global date %(date "+%Y%m%d") %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global archivename yggdrasil-worker-package-manager-%{version} %if %{has_go_rpm_macros} %gometa %{?fedora:-f} %else %global gourl https://github.com/RedHatInsights/%{name} %global gomodulesmode GO111MODULES=off %global gosource %{gourl}/releases/download/%{version}/%{name}-%{version}.tar.gz %global gocompilerflags "-buildmode pie -compiler gc" %global scm git %forgemeta %endif %if 0%{?fedora} %global setup_flags -Dvendor=False %else %global setup_flags -Dvendor=True %endif %global common_description %{expand: yggdrasil-worker-package-manager is a simple package manager yggd worker. It knows how to install and remove packages, add, remove, enable and disable repositories, and does rudimentary detection of the host it is running on to guess the package manager to use. It only installs packages that match one of the provided allow-pattern regular expressions.} %global golicenses LICENSE %global godocs README.md Name: yggdrasil-worker-package-manager Release: 99%{?dist} Summary: Package manager worker for yggdrasil License: GPL-3.0-only URL: %{gourl} Source: %{gosource} BuildRequires: systemd-rpm-macros BuildRequires: meson BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(systemd) BuildRequires: golang >= 1.18 %description %{common_description} %if %{has_go_rpm_macros} %gopkg %endif %prep %if %{has_go_rpm_macros} %goprep %{?rhel:-k} %else %autosetup %endif %if 0%{?fedora} %generate_buildrequires %go_generate_buildrequires %endif %build %undefine _auto_set_build_flags export %gomodulesmode %{?gobuilddir:export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %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}"' %meson_build %install %meson_install %if %{has_go_rpm_macros} %gopkginstall %endif %if %{with check} %check %if %{has_go_rpm_macros} %gocheck %else %meson_test %endif %endif %post %systemd_post com.redhat.Yggdrasil1.Worker1.package_manager.service %preun %systemd_preun com.redhat.Yggdrasil1.Worker1.package_manager.service %postun %systemd_postun_with_restart com.redhat.Yggdrasil1.Worker1.package_manager.service %files %license LICENSE %if %{defined rhel} %license vendor/modules.txt %endif %doc README.md %{_libexecdir}/* %config(noreplace) %{_sysconfdir}/%{name} %{_datadir}/dbus-1/system-services/* %{_datadir}/dbus-1/system.d/* %{_unitdir}/* %if %{has_go_rpm_macros} %gopkgfiles %endif %changelog