From c69b16dca79e67e1b967243bc96e9fd865b30352 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mar 12 2020 09:57:56 +0000 Subject: Drop go-rpm-macros for RHEL As go-rpm-macros are still not part of RHEL Buildroot, let's add the conditional and only use it on Fedora. This change requires: - explicitly setting "_find_debuginfo_dwz_opts" and "_dwz_low_mem_die_limit", for generating the debug packages when not using go-rpm-macros; - explicitly define gobuild, in case its not defined; - The definition was taken from Fedora 33 podman.spec and tested on RHEL 8.2; - depend on golang instead of go-rpm-macros when building on RHEL; - depend on compiler(go-compiler), in order to have debugsource and debuginfo packages generated, when building on RHEL. Signed-off-by: Cole Robinson Signed-off-by: Fabiano FidĂȘncio --- diff --git a/kata-shim.spec b/kata-shim.spec index 7530cb4..114593e 100644 --- a/kata-shim.spec +++ b/kata-shim.spec @@ -1,3 +1,17 @@ +%global with_debug 1 + +%if 0%{?with_debug} +%global _find_debuginfo_dwz_opts %{nil} +%global _dwz_low_mem_die_limit 0 +%else +%global debug_package %{nil} +%endif + +%if ! 0%{?gobuild:1} +# %gobuild not available on RHEL. Definition lifted from Fedora33 podman.spec and tested on RHEL-8.2 +%define gobuild(o:) GO111MODULE=off go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -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 -x %{?**}; +%endif + %global domain github.com %global org kata-containers %global repo shim @@ -13,7 +27,12 @@ Summary: A shim running in the host for teh Kata Containers project Group: Development/Tools License: ASL 2.0 +%if 0%{?fedora} BuildRequires: go-rpm-macros +%else +BuildRequires: compiler(go-compiler) +BuildRequires: golang +%endif Provides: bundled(golang(github.com/Azure/go-ansiterm)) = d6e3b3328b783f23731bc4d058875b0371ff8109 Provides: bundled(golang(github.com/davecgh/go-spew)) = v1.1.0