-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus.spec
472 lines (397 loc) · 14.1 KB
/
prometheus.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
%define debug_package %{nil}
%if 0%{?fedora} || 0%{?rhel} == 6
%global with_devel 1
%global with_bundled 1
%global with_debug 1
# No test files so far
%global with_check 0
%global with_unit_test 0
%else
%global with_devel 0
%global with_bundled 1
%global with_debug 1
%global with_check 0
%global with_unit_test 0
%endif
%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif
%define copying() \
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \
%license %{*} \
%else \
%doc %{*} \
%endif
%global isgccgoarch 0
%if 0%{?gccgo_arches:1}
%ifarch %{gccgo_arches}
%global isgccgoarch 1
%endif
%endif
%global provider github
%global provider_tld com
%global project prometheus
%global repo prometheus
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
Name: %{repo}
%if "0%{?_version}" == "0"
Version: 2.51.2
%else
Version: %{_version}
%endif
%if "0%{?_release}" == "0"
Release: 1%{?dist}
%else
Release: %{_release}
%endif
Summary: The Prometheus monitoring system and time series database
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: https://%{provider_prefix}/archive/v%{version}/%{repo}-v%{version}.tar.gz
Source1: %{repo}.service
%if 0%{?fedora} || 0%{?rhel} == 7
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif
# If go_arches not defined fall through to implicit golang archs
%if 0%{?go_arches:1}
ExclusiveArch: %{go_arches}
%else
ExclusiveArch: %{ix86} x86_64 %{arm}
%endif
# If gccgo_arches does not fit or is not defined fall through to golang
%if %{isgccgoarch}
BuildRequires: gcc-go >= %{gccgo_min_vers}
%else
BuildRequires: golang >= 1.7.3
%endif
BuildRequires: nodejs
BuildRequires: npm
%description
%{summary}
%if ! 0%{?with_bundled}
BuildRequires: golang(bitbucket.org/ww/goautoneg)
BuildRequires: golang(github.com/golang/protobuf/proto)
BuildRequires: golang(github.com/hashicorp/consul/api)
BuildRequires: golang(github.com/julienschmidt/httprouter)
BuildRequires: golang(github.com/miekg/dns)
BuildRequires: golang(github.com/samuel/go-zookeeper/zk)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/filter)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/iterator)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/opt)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/util)
BuildRequires: golang(golang.org/x/net/context)
BuildRequires: golang(gopkg.in/fsnotify.v1)
BuildRequires: golang(gopkg.in/yaml.v2)
%endif
%description
%{summary}
%if 0%{?with_devel}
%package devel
Summary: %{summary}
BuildArch: noarch
%if 0%{?with_check}
BuildRequires: golang(bitbucket.org/ww/goautoneg)
BuildRequires: golang(github.com/golang/protobuf/proto)
BuildRequires: golang(github.com/hashicorp/consul/api)
BuildRequires: golang(github.com/julienschmidt/httprouter)
BuildRequires: golang(github.com/miekg/dns)
BuildRequires: golang(github.com/samuel/go-zookeeper/zk)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/filter)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/iterator)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/opt)
BuildRequires: golang(github.com/syndtr/goleveldb/leveldb/util)
BuildRequires: golang(golang.org/x/net/context)
BuildRequires: golang(gopkg.in/fsnotify.v1)
BuildRequires: golang(gopkg.in/yaml.v2)
%endif
Requires: golang(bitbucket.org/ww/goautoneg)
Requires: golang(github.com/golang/protobuf/proto)
Requires: golang(github.com/hashicorp/consul/api)
Requires: golang(github.com/julienschmidt/httprouter)
Requires: golang(github.com/miekg/dns)
Requires: golang(github.com/samuel/go-zookeeper/zk)
Requires: golang(github.com/syndtr/goleveldb/leveldb)
Requires: golang(github.com/syndtr/goleveldb/leveldb/filter)
Requires: golang(github.com/syndtr/goleveldb/leveldb/iterator)
Requires: golang(github.com/syndtr/goleveldb/leveldb/opt)
Requires: golang(github.com/syndtr/goleveldb/leveldb/util)
Requires: golang(golang.org/x/net/context)
Requires: golang(gopkg.in/fsnotify.v1)
Requires: golang(gopkg.in/yaml.v2)
%description devel
%{summary}
This package contains library source intended for
building other packages which use %{project}/%{repo}.
%endif
%if 0%{?with_unit_test}
%package unit-test
Summary: Unit tests for %{name} package
# If go_arches not defined fall through to implicit golang archs
%if 0%{?go_arches:1}
ExclusiveArch: %{go_arches}
%else
ExclusiveArch: %{ix86} x86_64 %{arm}
%endif
# If gccgo_arches does not fit or is not defined fall through to golang
%if %{isgccgoarch}
BuildRequires: gcc-go >= %{gccgo_min_vers}
%else
BuildRequires: golang
%endif
%if 0%{?with_check}
#Here comes all BuildRequires: PACKAGE the unit tests
#in %%check section need for running
%endif
# test subpackage tests code from devel subpackage
Requires: %{name}-devel = %{version}-%{release}
%description unit-test
%{summary}
This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif
%prep
%setup -q -n %{repo}-%{version}
#patch0 -p1
%build
# If gccgo_arches does not fit or is not defined fall through to golang
# gccco arches
%if %{isgccgoarch}
%if 0%{?gcc_go_build:1}
export GOCOMPILER='%{gcc_go_build}'
%else
echo "No compiler for SA"
exit 1
%endif
# golang arches (due to ExclusiveArch)
%else
%if 0%{?golang_build:1}
export GOCOMPILER='%{golang_build} -ldflags "$LDFLAGS"'
%else
export GOCOMPILER='go build -ldflags "$LDFLAGS"'
%endif
%endif
export LDFLAGS="-s -w"
%if 0%{?with_debug}
%if %{isgccgoarch}
export OLD_RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
function gobuild {
export RPM_OPT_FLAGS="$OLD_RPM_OPT_FLAGS -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')"
eval ${GOCOMPILER} -a -v -x "$@";
}
%else
export OLD_LDFLAGS="$LDFLAGS"
function gobuild {
export LDFLAGS="$OLD_LDFLAGS -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')"
eval ${GOCOMPILER} -a -v -x "$@";
}
%endif
%else
function gobuild { eval ${GOCOMPILER} -a -v -x "$@"; }
%endif
# set working directory
mkdir -p src/github.com/prometheus
ln -s ../../../ src/github.com/prometheus/prometheus
# set environment variables
export GO_VERSION=$(go version | cut -d' ' -f3 | sed 's/go//')
export BUILDDATE=$(date +%%Y%%m%%d-%%H:%%M:%%S)
# build and embed web ui
pushd web/ui
CI="" npm run build
cp embed.go.tmpl embed.go
GZIP_OPTS="-fk"
# gzip option '-k' may not always exist in the latest gzip available on different distros.
if ! gzip -k -h &>/dev/null; then GZIP_OPTS="-f"; fi
find static -type f -name '*.gz' -delete
find static -type f -exec gzip $GZIP_OPTS '{}' \; -print0 | xargs -0 -I % echo %.gz | sort | xargs echo //go:embed >> embed.go
echo var EmbedFS embed.FS >> embed.go
popd
# build prometheus
export OLD_LDFLAGS="$OLD_LDFLAGS -X github.com/prometheus/common/version.Branch=v%{version} "
export OLD_LDFLAGS="$OLD_LDFLAGS -X github.com/prometheus/common/version.Version=v%{version} "
export OLD_LDFLAGS="$OLD_LDFLAGS -X github.com/prometheus/common/version.Revision=v%{version} "
export OLD_LDFLAGS="$OLD_LDFLAGS -X github.com/prometheus/common/version.BuildUser=ssm "
export OLD_LDFLAGS="$OLD_LDFLAGS -X github.com/prometheus/common/version.BuildDate=${BUILDDATE} "
gobuild -o bin/prometheus -tags builtinassets %{import_path}/cmd/prometheus
gobuild -o bin/promtool -tags builtinassets %{import_path}/cmd/promtool
%install
install -D -p -m 0755 bin/%{repo} %{buildroot}%{_sbindir}/%{repo}
install -D -p -m 0755 bin/promtool %{buildroot}%{_bindir}/promtool
install -d %{buildroot}%{_datadir}/%{repo}
cp -rpa ./consoles %{buildroot}%{_datadir}/%{repo}/consoles
cp -rpa ./console_libraries %{buildroot}%{_datadir}/%{repo}/console_libraries
install -d %{buildroot}/usr/lib/systemd/system
install -p -m 0644 %{SOURCE1} %{buildroot}/usr/lib/systemd/system/%{repo}.service
install -d %{buildroot}%{_sharedstatedir}/%{repo}
# source codes for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
done
%endif
# testing files for this project
%if 0%{?with_unit_test}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *_test.go files and generate unit-test.file-list
for file in $(find . -iname "*_test.go"); do
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
done
for file in $(find ./config/testdata -iname "*"); do
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
done
for file in $(find ./promql/testdata -iname "*"); do
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
done
%endif
%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%if %{isgccgoarch}
function gotest { %{gcc_go_test} "$@"; }
%else
%if 0%{?golang_test:1}
function gotest { %{golang_test} "$@"; }
%else
function gotest { go test "$@"; }
%endif
%endif
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
gotest %{import_path}/web/api
gotest %{import_path}/utility
gotest %{import_path}/templates
gotest %{import_path}/storage/remote
gotest %{import_path}/storage/remote/opentsdb
gotest %{import_path}/storage/remote/influxdb
gotest %{import_path}/storage/metric
#gotest %{import_path}/storage/local
#gotest %{import_path}/storage/local/flock
#gotest %{import_path}/storage/local/codable
#gotest %{import_path}/rules
#gotest %{import_path}/promql
gotest %{import_path}/retrieval
gotest %{import_path}/notification
gotest %{import_path}/config
%endif
%post
%if 0%{?fedora} || 0%{?rhel} == 7
%systemd_post %{repo}.service
%else
#/sbin/chkconfig --add %{repo}
%endif
%preun
%if 0%{?fedora} || 0%{?rhel} == 7
%systemd_preun %{repo}.service
%else
if [ $1 = 0 ]; then
#service %{repo} stop >/dev/null 2>&1 ||:
#/sbin/chkconfig --del %{repo}
fi
%endif
%postun
%if 0%{?fedora} || 0%{?rhel} == 7
%systemd_postun %{repo}.service
%else
if [ "$1" -ge "1" ]; then
#service %{repo} condrestart > /dev/null 2>&1 ||:
fi
%endif
%files
%copying LICENSE
%doc CHANGELOG.md CONTRIBUTING.md README.md NOTICE
#doc Godeps/Godeps.json
%{_sbindir}/%{repo}
%{_bindir}/promtool
%{_datadir}/%{repo}
/usr/lib/systemd/system/%{repo}.service
%dir %attr(-, nobody, nobody) %{_sharedstatedir}/%{repo}
%if 0%{?with_devel}
%files devel -f devel.file-list
%copying LICENSE
%doc CHANGELOG.md CONTRIBUTING.md README.md
#doc Godeps/Godeps.json
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%dir %{gopath}/src/%{import_path}
%endif
%if 0%{?with_unit_test}
%files unit-test -f unit-test.file-list
%copying LICENSE.md
%doc README.md
%endif
%changelog
* Tue Jul 24 2018 Kamil Dziedzic <[email protected]> - 2.3.2-1
- PMM-2725 update to 2.3.2
* Thu Jun 28 2018 Kamil Dziedzic <[email protected]> - 2.3.1-1
- PMM-2182 update to 2.3.1
* Mon Jun 18 2018 Mykola Marzhan <[email protected]> - 2.3.0-1
- PMM-2182 update to 2.3.0
* Mon May 28 2018 Kamil Dziedzic <[email protected]> - 2.2.1-1
- PMM-2182 update to 2.2.1
* Thu May 17 2018 Mykola Marzhan <[email protected]> - 2.1.0-1
- PMM-2182 update to 2.1.0
* Tue Apr 17 2018 Mykola Marzhan <[email protected]> - 1.8.2-3
- PMM-2358 add sleep to unit file, maybe system time will be synced
* Mon Mar 26 2018 Mykola Marzhan <[email protected]> - 1.8.2-2
- PMM-2282 start prometheus.service after chronyd.service
* Mon Nov 13 2017 Mykola Marzhan <[email protected]> - 1.8.2-1
- PMM-1577 update to 1.8.2
* Tue Oct 24 2017 Mykola Marzhan <[email protected]> - 1.8.1-1
- PMM-1577 update to 1.8.1
* Thu Oct 5 2017 Mykola Marzhan <[email protected]> - 1.7.2-1
- update to 1.7.2
- PMM-1519 add prometheus stop timeout to systemd unit
* Mon Jun 19 2017 Mykola Marzhan <[email protected]> - 1.7.1-2
- add BuildUser and Branch tags.
resolves: PMM-968
* Tue Jun 13 2017 Mykola Marzhan <[email protected]> - 1.7.1-1
- update to 1.7.1
* Mon Jun 12 2017 Mykola Marzhan <[email protected]> - 1.7.0-1
- update to 1.7.0
* Thu Jun 1 2017 Mykola Marzhan <[email protected]> - 1.6.3-1
- update to 1.6.3
* Thu Apr 20 2017 Mykola Marzhan <[email protected]> - 1.6.1-1
- update to 1.6.0
* Mon Apr 17 2017 Mykola Marzhan <[email protected]> - 1.6.0-1
- update to 1.6.0
* Tue Mar 14 2017 Mykola Marzhan <[email protected]> - 1.5.2-1
- update to 1.5.2
* Thu Feb 9 2017 Mykola Marzhan <[email protected]> - 1.5.1-1
- update to 1.5.1
* Thu Jan 26 2017 Mykola Marzhan <[email protected]> - 1.5.0-1
- update to 1.5.0
* Mon Feb 22 2016 Fedora Release Engineering <[email protected]> - 0.15.0-3
- https://fedoraproject.org/wiki/Changes/golang1.6
* Wed Feb 03 2016 Fedora Release Engineering <[email protected]> - 0.15.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Thu Jul 23 2015 jchaloup <[email protected]> - 0.15.0-1
- Update to 0.15.0
resolves: #1246058
* Wed Jun 17 2015 Fedora Release Engineering <[email protected]> - 0.13.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Wed May 13 2015 jchaloup <[email protected]> - 0.13.3-2
- Add debug info
related: #1190426
* Tue May 12 2015 jchaloup <[email protected]> - 0.13.3-1
- Update to 0.13.3
related: #1190426
* Sat May 09 2015 jchaloup <[email protected]> - 0.13.2-1
- Update to 0.13.2
related: #1190426
* Sat Feb 07 2015 jchaloup <[email protected]> - 0-0.1.git4e6a807
- First package for Fedora
resolves: #1190426