forked from mperham/inspeqtor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (111 loc) · 5.18 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
NAME=inspeqtor
VERSION=0.5.0
# when fixing packaging bugs but not changing the binary, we increment ITERATION
ITERATION=1
BASENAME=$(NAME)_$(VERSION)-$(ITERATION)
# contains various secret or machine-specific variables.
# DEB_PRODUCTION: hostname of a debian-based upstart machine (e.g. Ubuntu {12,14}.04 LTS)
# RPM_PRODUCTION: hostname of a redhat-based systemd machine (e.g. CentOS 7)
-include .local.sh
# TODO I'd love some help making this a proper Makefile
# with real file dependencies.
all: test
prepare:
#wget https://storage.googleapis.com/golang/go1.3.1.linux-amd64.tar.gz
#sudo tar -C /usr/local -xzf go1.3.1.linux-amd64.tar.gz
go get github.com/stretchr/testify/...
go get github.com/jteeuwen/go-bindata/...
@echo Now you should be ready to run "make"
test:
@go-bindata -pkg inspeqtor -o templates.go templates/...
@go test -parallel 4 ./... | grep -v "no test files"
build: test
@GOOS=linux GOARCH=amd64 go build -o inspeqtor cmd/main.go
clean:
rm -f main inspeqtor templates.go
rm -rf packaging/output
mkdir -p packaging/output/upstart
mkdir -p packaging/output/systemd
real:
# Place real configuration with passwords, etc in "realtest".
# git will ignore that directory and you can integration test
# Inspeqtor on your local machine just by running "make real"
go run cmd/main.go -l debug -s i.sock -c realtest
package: clean version_check build_deb build_rpm
version_check:
@grep -q $(VERSION) inspeqtor.go || (echo VERSIONS OUT OF SYNC && false)
purge_deb:
ssh -t $(DEB_PRODUCTION) 'sudo apt-get purge -y $(NAME) && sudo rm -f /etc/inspeqtor' || true
purge_rpm:
ssh -t $(RPM_PRODUCTION) 'sudo rpm -e $(NAME) && sudo rm -f /etc/inspeqtor' || true
deploy_deb: clean build_deb purge_deb
scp packaging/output/upstart/*.deb $(DEB_PRODUCTION):~
ssh $(DEB_PRODUCTION) 'sudo rm -f /etc/inspeqtor && sudo dpkg -i $(NAME)_$(VERSION)-$(ITERATION)_amd64.deb && sudo ./fix && sudo restart inspeqtor || true'
deploy_rpm: clean build_rpm purge_rpm
scp packaging/output/systemd/*.rpm $(RPM_PRODUCTION):~
ssh -t $(RPM_PRODUCTION) 'sudo rm -f /etc/inspeqtor && sudo yum install -q -y $(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm && sudo ./fix && sudo systemctl restart inspeqtor'
update_deb: clean build_deb
scp packaging/output/upstart/*.deb $(DEB_PRODUCTION):~
ssh $(DEB_PRODUCTION) 'sudo dpkg -i $(NAME)_$(VERSION)-$(ITERATION)_amd64.deb'
update_rpm: clean build_rpm
scp packaging/output/systemd/*.rpm $(RPM_PRODUCTION):~
ssh -t $(RPM_PRODUCTION) 'sudo yum install -q -y $(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm'
deploy: deploy_deb deploy_rpm
purge: purge_deb purge_rpm
cover:
go test -cover -coverprofile cover.out
go tool cover -html=cover.out
build_rpm: build_rpm_upstart build_rpm_systemd
build_deb: build_deb_upstart
build_rpm_upstart: build
# gem install fpm
# brew install rpm
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/upstart \
--rpm-compression bzip2 --rpm-os linux \
--after-install packaging/scripts/postinst.rpm.upstart \
--before-remove packaging/scripts/prerm.rpm.upstart \
--after-remove packaging/scripts/postrm.rpm.upstart \
--url http://contribsys.com/inspeqtor \
--description "Application infrastructure monitoring" \
-m "Contributed Systems LLC <[email protected]>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a amd64 \
inspeqtor=/usr/bin/inspeqtor \
packaging/root/=/
build_rpm_systemd: build
# gem install fpm
# brew install rpm
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--rpm-compression bzip2 --rpm-os linux \
--after-install packaging/scripts/postinst.rpm.systemd \
--before-remove packaging/scripts/prerm.rpm.systemd \
--after-remove packaging/scripts/postrm.rpm.systemd \
--url http://contribsys.com/inspeqtor \
--description "Application infrastructure monitoring" \
-m "Contributed Systems LLC <[email protected]>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a amd64 \
inspeqtor=/usr/bin/inspeqtor \
packaging/root/=/
# TODO build_deb_systemd
build_deb_upstart: build
# gem install fpm
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p packaging/output/upstart \
--deb-priority optional --category admin \
--deb-compression bzip2 \
--after-install packaging/scripts/postinst.deb.upstart \
--before-remove packaging/scripts/prerm.deb.upstart \
--after-remove packaging/scripts/postrm.deb.upstart \
--url http://contribsys.com/inspeqtor \
--description "Application infrastructure monitoring" \
-m "Contributed Systems LLC <[email protected]>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a amd64 \
inspeqtor=/usr/bin/inspeqtor \
packaging/root/=/
upload: package
package_cloud push contribsys/inspeqtor/ubuntu/precise packaging/output/upstart/$(NAME)_$(VERSION)-$(ITERATION)_amd64.deb
package_cloud push contribsys/inspeqtor/ubuntu/trusty packaging/output/upstart/$(NAME)_$(VERSION)-$(ITERATION)_amd64.deb
package_cloud push contribsys/inspeqtor/el/7 packaging/output/systemd/$(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
package_cloud push contribsys/inspeqtor/el/6 packaging/output/upstart/$(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
.PHONY: all clean test build package upload