Add PlanetStack plugin install
[nodemanager.git] / Makefile
1 #
2 # Node Manager Makefile
3 #
4 # David Eisenstat <deisenst@cs.princeton.edu>
5 # Mark Huang <mlhuang@cs.princeton.edu>
6 # Copyright (C) 2006 The Trustees of Princeton University
7 #
8
9 # autoconf compatible variables
10 datadir := /usr/share
11 bindir := /usr/bin
12
13 lib: forward_api_calls
14         python setup-lib.py build
15
16 vs: 
17         python setup-vs.py build
18
19 lxc: 
20         python setup-lxc.py build
21
22 forward_api_calls: forward_api_calls.c
23         $(CC) -Wall -Os -o $@ $?
24         strip $@
25
26 install-lib:
27         python setup-lib.py install \
28                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
29                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
30                 --install-scripts=$(DESTDIR)/$(bindir)
31         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
32
33 install-vs:
34         python setup-vs.py install \
35                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
36                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
37                 --install-scripts=$(DESTDIR)/$(bindir)
38         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
39
40 install-lxc:
41         python setup-lxc.py install \
42                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
43                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
44                 --install-scripts=$(DESTDIR)/$(bindir)
45         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
46
47 install-planetstack:
48         python setup-planetstack.py install \
49                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
50                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
51                 --install-scripts=$(DESTDIR)/$(bindir)
52
53 install-scripts: 
54         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
55         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/sliver-initscripts/
56         chmod 755 $(DESTDIR)/$(datadir)/sliver-initscripts/
57
58         mkdir -p $(DESTDIR)/etc/init.d
59         chmod 755 initscripts/*
60         rsync -av initscripts/ $(DESTDIR)/etc/init.d/
61
62         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
63
64         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
65         install -D -m 755 sshsh $(DESTDIR)/bin/sshsh
66
67
68 clean:
69         python setup-lib.py clean
70         python setup-vs.py clean
71         python setup-lxc.py clean
72         rm -f forward_api_calls *.pyc build
73
74 .PHONY: all install clean
75
76 ##########
77 tags:
78         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
79
80 .PHONY: tags
81
82 ########## sync
83 # for use with the test framework; push local stuff on a test node
84 # howto use: go on testmaster in the build you want to use and just run
85 # $ exp
86 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
87 # $ export BUILD=2013.07.02--lxc18
88 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
89 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
90 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
91 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
92 # $ export NODE=vnode01.pl.sophia.inria.fr
93 # and then just run
94 # $ make sync
95
96 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
97 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
98 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
99 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
100
101 ifdef NODE
102 NODEURL:=root@$(NODE):/
103 endif
104
105 sync: $(NODE).key.rsa
106 ifeq (,$(NODEURL))
107         @echo "sync: You must define NODE on the command line"
108         @echo "  e.g. make sync NODE=vnode01.inria.fr"
109         @exit 1
110 else
111         +$(RSYNC) --exclude sshsh ./ $(NODEURL)/usr/share/NodeManager/
112         +$(RSYNC) ./sshsh $(NODEURL)/bin/
113         +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm
114         ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
115 endif
116
117 ### fetching the key
118
119 TESTMASTER ?= testmaster.onelab.eu
120
121 ifdef BUILD
122 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
123 endif
124
125 key: $(NODE).key.rsa
126
127 $(NODE).key.rsa:
128 ifeq (,$(KEYURL))
129         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
130         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
131         @echo "  note that for now all test builds use the same key, so any BUILD would do"
132         @exit 1
133 else
134         @echo "FETCHING key"
135         +scp $(KEYURL) $@
136 endif