Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (85 loc) · 4.02 KB
/
Copy pathMakefile
File metadata and controls
99 lines (85 loc) · 4.02 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
.PHONY: test deps docs
.EXPORT_ALL_VARIABLES:
GO111MODULE ?= on
LOCALS := $(shell find . -type f -name '*.go')
BIN ?= diecast-$(shell go env GOOS)-$(shell go env GOARCH)
BUILD_VERSION ?= `git describe --tags --always`
BUILD_COMMIT ?= `git rev-parse --short HEAD`
BUILT_AT ?= `date +%FT%T%z`
BUILT_BY ?= ${USER}
BUILT_ON ?= `hostname`
BUILD_BRANCH ?= `git rev-parse --abbrev-ref HEAD`
BUILD_PATH ?= "github.com/PerformLine/go-performline-stdlib/build"
all: deps test build docs
deps:
go get ./...
-go mod tidy
fmt:
go generate -x ./...
gofmt -w $(LOCALS)
go vet ./...
test:
go test -count=1 ./...
@cd tests/env-render && make --quiet --always-make
favicon.go:
@convert -background transparent -define icon:auto-resize=16 contrib/diecast-ico-source.svg contrib/favicon.ico
@echo 'package diecast' > favicon.go
@echo '' >> favicon.go
@echo 'func DefaultFavicon() []byte {' >> favicon.go
@echo ' // autogenerated from github.com/PerformLine/diecast:contrib/favicon.ico' >> favicon.go
@echo ' return []byte{' >> favicon.go
@hexdump -v -e '8/1 "0x%02x, " "\n"' contrib/favicon.ico | sed -e 's/0x ,//g' >> favicon.go
@echo ' }' >> favicon.go
@echo '}' >> favicon.go
@echo '' >> favicon.go
@gofmt -w favicon.go
build: fmt
go build --ldflags '-extldflags "-static"' -installsuffix cgo -ldflags "-s -X $(BUILD_PATH).Version=$(BUILD_VERSION) -X $(BUILD_PATH).Branch=$(BUILD_BRANCH) -X $(BUILD_PATH).Commit=$(BUILD_COMMIT) -X $(BUILD_PATH).Date=$(BUILT_AT) -X $(BUILD_PATH).User=$(BUILT_BY) -X $(BUILD_PATH).Host=$(BUILT_ON) " -o bin/$(BIN) cmd/diecast/main.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build --ldflags '-extldflags "-static"' -installsuffix cgo -ldflags "-s -X $(BUILD_PATH).Version=$(BUILD_VERSION) -X $(BUILD_PATH).Branch=$(BUILD_BRANCH) -X $(BUILD_PATH).Commit=$(BUILD_COMMIT) -X $(BUILD_PATH).Date=$(BUILT_AT) -X $(BUILD_PATH).User=$(BUILT_BY) -X $(BUILD_PATH).Host=$(BUILT_ON) " -o bin/$(BIN)-nocgo cmd/diecast/main.go
GOOS=darwin go build --ldflags '-extldflags "-static"' -installsuffix cgo -ldflags "-s -X $(BUILD_PATH).Version=$(BUILD_VERSION) -X $(BUILD_PATH).Branch=$(BUILD_BRANCH) -X $(BUILD_PATH).Commit=$(BUILD_COMMIT) -X $(BUILD_PATH).Date=$(BUILT_AT) -X $(BUILD_PATH).User=$(BUILT_BY) -X $(BUILD_PATH).Host=$(BUILT_ON) " -o bin/diecast-darwin-amd64 cmd/diecast/main.go
which diecast && cp -v bin/$(BIN) $(shell which diecast) || true
docs:
cd docs && make
package:
-rm -rf pkg
mkdir -p pkg/usr/bin
cp bin/$(BIN) pkg/usr/bin/diecast
fpm \
--input-type dir \
--output-type deb \
--deb-user root \
--deb-group root \
--name diecast \
--version `./pkg/usr/bin/diecast -v | cut -d' ' -f3` \
-C pkg
clients.csr:
openssl req -new -newkey rsa:4096 -nodes -keyout clients.key -out clients.csr -subj '/O=ghetzel/CN=diecast'
clients.crt: clients.csr
openssl x509 -req -days 3650 -in clients.csr -signkey clients.key -out clients.crt
sign-client: clients.crt
test -n "$(NAME)" || $(error NAME (client name) is not set)
# Generate new client private key and signing request (CSR)
openssl req \
-new \
-nodes \
-keyout $(NAME).key \
-out $(NAME).csr \
-days 3650 \
-subj '/O=diecast/CN=$(NAME)' \
-extensions v3_req
# Sign client certificate with clients CA
openssl x509 \
-req \
-days 3650 \
-in $(NAME).csr \
-CA clients.crt \
-CAkey clients.key \
-CAcreateserial \
-out $(NAME).crt \
-extensions v3_req
# Also generate a PKCS#12 encoded bundle of the newly generated cert+key
openssl pkcs12 \
-export \
-in $(NAME).crt \
-inkey $(NAME).key \
-out $(NAME).p12