Blame golang-github-thejerf-suture.spec

94787a5
# Generate devel rpm
94787a5
%global with_devel 1
94787a5
# Build project from bundled dependencies
94787a5
%global with_bundled 0
94787a5
# Build with debug info rpm
94787a5
%global with_debug 0
94787a5
# Run tests in check section
94787a5
%global with_check 1
94787a5
# Generate unit-test rpm
94787a5
%global with_unit_test 1
94787a5
94787a5
%if 0%{?with_debug}
94787a5
%global _dwz_low_mem_die_limit 0
94787a5
%else
94787a5
%global debug_package   %{nil}
94787a5
%endif
94787a5
94787a5
94787a5
%global provider        github
94787a5
%global provider_tld    com
94787a5
%global project         thejerf
94787a5
%global repo            suture
94787a5
# https://github.com/thejerf/suture
94787a5
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
94787a5
%global import_path     %{provider_prefix}
94787a5
%global commit          fe1c0d795ff7a7e54fc54ef6afb36ee0adf0c276
94787a5
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
94787a5
94787a5
94787a5
Name:           golang-%{provider}-%{project}-%{repo}
94787a5
Version:        2.0.0
94787a5
Release:        1%{?dist}
94787a5
Summary:        Supervisor trees for Go
94787a5
License:        MIT
94787a5
URL:            https://%{provider_prefix}
94787a5
Source0:        https://%{provider_prefix}/archive/v%{version}/%{repo}-%{version}.tar.gz
94787a5
94787a5
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
94787a5
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
94787a5
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
94787a5
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
94787a5
94787a5
94787a5
%description
94787a5
%{summary}
94787a5
94787a5
94787a5
%if 0%{?with_devel}
94787a5
%package        devel
94787a5
Summary:        %{summary}
94787a5
BuildArch:      noarch
94787a5
94787a5
%if 0%{?with_check} && ! 0%{?with_bundled}
94787a5
%endif
94787a5
94787a5
Provides:       golang(%{import_path}) = %{version}-%{release}
94787a5
94787a5
%description    devel
94787a5
%{summary}
94787a5
94787a5
This package contains library source intended for
94787a5
building other packages which use import path with
94787a5
%{import_path} prefix.
94787a5
%endif
94787a5
94787a5
94787a5
%if 0%{?with_unit_test} && 0%{?with_devel}
94787a5
%package        unit-test-devel
94787a5
Summary:        Unit tests for %{name} package
94787a5
%if 0%{?with_check}
94787a5
#Here comes all BuildRequires: PACKAGE the unit tests
94787a5
#in %%check section need for running
94787a5
%endif
94787a5
94787a5
# test subpackage tests code from devel subpackage
94787a5
Requires:       %{name}-devel = %{version}-%{release}
94787a5
94787a5
%if 0%{?with_check} && ! 0%{?with_bundled}
94787a5
%endif
94787a5
94787a5
%description    unit-test-devel
94787a5
%{summary}
94787a5
94787a5
This package contains unit tests for project
94787a5
providing packages with %{import_path} prefix.
94787a5
%endif
94787a5
94787a5
94787a5
%prep
94787a5
%setup -q -n %{repo}-%{version}
94787a5
94787a5
94787a5
%build
94787a5
94787a5
94787a5
%install
94787a5
# source codes for building projects
94787a5
%if 0%{?with_devel}
94787a5
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
94787a5
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
94787a5
# find all *.go but no *_test.go files and generate devel.file-list
94787a5
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do
94787a5
    dirprefix=$(dirname $file)
94787a5
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
94787a5
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
94787a5
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
94787a5
94787a5
    while [ "$dirprefix" != "." ]; do
94787a5
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
94787a5
        dirprefix=$(dirname $dirprefix)
94787a5
    done
94787a5
done
94787a5
%endif
94787a5
94787a5
# testing files for this project
94787a5
%if 0%{?with_unit_test} && 0%{?with_devel}
94787a5
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
94787a5
# find all *_test.go files and generate unit-test-devel.file-list
94787a5
for file in $(find . -iname "*_test.go") ; do
94787a5
    dirprefix=$(dirname $file)
94787a5
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
94787a5
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
94787a5
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
94787a5
94787a5
    while [ "$dirprefix" != "." ]; do
94787a5
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
94787a5
        dirprefix=$(dirname $dirprefix)
94787a5
    done
94787a5
done
94787a5
%endif
94787a5
94787a5
%if 0%{?with_devel}
94787a5
sort -u -o devel.file-list devel.file-list
94787a5
%endif
94787a5
94787a5
94787a5
%check
94787a5
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
94787a5
%if ! 0%{?with_bundled}
94787a5
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
94787a5
%else
94787a5
# No dependency directories so far
94787a5
94787a5
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
94787a5
%endif
94787a5
94787a5
%if ! 0%{?gotest:1}
94787a5
%global gotest go test
94787a5
%endif
94787a5
94787a5
%gotest %{import_path}
94787a5
%endif
94787a5
94787a5
#define license tag if not already defined
94787a5
%{!?_licensedir:%global license %doc}
94787a5
94787a5
94787a5
%if 0%{?with_devel}
94787a5
%files devel -f devel.file-list
94787a5
%license LICENSE
94787a5
%doc README.md
94787a5
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
94787a5
%endif
94787a5
94787a5
94787a5
%if 0%{?with_unit_test} && 0%{?with_devel}
94787a5
%files unit-test-devel -f unit-test-devel.file-list
94787a5
%license LICENSE
94787a5
%doc README.md
94787a5
%endif
94787a5
94787a5
94787a5
%changelog
94787a5
* Tue Feb 28 2017 Fabio Valentini <decathorpe@gmail.com> - 2.0.0-1
94787a5
- First package for Fedora
94787a5