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