Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} == 6
%global with_devel 1
# package depends on kubernetes which atm does
# not provide complete source codes
%global with_bundled 1
%if 0%{?rhel} == 6
%global with_debug 0
%else
%global with_debug 1
%endif
# missing deps on kubernetes
%global with_check 0
%global with_unit_test 1
%else
%global with_devel 0
%global with_bundled 1
%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

%global provider        github
%global provider_tld    com
%global project         appc
%global repo            spec
# https://github.com/appc/spec
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}
%global commit          37bef679148751952f169298fa0ea8171373d95c
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Name:           golang-%{provider}-%{project}-%{repo}
Version:        0.5.1
Release:        7.git%{shortcommit}%{?dist}
Summary:        Schema defs and tools for app container specification
License:        ASL 2.0
URL:            https://%{provider_prefix}
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz

# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

Provides:   actool = %{version}-%{release}
Provides:   ace-validator = %{version}-%{release}

%description
%{summary}

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

%if 0%{?with_check}
#BuildRequires: golang(github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource)
BuildRequires: golang(github.com/coreos/go-semver/semver) >= 0-0.2
BuildRequires: golang(golang.org/x/net/html)
BuildRequires: golang(golang.org/x/net/html/atom)
%endif

#Requires: golang(github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource)
Requires: golang(github.com/coreos/go-semver/semver) >= 0-0.2
Requires: golang(golang.org/x/net/html)
Requires: golang(golang.org/x/net/html/atom)

Provides:      golang(%{import_path}/aci) = %{version}-%{release}
Provides:      golang(%{import_path}/discovery) = %{version}-%{release}
Provides:      golang(%{import_path}/pkg/acirenderer) = %{version}-%{release}
Provides:      golang(%{import_path}/pkg/tarheader) = %{version}-%{release}
Provides:      golang(%{import_path}/schema) = %{version}-%{release}
Provides:      golang(%{import_path}/schema/types) = %{version}-%{release}

%description devel
%{summary}

This package contains library source intended for
building other packages which use import path with
%{import_path} prefix.
%endif

%if 0%{?with_unit_test} && 0%{?with_devel}
%package unit-test
Summary:         Unit tests for %{name} package
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

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

%build
mkdir -p src/github.com/appc
ln -s ../../../ src/github.com/appc/spec

%if 0%{?with_bundled}
export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
%else
export GOPATH=$(pwd):%{gopath}
%endif

%if 0%{?with_debug}
function gobuild { go build -a -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" -v -x "$@"; }
%else
function gobuild { go build -a "$@"; }
%endif

gobuild -o bin/actool %{import_path}/actool
gobuild -o bin/ace-validator -installsuffix ace %{import_path}/ace

find . -name "*.go" \
    -print |\
    xargs sed -i 's/github.com\/appc\/spec\/Godeps\/_workspace\/src\///g'

%install
install -d -p %{buildroot}%{_bindir}
install -p -m 755 bin/actool %{buildroot}%{_bindir}
install -p -m 755 bin/ace-validator %{buildroot}%{_bindir}

# source codes for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . -iname "*.go" \! -iname "*_test.go" | grep -v "^./Godeps") ; do
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
    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} && 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/discovery
echo "%%dir %%{gopath}/src/%%{import_path}/./discovery" >> devel.file-list
cp -pav discovery/myapp.html %{buildroot}/%{gopath}/src/%{import_path}/discovery/.
cp -pav discovery/myapp2.html %{buildroot}/%{gopath}/src/%{import_path}/discovery/.
echo "%%{gopath}/src/%%{import_path}/discovery/myapp.html" >> unit-test.file-list
echo "%%{gopath}/src/%%{import_path}/discovery/myapp2.html" >> unit-test.file-list
# find all *_test.go files and generate unit-test.file-list
for file in $(find . -iname "*_test.go" | grep -v "^./Godeps"); do
    echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list
    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

%if 0%{?with_devel}
sort -u -o devel.file-list devel.file-list
%endif

%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%if ! 0%{?with_bundled}
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
%else
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
%endif

%if ! 0%{?gotest:1}
%global gotest go test
%endif

%gotest %{import_path}/aci
%gotest %{import_path}/discovery
%gotest %{import_path}/pkg/acirenderer
%gotest %{import_path}/pkg/tarheader
%gotest %{import_path}/schema
%gotest %{import_path}/schema/types
%endif

#define license tag if not already defined
%{!?_licensedir:%global license %doc}

%files
%license LICENSE
%doc SPEC.md README.md OS-SPEC.md GUIDE.md CONTRIBUTING.md
%{_bindir}/actool
%{_bindir}/ace-validator

%if 0%{?with_devel}
%files devel -f devel.file-list
%license LICENSE
%doc SPEC.md README.md OS-SPEC.md GUIDE.md CONTRIBUTING.md
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%endif

%if 0%{?with_unit_test} && 0%{?with_devel}
%files unit-test -f unit-test.file-list
%license LICENSE
%doc SPEC.md README.md OS-SPEC.md GUIDE.md CONTRIBUTING.md
%endif

%changelog
* Mon Feb 22 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5.1-7.git37bef67
- https://fedoraproject.org/wiki/Changes/golang1.6

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.1-6.git37bef67
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Sat Sep 12 2015 jchaloup <jchaloup@redhat.com> - 0.5.1-5.git37bef67
- Update to spec-2.1
  related: #1248491

* Thu Jul 30 2015 jchaloup <jchaloup@redhat.com> - 0.5.1-4.git37bef67
- Update of spec file to spec-2.0
  resolves: #1248491

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

* Thu Apr 02 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.5.1-2.git37bef67
- update to latest upstream master

* Fri Mar 27 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.5.1-1.gitc8559a2
- update to latest upstream master branch

* Wed Feb 18 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.3.0-2.gitfa6d3af
- only build for x86_64, ace-validator doesn't work for arm

* Wed Feb 18 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.3.0-1.gitfa6d3af
- update to commit fa6d3af86db496053a2d3c907c676fd9ee1118a8

* Tue Feb 03 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.2.0-2.git2fee340
- update to master commit#2fee340
- provide actool and ace-validator in main package
- remove mentions of fedora 19 (EOL)

* Sat Jan 31 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.2.0-1.git202fd7b
- Resolves: rhbz#1174030 - first package upload
- update to master commit#202fd7b

* Mon Dec 15 2014 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.1.1-2
- update metaprovides
- update docs packaged

* Tue Dec 09 2014 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.1.1-1
- First package for Fedora