aee5594
%if 0%{?fedora} || 0%{?rhel} == 6
aee5594
%global with_devel 1
aee5594
%global with_bundled 0
aee5594
%global with_debug 0
aee5594
# Tests need Internet access
aee5594
%global with_check 0
aee5594
%global with_unit_test 1
aee5594
%else
aee5594
%global with_devel 0
aee5594
%global with_bundled 0
aee5594
%global with_debug 0
aee5594
%global with_check 0
aee5594
%global with_unit_test 0
aee5594
%endif
aee5594
aee5594
%if 0%{?with_debug}
aee5594
%global _dwz_low_mem_die_limit 0
aee5594
%else
45a3f41
%global debug_package   %{nil}
aee5594
%endif
aee5594
45a3f41
%global provider        github
45a3f41
%global provider_tld    com
45a3f41
%global project         hashicorp
45a3f41
%global repo            mdns
45a3f41
# https://github.com/hashicorp/mdns
aee5594
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
aee5594
%global import_path     %{provider_prefix}
45a3f41
%global commit          2b439d37011456df8ff83a70ffd1cd6046410113
45a3f41
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
45a3f41
45a3f41
Name:           golang-%{provider}-%{project}-%{repo}
45a3f41
Version:        0
45615d0
Release:        0.4.git%{shortcommit}%{?dist}
45a3f41
Summary:        Simple mDNS client/server library in Golang 
45a3f41
License:        MIT
aee5594
URL:            https://%{provider_prefix}
aee5594
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
aee5594
Patch0:         change-import-path-of-go.net.patch
45a3f41
45615d0
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
45615d0
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
45615d0
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
45615d0
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
45a3f41
45a3f41
%description
45a3f41
%{summary}
aee5594
aee5594
%if 0%{?with_devel}
45a3f41
%package devel
45a3f41
Summary:       %{summary}
aee5594
BuildArch:     noarch
aee5594
aee5594
%if 0%{?with_check}
1936d62
BuildRequires: golang(code.google.com/p/go.net/ipv4)
1936d62
BuildRequires: golang(code.google.com/p/go.net/ipv6)
45a3f41
BuildRequires: golang(github.com/miekg/dns)
aee5594
%endif
aee5594
1936d62
Requires:      golang(code.google.com/p/go.net/ipv4)
1936d62
Requires:      golang(code.google.com/p/go.net/ipv6)
45a3f41
Requires:      golang(github.com/miekg/dns)
aee5594
45a3f41
Provides:      golang(%{import_path}) = %{version}-%{release}
45a3f41
45a3f41
%description devel
45a3f41
%{summary}
45a3f41
45a3f41
This package contains library source intended for
aee5594
building other packages which use import path with
aee5594
%{import_path} prefix.
aee5594
%endif
aee5594
45615d0
%if 0%{?with_unit_test} && 0%{?with_devel}
aee5594
%package unit-test
aee5594
Summary:         Unit tests for %{name} package
45615d0
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
45615d0
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
aee5594
aee5594
%if 0%{?with_check}
aee5594
#Here comes all BuildRequires: PACKAGE the unit tests
aee5594
#in %%check section need for running
aee5594
%endif
aee5594
aee5594
# test subpackage tests code from devel subpackage
aee5594
Requires:        %{name}-devel = %{version}-%{release}
aee5594
aee5594
%description unit-test
aee5594
%{summary}
aee5594
aee5594
This package contains unit tests for project
aee5594
providing packages with %{import_path} prefix.
aee5594
%endif
45a3f41
45a3f41
%prep
45a3f41
%setup -q -n %{repo}-%{commit}
45a3f41
%patch0 -p1
45a3f41
45a3f41
%build
45a3f41
45a3f41
%install
aee5594
# source codes for building projects
aee5594
%if 0%{?with_devel}
45a3f41
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
45615d0
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
aee5594
# find all *.go but no *_test.go files and generate devel.file-list
aee5594
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
45615d0
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
aee5594
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
aee5594
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
aee5594
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
aee5594
done
aee5594
%endif
45a3f41
aee5594
# testing files for this project
45615d0
%if 0%{?with_unit_test} && 0%{?with_devel}
aee5594
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
aee5594
# find all *_test.go files and generate unit-test.file-list
aee5594
for file in $(find . -iname "*_test.go"); do
45615d0
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
aee5594
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
aee5594
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
aee5594
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
45a3f41
done
aee5594
%endif
45a3f41
45615d0
%if 0%{?with_devel}
45615d0
sort -u -o devel.file-list devel.file-list
45615d0
%endif
45615d0
45a3f41
%check
aee5594
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
45615d0
%if ! 0%{?with_bundled}
45615d0
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
aee5594
%else
45615d0
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
aee5594
%endif
45615d0
45615d0
%if ! 0%{?gotest:1}
45615d0
%global gotest go test
aee5594
%endif
aee5594
45615d0
%gotest %{import_path}
45a3f41
%endif
aee5594
45615d0
#define license tag if not already defined
45615d0
%{!?_licensedir:%global license %doc}
45615d0
aee5594
%if 0%{?with_devel}
aee5594
%files devel -f devel.file-list
45615d0
%license LICENSE
aee5594
%doc README.md
45a3f41
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
aee5594
%endif
aee5594
45615d0
%if 0%{?with_unit_test} && 0%{?with_devel}
aee5594
%files unit-test -f unit-test.file-list
45615d0
%license LICENSE
aee5594
%doc README.md
aee5594
%endif
45a3f41
45a3f41
%changelog
45615d0
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.4.git2b439d3
45615d0
- Update to spec-2.1
45615d0
  related: #1250470
45615d0
1936d62
* Mon Aug 10 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git2b439d3
1936d62
- Update dependencies on go.net
1936d62
  related: #1250470
1936d62
aee5594
* Wed Aug 05 2015 Fridolin Pokorny <fpokorny@redhat.com> - 0-0.2.git2b439d3
aee5594
- Update spec file to spec-2.0
aee5594
  resolves: #1250470
aee5594
45a3f41
* Wed Apr 15 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.git2b439d3
45a3f41
- First package for Fedora
45a3f41
  resolves: #1212116
45615d0