-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
56 lines (49 loc) · 1.34 KB
/
Makefile
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
NAME := nginx-prometheus
MAINTAINER:= Igor Novgorodov <igor@novg.net>
DESCRIPTION := Service for exporting Nginx metrics to Prometheus
LICENSE := MPLv2
GO ?= go
VERSION := $(shell cat VERSION)
OUT := .out
PACKAGE := github.com/blind-oracle/$(NAME)
all: build
build:
rm -rf $(OUT)
mkdir -p $(OUT)/root/etc/$(NAME)
go test ./...
GOARCH=amd64 GOOS=linux $(GO) build -o $(OUT) -ldflags "-s -w -X main.version=$(VERSION)"
deb:
make build
make build-deb ARCH=amd64
rpm:
make build
make build-rpm ARCH=amd64
build-deb:
fpm -s dir -t deb -n $(NAME) -v $(VERSION) \
--deb-priority optional \
--category admin \
--force \
--url https://$(PACKAGE) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a $(ARCH) \
$(OUT)/$(NAME)=/usr/bin/$(NAME) \
deploy/$(NAME).service=/usr/lib/systemd/system/$(NAME).service \
deploy/$(NAME)=/etc/default/$(NAME) \
$(OUT)/root/=/
build-rpm:
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \
--force \
--rpm-compression bzip2 \
--rpm-os linux \
--url https://$(PACKAGE) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a $(ARCH) \
--config-files /etc/default/$(NAME) \
$(OUT)/$(NAME)=/usr/bin/$(NAME) \
deploy/$(NAME).service=/usr/lib/systemd/system/$(NAME).service \
deploy/$(NAME)=/etc/default/$(NAME) \
$(OUT)/root/=/