[11107] | 1 | %global with_devel 1 |
---|
| 2 | %global with_bundled 0 |
---|
| 3 | %global with_debug 0 |
---|
| 4 | %global with_check 1 |
---|
| 5 | |
---|
| 6 | %if 0%{?with_debug} |
---|
| 7 | %global _dwz_low_mem_die_limit 0 |
---|
| 8 | %else |
---|
| 9 | %global debug_package %{nil} |
---|
| 10 | %endif |
---|
| 11 | |
---|
| 12 | %global gopath %{_datadir}/gocode |
---|
| 13 | |
---|
| 14 | %define copying() \ |
---|
| 15 | %if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \ |
---|
| 16 | %license %{*} \ |
---|
| 17 | %else \ |
---|
| 18 | %doc %{*} \ |
---|
| 19 | %endif |
---|
| 20 | |
---|
| 21 | %global provider github |
---|
| 22 | %global provider_tld com |
---|
| 23 | %global project pkg |
---|
| 24 | %global repo errors |
---|
| 25 | # https://github.com/pkg/errors |
---|
| 26 | %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} |
---|
| 27 | %global import_path %{provider_prefix} |
---|
| 28 | |
---|
| 29 | Name: golang-%{provider}-%{project}-%{repo} |
---|
| 30 | Version: 0.8.0 |
---|
| 31 | Release: 1%{?_dist_release} |
---|
| 32 | Summary: Simple error handling primitives for Go |
---|
| 33 | License: BSD |
---|
| 34 | URL: https://%{import_path} |
---|
| 35 | Source0: errors-%{version}.tar.gz |
---|
| 36 | |
---|
| 37 | BuildRequires: golang |
---|
| 38 | |
---|
| 39 | Vendor: Project Vine |
---|
| 40 | Distribution: Vine Linux |
---|
| 41 | Packager: iwaim |
---|
| 42 | |
---|
| 43 | # If go_arches not defined fall through to implicit golang archs |
---|
| 44 | %if 0%{?go_arches:1} |
---|
| 45 | ExclusiveArch: %{go_arches} |
---|
| 46 | %else |
---|
| 47 | ExclusiveArch: %{ix86} x86_64 %{arm} |
---|
| 48 | %endif |
---|
| 49 | |
---|
| 50 | %description |
---|
| 51 | %{summary}. |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | %if 0%{?with_devel} |
---|
| 56 | %package devel |
---|
| 57 | Summary: %{summary} |
---|
| 58 | BuildArch: noarch |
---|
| 59 | |
---|
| 60 | %if 0%{?with_check} |
---|
| 61 | %endif |
---|
| 62 | |
---|
| 63 | Provides: golang(%{import_path}) = %{version}-%{release} |
---|
| 64 | |
---|
| 65 | %description devel |
---|
| 66 | %{summary}. |
---|
| 67 | |
---|
| 68 | This package contains library source intended for |
---|
| 69 | building other packages which use import path with |
---|
| 70 | %{import_path} prefix. |
---|
| 71 | %endif |
---|
| 72 | |
---|
| 73 | %if 0%{?with_unit_test} |
---|
| 74 | %package unit-test |
---|
| 75 | Summary: Unit tests for %{name} package |
---|
| 76 | # If go_arches not defined fall through to implicit golang archs |
---|
| 77 | %if 0%{?go_arches:1} |
---|
| 78 | ExclusiveArch: %{go_arches} |
---|
| 79 | %else |
---|
| 80 | ExclusiveArch: %{ix86} x86_64 %{arm} |
---|
| 81 | %endif |
---|
| 82 | # If gccgo_arches does not fit or is not defined fall through to golang |
---|
| 83 | %ifarch 0%{?gccgo_arches} |
---|
| 84 | BuildRequires: gcc-go >= %{gccgo_min_vers} |
---|
| 85 | %else |
---|
| 86 | BuildRequires: golang |
---|
| 87 | %endif |
---|
| 88 | |
---|
| 89 | %if 0%{?with_check} |
---|
| 90 | #Here comes all BuildRequires: PACKAGE the unit tests |
---|
| 91 | #in %%check section need for running |
---|
| 92 | %endif |
---|
| 93 | |
---|
| 94 | # test subpackage tests code from devel subpackage |
---|
| 95 | Requires: %{name}-devel = %{version}-%{release} |
---|
| 96 | |
---|
| 97 | %description unit-test |
---|
| 98 | %{summary}. |
---|
| 99 | |
---|
| 100 | This package contains unit tests for project |
---|
| 101 | providing packages with %{import_path} prefix. |
---|
| 102 | %endif |
---|
| 103 | |
---|
| 104 | %prep |
---|
| 105 | %setup -q -n %{repo}-%{version} |
---|
| 106 | |
---|
| 107 | %build |
---|
| 108 | |
---|
| 109 | %install |
---|
| 110 | # source codes for building projects |
---|
| 111 | %if 0%{?with_devel} |
---|
| 112 | install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ |
---|
| 113 | # find all *.go but no *_test.go files and generate unit-test.file-list |
---|
| 114 | for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do |
---|
| 115 | install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) |
---|
| 116 | cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file |
---|
| 117 | echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list |
---|
| 118 | done |
---|
| 119 | %endif |
---|
| 120 | |
---|
| 121 | # testing files for this project |
---|
| 122 | %if 0%{?with_unit_test} |
---|
| 123 | install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ |
---|
| 124 | # find all *_test.go files and generate unit-test.file-list |
---|
| 125 | for file in $(find . -iname "*_test.go"); do |
---|
| 126 | install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) |
---|
| 127 | cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file |
---|
| 128 | echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list |
---|
| 129 | done |
---|
| 130 | %endif |
---|
| 131 | |
---|
| 132 | %check |
---|
| 133 | %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} |
---|
| 134 | %ifarch 0%{?gccgo_arches} |
---|
| 135 | function gotest { %{gcc_go_test} "$@"; } |
---|
| 136 | %else |
---|
| 137 | %if 0%{?golang_test:1} |
---|
| 138 | function gotest { %{golang_test} "$@"; } |
---|
| 139 | %else |
---|
| 140 | function gotest { go test "$@"; } |
---|
| 141 | %endif |
---|
| 142 | %endif |
---|
| 143 | |
---|
| 144 | export GOPATH=%{buildroot}/%{gopath}:%{gopath} |
---|
| 145 | gotest %{import_path} |
---|
| 146 | %endif |
---|
| 147 | |
---|
| 148 | %if 0%{?with_devel} |
---|
| 149 | %files devel -f devel.file-list |
---|
| 150 | %copying LICENSE |
---|
| 151 | %doc README.md |
---|
| 152 | %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} |
---|
| 153 | %dir %{gopath}/src/%{import_path} |
---|
| 154 | %endif |
---|
| 155 | |
---|
| 156 | %if 0%{?with_unit_test} |
---|
| 157 | %files unit-test -f unit-test.file-list |
---|
| 158 | %copying LICENSE |
---|
| 159 | %doc README.md AUTHORS |
---|
| 160 | %endif |
---|
| 161 | |
---|
| 162 | %changelog |
---|
| 163 | * Wed Jun 7 2017 IWAI, Masaharu <iwaim.sub@gmail.com> 0.8.0-1 |
---|
| 164 | - initial build for Vine Linux |
---|
| 165 | |
---|