File: rules

package info (click to toggle)
prometheus-snmp-exporter 0.18.0+ds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 432 kB
  • sloc: makefile: 228
file content (57 lines) | stat: -rwxr-xr-x 2,024 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

export DH_VERBOSE=1

BUILDDIR := $(CURDIR)/build
METAPKG := github.com/prometheus/common

BRANCH     := debian/sid
USER       := pkg-go-maintainers@lists.alioth.debian.org
BUILD_DATE := $(shell date --utc --date='@$(SOURCE_DATE_EPOCH)' \
    +%Y%m%d-%H:%M:%S)
GO_VERSION := $(shell go version | sed 's/go version \(\S*\).*/\1/')
BUILDTAGS  :=
BUILDFLAGS  = -tags "$(BUILDTAGS)" -ldflags \
  " -X $(METAPKG)/version.Version=$(DEB_VERSION_UPSTREAM)\
    -X $(METAPKG)/version.Revision=$(DEB_VERSION)\
    -X $(METAPKG)/version.Branch=$(BRANCH)\
    -X $(METAPKG)/version.BuildUser=$(USER)\
    -X $(METAPKG)/version.BuildDate=$(BUILD_DATE)\
    -X $(METAPKG)/version.GoVersion=$(GO_VERSION)"

EXPORTER_BINNAME := $(DEB_SOURCE)
WHATIS_EXPORTER := "$(EXPORTER_BINNAME) \\- Prometheus exporter for SNMP-enabled devices"

GENERATOR_BINNAME := prometheus-snmp-generator
WHATIS_GENERATOR := "$(GENERATOR_BINNAME) \\- Config generator for $(DEB_SOURCE)"

%:
	dh $@ --buildsystem=golang --with=golang --builddirectory=$(BUILDDIR)

override_dh_auto_build:
	dh_auto_build -- $(BUILDFLAGS)

	# Rename the binaries to match the debian package.
	mv -v $(BUILDDIR)/bin/snmp_exporter $(BUILDDIR)/bin/$(EXPORTER_BINNAME)
	mv -v $(BUILDDIR)/bin/generator $(BUILDDIR)/bin/$(GENERATOR_BINNAME)

	# Create manpages
	build/bin/$(EXPORTER_BINNAME) --help-man > build/$(EXPORTER_BINNAME).1
	build/bin/$(GENERATOR_BINNAME) --help-man > build/$(GENERATOR_BINNAME).1

	# Remove build user/build date/go version headers, which is ugly.
	sed -i -e '/^  /d' build/*.1

	# Fix whatis entries.
	sed -i '/^.SH "NAME"/,+1c.SH "NAME"\n'$(WHATIS_EXPORTER) build/$(EXPORTER_BINNAME).1
	sed -i '/^.SH "NAME"/,+1c.SH "NAME"\n'$(WHATIS_GENERATOR) build/$(GENERATOR_BINNAME).1

	# Remove default values as they create unwieldy long lines.
	sed -i 's/\\fB--\(.*\)=".*"\\fR/\\fB--\1\\fR/' build/*.1

override_dh_auto_install:
	dh_auto_install -- --no-source

override_dh_installinit:
	dh_installinit --noscripts