Blame golang-github-cznic-lexer.spec

4f3aceb
# Generate devel rpm
4f3aceb
%global with_devel 1
4f3aceb
# Build project from bundled dependencies
4f3aceb
%global with_bundled 0
4f3aceb
# Build with debug info rpm
4f3aceb
%global with_debug 0
4f3aceb
# Run tests in check section
4f3aceb
%global with_check 1
4f3aceb
# Generate unit-test rpm
4f3aceb
%global with_unit_test 1
4f3aceb
4f3aceb
%if 0%{?with_debug}
4f3aceb
%global _dwz_low_mem_die_limit 0
4f3aceb
%else
4f3aceb
%global debug_package   %{nil}
4f3aceb
%endif
4f3aceb
4f3aceb
%global provider        github
4f3aceb
%global provider_tld    com
4f3aceb
%global project         cznic
4f3aceb
%global repo            lexer
4f3aceb
# https://github.com/cznic/lexer
4f3aceb
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
4f3aceb
%global import_path     %{provider_prefix}
4f3aceb
%global commit          52ae7862082bd9649e03c1c4013a104b37811bfa
4f3aceb
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
4f3aceb
%global commitdate      20141211
4f3aceb
4f3aceb
4f3aceb
Name:           golang-%{provider}-%{project}-%{repo}
4f3aceb
Version:        0
4f3aceb
Release:        0.1.%{commitdate}.git%{shortcommit}%{?dist}
4f3aceb
Summary:        Run time generator of action less scanners written in Go
4f3aceb
License:        BSD
4f3aceb
URL:            https://%{provider_prefix}
4f3aceb
Source0:        https://%{provider_prefix}/archive/%{commit}/%{project}-%{repo}-%{shortcommit}.tar.gz
4f3aceb
4f3aceb
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
4f3aceb
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
4f3aceb
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
4f3aceb
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
4f3aceb
4f3aceb
%description
4f3aceb
%{summary}
4f3aceb
4f3aceb
4f3aceb
%if 0%{?with_devel}
4f3aceb
%package        devel
4f3aceb
Summary:        %{summary}
4f3aceb
BuildArch:      noarch
4f3aceb
4f3aceb
%if 0%{?with_check} && ! 0%{?with_bundled}
4f3aceb
BuildRequires:  golang(github.com/cznic/fileutil)
4f3aceb
BuildRequires:  golang(golang.org/x/exp/ebnf)
4f3aceb
%endif
4f3aceb
4f3aceb
Requires:       golang(github.com/cznic/fileutil)
4f3aceb
Requires:       golang(golang.org/x/exp/ebnf)
4f3aceb
4f3aceb
Provides:       golang(%{import_path}) = %{version}-%{release}
4f3aceb
4f3aceb
%description    devel
4f3aceb
%{summary}
4f3aceb
4f3aceb
This package contains library source intended for
4f3aceb
building other packages which use import path with
4f3aceb
%{import_path} prefix.
4f3aceb
%endif
4f3aceb
4f3aceb
4f3aceb
%if 0%{?with_unit_test} && 0%{?with_devel}
4f3aceb
%package        unit-test-devel
4f3aceb
Summary:        Unit tests for %{name} package
4f3aceb
4f3aceb
# test subpackage tests code from devel subpackage
4f3aceb
Requires:       %{name}-devel = %{version}-%{release}
4f3aceb
4f3aceb
%description    unit-test-devel
4f3aceb
%{summary}
4f3aceb
4f3aceb
This package contains unit tests for project
4f3aceb
providing packages with %{import_path} prefix.
4f3aceb
%endif
4f3aceb
4f3aceb
4f3aceb
%prep
4f3aceb
%setup -q -n %{repo}-%{commit}
4f3aceb
4f3aceb
4f3aceb
%build
4f3aceb
4f3aceb
4f3aceb
%install
4f3aceb
# Remove a rather unnecessary (and nearly empty) file
4f3aceb
rm test_deps.go
4f3aceb
4f3aceb
# source codes for building projects
4f3aceb
%if 0%{?with_devel}
4f3aceb
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
4f3aceb
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
4f3aceb
4f3aceb
# find all *.go but no *_test.go files and generate devel.file-list
4f3aceb
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do
4f3aceb
    dirprefix=$(dirname $file)
4f3aceb
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
4f3aceb
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
4f3aceb
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
4f3aceb
4f3aceb
    while [ "$dirprefix" != "." ]; do
4f3aceb
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
4f3aceb
        dirprefix=$(dirname $dirprefix)
4f3aceb
    done
4f3aceb
done
4f3aceb
%endif
4f3aceb
4f3aceb
# testing files for this project
4f3aceb
%if 0%{?with_unit_test} && 0%{?with_devel}
4f3aceb
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
4f3aceb
4f3aceb
# find all *_test.go files and generate unit-test-devel.file-list
4f3aceb
for file in $(find . -iname "*_test.go") ; do
4f3aceb
    dirprefix=$(dirname $file)
4f3aceb
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
4f3aceb
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
4f3aceb
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
4f3aceb
4f3aceb
    while [ "$dirprefix" != "." ]; do
4f3aceb
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
4f3aceb
        dirprefix=$(dirname $dirprefix)
4f3aceb
    done
4f3aceb
done
4f3aceb
%endif
4f3aceb
4f3aceb
%if 0%{?with_devel}
4f3aceb
sort -u -o devel.file-list devel.file-list
4f3aceb
%endif
4f3aceb
4f3aceb
4f3aceb
%check
4f3aceb
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
4f3aceb
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
4f3aceb
4f3aceb
%if ! 0%{?gotest:1}
4f3aceb
%global gotest go test
4f3aceb
%endif
4f3aceb
4f3aceb
%gotest %{import_path}
4f3aceb
%endif
4f3aceb
4f3aceb
4f3aceb
#define license tag if not already defined
4f3aceb
%{!?_licensedir:%global license %doc}
4f3aceb
4f3aceb
4f3aceb
%if 0%{?with_devel}
4f3aceb
%files devel -f devel.file-list
4f3aceb
%license LICENSE
4f3aceb
%doc CONTRIBUTORS README AUTHORS
4f3aceb
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
4f3aceb
%endif
4f3aceb
4f3aceb
%if 0%{?with_unit_test} && 0%{?with_devel}
4f3aceb
%files unit-test-devel -f unit-test-devel.file-list
4f3aceb
%license LICENSE
4f3aceb
%doc CONTRIBUTORS README AUTHORS
4f3aceb
%endif
4f3aceb
4f3aceb
4f3aceb
%changelog
4f3aceb
* Wed Jun 28 2017 Fabio Valentini <decathorpe@gmail.com> - 0-0.1.20141211.git52ae786
4f3aceb
- First package for Fedora
4f3aceb