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