3f3006e
%if 0%{?fedora} || 0%{?rhel} == 6
3f3006e
%global with_devel 1
3f3006e
%global with_bundled 0
3f3006e
%global with_debug 0
3f3006e
%global with_check 1
3f3006e
%global with_unit_test 1
ee09be1
%else
3f3006e
%global with_devel 0
3f3006e
%global with_bundled 0
3f3006e
%global with_debug 0
3f3006e
%global with_check 0
3f3006e
%global with_unit_test 0
3f3006e
%endif
3f3006e
3f3006e
%if 0%{?with_debug}
3f3006e
%global _dwz_low_mem_die_limit 0
3f3006e
%else
3f3006e
%global debug_package   %{nil}
3f3006e
%endif
3f3006e
3f3006e
%define copying() \
3f3006e
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \
3f3006e
%license %{*} \
3f3006e
%else \
3f3006e
%doc %{*} \
3f3006e
%endif
3f3006e
3f3006e
%global provider        github
3f3006e
%global provider_tld    com
3f3006e
%global project         google
3f3006e
%global repo            gofuzz
3f3006e
# https://github.com/google/gofuzz
3f3006e
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
3f3006e
%global import_path     %{provider_prefix}
3f3006e
%global commit          bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
3f3006e
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
3f3006e
3f3006e
Name:           golang-%{provider}-%{project}-%{repo}
3f3006e
Version:        0
3f3006e
Release:        0.7.git%{shortcommit}%{?dist}
3f3006e
Summary:        Library for populating go objects with random values
3f3006e
License:        ASL 2.0
3f3006e
URL:            https://%{provider_prefix}
3f3006e
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
3f3006e
3f3006e
# If go_arches not defined fall through to implicit golang archs
3f3006e
%if 0%{?go_arches:1}
3f3006e
ExclusiveArch:  %{go_arches}
3f3006e
%else
3f3006e
ExclusiveArch:   %{ix86} x86_64 %{arm}
3f3006e
%endif
3f3006e
# If gccgo_arches does not fit or is not defined fall through to golang
3f3006e
%ifarch 0%{?gccgo_arches}
3f3006e
BuildRequires:   gcc-go >= %{gccgo_min_vers}
3f3006e
%else
3f3006e
BuildRequires:   golang
ee09be1
%endif
74f5666
74f5666
%description
74f5666
%{summary}
74f5666
3f3006e
%if 0%{?with_devel}
74f5666
%package devel
3f3006e
Summary:       %{summary}
3f3006e
BuildArch:     noarch
3f3006e
3f3006e
%if 0%{?with_check}
3f3006e
%endif
3f3006e
3f3006e
3f3006e
Provides:      golang(%{import_path}) = %{version}-%{release}
74f5666
74f5666
%description devel
74f5666
%{summary}
74f5666
3f3006e
This package contains library source intended for
3f3006e
building other packages which use import path with
3f3006e
%{import_path} prefix.
3f3006e
%endif
3f3006e
3f3006e
%if 0%{?with_unit_test}
3f3006e
%package unit-test
3f3006e
Summary:         Unit tests for %{name} package
3f3006e
# If go_arches not defined fall through to implicit golang archs
3f3006e
%if 0%{?go_arches:1}
3f3006e
ExclusiveArch:  %{go_arches}
3f3006e
%else
3f3006e
ExclusiveArch:   %{ix86} x86_64 %{arm}
3f3006e
%endif
3f3006e
# If gccgo_arches does not fit or is not defined fall through to golang
3f3006e
%ifarch 0%{?gccgo_arches}
3f3006e
BuildRequires:   gcc-go >= %{gccgo_min_vers}
3f3006e
%else
3f3006e
BuildRequires:   golang
3f3006e
%endif
3f3006e
3f3006e
%if 0%{?with_check}
3f3006e
#Here comes all BuildRequires: PACKAGE the unit tests
3f3006e
#in %%check section need for running
3f3006e
%endif
3f3006e
3f3006e
# test subpackage tests code from devel subpackage
3f3006e
Requires:        %{name}-devel = %{version}-%{release}
3f3006e
3f3006e
%description unit-test
3f3006e
%{summary}
3f3006e
3f3006e
This package contains unit tests for project
3f3006e
providing packages with %{import_path} prefix.
3f3006e
%endif
74f5666
74f5666
%prep
74f5666
%setup -q -n %{repo}-%{commit}
74f5666
74f5666
%build
74f5666
74f5666
%install
3f3006e
# source codes for building projects
3f3006e
%if 0%{?with_devel}
74f5666
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
3f3006e
# find all *.go but no *_test.go files and generate devel.file-list
3f3006e
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
3f3006e
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
3f3006e
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
3f3006e
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
3f3006e
done
3f3006e
%endif
74f5666
3f3006e
# testing files for this project
3f3006e
%if 0%{?with_unit_test}
3f3006e
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
3f3006e
# find all *_test.go files and generate unit-test.file-list
3f3006e
for file in $(find . -iname "*_test.go"); do
3f3006e
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
3f3006e
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
3f3006e
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
3f3006e
done
3f3006e
%endif
3f3006e
3f3006e
%check
3f3006e
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
3f3006e
%ifarch 0%{?gccgo_arches}
3f3006e
function gotest { %{gcc_go_test} "$@"; }
3f3006e
%else
3f3006e
%if 0%{?golang_test:1}
3f3006e
function gotest { %{golang_test} "$@"; }
3f3006e
%else
3f3006e
function gotest { go test "$@"; }
3f3006e
%endif
3f3006e
%endif
3f3006e
3f3006e
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
3f3006e
gotest %{import_path}
3f3006e
%endif
3f3006e
3f3006e
%if 0%{?with_devel}
3f3006e
%files devel -f devel.file-list
3f3006e
%copying LICENSE
3f3006e
%doc README.md CONTRIBUTING.md
74f5666
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
74f5666
%dir %{gopath}/src/%{import_path}
3f3006e
%endif
3f3006e
3f3006e
%if 0%{?with_unit_test}
3f3006e
%files unit-test -f unit-test.file-list
3f3006e
%copying LICENSE
3f3006e
%doc README.md CONTRIBUTING.md
3f3006e
%endif
74f5666
74f5666
%changelog
3f3006e
* Fri Jul 31 2015 jchaloup <jchaloup@redhat.com> - 0-0.7.gitbbcb9da
3f3006e
- Update spec file spec-2.0
3f3006e
  resolves: #1249075
3f3006e
ee09be1
* Mon Mar 30 2015 jchaloup <jchaloup@redhat.com> - 0-0.6.gitbbcb9da
ee09be1
- Choose the correct architecture
ee09be1
  related: #1141817
ee09be1
23f99a3
* Sun Mar 08 2015 jchaloup <jchaloup@redhat.com> - 0-0.5.gitbbcb9da
23f99a3
- Bump to upstream bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
23f99a3
  related: #1141817
23f99a3
74f5666
* Fri Sep 19 2014 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0-0.4.gitaef70da
74f5666
- don't redefine gopath
74f5666
- don't own dirs owned by golang
74f5666
- preserve timestamps of copied files
74f5666
- use golang 1.2.1-3 or higher
74f5666
- quiet setup
74f5666
- add check
74f5666
74f5666
* Tue Aug 12 2014 Eric Paris <eparis@redhat.com> - 0.3.gitaef70da
74f5666
- Move location and make a bit more generic
74f5666
74f5666
* Tue Aug 12 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.2.gitaef70da
74f5666
- Fix License
74f5666
74f5666
* Mon Aug 11 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.1.gitaef70da
74f5666
- First package for Fedora.