-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
89 lines (77 loc) · 3.17 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
79
80
81
82
83
84
85
86
87
88
89
VERSION=$(shell git describe --tags)
LDFLAGS=-X github.com/joyent/triton-kubernetes/cmd.cliVersion=$(shell git rev-list -1 HEAD)
BUILD_PATH=build
OSX_ARCHIVE_PATH=$(BUILD_PATH)/triton-kubernetes_$(VERSION)_osx-amd64.zip
OSX_BINARY_PATH=$(BUILD_PATH)/triton-kubernetes_osx-amd64
OSX_TMP_DIR=$(BUILD_PATH)/build-osx-tmp
LINUX_ARCHIVE_PATH=$(BUILD_PATH)/triton-kubernetes_$(VERSION)_linux-amd64.zip
LINUX_BINARY_PATH=$(BUILD_PATH)/triton-kubernetes_linux-amd64
LINUX_TMP_DIR=$(BUILD_PATH)/build-linux-tmp
RPM_FILE_NAME=triton-kubernetes_$(VERSION)_linux-amd64.rpm
RPM_PATH=$(BUILD_PATH)/$(RPM_FILE_NAME)
RPM_INSTALL_DIR=/usr/bin
RPM_TMP_DIR=$(BUILD_PATH)/build-rpm-tmp
DEB_FILE_NAME=triton-kubernetes_$(VERSION)_linux-amd64.deb
DEB_PATH=$(BUILD_PATH)/$(DEB_FILE_NAME)
DEB_INSTALL_DIR=/usr/bin
DEB_TMP_DIR=$(BUILD_PATH)/build-deb-tmp
clean:
@rm -rf ./build
build: clean build-osx build-linux build-rpm build-deb
@echo "Generating checksums..."
@cd build; shasum -a 256 * > sha256-checksums.txt
build-local: clean build-osx
build-osx: clean
@echo "Building OSX..."
# Copying and renaming the linux binary to just 'triton-kubernetes'. Making a temp directory to avoid potential naming conflicts.
@mkdir -p $(OSX_TMP_DIR)
@mkdir -p $(BUILD_PATH)
@GOOS=darwin GOARCH=amd64 go build -v -ldflags="$(LDFLAGS)" -o $(OSX_BINARY_PATH)
@cp $(OSX_BINARY_PATH) $(OSX_TMP_DIR)/triton-kubernetes
@zip --junk-paths $(OSX_ARCHIVE_PATH) $(OSX_TMP_DIR)/triton-kubernetes
@rm -rf $(OSX_TMP_DIR)
build-linux: clean
@echo "Building Linux..."
@mkdir -p $(LINUX_TMP_DIR)
@mkdir -p $(BUILD_PATH)
@GOOS=linux GOARCH=amd64 go build -v -ldflags="$(LDFLAGS)" -o $(LINUX_BINARY_PATH)
@cp $(LINUX_BINARY_PATH) $(LINUX_TMP_DIR)/triton-kubernetes
@zip --junk-paths $(LINUX_ARCHIVE_PATH) $(LINUX_TMP_DIR)/triton-kubernetes
@rm -rf $(LINUX_TMP_DIR)
build-rpm: build-linux
@echo "Building RPM..."
# Copying and renaming the linux binary to just 'triton-kubernetes'. Making a temp directory to avoid potential naming conflicts.
@mkdir -p $(RPM_TMP_DIR)
@cp $(LINUX_BINARY_PATH) $(RPM_TMP_DIR)/triton-kubernetes
@fpm \
--chdir $(RPM_TMP_DIR) \
--input-type dir \
--output-type rpm \
--rpm-os linux \
--name triton-kubernetes \
--version $(VERSION) \
--prefix $(RPM_INSTALL_DIR) \
--package $(RPM_PATH) triton-kubernetes
# Cleaning up the tmp directory
@rm -rf $(RPM_TMP_DIR)
build-deb: build-linux
@echo "Building DEB..."
# Copying and renaming the linux binary to just 'triton-kubernetes'. Making a temp directory to avoid potential naming conflicts.
@mkdir -p $(DEB_TMP_DIR)
@cp $(LINUX_BINARY_PATH) $(DEB_TMP_DIR)/triton-kubernetes
# fpm fails with a tar error when building the DEB package on OSX 10.10.
# Current workaround is to modify PATH so that fpm uses gnu-tar instead of the regular tar command.
# Issue URL: https://github.com/jordansissel/fpm/issues/882
@PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$$PATH" fpm \
--chdir $(DEB_TMP_DIR) \
--input-type dir \
--output-type deb \
--name triton-kubernetes \
--version $(VERSION) \
--prefix $(DEB_INSTALL_DIR) \
--package $(DEB_PATH) triton-kubernetes
# Cleaning up the tmp directory
@rm -rf $(DEB_TMP_DIR)
test:
@echo "Running unit-tests..."
go test ./...