1385d4c
%if 0%{?fedora} || 0%{?rhel} == 6
1385d4c
%global with_devel 1
1385d4c
%global with_bundled 0
1385d4c
%global with_debug 0
1385d4c
# tests fail
1385d4c
%global with_check 0
1385d4c
%global with_unit_test 1
1385d4c
%else
1385d4c
%global with_devel 0
1385d4c
%global with_bundled 0
1385d4c
%global with_debug 0
1385d4c
%global with_check 0
1385d4c
%global with_unit_test 0
1385d4c
%endif
1385d4c
1385d4c
%if 0%{?with_debug}
1385d4c
%global _dwz_low_mem_die_limit 0
1385d4c
%else
74d7cb0
%global debug_package   %{nil}
1385d4c
%endif
1385d4c
1385d4c
%global provider        github
1385d4c
%global provider_tld    com
1385d4c
%global project         kr
1385d4c
%global repo            pretty
1385d4c
# https://github.com/kr/pretty
1385d4c
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
1385d4c
%global import_path     %{provider_prefix}
a80eb0f
%global commit          f31442d60e51465c69811e2107ae978868dbea5c
74d7cb0
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
74d7cb0
1385d4c
Name:           golang-%{provider}-%{project}-%{repo}
74d7cb0
Version:        0
78734c3
Release:        0.7.git%{shortcommit}%{?dist}
74d7cb0
Summary:        Provides pretty-printing for go values
74d7cb0
License:        MIT
1385d4c
URL:            https://%{provider_prefix}
1385d4c
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
1385d4c
78734c3
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
78734c3
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
78734c3
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
78734c3
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
74d7cb0
74d7cb0
%description
74d7cb0
Package pretty provides pretty-printing for go values. This is useful during
74d7cb0
debugging, to avoid wrapping long output lines in the terminal.
74d7cb0
1385d4c
%{summary}
1385d4c
1385d4c
%if 0%{?with_devel}
74d7cb0
%package devel
1385d4c
Summary:       %{summary}
1385d4c
BuildArch:     noarch
1385d4c
1385d4c
%if 0%{?with_check}
1385d4c
BuildRequires: golang(github.com/kr/text)
1385d4c
%endif
1385d4c
1385d4c
Requires:      golang(github.com/kr/text)
1385d4c
1385d4c
Provides:      golang(%{import_path}) = %{version}-%{release}
74d7cb0
74d7cb0
%description devel
74d7cb0
Package pretty provides pretty-printing for go values. This is useful during
74d7cb0
debugging, to avoid wrapping long output lines in the terminal.
74d7cb0
1385d4c
%{summary}
1385d4c
1385d4c
This package contains library source intended for
1385d4c
building other packages which use import path with
1385d4c
%{import_path} prefix.
1385d4c
%endif
1385d4c
78734c3
%if 0%{?with_unit_test} && 0%{?with_devel}
1385d4c
%package unit-test
1385d4c
Summary:         Unit tests for %{name} package
78734c3
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
78734c3
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
1385d4c
1385d4c
%if 0%{?with_check}
1385d4c
#Here comes all BuildRequires: PACKAGE the unit tests
1385d4c
#in %%check section need for running
1385d4c
%endif
1385d4c
1385d4c
# test subpackage tests code from devel subpackage
1385d4c
Requires:        %{name}-devel = %{version}-%{release}
1385d4c
1385d4c
%description unit-test
1385d4c
%{summary}
1385d4c
1385d4c
This package contains unit tests for project
1385d4c
providing packages with %{import_path} prefix.
1385d4c
%endif
1385d4c
74d7cb0
%prep
1385d4c
%setup -q -n %{repo}-%{commit}
74d7cb0
74d7cb0
%build
74d7cb0
74d7cb0
%install
1385d4c
# source codes for building projects
1385d4c
%if 0%{?with_devel}
1385d4c
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
78734c3
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
1385d4c
# find all *.go but no *_test.go files and generate devel.file-list
1385d4c
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
78734c3
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
1385d4c
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
1385d4c
    cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file
1385d4c
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
1385d4c
done
1385d4c
%endif
1385d4c
1385d4c
# testing files for this project
78734c3
%if 0%{?with_unit_test} && 0%{?with_devel}
1385d4c
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
1385d4c
# find all *_test.go files and generate unit-test.file-list
1385d4c
for file in $(find . -iname "*_test.go"); do
78734c3
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
1385d4c
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
1385d4c
    cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file
1385d4c
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
1385d4c
done
1385d4c
%endif
74d7cb0
78734c3
%if 0%{?with_devel}
78734c3
sort -u -o devel.file-list devel.file-list
78734c3
%endif
78734c3
74d7cb0
%check
1385d4c
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
78734c3
%if ! 0%{?with_bundled}
78734c3
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
1385d4c
%else
78734c3
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
1385d4c
%endif
78734c3
78734c3
%if ! 0%{?gotest:1}
78734c3
%global gotest go test
1385d4c
%endif
74d7cb0
78734c3
%gotest %{import_path}
1385d4c
%endif
1385d4c
78734c3
#define license tag if not already defined
78734c3
%{!?_licensedir:%global license %doc}
78734c3
1385d4c
%if 0%{?with_devel}
1385d4c
%files devel -f devel.file-list
78734c3
%license License
1385d4c
%doc Readme
1385d4c
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
1385d4c
%endif
1385d4c
78734c3
%if 0%{?with_unit_test} && 0%{?with_devel}
1385d4c
%files unit-test -f unit-test.file-list
78734c3
%license License
1385d4c
%doc Readme
1385d4c
%endif
74d7cb0
74d7cb0
%changelog
78734c3
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.7.gitf31442d
78734c3
- Update to spec-2.1
78734c3
  related: #1248169
78734c3
f3e7384
* Mon Aug 17 2015 jchaloup <jchaloup@redhat.com> - 0-0.6.gitf31442d
f3e7384
- Update sources and .gitiginore files
f3e7384
  related: #1248169
f3e7384
1385d4c
* Wed Jul 29 2015 jchaloup <jchaloup@redhat.com> - 0-0.5.gitf31442d
1385d4c
- Update of spec file to spec-2.0
1385d4c
  resolves: #1248169
1385d4c
0b6c58a
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.4.gitf31442d
0b6c58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
0b6c58a
316bf57
* Mon Oct 20 2014 jchaloup <jchaloup@redhat.com> - 0-0.3.git5feda8d
a80eb0f
- Bump to f31442d60e51465c69811e2107ae978868dbea5c
316bf57
- Choose the correct architecture
316bf57
74d7cb0
* Mon Sep 15 2014 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0-0.2.git
74d7cb0
- don't redefine gopath
74d7cb0
- preserve timestamps
74d7cb0
74d7cb0
* Wed Aug 06 2014 Adam Miller <maxamillion@fedoraproject.org> - 0.1.git5feda8d
74d7cb0
- First package for Fedora.
78734c3