| 1 |
#!/usr/bin/make -f |
| 2 |
include /usr/share/dpkg/pkg-info.mk |
| 3 |
|
| 4 |
export DH_VERBOSE=1 |
| 5 |
|
| 6 |
BUILDDIR := $(CURDIR)/build |
| 7 |
METAPKG := github.com/prometheus/common |
| 8 |
|
| 9 |
BRANCH := debian/sid |
| 10 |
USER := [email protected] |
| 11 |
BUILD_DATE = $(shell date --utc --date='@$(SOURCE_DATE_EPOCH)' \ |
| 12 |
+%Y%m%d-%H:%M:%S) |
| 13 |
GO_VERSION = $(shell go version | sed 's/go version \(\S*\).*/\1/') |
| 14 |
BUILDTAGS = |
| 15 |
BUILDFLAGS = -tags "$(BUILDTAGS)" -ldflags \ |
| 16 |
" -X $(METAPKG)/version.Version=$(DEB_VERSION_UPSTREAM)\ |
| 17 |
-X $(METAPKG)/version.Revision=$(DEB_VERSION)\ |
| 18 |
-X $(METAPKG)/version.Branch=$(BRANCH)\ |
| 19 |
-X $(METAPKG)/version.BuildUser=$(USER)\ |
| 20 |
-X $(METAPKG)/version.BuildDate=$(BUILD_DATE)\ |
| 21 |
-X $(METAPKG)/version.GoVersion=$(GO_VERSION)" |
| 22 |
|
| 23 |
%: |
| 24 |
dh $@ --buildsystem=golang --builddirectory=$(BUILDDIR) |
| 25 |
|
| 26 |
BINNAME := $(DEB_SOURCE) |
| 27 |
WHATIS := "$(BINNAME) \\- Prometheus exporter for HomePlug/Power Line Communication" |
| 28 |
|
| 29 |
override_dh_auto_build: |
| 30 |
dh_auto_build -- $(BUILDFLAGS) |
| 31 |
# Rename the binary to match the debian package. |
| 32 |
mv -v $(BUILDDIR)/bin/homeplug_exporter $(BUILDDIR)/bin/$(BINNAME) |
| 33 |
build/bin/$(BINNAME) --help-man > build/$(BINNAME).1 |
| 34 |
# Remove build user/build date/go version headers, which is ugly. |
| 35 |
sed -i -e '/^ /d' build/$(BINNAME).1 |
| 36 |
# Fix whatis entry. |
| 37 |
sed -i '/^.SH "NAME"/,+1c.SH "NAME"\n'$(WHATIS) build/$(BINNAME).1 |
| 38 |
# Remove default values as they create unwieldy long lines. |
| 39 |
sed -i 's/\\fB--\(.*\)=".*"\\fR/\\fB--\1\\fR/' build/$(BINNAME).1 |
| 40 |
|
| 41 |
override_dh_auto_install: |
| 42 |
dh_auto_install -- --no-source |