This repository has been archived by the owner on Apr 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (61 loc) · 2.5 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
CWD := $(shell pwd)
BIN = $(CWD)/bin
SSH_USER = $(shell whoami)
SSH_OPTS = -o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=5
NODE = $(CWD)/bin/node
NAUTO_USER = nauto
NAUTO_GROUP = GLGDEV\domain^admins
NAUTO_DIR = /var/$(NAUTO_USER)
NODE_URL = git://github.com/joyent/node.git
NODE_V = v0.6.9
WITH_NODE = export PATH=$(BIN):$(PATH); export NODE_ENV=$(NODE_ENV);
GIT_URL = git://github.com/jstewmon/nauto.git
TAG = master
REMOTE_SCRIPT = $(CWD)/deployment/ubuntu.sh
.PHONY: environment \
install_node \
update_node \
install_app_modules \
rebuild_app_modules \
deploy
environment:
$(MAKE) --environment-overrides update_node
$(MAKE) install_app_modules
if [ ! -d $(CWD)/watch ]; then mkdir $(CWD)/watch; fi;
install_node:
cd packages/node; ./configure --prefix=$(CWD); $(MAKE); $(MAKE) -j install
$(MAKE) --environment-overrides install_app_modules rebuild_app_modules
update_node:
# if clone is ok, checkout node_v and make install_node
# else if packages/node is on a tag, but not the tag for node_v, fetch origin, checkout node_v and make install_node
# if any of that failed, delete package/node, clone it, checkout node_v and make install_node
# easy, right?
git clone $(NODE_URL) $(CWD)/packages/node && cd $(CWD)/packages/node && git checkout $(NODE_V) && cd $(CWD) && $(MAKE) install_node; \
if [ ! $$? = 0 ]; \
then cd $(CWD)/packages/node; \
git describe && if [ ! "$(NODE_V)" = `git describe` ]; \
then git fetch origin && git checkout $(NODE_V) && cd $(CWD) && $(MAKE) install_node; \
else echo 'node repo already on $(NODE_V)'; \
fi; \
fi; \
if [ ! $$? = 0 ]; \
then cd $(CWD) \
&& rm -rf $(CWD)/packages/node \
&& git clone $(NODE_URL) $(CWD)/packages/node \
&& cd $(CWD)/packages/node && git checkout $(NODE_V) \
&& cd $(CWD) && $(MAKE) install_node; \
fi;
install_app_modules:
$(WITH_NODE) npm prune; npm install
rebuild_app_modules:
$(WITH_NODE) npm rebuild
setup_remote:
scp $(SSH_OPTS) $(REMOTE_SCRIPT) $(SSH_USER)@$(REMOTE):nauto_setup.sh
ssh $(SSH_OPTS) -t $(SSH_USER)@$(REMOTE) \
"chmod +x ./nauto_setup.sh && sudo NAUTO_USER=$(NAUTO_USER) NAUTO_DIR=$(NAUTO_DIR) ./nauto_setup.sh && git clone $(GIT_URL) $(NAUTO_DIR); cd $(NAUTO_DIR) && make --environment-overrides environment"
update_remote:
ssh $(SSH_OPTS) $(SSH_USER)@$(REMOTE) 'cd /var/nauto && git pull origin && make --environment-overrides environment'
deploy:
$(WITH_NODE) node $(CWD)/controller.js -b $(BRANCH) --cwd=$(REPO_DIR) -d $(DEPLOY_SCRIPT) -o