Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} == 6
%global with_devel 1
%global with_bundled 0
%global with_debug 0
%global with_check 1
%global with_unit_test 1
%else
%global with_devel 0
%global with_bundled 0
%global with_debug 0
%global with_check 0
%global with_unit_test 0
%endif

%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package   %{nil}
%endif

%define copying() \
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \
%license %{*} \
%else \
%doc %{*} \
%endif

%global provider        github
%global provider_tld    com
%global project         golang
%global repo            exp
# https://github.com/golang/exp
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     golang.org/x/exp
%global commit          e1eb486a5dd97885433e5fc85a751313af1df3cc
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

%global gi_name         golang-%{provider}-%{project}-%{repo}
%global gc_import_path  code.google.com/p/go.exp

Name:           golang-googlecode-go-exp
Version:        0
Release:        0.8.git%{shortcommit}%{?dist}
Summary:        Experimental tools and packages for Go
License:        BSD
URL:            https://%{provider_prefix}
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz

# If go_arches not defined fall through to implicit golang archs
%if 0%{?go_arches:1}
ExclusiveArch:  %{go_arches}
%else
ExclusiveArch:   %{ix86} x86_64 %{arm}
%endif
# If gccgo_arches does not fit or is not defined fall through to golang
%ifarch 0%{?gccgo_arches}
BuildRequires:   gcc-go >= %{gccgo_min_vers}
%else
BuildRequires:   golang
%endif

%description
%{summary}

%if 0%{?with_devel}
%package devel
Summary:       %{summary}
BuildArch:     noarch

%if 0%{?with_check}
BuildRequires: golang(code.google.com/p/go.text/collate/colltab)
BuildRequires: golang(code.google.com/p/go.text/language)
%endif

Requires:      golang(code.google.com/p/go.text/collate/colltab)
Requires:      golang(code.google.com/p/go.text/language)

Provides:      golang(%{gc_import_path}/ebnf) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/fsnotify) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/inotify) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/locale/search) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/old/netchan) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/utf8string) = %{version}-%{release}
Provides:      golang(%{gc_import_path}/winfsnotify) = %{version}-%{release}

%description devel
%{summary}

This package contains library source intended for
building other packages which use import path with
%{gc_import_path} prefix.

%package -n %{gi_name}-devel
Summary:       %{summary}
BuildArch:     noarch

%if 0%{?with_check}
BuildRequires: golang(golang.org/x/text/collate/colltab)
BuildRequires: golang(golang.org/x/text/language)
%endif

Requires:      golang(golang.org/x/text/collate/colltab)
Requires:      golang(golang.org/x/text/language)

Provides:      golang(%{import_path}/ebnf) = %{version}-%{release}
Provides:      golang(%{import_path}/fsnotify) = %{version}-%{release}
Provides:      golang(%{import_path}/inotify) = %{version}-%{release}
Provides:      golang(%{import_path}/locale/search) = %{version}-%{release}
Provides:      golang(%{import_path}/old/netchan) = %{version}-%{release}
Provides:      golang(%{import_path}/utf8string) = %{version}-%{release}
Provides:      golang(%{import_path}/winfsnotify) = %{version}-%{release}

%description -n %{gi_name}-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}
%package unit-test
Summary:         Unit tests for %{name} package
# If go_arches not defined fall through to implicit golang archs
%if 0%{?go_arches:1}
ExclusiveArch:  %{go_arches}
%else
ExclusiveArch:   %{ix86} x86_64 %{arm}
%endif
# If gccgo_arches does not fit or is not defined fall through to golang
%ifarch 0%{?gccgo_arches}
BuildRequires:   gcc-go >= %{gccgo_min_vers}
%else
BuildRequires:   golang
%endif

%if 0%{?with_check}
#Here comes all BuildRequires: PACKAGE the unit tests
#in %%check section need for running
%if 0%{?fedora} >= 23
BuildRequires:   golang-docs
%endif
%endif

# test subpackage tests code from devel subpackage
Requires:        %{gi_name}-devel = %{version}-%{release}
%if 0%{?fedora} >= 23
Requires:        golang-docs
%endif

%description unit-test
%{summary}

This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif

%prep
%setup -q -n %{repo}-%{commit}

%build

%install
# source codes for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{gc_import_path}/
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
    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
    install -d -p %{buildroot}/%{gopath}/src/%{gc_import_path}/$(dirname $file)
    cp -pav $file %{buildroot}/%{gopath}/src/%{gc_import_path}/$file
    echo "%%{gopath}/src/%%{gc_import_path}/$file" >> gc_devel.file-list
done
pushd %{buildroot}/%{gopath}/src/%{gc_import_path}/
# from https://groups.google.com/forum/#!topic/golang-nuts/eD8dh3T9yyA, first post
sed -i 's/"golang\.org\/x\//"code\.google\.com\/p\/go\./g' \
        $(find . -name '*.go')
popd
%endif

# testing files for this project
%if 0%{?with_unit_test}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *_test.go files and generate unit-test.file-list
for file in $(find . -iname "*_test.go"); do
    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.file-list
done
%endif

%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%ifarch 0%{?gccgo_arches}
function gotest { %{gcc_go_test} "$@"; }
%else
%if 0%{?golang_test:1}
function gotest { %{golang_test} "$@"; }
%else
function gotest { go test "$@"; }
%endif
%endif

export GOPATH=%{buildroot}/%{gopath}:%{gopath}
gotest %{import_path}/ebnf
%if 0%{?fedora} >= 23
gotest %{import_path}/ebnflint
%endif
# fails in arm
#gotest %%{import_path}/fsnotify
gotest %{import_path}/inotify
gotest %{import_path}/locale/search
gotest %{import_path}/old/netchan
gotest %{import_path}/utf8string
#gotest %%{import_path}/winfsnotify
%endif

%if 0%{?with_devel}
%files devel -f gc_devel.file-list
%copying LICENSE
%doc README AUTHORS CONTRIBUTORS PATENTS
%dir %{gopath}/src/%{gc_import_path}

%files -n %{gi_name}-devel -f devel.file-list
%copying LICENSE
%doc README AUTHORS CONTRIBUTORS PATENTS
%dir %{gopath}/src/%{import_path}
%endif

%if 0%{?with_unit_test}
%files unit-test -f unit-test.file-list
%copying LICENSE
%doc README AUTHORS CONTRIBUTORS PATENTS
%endif

%changelog
* Thu Aug 20 2015 jchaloup <jchaloup@redhat.com> - 0-0.8.gite1eb486
- Choose the correct devel subpackage
  related: #1250519

* Thu Aug 20 2015 jchaloup <jchaloup@redhat.com> - 0-0.7.gite1eb486
- Fix %%files devel section
- Fix BR and R, change import path prefix to code.google.com/p
  related: #1250519

* Wed Aug 19 2015 jchaloup <jchaloup@redhat.com>
- Update spec file to spec-2.0
  resolves: #1250519

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.5.hg77a5f324d8f5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Dec 09 2014 jchaloup <jchaloup@redhat.com> - 0-0.4.hg77a5f324d8f5
- Update to the latest commit 77a5f324d8f52bc9a7116aab8ed7136f08ea5310
  related: #1148481

* Fri Nov 21 2014 jchaloup <jchaloup@redhat.com> - 0-0.3.hgbd8df7009305
- Extend import paths for golang.org/x/
  related: #1148481

* Sun Oct 26 2014 jchaloup <jchaloup@redhat.com> - 0-0.2.hgbd8df7009305
- Choose the correct architecture
  related: #1148481

* Mon Sep 15 2014 Eric Paris <eparis@redhat.com - 0-0.1.hgbd8df7009305
- Bump to upstream bd8df7009305d6ada223ea3c95b94c0f38bfa119