ce7b997
# If any of the following macros should be set otherwise,
ce7b997
# you can wrap any of them with the following conditions:
ce7b997
# - %%if 0%%{centos} == 7
ce7b997
# - %%if 0%%{?rhel} == 7
ce7b997
# - %%if 0%%{?fedora} == 23
ce7b997
# Or just test for particular distribution:
ce7b997
# - %%if 0%%{centos}
ce7b997
# - %%if 0%%{?rhel}
ce7b997
# - %%if 0%%{?fedora}
ce7b997
#
ce7b997
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
ce7b997
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
ce7b997
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)
ce7b997
ce7b997
# Generate devel rpm
cec0208
%global with_devel 1
ce7b997
# Build project from bundled dependencies
cec0208
%global with_bundled 0
ce7b997
# Build with debug info rpm
cec0208
%global with_debug 0
ce7b997
# Run tests in check section
cec0208
%global with_check 1
ce7b997
# Generate unit-test rpm
cec0208
%global with_unit_test 1
cec0208
cec0208
%if 0%{?with_debug}
cec0208
%global _dwz_low_mem_die_limit 0
cec0208
%else
3854fab
%global debug_package   %{nil}
cec0208
%endif
cec0208
3854fab
%global provider        github
3854fab
%global provider_tld    com
3854fab
%global project         jtolds
3854fab
%global repo            gls
3854fab
# https://github.com/jtolds/gls
cec0208
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
cec0208
%global import_path     %{provider_prefix}
3854fab
%global commit          9a4a02dbe491bef4bab3c24fd9f3087d6c4c6690
3854fab
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
3854fab
3854fab
Name:           golang-%{provider}-%{project}-%{repo}
3854fab
Version:        0
ce7b997
Release:        0.7.git%{shortcommit}%{?dist}
3854fab
Summary:        Goroutine local storage
3854fab
License:        MIT
cec0208
URL:            https://%{provider_prefix}
cec0208
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
3854fab
6a83a63
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ce7b997
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
6a83a63
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
6a83a63
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
3854fab
3854fab
%description
3854fab
%{summary}
3854fab
cec0208
%if 0%{?with_devel}
3854fab
%package devel
3854fab
Summary:       %{summary}
cec0208
BuildArch:     noarch
cec0208
cec0208
%if 0%{?with_check}
cec0208
%endif
3854fab
3854fab
Provides:      golang(%{import_path}) = %{version}-%{release}
cec0208
3854fab
%description devel
3854fab
%{summary}
3854fab
3854fab
This package contains library source intended for
cec0208
building other packages which use import path with
cec0208
%{import_path} prefix.
cec0208
%endif
3854fab
6a83a63
%if 0%{?with_unit_test} && 0%{?with_devel}
cec0208
%package unit-test
cec0208
Summary:         Unit tests for %{name} package
6a83a63
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
6a83a63
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
cec0208
cec0208
%if 0%{?with_check}
cec0208
#Here comes all BuildRequires: PACKAGE the unit tests
cec0208
#in %%check section need for running
cec0208
%endif
cec0208
cec0208
# test subpackage tests code from devel subpackage
cec0208
Requires:        %{name}-devel = %{version}-%{release}
3854fab
cec0208
%description unit-test
cec0208
%{summary}
cec0208
cec0208
This package contains unit tests for project
cec0208
providing packages with %{import_path} prefix.
cec0208
%endif
cec0208
cec0208
%prep
3854fab
%setup -q -n %{repo}-%{commit}
3854fab
3854fab
%build
3854fab
3854fab
%install
cec0208
# source codes for building projects
cec0208
%if 0%{?with_devel}
3854fab
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
6a83a63
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
cec0208
# find all *.go but no *_test.go files and generate devel.file-list
cec0208
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
6a83a63
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
cec0208
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cec0208
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
cec0208
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
cec0208
done
cec0208
%endif
3854fab
cec0208
# testing files for this project
6a83a63
%if 0%{?with_unit_test} && 0%{?with_devel}
cec0208
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
cec0208
# find all *_test.go files and generate unit-test.file-list
cec0208
for file in $(find . -iname "*_test.go"); do
6a83a63
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
cec0208
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cec0208
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
cec0208
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
3854fab
done
cec0208
%endif
3854fab
6a83a63
%if 0%{?with_devel}
6a83a63
sort -u -o devel.file-list devel.file-list
6a83a63
%endif
6a83a63
3854fab
%check
cec0208
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
6a83a63
%if ! 0%{?with_bundled}
6a83a63
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
cec0208
%else
6a83a63
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
cec0208
%endif
6a83a63
6a83a63
%if ! 0%{?gotest:1}
6a83a63
%global gotest go test
cec0208
%endif
3854fab
6a83a63
%gotest %{import_path}
cec0208
%endif
3854fab
6a83a63
#define license tag if not already defined
6a83a63
%{!?_licensedir:%global license %doc}
6a83a63
cec0208
%if 0%{?with_devel}
cec0208
%files devel -f devel.file-list
6a83a63
%license LICENSE
3854fab
%doc README.md
3854fab
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
cec0208
%endif
cec0208
6a83a63
%if 0%{?with_unit_test} && 0%{?with_devel}
cec0208
%files unit-test -f unit-test.file-list
6a83a63
%license LICENSE
cec0208
%doc README.md
cec0208
%endif
3854fab
3854fab
%changelog
ce7b997
* Thu Jan 12 2017 Jan Chaloupka <jchaloup@redhat.com> - 0-0.7.git9a4a02d
ce7b997
- Polish the spec file
ce7b997
  related: #1250490
ce7b997
e9ba25a
* Thu Jul 21 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.6.git9a4a02d
e9ba25a
- https://fedoraproject.org/wiki/Changes/golang1.7
e9ba25a
7c01164
* Mon Feb 22 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.5.git9a4a02d
7c01164
- https://fedoraproject.org/wiki/Changes/golang1.6
7c01164
f01cd08
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0-0.4.git9a4a02d
f01cd08
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
f01cd08
6a83a63
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git9a4a02d
6a83a63
- Update to spec-2.1
6a83a63
  related: #1250490
6a83a63
cec0208
* Thu Aug 06 2015 Fridolin Pokorny <fpokorny@redhat.com> - 0-0.2.git9a4a02d
cec0208
- Update spec file to spec-2.0
cec0208
  resolves: #1250490
cec0208
3854fab
* Thu Apr 23 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.git9a4a02d
3854fab
- First package for Fedora
3854fab
  resolves: #1214809
cec0208
6a83a63