Skip to content

Commit acbed0a

Browse files
committed
Add make targets for building .deb and .rpm packages
1 parent 67aae94 commit acbed0a

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ cli/serve/static.rice-box.go
33
coverage.txt
44
profile.out
55
bin
6+
*.deb
7+
*.rpm

Makefile

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
VERSION := $(shell git describe --tags --abbrev=0 | tr -d '[:alpha:]')
2+
LDFLAGS := "-s -w -X github.com/cloudflare/cfssl/cli/version.version=$(VERSION)"
3+
14
export GOFLAGS := -mod=vendor
25
export GOPROXY := off
36

@@ -6,7 +9,7 @@ all: bin/cfssl bin/cfssl-bundle bin/cfssl-certinfo bin/cfssl-newkey bin/cfssl-sc
69

710
bin/%: $(shell find . -type f -name '*.go')
811
@mkdir -p $(dir $@)
9-
go build -o $@ ./cmd/$(@F)
12+
go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F)
1013

1114
.PHONY: install
1215
install: install-cfssl install-cfssl-bundle install-cfssl-certinfo install-cfssl-newkey install-cfssl-scan install-cfssljson install-mkbundle install-multirootca
@@ -29,7 +32,7 @@ bin/goose: $(shell find . -type f -name '*.go')
2932

3033
.PHONY: clean
3134
clean:
32-
rm -rf bin
35+
rm -rf bin *.deb *.rpm
3336

3437
# Check that given variables are set and all have non-empty values,
3538
# die with an error otherwise.
@@ -50,3 +53,31 @@ __check_defined = \
5053
release:
5154
@:$(call check_defined, GITHUB_TOKEN)
5255
docker run -e GITHUB_TOKEN=$(GITHUB_TOKEN) --rm -v $(PWD):/workdir -w /workdir cbroglie/goreleaser-cgo:1.12.12 goreleaser --rm-dist
56+
57+
BUILD_PATH := $(CURDIR)/build
58+
INSTALL_PATH := $(BUILD_PATH)/usr/local/bin
59+
60+
FPM = fakeroot fpm -C $(BUILD_PATH) \
61+
-a $(shell uname -m) \
62+
-s dir \
63+
-v $(VERSION) \
64+
--url 'https://github.com/cloudflare/cfssl' \
65+
--vendor Cloudflare \
66+
-n cfssl
67+
68+
.PHONY: package
69+
package: package-deb package-rpm
70+
71+
.PHONY: package-deb
72+
package-deb: all
73+
$(RM) -r build
74+
mkdir -p $(INSTALL_PATH)
75+
cp bin/* $(INSTALL_PATH)
76+
$(FPM) -t deb .
77+
78+
.PHONY: package-rpm
79+
package-rpm: all
80+
$(RM) -r build
81+
mkdir -p $(INSTALL_PATH)
82+
cp bin/* $(INSTALL_PATH)
83+
$(FPM) -t rpm .

0 commit comments

Comments
 (0)