forked from AdRoll/hologram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
141 lines (119 loc) · 7.07 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2014 AdRoll, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
REVISION := $(shell git rev-parse HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GIT_DIRTY := $(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GIT_TAG := $(shell git describe --tags --long | sed 's/-/\./' | sed 's/-g/-/' | sed 's/-/~/')
all: test build package
setup: .setup-complete
.setup-complete:
@go get github.com/mitchellh/gox
@go get github.com/jteeuwen/go-bindata/...
@gox -build-toolchain -osarch="linux/amd64 darwin/amd64"
@brew install gpm jq protobuf
@sudo gem install fpm deb-s3
@touch .setup-complete
package: bin/darwin/Hologram-$(GIT_TAG).pkg bin/linux/hologram-$(GIT_TAG).deb bin/linux/hologram-server-$(GIT_TAG).deb
build: bin/darwin/hologram-server bin/linux/hologram-server bin/darwin/hologram-agent bin/linux/hologram-agent bin/darwin/hologram-cli bin/linux/hologram-cli
protocol/hologram.pb.go: protocol/hologram.proto
protoc --go_out=. protocol/hologram.proto
transport/remote/bindata.go: transport/remote/self-signed-ca.cert transport/remote/self-signed.cert transport/remote/self-signed.key
cd transport/remote; go-bindata -pkg remote self-signed-ca.cert self-signed.cert self-signed.key
agent/bindata.go: agent/test_ssh_key
cd agent; go-bindata -pkg agent test_ssh_key
%/.deps: %/Godeps
cd $*; gpm install; touch .deps
bin/%/hologram-agent: protocol/hologram.pb.go agent/.deps agent/*.go agent/*/*.go log/*.go log/.deps transport/remote/*.go transport/local/*.go transport/remote/bindata.go
@echo "Building agent version $(GIT_TAG)$(GIT_DIRTY)"
@cd agent/bin; gox -osarch="$*/amd64" -output="../../bin/$*/hologram-agent"
bin/%/hologram-server: protocol/hologram.pb.go server/.deps server/*.go server/*/*.go log/*.go log/.deps transport/remote/*.go transport/remote/bindata.go
@echo "Building server version $(GIT_TAG)$(GIT_DIRTY)"
@cd server/bin; gox -osarch="$*/amd64" -output="../../bin/$*/hologram-server"
bin/%/hologram-cli: protocol/hologram.pb.go cli/*/*.go log/*.go log/.deps transport/local/*.go cli/.deps
@echo "Building CLI version $(GIT_TAG)$(GIT_DIRTY)"
@cd cli/bin; gox -osarch="$*/amd64" -output="../../bin/$*/hologram-cli"
bin/ping: tools/ping/main.go log/*.go log/.deps
@cd tools/ping; go build
@mv tools/ping/ping bin/ping
bin/darwin/Hologram-%.pkg: bin/darwin/hologram-agent bin/darwin/hologram-cli agent/support/darwin/com.adroll.hologram*.plist agent/support/darwin/postinstall.sh
@echo "Creating temporary directory for pkgbuild..."
@mkdir -p pkg/darwin/{root,scripts}
@mkdir -p ./pkg/darwin/root/{usr/bin,Library/{LaunchDaemons,LaunchAgents},etc/hologram}
@cp ./bin/darwin/hologram-agent ./pkg/darwin/root/usr/bin/hologram-agent
@cp ./bin/darwin/hologram-cli ./pkg/darwin/root/usr/bin/hologram
@cp ./config/agent.json ./pkg/darwin/root/etc/hologram/agent.json
@cp ./agent/support/darwin/hologram-boot.sh ./pkg/darwin/root/usr/bin/hologram-boot
@cp ./agent/support/darwin/com.adroll.hologram-ip.plist ./pkg/darwin/root/Library/LaunchDaemons
@cp ./agent/support/darwin/com.adroll.hologram.plist ./pkg/darwin/root/Library/LaunchDaemons
@cp ./agent/support/darwin/com.adroll.hologram-me.plist ./pkg/darwin/root/Library/LaunchAgents
@cp ./agent/support/darwin/postinstall.sh ./pkg/darwin/scripts/postinstall
@chmod a+x ./pkg/darwin/root/usr/bin/hologram*
@chmod a+x ./pkg/darwin/scripts/postinstall
@echo "Changing ownership of files - you will need to sudo here!"
@sudo chown -R root:wheel ./pkg/darwin
@echo "Building installer package..."
@pkgbuild --root ./pkg/darwin/root \
--identifier com.adroll.hologram \
--version $(GIT_TAG) \
--ownership recommended \
--scripts ./pkg/darwin/scripts \
./bin/darwin/Hologram-$(GIT_TAG).pkg
bin/linux/hologram-server-%.deb: bin/linux/hologram-server server/after-install.sh server/before-remove.sh
@echo "Creating temporary directory for fpm..."
@mkdir -p ./pkg/linux/hologram-server/{root,scripts}
@mkdir -p ./pkg/linux/hologram-server/root/{usr/local/bin,etc/{hologram,init.d}}
@cp ./config/server.json ./pkg/linux/hologram-server/root/etc/hologram/server.json
@cp ./server/support/hologram.init.sh ./pkg/linux/hologram-server/root/etc/init.d/hologram
@cp ./server/after-install.sh ./pkg/linux/hologram-server/scripts/after-install.sh
@cp ./server/before-remove.sh ./pkg/linux/hologram-server/scripts/before-remove.sh
@cp ./bin/linux/hologram-server ./pkg/linux/hologram-server/root/usr/local/bin/
@chmod a+x ./pkg/linux/hologram-server/root/etc/init.d/hologram
@fpm -s dir -t deb -f \
-n hologram-server \
-v $(GIT_TAG) \
--after-install ./pkg/linux/hologram-server/scripts/after-install.sh \
--before-remove ./pkg/linux/hologram-server/scripts/before-remove.sh \
-C ./pkg/linux/hologram-server/root \
-p ./bin/linux/hologram-server-$(GIT_TAG).deb \
-a amd64 \
./
bin/linux/hologram-%.deb: bin/linux/hologram-cli bin/linux/hologram-agent
@echo "Creating temporary directory for fpm..."
@mkdir -p ./pkg/linux/hologram/{root,scripts}
@mkdir -p ./pkg/linux/hologram/root/{usr/local/bin,etc/{hologram,init.d}}
@cp ./config/agent.json ./pkg/linux/hologram/root/etc/hologram/agent.json
@cp ./bin/linux/hologram-cli ./pkg/linux/hologram/root/usr/local/bin/hologram
@cp ./bin/linux/hologram-agent ./pkg/linux/hologram/root/usr/local/bin/hologram-agent
@cp ./agent/support/debian/after-install.sh ./pkg/linux/hologram/scripts/
@cp ./agent/support/debian/before-remove.sh ./pkg/linux/hologram/scripts/
@cp ./agent/support/debian/init.sh ./pkg/linux/hologram/root/etc/init.d/hologram-agent
@chmod a+x ./pkg/linux/hologram/root/etc/init.d/hologram-agent
@fpm -s dir -t deb \
-n hologram-agent \
-v $(GIT_TAG) \
--after-install ./pkg/linux/hologram/scripts/after-install.sh \
--before-remove ./pkg/linux/hologram/scripts/before-remove.sh \
-C ./pkg/linux/hologram/root \
-p ./bin/linux/hologram-$(GIT_TAG).deb \
-a amd64 \
./
test: protocol/hologram.pb.go server/.deps agent/.deps transport/remote/bindata.go agent/bindata.go
@echo "Running test suite."
@go test ./... -v -cover
clean:
rm -rf ./bin ./build
sudo rm -rf ./pkg
version:
@echo "$(GIT_TAG)"
.PHONY: setup all build package clean test version