7678c19
%if 0%{?fedora} || 0%{?rhel} == 6
7678c19
%global with_devel 1
7678c19
%global with_bundled 0
7678c19
%global with_debug 0
7678c19
%global with_check 1
7678c19
%global with_unit_test 1
7678c19
%else
7678c19
%global with_devel 0
7678c19
%global with_bundled 0
7678c19
%global with_debug 0
7678c19
%global with_check 0
7678c19
%global with_unit_test 0
7678c19
%endif
7678c19
7678c19
%if 0%{?with_debug}
7678c19
%global _dwz_low_mem_die_limit 0
7678c19
%else
7678c19
%global debug_package   %{nil}
7678c19
%endif
7678c19
7678c19
%global provider        github
7678c19
%global provider_tld    com
7678c19
%global project         coreos
7678c19
%global repo            go-oidc
7678c19
# https://github.com/coreos/go-oidc
7678c19
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
7678c19
%global import_path     %{provider_prefix}
7678c19
%global commit          ee7cb1fb480df22f7d8c4c90199e438e454ca3b6
7678c19
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
7678c19
7678c19
Name:           golang-%{provider}-%{project}-%{repo}
7678c19
Version:        0
7678c19
Release:        0.1.git%{shortcommit}%{?dist}
7678c19
Summary:        Go libraries for implementing OIDC clients and servers
7678c19
License:        ASL 2.0
7678c19
URL:            https://%{provider_prefix}
7678c19
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
7678c19
7678c19
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
7678c19
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
7678c19
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
7678c19
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
7678c19
7678c19
%description
7678c19
%{summary}
7678c19
7678c19
%if 0%{?with_devel}
7678c19
%package devel
7678c19
Summary:       %{summary}
7678c19
BuildArch:     noarch
7678c19
7678c19
%if 0%{?with_check}
7678c19
BuildRequires: golang(github.com/coreos/pkg/capnslog)
7678c19
BuildRequires: golang(github.com/coreos/pkg/health)
7678c19
BuildRequires: golang(github.com/coreos/pkg/timeutil)
7678c19
BuildRequires: golang(github.com/jonboulle/clockwork)
7678c19
%endif
7678c19
7678c19
Requires:      golang(github.com/coreos/pkg/capnslog)
7678c19
Requires:      golang(github.com/coreos/pkg/health)
7678c19
Requires:      golang(github.com/coreos/pkg/timeutil)
7678c19
Requires:      golang(github.com/jonboulle/clockwork)
7678c19
7678c19
Provides:      golang(%{import_path}/http) = %{version}-%{release}
7678c19
Provides:      golang(%{import_path}/jose) = %{version}-%{release}
7678c19
Provides:      golang(%{import_path}/key) = %{version}-%{release}
7678c19
Provides:      golang(%{import_path}/oauth2) = %{version}-%{release}
7678c19
Provides:      golang(%{import_path}/oidc) = %{version}-%{release}
7678c19
7678c19
%description devel
7678c19
%{summary}
7678c19
7678c19
This package contains library source intended for
7678c19
building other packages which use import path with
7678c19
%{import_path} prefix.
7678c19
%endif
7678c19
7678c19
%if 0%{?with_unit_test} && 0%{?with_devel}
7678c19
%package unit-test
7678c19
Summary:         Unit tests for %{name} package
7678c19
%if 0%{?with_check}
7678c19
#Here comes all BuildRequires: PACKAGE the unit tests
7678c19
#in %%check section need for running
7678c19
%endif
7678c19
7678c19
# test subpackage tests code from devel subpackage
7678c19
Requires:        %{name}-devel = %{version}-%{release}
7678c19
7678c19
%description unit-test
7678c19
%{summary}
7678c19
7678c19
This package contains unit tests for project
7678c19
providing packages with %{import_path} prefix.
7678c19
%endif
7678c19
7678c19
%prep
7678c19
%setup -q -n %{repo}-%{commit}
7678c19
7678c19
%build
7678c19
7678c19
%install
7678c19
# source codes for building projects
7678c19
%if 0%{?with_devel}
7678c19
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
7678c19
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
7678c19
# find all *.go but no *_test.go files and generate devel.file-list
7678c19
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
7678c19
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
7678c19
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
7678c19
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
7678c19
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
7678c19
done
7678c19
%endif
7678c19
7678c19
# testing files for this project
7678c19
%if 0%{?with_unit_test} && 0%{?with_devel}
7678c19
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
7678c19
# find all *_test.go files and generate unit-test.file-list
7678c19
for file in $(find . -iname "*_test.go"); do
7678c19
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
7678c19
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
7678c19
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
7678c19
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
7678c19
done
7678c19
%endif
7678c19
7678c19
%if 0%{?with_devel}
7678c19
sort -u -o devel.file-list devel.file-list
7678c19
%endif
7678c19
7678c19
%check
7678c19
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
7678c19
%if ! 0%{?with_bundled}
7678c19
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
7678c19
%else
7678c19
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
7678c19
%endif
7678c19
7678c19
%if ! 0%{?gotest:1}
7678c19
%global gotest go test
7678c19
%endif
7678c19
7678c19
%gotest %{import_path}/http
7678c19
%gotest %{import_path}/jose
7678c19
%gotest %{import_path}/key
7678c19
%gotest %{import_path}/oauth2
7678c19
%gotest %{import_path}/oidc
7678c19
%endif
7678c19
7678c19
#define license tag if not already defined
7678c19
%{!?_licensedir:%global license %doc}
7678c19
7678c19
%if 0%{?with_devel}
7678c19
%files devel -f devel.file-list
7678c19
%license LICENSE
7678c19
%doc README.md CONTRIBUTING.md
7678c19
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
7678c19
%endif
7678c19
7678c19
%if 0%{?with_unit_test} && 0%{?with_devel}
7678c19
%files unit-test -f unit-test.file-list
7678c19
%license LICENSE
7678c19
%doc README.md CONTRIBUTING.md
7678c19
%endif
7678c19
7678c19
%changelog
7678c19
* Thu Oct 08 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.gitee7cb1f
7678c19
- First package for Fedora
7678c19
  resolves: #1269801
7678c19