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