Blame golang-github-robertkrimen-otto.spec

5f30f4e
# If any of the following macros should be set otherwise,
5f30f4e
# you can wrap any of them with the following conditions:
5f30f4e
# - %%if 0%%{centos} == 7
5f30f4e
# - %%if 0%%{?rhel} == 7
5f30f4e
# - %%if 0%%{?fedora} == 23
5f30f4e
# Or just test for particular distribution:
5f30f4e
# - %%if 0%%{centos}
5f30f4e
# - %%if 0%%{?rhel}
5f30f4e
# - %%if 0%%{?fedora}
5f30f4e
#
5f30f4e
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
5f30f4e
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
5f30f4e
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)
5f30f4e
5f30f4e
# Generate devel rpm
5f30f4e
%global with_devel 1
5f30f4e
# Build project from bundled dependencies
5f30f4e
%global with_bundled 0
5f30f4e
# Build with debug info rpm
5f30f4e
%global with_debug 0
5f30f4e
# Tests fail on arches != x86_64
5f30f4e
%global with_check 0
5f30f4e
# Generate unit-test rpm
5f30f4e
%global with_unit_test 1
5f30f4e
5f30f4e
%if 0%{?with_debug}
5f30f4e
%global _dwz_low_mem_die_limit 0
5f30f4e
%else
5f30f4e
%global debug_package   %{nil}
5f30f4e
%endif
5f30f4e
5f30f4e
5f30f4e
%global provider        github
5f30f4e
%global provider_tld    com
5f30f4e
%global project         robertkrimen
5f30f4e
%global repo            otto
5f30f4e
# https://github.com/robertkrimen/otto
5f30f4e
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
5f30f4e
%global import_path     %{provider_prefix}
5f30f4e
%global commit          3b44b4dcb6c00477273595c312908e2412d07da6
5f30f4e
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
5f30f4e
%global commitdate      20171130
5f30f4e
5f30f4e
Name:           golang-%{provider}-%{project}-%{repo}
5f30f4e
Version:        0
5f30f4e
Release:        0.1.%{commitdate}git%{shortcommit}%{?dist}
5f30f4e
Summary:        A JavaScript interpreter in Golang
5f30f4e
License:        MIT
5f30f4e
URL:            https://%{provider_prefix}
5f30f4e
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
5f30f4e
5f30f4e
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
5f30f4e
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
5f30f4e
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
5f30f4e
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
5f30f4e
5f30f4e
5f30f4e
5f30f4e
%description
5f30f4e
%{summary}
5f30f4e
5f30f4e
%if 0%{?with_devel}
5f30f4e
%package devel
5f30f4e
Summary:       %{summary}
5f30f4e
BuildArch:     noarch
5f30f4e
5f30f4e
%if 0%{?with_check} && ! 0%{?with_bundled}
5f30f4e
BuildRequires: golang(gopkg.in/readline.v1)
5f30f4e
BuildRequires: golang(gopkg.in/sourcemap.v1)
5f30f4e
%endif
5f30f4e
5f30f4e
Requires:      golang(gopkg.in/readline.v1)
5f30f4e
Requires:      golang(gopkg.in/sourcemap.v1)
5f30f4e
5f30f4e
Provides:      golang(%{import_path}) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/ast) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/dbg) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/file) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/parser) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/registry) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/repl) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/terst) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/token) = %{version}-%{release}
5f30f4e
Provides:      golang(%{import_path}/underscore) = %{version}-%{release}
5f30f4e
5f30f4e
%description devel
5f30f4e
%{summary}
5f30f4e
5f30f4e
This package contains library source intended for
5f30f4e
building other packages which use import path with
5f30f4e
%{import_path} prefix.
5f30f4e
%endif
5f30f4e
5f30f4e
%if 0%{?with_unit_test} && 0%{?with_devel}
5f30f4e
%package unit-test-devel
5f30f4e
Summary:         Unit tests for %{name} package
5f30f4e
%if 0%{?with_check}
5f30f4e
#Here comes all BuildRequires: PACKAGE the unit tests
5f30f4e
#in %%check section need for running
5f30f4e
%endif
5f30f4e
5f30f4e
# test subpackage tests code from devel subpackage
5f30f4e
Requires:        %{name}-devel = %{version}-%{release}
5f30f4e
5f30f4e
%if 0%{?with_check} && ! 0%{?with_bundled}
5f30f4e
%endif
5f30f4e
5f30f4e
5f30f4e
%description unit-test-devel
5f30f4e
%{summary}
5f30f4e
5f30f4e
This package contains unit tests for project
5f30f4e
providing packages with %{import_path} prefix.
5f30f4e
%endif
5f30f4e
5f30f4e
%prep
5f30f4e
%autosetup -n %{repo}-%{commit}
5f30f4e
5f30f4e
%build
5f30f4e
%install
5f30f4e
# source codes for building projects
5f30f4e
%if 0%{?with_devel}
5f30f4e
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
5f30f4e
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
5f30f4e
# find all *.go but no *_test.go files and generate devel.file-list
5f30f4e
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do
5f30f4e
    dirprefix=$(dirname $file)
5f30f4e
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
5f30f4e
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
5f30f4e
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
5f30f4e
5f30f4e
    while [ "$dirprefix" != "." ]; do
5f30f4e
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
5f30f4e
        dirprefix=$(dirname $dirprefix)
5f30f4e
    done
5f30f4e
done
5f30f4e
%endif
5f30f4e
5f30f4e
# testing files for this project
5f30f4e
%if 0%{?with_unit_test} && 0%{?with_devel}
5f30f4e
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
5f30f4e
# find all *_test.go files and generate unit-test-devel.file-list
5f30f4e
for file in $(find . -iname "*_test.go") ; do
5f30f4e
    dirprefix=$(dirname $file)
5f30f4e
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
5f30f4e
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
5f30f4e
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
5f30f4e
5f30f4e
    while [ "$dirprefix" != "." ]; do
5f30f4e
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
5f30f4e
        dirprefix=$(dirname $dirprefix)
5f30f4e
    done
5f30f4e
done
5f30f4e
%endif
5f30f4e
5f30f4e
%if 0%{?with_devel}
5f30f4e
sort -u -o devel.file-list devel.file-list
5f30f4e
%endif
5f30f4e
5f30f4e
%check
5f30f4e
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
5f30f4e
%if ! 0%{?with_bundled}
5f30f4e
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
5f30f4e
%else
5f30f4e
# No dependency directories so far
5f30f4e
5f30f4e
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
5f30f4e
%endif
5f30f4e
5f30f4e
%if ! 0%{?gotest:1}
5f30f4e
%global gotest go test
5f30f4e
%endif
5f30f4e
5f30f4e
%gotest %{import_path}
5f30f4e
%gotest %{import_path}/ast
5f30f4e
%gotest %{import_path}/parser
5f30f4e
%endif
5f30f4e
5f30f4e
#define license tag if not already defined
5f30f4e
%{!?_licensedir:%global license %doc}
5f30f4e
5f30f4e
5f30f4e
%if 0%{?with_devel}
5f30f4e
%files devel -f devel.file-list
5f30f4e
%license LICENSE
5f30f4e
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
5f30f4e
%endif
5f30f4e
5f30f4e
%if 0%{?with_unit_test} && 0%{?with_devel}
5f30f4e
%files unit-test-devel -f unit-test-devel.file-list
5f30f4e
%license LICENSE
5f30f4e
%endif
5f30f4e
5f30f4e
%changelog
5f30f4e
* Thu Dec 07 2017 Robert-André Mauchin <zebob.m@gmail.com> - 0-0.1.20171130git3b44b4d
5f30f4e
- Upstream GIT revision 3b44b4d
5f30f4e
5f30f4e
* Fri Sep 29 2017 Robert-André Mauchin <zebob.m@gmail.com> - 0-0.1.20170818gita813c59
5f30f4e
- First package for Fedora
5f30f4e