forked from cloudflare/cfrpki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (68 loc) · 2.75 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
EXTENSION ?=
DIST_DIR ?= dist/
GOOS ?= linux
ARCH ?= $(shell uname -m)
BUILDINFOSDET ?=
DOCKER_REPO := cloudflare/
OCTORPKI_NAME := octorpki
OCTORPKI_VERSION ?= $(shell git describe)
VERSION_PKG := $(shell echo $(OCTORPKI_VERSION) | sed 's/^v//g')
ARCH := x86_64
LICENSE := BSD-3
URL := https://github.com/cloudflare/octorpki
DESCRIPTION := OctoRPKI: a RPKI validator
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
LDFLAGS := '-X main.version=$(OCTORPKI_VERSION) -X main.buildinfos=$(BUILDINFOS)'
OUTPUT_OCTORPKI := $(DIST_DIR)octorpki-$(OCTORPKI_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
.PHONY: vet
vet:
go vet -v ./...
.PHONY: test
test:
go test -v ./...
.PHONY: prepare
prepare:
mkdir -p $(DIST_DIR)
.PHONY: clean
clean:
rm -rf $(DIST_DIR)
.PHONY: build-octorpki
build-octorpki: prepare
go build -ldflags $(LDFLAGS) -o $(OUTPUT_OCTORPKI) cmd/octorpki/*.go
.PHONY: docker-octorpki
docker-octorpki:
docker build -t $(DOCKER_REPO)$(OCTORPKI_NAME):$(OCTORPKI_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile .
.PHONY: package-deb-octorpki
package-deb-octorpki: prepare
fpm -s dir -t deb -n $(OCTORPKI_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--after-install package/after-install-octorpki.sh \
--before-remove package/before-remove-octorpki.sh \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE)" \
--package $(DIST_DIR) \
$(OUTPUT_OCTORPKI)=/usr/bin/octorpki \
package/octorpki.service=/lib/systemd/system/octorpki.service \
package/octorpki.env=/etc/default/octorpki \
cmd/octorpki/tals/afrinic.tal=/usr/share/octorpki/tals/afrinic.tal \
cmd/octorpki/tals/apnic.tal=/usr/share/octorpki/tals/apnic.tal \
cmd/octorpki/tals/lacnic.tal=/usr/share/octorpki/tals/lacnic.tal \
cmd/octorpki/tals/ripe.tal=/usr/share/octorpki/tals/ripe.tal
.PHONY: package-rpm-octorpki
package-rpm-octorpki: prepare
fpm -s dir -t rpm -n $(OCTORPKI_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--after-install package/after-install-octorpki.sh \
--before-remove package/before-remove-octorpki.sh \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE) "\
--package $(DIST_DIR) \
$(OUTPUT_OCTORPKI)=/usr/bin/octorpki \
package/octorpki.service=/lib/systemd/system/octorpki.service \
package/octorpki.env=/etc/default/octorpki \
cmd/octorpki/tals/afrinic.tal=/usr/share/octorpki/tals/afrinic.tal \
cmd/octorpki/tals/apnic.tal=/usr/share/octorpki/tals/apnic.tal \
cmd/octorpki/tals/lacnic.tal=/usr/share/octorpki/tals/lacnic.tal \
cmd/octorpki/tals/ripe.tal=/usr/share/octorpki/tals/ripe.tal