diff --git a/consul.spec b/consul.spec index 4efb5ab..587cf27 100644 --- a/consul.spec +++ b/consul.spec @@ -17,71 +17,53 @@ %else %global debug_package %{nil} %endif + +%if ! 0%{?gobuild:1} +%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; +%endif + %global provider github %global provider_tld com %global project hashicorp %global repo consul # https://github.com/hashicorp/consul -%global import_path %{provider}.%{provider_tld}/%{project}/%{repo} +%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} +%global import_path %{provider_prefix} %global commit 46499d6e7237ca8547c15ce44e9b93bea48a455b %global shortcommit %(c=%{commit}; echo ${c:0:7}) Name: consul Version: 0.6.0 -Release: 0.4.git%{shortcommit}%{?dist} +Release: 0.5.git%{shortcommit}%{?dist} Summary: Tool for service discovery, monitoring and configuration http://www.consul.io License: MPLv2.0 -URL: https://%{import_path} -Source0: https://%{import_path}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz +URL: https://%{provider_prefix} +Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz -ExclusiveArch: %{ix86} x86_64 %{arm} +# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required +ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{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} -BuildRequires: golang >= 1.2.1-3 %if ! 0%{?with_bundled} -BuildRequires: golang(github.com/armon/circbuf) -BuildRequires: golang(github.com/armon/go-metrics) -BuildRequires: golang(github.com/armon/go-metrics/datadog) -BuildRequires: golang(github.com/armon/go-radix) -BuildRequires: golang(github.com/fsouza/go-dockerclient) -BuildRequires: golang(github.com/hashicorp/go-checkpoint) -BuildRequires: golang(github.com/hashicorp/go-cleanhttp) -BuildRequires: golang(github.com/hashicorp/go-memdb) -BuildRequires: golang(github.com/hashicorp/go-msgpack/codec) -BuildRequires: golang(github.com/hashicorp/go-syslog) -BuildRequires: golang(github.com/hashicorp/golang-lru) -BuildRequires: golang(github.com/hashicorp/hcl) -BuildRequires: golang(github.com/hashicorp/logutils) -BuildRequires: golang(github.com/hashicorp/memberlist) -BuildRequires: golang(github.com/hashicorp/net-rpc-msgpackrpc) -BuildRequires: golang(github.com/hashicorp/raft) -BuildRequires: golang(github.com/hashicorp/raft-boltdb) -BuildRequires: golang(github.com/hashicorp/scada-client) -BuildRequires: golang(github.com/hashicorp/serf/coordinate) -BuildRequires: golang(github.com/hashicorp/serf/serf) -BuildRequires: golang(github.com/hashicorp/yamux) -BuildRequires: golang(github.com/inconshreveable/muxado) -BuildRequires: golang(github.com/miekg/dns) +# commands.go +#BuildRequires: golang(github.com/mitchellh/cli) +BuildRequires: golang-github-mitchellh-cli-devel-temporary + +# main.go #BuildRequires: golang(github.com/mitchellh/cli) BuildRequires: golang-github-mitchellh-cli-devel-temporary -BuildRequires: golang(github.com/mitchellh/mapstructure) -BuildRequires: golang(github.com/ryanuber/columnize) -# Missing in docker (runc, go-units) -BuildRequires: golang(github.com/opencontainers/runc/libcontainer/user) -BuildRequires: golang(github.com/docker/go-units) %endif %description %{summary} -%if 0%{?with_devel} +%if 0%{?with_devel} || ! 0%{?with_bundled} %package -n golang-%{provider}-%{project}-%{repo}-devel Summary: %{summary} -%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7 BuildArch: noarch -%else -ExclusiveArch: %{ix86} x86_64 %{arm} -%endif -BuildRequires: golang >= 1.2.1-3 + +%if 0%{?with_check} && ! 0%{?with_bundled} BuildRequires: golang(github.com/armon/circbuf) BuildRequires: golang(github.com/armon/go-metrics) BuildRequires: golang(github.com/armon/go-metrics/datadog) @@ -109,8 +91,10 @@ BuildRequires: golang(github.com/miekg/dns) BuildRequires: golang-github-mitchellh-cli-devel-temporary BuildRequires: golang(github.com/mitchellh/mapstructure) BuildRequires: golang(github.com/ryanuber/columnize) -BuildRequires: golang(github.com/mitchellh/mapstructure) -BuildRequires: golang(github.com/ryanuber/columnize) +# indirect dep +BuildRequires: golang(github.com/docker/go-units) +BuildRequires: golang(github.com/opencontainers/runc/libcontainer/user) +%endif Requires: golang(github.com/armon/circbuf) Requires: golang(github.com/armon/go-metrics) @@ -139,8 +123,9 @@ Requires: golang(github.com/miekg/dns) Requires: golang-github-mitchellh-cli-devel-temporary Requires: golang(github.com/mitchellh/mapstructure) Requires: golang(github.com/ryanuber/columnize) -Requires: golang(github.com/mitchellh/mapstructure) -Requires: golang(github.com/ryanuber/columnize) +# Indirect dep +Requires: golang(github.com/docker/go-units) +Requires: golang(github.com/opencontainers/runc/libcontainer/user) Provides: golang(%{import_path}/acl) = %{version}-%{release} Provides: golang(%{import_path}/api) = %{version}-%{release} @@ -160,76 +145,125 @@ This package contains library source intended for building other packages which use %{project}/%{repo}. %endif +%if 0%{?with_unit_test} && 0%{?with_devel} +%package -n golang-%{provider}-%{project}-%{repo}-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} +%endif + +%description -n golang-%{provider}-%{project}-%{repo}-unit-test-devel +%{summary} + +This package contains unit tests for project +providing packages with %{import_path} prefix. +%endif + %prep %setup -q -n %{repo}-%{commit} %build -# Make link for etcd itself mkdir -p src/github.com/hashicorp -ln -s $(pwd) src/github.com/hashicorp/consul +ln -s ../../../ src/github.com/hashicorp/consul +%if ! 0%{?with_bundled} export GOPATH=$(pwd):%{gopath} - -%if 0%{?with_debug} -function gobuild { go build -a -ldflags "${CGO_LDFLAGS} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" -v -x "$@"; } %else -function gobuild { go build -a -v -x "$@"; } +export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath} %endif -gobuild -o bin/%{name} %{import_path} + +%gobuild -o bin/%{name} %{import_path} %install # consul subpackage install -D -p -m 0755 bin/%{name} %{buildroot}%{_bindir}/%{name} -%if 0%{?with_devel} -# devel subpackage +%if 0%{?with_devel} || ! 0%{?with_bundled} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ -cp -pav *.go %{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" \! -iname "*_test.go") ; do + echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list + install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) + cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file + echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list +done +%endif -#rm -rf website ui bench contrib demo deps scripts terraform -# copy directories -for file in acl api command consul testutil tlsutil watch; do - cp -rpav $file %{buildroot}%{gopath}/src/%{import_path}/ +# 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"); do + echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list + install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) + cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file + echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list done %endif +%if 0%{?with_devel} || ! 0%{?with_bundled} +sort -u -o devel.file-list devel.file-list +%endif + %check -%if 0%{?with_check} +%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} +%if ! 0%{?with_bundled} export GOPATH=%{buildroot}/%{gopath}:%{gopath} -go test %{import_path} -go test %{import_path}/acl -go test %{import_path}/api -#go test %{import_path}/command -#command/agent test fails from time to time -#/consul test fails from time to time -go test %{import_path}/consul/structs -go test %{import_path}/testutil -#go test %{import_path}/tlsutil -go test %{import_path}/watch +%else +export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath} +%endif + +%if ! 0%{?gotest:1} +%global gotest go test +%endif + +%gotest %{import_path} +%gotest %{import_path}/acl +%gotest %{import_path}/api +#%%gotest %{import_path}/command +#%%gotest %{import_path}/command/agent +#%%gotest %{import_path}/consul +%gotest %{import_path}/consul/state +%gotest %{import_path}/consul/structs +%gotest %{import_path}/testutil +#%%gotest %{import_path}/tlsutil +%gotest %{import_path}/watch %endif +#define license tag if not already defined +%{!?_licensedir:%global license %doc} + %files -%if 0%{?fedora} %license LICENSE %doc CHANGELOG.md README.md -%else -%doc CHANGELOG.md README.md LICENSE -%endif %{_bindir}/%{name} -%if 0%{?with_devel} -%files -n golang-%{provider}-%{project}-%{repo}-devel -%if 0%{?fedora} +%if 0%{?with_devel} || ! 0%{?with_bundled} +%files -n golang-%{provider}-%{project}-%{repo}-devel -f devel.file-list %license LICENSE %doc CHANGELOG.md README.md -%else -%doc CHANGELOG.md README.md LICENSE -%endif %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} -%{gopath}/src/%{import_path} +%endif + +%if 0%{?with_unit_test} && 0%{?with_devel} +%files -n golang-%{provider}-%{project}-%{repo}-unit-test-devel -f unit-test-devel.file-list +%license LICENSE +%doc CHANGELOG.md README.md %endif %changelog +* Thu Mar 17 2016 jchaloup - 0.6.0-0.5.git46499d6 +- Polish the spec file + resolves: #1318556 + * Mon Feb 22 2016 Fedora Release Engineering - 0.6.0-0.4.git46499d6 - https://fedoraproject.org/wiki/Changes/golang1.6