ed44848
%if 0%{?fedora} || 0%{?rhel} == 6
ed44848
%global with_devel 1
ed44848
%global with_bundled 0
ed44848
%global with_debug 0
ed44848
%global with_check 1
ed44848
%global with_unit_test 1
ed44848
%else
ed44848
%global with_devel 0
ed44848
%global with_bundled 0
ed44848
%global with_debug 0
ed44848
%global with_check 0
ed44848
%global with_unit_test 0
ed44848
%endif
ed44848
ed44848
%if 0%{?with_debug}
ed44848
%global _dwz_low_mem_die_limit 0
ed44848
%else
b52b093
%global debug_package   %{nil}
ed44848
%endif
ed44848
b52b093
%global provider        github
b52b093
%global provider_tld    com
b52b093
%global project         jessevdk
b52b093
%global repo            go-flags
b52b093
# https://github.com/jessevdk/go-flags
ed44848
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
ed44848
%global import_path     %{provider_prefix}
4a31f9a
%global commit          f2785f5820ec967043de79c8be97edfc464ca745
b52b093
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
b52b093
b52b093
Name:           golang-%{provider}-%{project}-%{repo}
b52b093
Version:        0
4a31f9a
Release:        0.7.git%{shortcommit}%{?dist}
b52b093
Summary:        Go command line option parser
b52b093
License:        BSD
ed44848
URL:            https://%{provider_prefix}
ed44848
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
b52b093
242411a
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
242411a
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
242411a
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
242411a
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
b52b093
b52b093
%description
b52b093
%{summary}
b52b093
ed44848
%if 0%{?with_devel}
b52b093
%package devel
b52b093
Summary:       %{summary}
ed44848
BuildArch:     noarch
b52b093
ed44848
%if 0%{?with_check}
ed44848
%endif
b52b093
b52b093
Provides:      golang(%{import_path}) = %{version}-%{release}
b52b093
b52b093
%description devel
b52b093
%{summary}
b52b093
b52b093
This package contains library source intended for
ed44848
building other packages which use import path with
ed44848
%{import_path} prefix.
ed44848
%endif
b52b093
242411a
%if 0%{?with_unit_test} && 0%{?with_devel}
ed44848
%package unit-test
ed44848
Summary:         Unit tests for %{name} package
242411a
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
242411a
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
ed44848
ed44848
%if 0%{?with_check}
ed44848
#Here comes all BuildRequires: PACKAGE the unit tests
ed44848
#in %%check section need for running
ed44848
%endif
b52b093
ed44848
# test subpackage tests code from devel subpackage
ed44848
Requires:        %{name}-devel = %{version}-%{release}
ed44848
ed44848
%description unit-test
ed44848
%{summary}
ed44848
ed44848
This package contains unit tests for project
ed44848
providing packages with %{import_path} prefix.
ed44848
%endif
ed44848
ed44848
%prep
b52b093
%setup -q -n %{repo}-%{commit}
b52b093
b52b093
%build
b52b093
b52b093
%install
ed44848
# source codes for building projects
ed44848
%if 0%{?with_devel}
b52b093
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
242411a
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
ed44848
# find all *.go but no *_test.go files and generate devel.file-list
ed44848
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
242411a
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
ed44848
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
ed44848
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
ed44848
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
ed44848
done
ed44848
%endif
b52b093
ed44848
# testing files for this project
242411a
%if 0%{?with_unit_test} && 0%{?with_devel}
ed44848
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
ed44848
# find all *_test.go files and generate unit-test.file-list
ed44848
for file in $(find . -iname "*_test.go"); do
242411a
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
ed44848
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
ed44848
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
ed44848
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
b52b093
done
ed44848
%endif
b52b093
242411a
%if 0%{?with_devel}
242411a
sort -u -o devel.file-list devel.file-list
242411a
%endif
242411a
b52b093
%check
ed44848
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
242411a
%if ! 0%{?with_bundled}
242411a
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
ed44848
%else
242411a
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
ed44848
%endif
242411a
242411a
%if ! 0%{?gotest:1}
242411a
%global gotest go test
ed44848
%endif
b52b093
242411a
%gotest %{import_path}
ed44848
%endif
b52b093
242411a
#define license tag if not already defined
242411a
%{!?_licensedir:%global license %doc}
242411a
ed44848
%if 0%{?with_devel}
ed44848
%files devel -f devel.file-list
242411a
%license LICENSE
b52b093
%doc README.md
b52b093
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
ed44848
%endif
ed44848
242411a
%if 0%{?with_unit_test} && 0%{?with_devel}
ed44848
%files unit-test -f unit-test.file-list
242411a
%license LICENSE
ed44848
%doc README.md
ed44848
%endif
b52b093
b52b093
%changelog
4a31f9a
* Mon Jul 25 2016 jchaloup <jchaloup@redhat.com> - 0-0.7.gitf2785f5
4a31f9a
- Bump to upstream f2785f5820ec967043de79c8be97edfc464ca745
4a31f9a
  related: #1250487
4a31f9a
d632183
* Thu Jul 21 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.6.git5e11878
d632183
- https://fedoraproject.org/wiki/Changes/golang1.7
d632183
9039740
* Mon Feb 22 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.5.git5e11878
9039740
- https://fedoraproject.org/wiki/Changes/golang1.6
9039740
0326501
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0-0.4.git5e11878
0326501
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
0326501
242411a
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git5e11878
242411a
- Update to spec-2.1
242411a
  related: #1250487
242411a
ed44848
* Thu Aug 06 2015 Fridolin Pokorny <fpokorny@redhat.com> - 0-0.2.git5e11878
ed44848
- Update spec file to spec-2.0
ed44848
  resolves: #1250487
ed44848
b52b093
* Mon Jun 15 2015 Marek Skalicky <mskalick@redhat.com> - 0-0.1.git5e11878
b52b093
- First package for Fedora
b52b093
  resolves: #1232218
ed44848
242411a