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