packaging/{opensuse,fedora}: allow package build with testkeys included #3450

Merged
merged 7 commits into from Jun 19, 2017
@@ -6,10 +6,15 @@
%bcond_without vendorized
%endif
+# A switch to allow building the package with support for testkeys which
+# are used for the spread test suite of snapd.
+%bcond_with testkeys
+
%global with_devel 1
%global with_debug 1
%global with_check 0
%global with_unit_test 0
+%global with_test_keys 0
# For the moment, we don't support all golang arches...
%global with_goarches 0
@@ -20,6 +25,12 @@
%global with_bundled 1
%endif
+%if ! %{with testkeys}
+%global with_test_keys 0
+%else
+%global with_test_keys 1
+%endif
+
%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
@@ -320,11 +331,19 @@ export GOPATH=$(pwd):%{gopath}
export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
%endif
-%gobuild -o bin/snap %{import_path}/cmd/snap
-%gobuild -o bin/snap-exec %{import_path}/cmd/snap-exec
-%gobuild -o bin/snapctl %{import_path}/cmd/snapctl
-%gobuild -o bin/snapd %{import_path}/cmd/snapd
-%gobuild -o bin/snap-update-ns %{import_path}/cmd/snap-update-ns
+GOFLAGS=
@Conan-Kudo

Conan-Kudo Jun 17, 2017

Contributor

You're still erasing the GOFLAGS here... :(

@morphis

morphis Jun 19, 2017

Contributor

Who else uses GOFLAGS? Nothing in the spec file does and nothing of the RPM golang macros does.

+%if 0%{?with_test_keys}
+GOFLAGS="$GOFLAGS -tags withtestkeys"
+%endif
+
+# We have to build snapd first to prevent the build from
+# building various things from the tree without additional
+# set tags.
+%gobuild -o bin/snapd $GOFLAGS %{import_path}/cmd/snapd
+%gobuild -o bin/snap $GOFLAGS %{import_path}/cmd/snap
+%gobuild -o bin/snap-exec $GOFLAGS %{import_path}/cmd/snap-exec
+%gobuild -o bin/snapctl $GOFLAGS %{import_path}/cmd/snapctl
+%gobuild -o bin/snap-update-ns $GOFLAGS %{import_path}/cmd/snap-update-ns
# Build SELinux module
pushd ./data/selinux
@@ -13,13 +13,23 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
+%bcond_with testkeys
+
%global provider github
%global provider_tld com
%global project snapcore
%global repo snapd
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
+%global with_test_keys 0
+
+%if %{with testkeys}
+%global with_test_keys 1
+%else
+%global with_test_keys 0
+%endif
+
%define systemd_services_list snapd.refresh.timer snapd.refresh.service snapd.socket snapd.service snapd.autoimport.service snapd.system-shutdown.service
Name: snapd
Version: 2.25
@@ -117,11 +127,28 @@ export CXXFLAGS
%build
# Build golang executables
%goprep %{import_path}
+
+%if 0%{?with_test_keys}
+# The %gobuild macro doesn't allow us to pass any additional parameters
+# so we we have to invoke `go install` here manually.
+export GOPATH=%{_builddir}/go:%{_libdir}/go/contrib
+export GOBIN=%{_builddir}/go/bin
+# Options used are the same as the %gobuild macro does but as it
+# doesn't allow us to amend new flags we have to repeat them here:
+# -s: tell long running tests to shorten their build time
+# -v: be verbose
+# -p 4: allow parallel execution of tests
+# -x: print commands
+go install -s -v -p 4 -x -tags withtestkeys github.com/snapcore/snapd/cmd/snapd
+%else
+%gobuild cmd/snapd
+%endif
+
%gobuild cmd/snap
%gobuild cmd/snap-exec
%gobuild cmd/snapctl
-%gobuild cmd/snapd
%gobuild cmd/snap-update-ns
+
# Build C executables
make %{?_smp_mflags} -C cmd