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