forked from cloudflare/gokeyless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (64 loc) · 2.16 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
BUILD_DEPS := go
NAME := gokeyless
VENDOR := "CloudFlare"
LICENSE := "See License File"
URL := "https://github.com/cloudflare/gokeyless"
DESCRIPTION="A Go implementation of the keyless server protocol"
VERSION := $(shell git describe --tags --always --dirty=-dev)
DESTDIR := build
PREFIX := usr/local
INSTALL_BIN := $(DESTDIR)/$(PREFIX)/bin
INIT_PREFIX := $(DESTDIR)/etc/init.d
CONFIG_PREFIX := $(DESTDIR)/etc/keyless
ARCH := amd64
DEB_PACKAGE := $(NAME)_$(VERSION)_$(ARCH).deb
RPM_PACKAGE := $(NAME)-$(VERSION).$(ARCH).rpm
.PHONY: all
all: $(DEB_PACKAGE) $(RPM_PACKAGE)
.PHONY: install-config
install-config:
@mkdir -p $(INSTALL_BIN)
@mkdir -p $(CONFIG_PREFIX)/keys
@chmod 700 $(CONFIG_PREFIX)/keys
@mkdir -p $(INIT_PREFIX)
@install -m755 pkg/gokeyless.sysv $(INIT_PREFIX)/gokeyless
@install -m644 pkg/keyless_cacert.pem $(CONFIG_PREFIX)/keyless_cacert.pem
@install -m644 pkg/default.pem $(CONFIG_PREFIX)/default.pem
@install -m400 pkg/default-key.pem $(CONFIG_PREFIX)/default-key.pem
@install -m400 pkg/testing-ecdsa.key $(CONFIG_PREFIX)/keys/testing-ecdsa.key
@install -m400 pkg/testing-rsa.key $(CONFIG_PREFIX)/keys/testing-rsa.key
$(INSTALL_BIN)/$(NAME): | install-config
@GOOS=linux GOARCH=$(ARCH) go build -o $@ ./cmd/$(NAME)/...
.PHONY: clean
clean:
@$(RM) -r $(DESTDIR)
@$(RM) $(DEB_PACKAGE)
@$(RM) $(RPM_PACKAGE)
FPM = fpm -C $(DESTDIR) \
-n $(NAME) \
-a $(ARCH) \
-s dir \
-v $(VERSION) \
--url $(URL) \
--description $(DESCRIPTION) \
--vendor $(VENDOR) \
--license $(LICENSE) \
$(DEB_PACKAGE): | $(INSTALL_BIN)/$(NAME) install-config
@$(FPM) \
-t deb \
--before-install pkg/debian/before-install.sh \
--before-remove pkg/debian/before-remove.sh \
--after-install pkg/debian/after-install.sh \
--deb-compression bzip2 \
--deb-user root --deb-group root \
.
$(RPM_PACKAGE): | $(INSTALL_BIN)/$(NAME) install-config
@$(FPM) \
-t rpm \
--rpm-os linux \
--before-install pkg/centos/before-install.sh \
--before-remove pkg/centos/before-remove.sh \
--after-install pkg/centos/after-install.sh \
--rpm-use-file-permissions \
--rpm-user root --rpm-group root \
.