Blame golang-github-xeipuuv-gojsonreference.spec

9cdf8c5
# If any of the following macros should be set otherwise,
9cdf8c5
# you can wrap any of them with the following conditions:
9cdf8c5
# - %%if 0%%{centos} == 7
9cdf8c5
# - %%if 0%%{?rhel} == 7
9cdf8c5
# - %%if 0%%{?fedora} == 23
9cdf8c5
# Or just test for particular distribution:
9cdf8c5
# - %%if 0%%{centos}
9cdf8c5
# - %%if 0%%{?rhel}
9cdf8c5
# - %%if 0%%{?fedora}
9cdf8c5
#
9cdf8c5
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
9cdf8c5
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
9cdf8c5
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)
9cdf8c5
9cdf8c5
# Generate devel rpm
9cdf8c5
%global with_devel 1
9cdf8c5
# Build project from bundled dependencies
9cdf8c5
%global with_bundled 0
9cdf8c5
# Build with debug info rpm
9cdf8c5
%global with_debug 0
9cdf8c5
# Run tests in check section
9cdf8c5
%global with_check 1
9cdf8c5
# Generate unit-test rpm
9cdf8c5
%global with_unit_test 1
9cdf8c5
9cdf8c5
%if 0%{?with_debug}
9cdf8c5
%global _dwz_low_mem_die_limit 0
9cdf8c5
%else
9cdf8c5
%global debug_package   %{nil}
9cdf8c5
%endif
9cdf8c5
9cdf8c5
9cdf8c5
%global provider        github
9cdf8c5
%global provider_tld    com
9cdf8c5
%global project         xeipuuv
9cdf8c5
%global repo            gojsonreference
9cdf8c5
# https://github.com/xeipuuv/gojsonreference
9cdf8c5
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
9cdf8c5
%global import_path     %{provider_prefix}
9cdf8c5
%global commit          e02fc20de94c78484cd5ffb007f8af96be030a45
9cdf8c5
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
9cdf8c5
9cdf8c5
Name:           golang-%{provider}-%{project}-%{repo}
9cdf8c5
Version:        0
9cdf8c5
Release:        0.1.git%{shortcommit}%{?dist}
9cdf8c5
Summary:        JSON Reference implementation in Golang
9cdf8c5
License:        ASL 2.0
9cdf8c5
URL:            https://%{provider_prefix}
9cdf8c5
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
9cdf8c5
9cdf8c5
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
9cdf8c5
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
9cdf8c5
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
9cdf8c5
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
9cdf8c5
9cdf8c5
9cdf8c5
9cdf8c5
%description
9cdf8c5
%{summary}
9cdf8c5
9cdf8c5
%if 0%{?with_devel}
9cdf8c5
%package devel
9cdf8c5
Summary:       %{summary}
9cdf8c5
BuildArch:     noarch
9cdf8c5
9cdf8c5
%if 0%{?with_check} && ! 0%{?with_bundled}
9cdf8c5
BuildRequires: golang(github.com/xeipuuv/gojsonpointer)
9cdf8c5
%endif
9cdf8c5
9cdf8c5
Requires:      golang(github.com/xeipuuv/gojsonpointer)
9cdf8c5
9cdf8c5
Provides:      golang(%{import_path}) = %{version}-%{release}
9cdf8c5
9cdf8c5
%description devel
9cdf8c5
%{summary}
9cdf8c5
9cdf8c5
This package contains library source intended for
9cdf8c5
building other packages which use import path with
9cdf8c5
%{import_path} prefix.
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%if 0%{?with_unit_test} && 0%{?with_devel}
9cdf8c5
%package unit-test-devel
9cdf8c5
Summary:         Unit tests for %{name} package
9cdf8c5
%if 0%{?with_check}
9cdf8c5
#Here comes all BuildRequires: PACKAGE the unit tests
9cdf8c5
#in %%check section need for running
9cdf8c5
%endif
9cdf8c5
9cdf8c5
# test subpackage tests code from devel subpackage
9cdf8c5
Requires:        %{name}-devel = %{version}-%{release}
9cdf8c5
9cdf8c5
%if 0%{?with_check} && ! 0%{?with_bundled}
9cdf8c5
%endif
9cdf8c5
9cdf8c5
9cdf8c5
%description unit-test-devel
9cdf8c5
%{summary}
9cdf8c5
9cdf8c5
This package contains unit tests for project
9cdf8c5
providing packages with %{import_path} prefix.
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%prep
9cdf8c5
%setup -q -n %{repo}-%{commit}
9cdf8c5
9cdf8c5
%build
9cdf8c5
%install
9cdf8c5
# source codes for building projects
9cdf8c5
%if 0%{?with_devel}
9cdf8c5
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
9cdf8c5
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
9cdf8c5
# find all *.go but no *_test.go files and generate devel.file-list
9cdf8c5
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do
9cdf8c5
    dirprefix=$(dirname $file)
9cdf8c5
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
9cdf8c5
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
9cdf8c5
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
9cdf8c5
9cdf8c5
    while [ "$dirprefix" != "." ]; do
9cdf8c5
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
9cdf8c5
        dirprefix=$(dirname $dirprefix)
9cdf8c5
    done
9cdf8c5
done
9cdf8c5
%endif
9cdf8c5
9cdf8c5
# testing files for this project
9cdf8c5
%if 0%{?with_unit_test} && 0%{?with_devel}
9cdf8c5
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
9cdf8c5
# find all *_test.go files and generate unit-test-devel.file-list
9cdf8c5
for file in $(find . -iname "*_test.go") ; do
9cdf8c5
    dirprefix=$(dirname $file)
9cdf8c5
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
9cdf8c5
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
9cdf8c5
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
9cdf8c5
9cdf8c5
    while [ "$dirprefix" != "." ]; do
9cdf8c5
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
9cdf8c5
        dirprefix=$(dirname $dirprefix)
9cdf8c5
    done
9cdf8c5
done
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%if 0%{?with_devel}
9cdf8c5
sort -u -o devel.file-list devel.file-list
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%check
9cdf8c5
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
9cdf8c5
%if ! 0%{?with_bundled}
9cdf8c5
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
9cdf8c5
%else
9cdf8c5
# No dependency directories so far
9cdf8c5
9cdf8c5
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%if ! 0%{?gotest:1}
9cdf8c5
%global gotest go test
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%gotest %{import_path}
9cdf8c5
%endif
9cdf8c5
9cdf8c5
#define license tag if not already defined
9cdf8c5
%{!?_licensedir:%global license %doc}
9cdf8c5
9cdf8c5
9cdf8c5
%if 0%{?with_devel}
9cdf8c5
%files devel -f devel.file-list
9cdf8c5
%license LICENSE-APACHE-2.0.txt
9cdf8c5
%doc README.md
9cdf8c5
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%if 0%{?with_unit_test} && 0%{?with_devel}
9cdf8c5
%files unit-test-devel -f unit-test-devel.file-list
9cdf8c5
%license LICENSE-APACHE-2.0.txt
9cdf8c5
%endif
9cdf8c5
9cdf8c5
%changelog
9cdf8c5
* Thu Dec 15 2016 Jan Chaloupka <jchaloup@redhat.com> - 0-0.1.gite02fc20
9cdf8c5
- First package for Fedora
9cdf8c5
  resolves: #1405072