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         spf13
%global repo            cobra
# https://github.com/spf13/cobra
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}
%global commit          8f5946caaeeff40a98d67f60c25e89c3525038a3
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Name:           golang-%{provider}-%{project}-%{repo}
Version:        0
Release:        0.12.git%{shortcommit}%{?dist}
Summary:        A Commander for modern go CLI interactions
License:        ASL 2.0
URL:            https://%{provider_prefix}
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
Patch0:         Remove-Windows-related-code.patch

# 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
Cobra is a commander providing a simple interface to create powerful modern
CLI interfaces similar to git & go tools.
In addition to providing an interface, Cobra simultaneously provides
a controller to organize your application code.

Inspired by go, go-Commander, gh and subcommand, Cobra improves on these
by providing fully posix compliant flags (including short & long versions),
nesting commands, and the ability to define your own help and usage
for any or all commands.

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

%if 0%{?with_check}
#BuildRequires: golang(github.com/inconshreveable/mousetrap)
BuildRequires: golang(github.com/spf13/pflag)
%endif

#Requires:      golang(github.com/inconshreveable/mousetrap)
Requires:      golang(github.com/spf13/pflag)

Provides:      golang(%{import_path}) = %{version}-%{release}

%description devel
Cobra is a commander providing a simple interface to create powerful modern
CLI interfaces similar to git & go tools.
In addition to providing an interface, Cobra simultaneously provides
a controller to organize your application code.

Inspired by go, go-Commander, gh and subcommand, Cobra improves on these
by providing fully posix compliant flags (including short & long versions),
nesting commands, and the ability to define your own help and usage
for any or all commands.

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
%endif

# test subpackage tests code from devel subpackage
Requires:        %{name}-devel = %{version}-%{release}

%description unit-test
%{summary}

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

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

%build

%install
# source codes for building projects
%if 0%{?with_devel}
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
done
%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}
%endif

%if 0%{?with_devel}
%files devel -f devel.file-list
%copying LICENSE.txt
%doc bash_completions.md README.md md_docs.md
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%dir %{gopath}/src/%{import_path}
%endif

%if 0%{?with_unit_test}
%files unit-test -f unit-test.file-list
%copying LICENSE.txt
%doc bash_completions.md README.md md_docs.md
%endif

%changelog
* Mon Aug 24 2015 jchaloup <jchaloup@redhat.com> - 0-0.12.git8f5946c
- Remove [B]R in comments, they are deleted by the patch
  related: #1214769

* Wed Aug 12 2015 Fridolin Pokorny <fpokorny@redhat.com> - 0-0.11.git8f5946c
- Update spec file to spec-2.0
  related: #1214769

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

* Tue Jun 02 2015 jchaloup <jchaloup@redhat.com> - 0-0.9.git8f5946c
- Bump to upstream 8f5946caaeeff40a98d67f60c25e89c3525038a3
  related: #1214769

* Thu Apr 23 2015 jchaloup <jchaloup@redhat.com> - 0-0.8.git3c187e9
- Bump to upstream 3c187e904540cd62f0a197cddd6da02645a7cc5a
  related: #1214769

* Tue Mar 31 2015 jchaloup <jchaloup@redhat.com> - 0-0.7.git79bd93d
- Bump to upstream 79bd93d369fb73d640179208d4e2b1a748915567
  related: #1085881

* Wed Feb 25 2015 jchaloup <jchaloup@redhat.com> - 0-0.6.gitf8e1ec5
- Bump to upstream f8e1ec56bdd7494d309c69681267859a6bfb7549
  related: #1085881

* Wed Dec 24 2014 jchaloup <jchaloup@redhat.com> - 0-0.5.gitb1e90a7
- Bump to e1e66f7b4e667751cf530ddb6e72b79d6eeb0235
  related: #1085881

* Thu Oct 16 2014 jchaloup <jchaloup@redhat.com> - 0-0.4.gite174a40
- Bump to b1e90a7943957b51bb96a13b44b844475bcf95c0

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.3.gite174a40
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Fri Apr 04 2014 Lokesh Mandvekar <lsm5@redhat.com> 0-0.2.git
- correct tarball name

* Fri Apr 04 2014 Lokesh Mandvekar <lsm5@redhat.com> 0-0.1.git
- Initial package