bc18920
%if 0%{?fedora} || 0%{?rhel} == 6
bc18920
%global with_devel 1
bc18920
%global with_bundled 0
bc18920
%global with_debug 0
bc18920
# Dict cannot be stringified as expected.
bc18920
%global with_check 0
bc18920
%global with_unit_test 1
bc18920
%else
bc18920
%global with_devel 0
bc18920
%global with_bundled 0
bc18920
%global with_debug 0
bc18920
%global with_check 0
bc18920
%global with_unit_test 0
bc18920
%endif
bc18920
bc18920
%if 0%{?with_debug}
bc18920
%global _dwz_low_mem_die_limit 0
bc18920
%else
d7ff908
%global debug_package   %{nil}
bc18920
%endif
bc18920
d7ff908
%global provider        github
d7ff908
%global provider_tld    com
d7ff908
%global project         glacjay
d7ff908
%global repo            goini
bc18920
# https://github.com/glacjay/goini
bc18920
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
bc18920
%global import_path     %{provider_prefix}
d7ff908
%global commit          5261baf26f41eeffae5fd27be784302e389b7699
d7ff908
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
bc18920
d7ff908
# github.com/rakyll/goini has no license.
d7ff908
# But it is forked from github.com/glacjay/goini and unchanged.
d7ff908
# Lets provide these source codes as well.
d7ff908
%global rcommit         907cca0f578a5316fb864ec6992dc3d9730ec58c
d7ff908
%global rscommit        %(c=%{rcommit}; echo ${c:0:7})
d7ff908
%global rimport_path    %{provider}.%{provider_tld}/rakyll/goini
d7ff908
d7ff908
Name:           golang-%{provider}-%{project}-%{repo}
d7ff908
Version:        0
61e6f99
Release:        0.4.git%{shortcommit}%{?dist}
d7ff908
Summary:        INI file parser in go
d7ff908
License:        MIT
bc18920
URL:            https://%{provider_prefix}
bc18920
Source0:        https://%{provider_prefix}/archive/%{rcommit}/%{repo}-%{rscommit}.tar.gz
bc18920
Source1:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
bc18920
61e6f99
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
61e6f99
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
61e6f99
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
61e6f99
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
d7ff908
d7ff908
%description
d7ff908
%{summary}
d7ff908
bc18920
%if 0%{?with_devel}
d7ff908
%package devel
bc18920
Summary:       %{summary}
bc18920
BuildArch:     noarch
bc18920
bc18920
%if 0%{?with_check}
bc18920
%endif
bc18920
bc18920
Provides:      golang(%{import_path}) = %{version}-%{release}
bc18920
Provides:      golang(%{rimport_path}) = %{version}-%{release}
d7ff908
d7ff908
%description devel
d7ff908
%{summary}
d7ff908
bc18920
This package contains library source intended for
bc18920
building other packages which use import path with
bc18920
%{import_path} prefix.
bc18920
%endif
bc18920
61e6f99
%if 0%{?with_unit_test} && 0%{?with_devel}
bc18920
%package unit-test
bc18920
Summary:         Unit tests for %{name} package
61e6f99
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
61e6f99
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
bc18920
bc18920
%if 0%{?with_check}
bc18920
#Here comes all BuildRequires: PACKAGE the unit tests
bc18920
#in %%check section need for running
bc18920
%endif
bc18920
bc18920
# test subpackage tests code from devel subpackage
bc18920
Requires:        %{name}-devel = %{version}-%{release}
bc18920
bc18920
%description unit-test
bc18920
%{summary}
bc18920
bc18920
This package contains unit tests for project
bc18920
providing packages with %{import_path} prefix.
bc18920
%endif
d7ff908
d7ff908
%prep
d7ff908
%setup -q -n %{repo}-%{rcommit}
d7ff908
%setup -q -n %{repo}-%{commit} -T -b 1
d7ff908
d7ff908
%build
d7ff908
d7ff908
%install
bc18920
# source codes for building projects
bc18920
%if 0%{?with_devel}
d7ff908
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
61e6f99
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
d7ff908
install -d -p %{buildroot}/%{gopath}/src/%{rimport_path}/
61e6f99
echo "%%dir %%{gopath}/src/%%{rimport_path}/." >> devel.file-list
bc18920
# find all *.go but no *_test.go files and generate devel.file-list
bc18920
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
61e6f99
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
bc18920
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
bc18920
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
bc18920
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
bc18920
done
bc18920
bc18920
pushd ../%{repo}-%{rcommit}
bc18920
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
61e6f99
    echo "%%dir %%{gopath}/src/%%{rimport_path}/$(dirname $file)" >> ../%{repo}-%{commit}/devel.file-list
bc18920
    install -d -p %{buildroot}/%{gopath}/src/%{rimport_path}/$(dirname $file)
bc18920
    cp -pav $file %{buildroot}/%{gopath}/src/%{rimport_path}/$file
bc18920
    echo "%%{gopath}/src/%%{rimport_path}/$file" >> ../%{repo}-%{commit}/devel.file-list
bc18920
done
bc18920
popd
bc18920
%endif
bc18920
bc18920
# testing files for this project
61e6f99
%if 0%{?with_unit_test} && 0%{?with_devel}
bc18920
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
bc18920
cp -pav empty.ini %{buildroot}/%{gopath}/src/%{import_path}/.
bc18920
cp -pav example.ini %{buildroot}/%{gopath}/src/%{import_path}/.
bc18920
echo "%%{gopath}/src/%%{import_path}/empty.ini" >> unit-test.file-list
bc18920
echo "%%{gopath}/src/%%{import_path}/example.ini" >> unit-test.file-list
bc18920
# find all *_test.go files and generate unit-test.file-list
bc18920
for file in $(find . -iname "*_test.go"); do
61e6f99
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
bc18920
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
bc18920
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
bc18920
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
bc18920
done
bc18920
%endif
d7ff908
61e6f99
%if 0%{?with_devel}
61e6f99
sort -u -o devel.file-list devel.file-list
61e6f99
%endif
61e6f99
d7ff908
%check
bc18920
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
61e6f99
%if ! 0%{?with_bundled}
61e6f99
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
bc18920
%else
61e6f99
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
bc18920
%endif
61e6f99
61e6f99
%if ! 0%{?gotest:1}
61e6f99
%global gotest go test
bc18920
%endif
d7ff908
61e6f99
%gotest %{import_path}
bc18920
%endif
bc18920
61e6f99
#define license tag if not already defined
61e6f99
%{!?_licensedir:%global license %doc}
61e6f99
bc18920
%if 0%{?with_devel}
bc18920
%files devel -f devel.file-list
61e6f99
%license LICENSE.txt
d7ff908
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
d7ff908
%dir %{gopath}/src/%{provider}.%{provider_tld}/rakyll
bc18920
%dir %{gopath}/src/%{rimport_path}
bc18920
%endif
d7ff908
61e6f99
%if 0%{?with_unit_test} && 0%{?with_devel}
bc18920
%files unit-test -f unit-test.file-list
61e6f99
%license LICENSE.txt
bc18920
%endif
d7ff908
d7ff908
%changelog
61e6f99
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.4.git5261baf
61e6f99
- Update to spec-2.1
61e6f99
  related: #1249032
61e6f99
bc18920
* Fri Jul 31 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git5261baf
bc18920
- Update spec file to spec-2.0
bc18920
  resolves: #1249032
bc18920
9999846
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.2.git5261baf
9999846
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
9999846
d7ff908
* Tue Jan 13 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.git5261baf
d7ff908
- First package for Fedora
d7ff908
  resolves: #1177486
61e6f99