a17912a
%if 0%{?fedora} || 0%{?rhel} == 6
a17912a
%global with_devel 1
a17912a
%global with_bundled 0
a17912a
%global with_debug 0
a17912a
%global with_check 1
a17912a
%global with_unit_test 1
a17912a
%else
a17912a
%global with_devel 0
a17912a
%global with_bundled 0
a17912a
%global with_debug 0
a17912a
%global with_check 0
a17912a
%global with_unit_test 0
a17912a
%endif
a17912a
a17912a
%if 0%{?with_debug}
a17912a
%global _dwz_low_mem_die_limit 0
a17912a
%else
8f6edcf
%global debug_package   %{nil}
a17912a
%endif
a17912a
8f6edcf
%global provider        github
8f6edcf
%global provider_tld    com
8f6edcf
%global project         hashicorp
8f6edcf
%global repo            hcl
8f6edcf
# https://github.com/hashicorp/hcl
a17912a
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
a17912a
%global import_path     %{provider_prefix}
8f6edcf
%global commit          513e04c400ee2e81e97f5e011c08fb42c6f69b84
8f6edcf
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
8f6edcf
8f6edcf
Name:           golang-%{provider}-%{project}-%{repo}
8f6edcf
Version:        0
5130261
Release:        0.3.git%{shortcommit}%{?dist}
8f6edcf
Summary:        HCL is a configuration language
8f6edcf
License:        MPLv2.0
a17912a
URL:            https://%{provider_prefix}
a17912a
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
8f6edcf
5130261
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
5130261
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
5130261
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
5130261
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
8f6edcf
8f6edcf
%description
8f6edcf
%{summary}
a17912a
a17912a
%if 0%{?with_devel}
8f6edcf
%package devel
8f6edcf
Summary:       %{summary}
a17912a
BuildArch:     noarch
a17912a
a17912a
%if 0%{?with_check}
8f6edcf
BuildRequires: golang(github.com/hashicorp/go-multierror)
a17912a
%endif
a17912a
8f6edcf
Requires:      golang(github.com/hashicorp/go-multierror)
a17912a
8f6edcf
Provides:      golang(%{import_path}) = %{version}-%{release}
8f6edcf
Provides:      golang(%{import_path}/hcl) = %{version}-%{release}
8f6edcf
Provides:      golang(%{import_path}/json) = %{version}-%{release}
8f6edcf
8f6edcf
%description devel
8f6edcf
%{summary}
8f6edcf
8f6edcf
This package contains library source intended for
a17912a
building other packages which use import path with
a17912a
%{import_path} prefix.
a17912a
%endif
a17912a
5130261
%if 0%{?with_unit_test} && 0%{?with_devel}
a17912a
%package unit-test
a17912a
Summary:         Unit tests for %{name} package
5130261
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
5130261
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
a17912a
a17912a
%if 0%{?with_check}
a17912a
#Here comes all BuildRequires: PACKAGE the unit tests
a17912a
#in %%check section need for running
a17912a
%endif
a17912a
a17912a
# test subpackage tests code from devel subpackage
a17912a
Requires:        %{name}-devel = %{version}-%{release}
a17912a
a17912a
%description unit-test
a17912a
%{summary}
a17912a
a17912a
This package contains unit tests for project
a17912a
providing packages with %{import_path} prefix.
a17912a
%endif
8f6edcf
8f6edcf
%prep
8f6edcf
%setup -q -n %{repo}-%{commit}
8f6edcf
8f6edcf
%build
8f6edcf
8f6edcf
%install
a17912a
# source codes for building projects
a17912a
%if 0%{?with_devel}
8f6edcf
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
5130261
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
a17912a
# find all *.go but no *_test.go files and generate devel.file-list
a17912a
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
5130261
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
a17912a
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
a17912a
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
a17912a
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
a17912a
done
a17912a
%endif
8f6edcf
a17912a
# testing files for this project
5130261
%if 0%{?with_unit_test} && 0%{?with_devel}
a17912a
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
a17912a
# find all *_test.go files and generate unit-test.file-list
a17912a
for file in $(find . -iname "*_test.go"); do
5130261
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
a17912a
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
a17912a
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
a17912a
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
a17912a
done
a17912a
for file in $(find ./test-fixtures/ -iname "*.hcl" -or -iname "*.json"); do
5130261
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
a17912a
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
a17912a
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
a17912a
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
a17912a
done
a17912a
for file in $(find ./hcl/test-fixtures/ -iname "*.hcl" -or -iname "*.json"); do
5130261
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
a17912a
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
a17912a
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
a17912a
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
8f6edcf
done
a17912a
for file in $(find ./json/test-fixtures/ -iname "*.hcl" -or -iname "*.json"); do
5130261
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
a17912a
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
a17912a
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
a17912a
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
a17912a
done
a17912a
%endif
8f6edcf
5130261
%if 0%{?with_devel}
5130261
sort -u -o devel.file-list devel.file-list
5130261
%endif
5130261
8f6edcf
%check
a17912a
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
5130261
%if ! 0%{?with_bundled}
5130261
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
8f6edcf
%else
5130261
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
a17912a
%endif
5130261
5130261
%if ! 0%{?gotest:1}
5130261
%global gotest go test
8f6edcf
%endif
a17912a
5130261
%gotest %{import_path}
5130261
%gotest %{import_path}/hcl
5130261
%gotest %{import_path}/json
a17912a
%endif
a17912a
5130261
#define license tag if not already defined
5130261
%{!?_licensedir:%global license %doc}
5130261
a17912a
%if 0%{?with_devel}
a17912a
%files devel -f devel.file-list
5130261
%license LICENSE
a17912a
%doc README.md
8f6edcf
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
a17912a
%endif
a17912a
5130261
%if 0%{?with_unit_test} && 0%{?with_devel}
a17912a
%files unit-test -f unit-test.file-list
5130261
%license LICENSE
a17912a
%doc README.md
a17912a
%endif
8f6edcf
8f6edcf
%changelog
5130261
* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0-0.3.git513e04c
5130261
- Update to spec-2.1
5130261
  related: #1250468
5130261
a17912a
* Wed Aug 05 2015 Fridolin Pokorny <fpokorny@redhat.com> - 0-0.2.git513e04c
a17912a
- Update spec file to spec-2.0
a17912a
  resolves: #1250468
a17912a
8f6edcf
* Wed Apr 15 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.git513e04c
8f6edcf
- First package for Fedora
8f6edcf
  resolves: #1212059
5130261