Blame golang-github-oschwald-geoip2-golang.spec

c41d9c0
# Generate devel rpm
c41d9c0
%global with_devel 1
c41d9c0
# Build project from bundled dependencies
c41d9c0
%global with_bundled 0
c41d9c0
# Build with debug info rpm
c41d9c0
%global with_debug 0
c41d9c0
# Run tests in check section
c41d9c0
%global with_check 1
c41d9c0
# Generate unit-test rpm
c41d9c0
%global with_unit_test 0
c41d9c0
c41d9c0
# Tests require the test-data directory, which is a git submodule - and
c41d9c0
# not available in the downloaded tarballs.
c41d9c0
c41d9c0
%if 0%{?with_debug}
c41d9c0
%global _dwz_low_mem_die_limit 0
c41d9c0
%else
c41d9c0
%global debug_package   %{nil}
c41d9c0
%endif
c41d9c0
c41d9c0
%global provider        github
c41d9c0
%global provider_tld    com
c41d9c0
%global project         oschwald
c41d9c0
%global repo            geoip2-golang
c41d9c0
# https://github.com/oschwald/geoip2-golang
c41d9c0
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
c41d9c0
%global import_path     %{provider_prefix}
3e39066
%global commit          7118115686e16b77967cdbf55d1b944fe14ad312
c41d9c0
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
f91366b
%global commitdate      20170423
f91366b
3e39066
# commit 7118115686e16b77967cdbf55d1b944fe14ad312 == version 1.2.1
c41d9c0
c41d9c0
c41d9c0
Name:           golang-%{provider}-%{project}-%{repo}
3e39066
Version:        1.2.1
f91366b
Release:        1%{?dist}
c41d9c0
Summary:        GeoIP2 lookup library for Go
c41d9c0
License:        ISC
c41d9c0
URL:            https://%{provider_prefix}
3e39066
Source0:        https://%{provider_prefix}/archive/v%{version}/%{project}-%{repo}-%{version}.tar.gz
c41d9c0
c41d9c0
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
c41d9c0
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
c41d9c0
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
c41d9c0
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
c41d9c0
c41d9c0
%description
c41d9c0
%{summary}
c41d9c0
c41d9c0
c41d9c0
%if 0%{?with_devel}
c41d9c0
%package        devel
c41d9c0
Summary:        %{summary}
c41d9c0
BuildArch:      noarch
c41d9c0
c41d9c0
%if 0%{?with_check} && ! 0%{?with_bundled}
c41d9c0
BuildRequires:  golang(github.com/oschwald/maxminddb-golang)
c41d9c0
%endif
c41d9c0
c41d9c0
Requires:       golang(github.com/oschwald/maxminddb-golang)
c41d9c0
c41d9c0
Provides:       golang(%{import_path}) = %{version}-%{release}
c41d9c0
c41d9c0
%description    devel
c41d9c0
%{summary}
c41d9c0
c41d9c0
This package contains library source intended for
c41d9c0
building other packages which use import path with
c41d9c0
%{import_path} prefix.
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
%if 0%{?with_unit_test} && 0%{?with_devel}
c41d9c0
%package        unit-test-devel
c41d9c0
Summary:        Unit tests for %{name} package
c41d9c0
c41d9c0
# test subpackage tests code from devel subpackage
c41d9c0
Requires:       %{name}-devel = %{version}-%{release}
c41d9c0
c41d9c0
%if 0%{?with_check} && ! 0%{?with_bundled}
ac61e16
BuildRequires:  golang(github.com/stretchr/testify/assert)
c41d9c0
%endif
c41d9c0
ac61e16
Requires:       golang(github.com/stretchr/testify/assert)
c41d9c0
c41d9c0
%description    unit-test-devel
c41d9c0
%{summary}
c41d9c0
c41d9c0
This package contains unit tests for project
c41d9c0
providing packages with %{import_path} prefix.
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
%prep
3e39066
%setup -q -n %{repo}-%{version}
c41d9c0
c41d9c0
c41d9c0
%build
c41d9c0
c41d9c0
c41d9c0
%install
c41d9c0
# source codes for building projects
c41d9c0
%if 0%{?with_devel}
c41d9c0
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
c41d9c0
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
c41d9c0
c41d9c0
# find all *.go but no *_test.go files and generate devel.file-list
c41d9c0
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do
c41d9c0
    dirprefix=$(dirname $file)
c41d9c0
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
c41d9c0
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
c41d9c0
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
c41d9c0
c41d9c0
    while [ "$dirprefix" != "." ]; do
c41d9c0
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
c41d9c0
        dirprefix=$(dirname $dirprefix)
c41d9c0
    done
c41d9c0
done
c41d9c0
%endif
c41d9c0
c41d9c0
# testing files for this project
c41d9c0
%if 0%{?with_unit_test} && 0%{?with_devel}
c41d9c0
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
c41d9c0
c41d9c0
# find all *_test.go files and generate unit-test-devel.file-list
c41d9c0
for file in $(find . -iname "*_test.go") ; do
c41d9c0
    dirprefix=$(dirname $file)
c41d9c0
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
c41d9c0
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
c41d9c0
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
c41d9c0
c41d9c0
    while [ "$dirprefix" != "." ]; do
c41d9c0
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
c41d9c0
        dirprefix=$(dirname $dirprefix)
c41d9c0
    done
c41d9c0
done
c41d9c0
%endif
c41d9c0
c41d9c0
%if 0%{?with_devel}
c41d9c0
sort -u -o devel.file-list devel.file-list
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
%check
c41d9c0
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
c41d9c0
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
c41d9c0
c41d9c0
%if ! 0%{?gotest:1}
c41d9c0
%global gotest go test
c41d9c0
%endif
c41d9c0
c41d9c0
%gotest %{import_path}
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
#define license tag if not already defined
c41d9c0
%{!?_licensedir:%global license %doc}
c41d9c0
c41d9c0
c41d9c0
%if 0%{?with_devel}
c41d9c0
%files devel -f devel.file-list
c41d9c0
%license LICENSE
c41d9c0
%doc README.md
c41d9c0
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
%if 0%{?with_unit_test} && 0%{?with_devel}
c41d9c0
%files unit-test-devel -f unit-test-devel.file-list
c41d9c0
%license LICENSE
c41d9c0
%doc README.md
c41d9c0
%endif
c41d9c0
c41d9c0
c41d9c0
%changelog
3e39066
* Mon Feb 26 2018 Fabio Valentini <decathorpe@gmail.com> - 1.2.1-1
3e39066
- Update to version 1.2.1.
3e39066
ac61e16
* Tue Feb 20 2018 Fabio Valentini <decathorpe@gmail.com> - 1.2.0-1
ac61e16
- Update to version 1.2.0.
ac61e16
f91366b
* Mon Apr 24 2017 Fabio Valentini <decathorpe@gmail.com> - 1.1.0-1
f91366b
- Update to version 1.1.0.
f91366b
c41d9c0
* Mon Mar 13 2017 Fabio Valentini <decathorpe@gmail.com> - 1.0.0-1.20170314.git0fd242d
c41d9c0
- First package for Fedora
c41d9c0