%global with_debug 1 %global with_devel 0 %global with_unit_test 0 %if 0%{?fedora} || 0%{?centos} %global with_check 1 %global with_integration_tests 1 %else %global with_check 0 %global with_integration_tests 0 %endif %if 0%{?with_debug} %global _dwz_low_mem_die_limit 0 %else %global debug_package %{nil} %endif %global provider github %global provider_tld com %global project opencontrol %global repo compliance-masonry # https://github.com/opencontrol/compliance-masonry %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} %global import_path %{provider_prefix} %global commit 8cf30c64110a719c53f169b5ac0415bd23f920dc %global shortcommit %(c=%{commit}; echo ${c:0:7}) %if ! 0%{?gobuild:1} %define gobuild(o:) go build -tags="$BUILDTAGS rpm_crashtraceback" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; %endif Name: compliance-masonry Version: 1.1.4 Release: 1 Summary: OpenControl CLI Tool License: CC0 URL: https://%{provider_prefix} Source0: https://%{provider_prefix}/archive/v%{version}.tar.gz # e.g. el6 has ppc64 arch without gcc-go, so EA tag is required ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}} # If go_compiler is not set to 1, there is no virtual provide. Use golang instead. BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %description Compliance Masonry is a command-line interface (CLI) that allows users to construct certification documentation using the OpenControl Schema. %if 0%{?with_devel} %package devel Summary: %{summary} BuildArch: noarch %if 0%{?with_check} && ! 0%{?with_bundled} BuildRequires: golang(github.com/Masterminds/vcs) BuildRequires: golang(github.com/blang/semver) BuildRequires: golang(github.com/metaleap/go-util/fs) BuildRequires: golang(github.com/onsi/ginkgo) BuildRequires: golang(github.com/onsi/gomega) BuildRequires: golang(github.com/onsi/gomega/gexec) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/stretchr/testify/mock) BuildRequires: golang(github.com/tg/gosortmap) BuildRequires: golang(github.com/vektra/errors) BuildRequires: golang(gopkg.in/yaml.v2) %endif Requires: golang(github.com/Masterminds/vcs) Requires: golang(github.com/blang/semver) Requires: golang(github.com/metaleap/go-util/fs) Requires: golang(github.com/onsi/ginkgo) Requires: golang(github.com/onsi/gomega) Requires: golang(github.com/onsi/gomega/gexec) Requires: golang(github.com/spf13/cobra) Requires: golang(github.com/stretchr/testify/mock) Requires: golang(github.com/tg/gosortmap) Requires: golang(github.com/vektra/errors) Requires: golang(gopkg.in/yaml.v2) Provides: golang(%{import_path}/pkg/cli/clierrors) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/diff) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/docs) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/docs/gitbook) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/export) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/get) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/get/resources) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/get/resources/mocks) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cli/version) = %{version}-%{release} Provides: golang(%{import_path}/pkg/cmd/masonry) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/certifications) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/certifications/versions/1_0_0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/common) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/common/mocks) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/components) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/components/versions/2_0_0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/components/versions/3_0_0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/components/versions/3_1_0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/opencontrol) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/opencontrol/mocks) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/opencontrol/versions/1.0.0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/result) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/standards) = %{version}-%{release} Provides: golang(%{import_path}/pkg/lib/standards/versions/1_0_0) = %{version}-%{release} Provides: golang(%{import_path}/pkg/tests) = %{version}-%{release} Provides: golang(%{import_path}/tools/certifications) = %{version}-%{release} Provides: golang(%{import_path}/tools/constants) = %{version}-%{release} Provides: golang(%{import_path}/tools/fs) = %{version}-%{release} Provides: golang(%{import_path}/tools/fs/mocks) = %{version}-%{release} Provides: golang(%{import_path}/tools/mapset) = %{version}-%{release} Provides: golang(%{import_path}/tools/vcs) = %{version}-%{release} Provides: golang(%{import_path}/tools/vcs/mocks) = %{version}-%{release} Provides: golang(%{import_path}/version) = %{version}-%{release} %description devel %{summary} This package contains library source intended for building other packages which use import path with %{import_path} prefix. %endif %if 0%{?with_unit_test} && 0%{?with_devel} %package unit-test-devel Summary: Unit tests for %{name} package %if 0%{?with_check} #Here comes all BuildRequires: PACKAGE the unit tests #in %%check section need for running %endif # test subpackage tests code from devel subpackage Requires: %{name}-devel = %{version}-%{release} %if 0%{?with_check} && ! 0%{?with_bundled} BuildRequires: golang(github.com/onsi/ginkgo/extensions/table) BuildRequires: golang(github.com/onsi/gomega/gbytes) BuildRequires: golang(github.com/stretchr/testify/assert) %endif Requires: golang(github.com/onsi/ginkgo/extensions/table) Requires: golang(github.com/onsi/gomega/gbytes) Requires: golang(github.com/stretchr/testify/assert) %description unit-test-devel %{summary} This package contains unit tests for project providing packages with %{import_path} prefix. %endif %prep %setup -q -n %{name}-%{version} %build mkdir _output pushd _output mkdir -p src/%{provider}.%{provider_tld}/%{project} ln -s $(dirs +1 -l) src/%{import_path} popd ln -s vendor src export GOPATH=$(pwd)/_output:$(pwd):%{gopath} export LDFLAGS="-X %{import_path}/version.Version=%{version}%{release} \ -X %{import_path}/version.Commit=%{shortcommit} \ -X %{import_path}/version.Date=%(date -u +%%Y-%%m-%%dT%%T%%z)" for i in masonry compliance-masonry; do GOPATH=$GOPATH %gobuild -o $i cmd/$i/$i.go done %install install -dp %{buildroot}%{_bindir} install -p -m 755 %{name} %{buildroot}%{_bindir} install -p -m 755 masonry %{buildroot}%{_bindir} # source codes for building projects %if 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list # find all *.go but no *_test.go files and generate devel.file-list for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go" | grep -v "vendor") ; do dirprefix=$(dirname $file) install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list while [ "$dirprefix" != "." ]; do echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list dirprefix=$(dirname $dirprefix) done done %endif # testing files for this project %if 0%{?with_unit_test} && 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ # find all *_test.go files and generate unit-test-devel.file-list for file in $(find . -iname "*_test.go" | grep -v "vendor") ; do dirprefix=$(dirname $file) install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list while [ "$dirprefix" != "." ]; do echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list dirprefix=$(dirname $dirprefix) done done %endif %if 0%{?with_devel} sort -u -o devel.file-list devel.file-list %endif %check %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} %if ! 0%{?with_bundled} export GOPATH=%{buildroot}/%{gopath}:%{gopath} %else # Since we aren't packaging up the vendor directory we need to link # back to it somehow. Hack it up so that we can add the vendor # directory from BUILD dir as a gopath to be searched when executing # tests from the BUILDROOT dir. ln -s ./ ./vendor/src # ./vendor/src -> ./vendor export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath} %endif %if ! 0%{?gotest:1} %global gotest go test %endif %gotest %{import_path}/cmd/masonry %gotest %{import_path}/examples %gotest %{import_path}/pkg/cli/diff %gotest %{import_path}/pkg/cli/docs %gotest %{import_path}/pkg/cli/docs/gitbook %gotest %{import_path}/pkg/cli/export %gotest %{import_path}/pkg/cli/get/resources %gotest %{import_path}/pkg/lib %gotest %{import_path}/pkg/lib/certifications %gotest %{import_path}/pkg/lib/certifications/versions/1_0_0 %gotest %{import_path}/pkg/lib/common %gotest %{import_path}/pkg/lib/components %gotest %{import_path}/pkg/lib/components/versions/2_0_0 %gotest %{import_path}/pkg/lib/components/versions/3_0_0 %gotest %{import_path}/pkg/lib/components/versions/3_1_0 %gotest %{import_path}/pkg/lib/opencontrol %gotest %{import_path}/pkg/lib/opencontrol/versions/1.0.0 %gotest %{import_path}/pkg/lib/result %gotest %{import_path}/pkg/lib/standards %gotest %{import_path}/pkg/lib/standards/versions/1_0_0 %gotest %{import_path}/tools/mapset %gotest %{import_path}/tools/vcs %endif #define license tag if not already defined %{!?_licensedir:%global license %doc} %files %license LICENSE.md %doc README.md docs/* %{_bindir}/masonry %{_bindir}/%{repo} %if 0%{?with_devel} %files devel -f devel.file-list %license LICENSE.md %doc README.md CONTRIBUTING.md %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} %endif %if 0%{?with_unit_test} && 0%{?with_devel} %files unit-test-devel -f unit-test-devel.file-list %license LICENSE.md %doc README.md CONTRIBUTING.md %endif %changelog * Wed Jun 27 2018 Gabe - 1.1.4-1 - First package for Fedora