sshsh is totally obsolete, since we use lxc-userspace
[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 # call with either WITH_SYSTEMD=true or WITH_INIT=true
13 initdir=/etc/rc.d/init.d
14 systemddir := /usr/lib/systemd/system
15
16 ####################
17 lib: forward_api_calls
18         python setup-lib.py build
19
20 vs: 
21         python setup-vs.py build
22
23 lxc: 
24         python setup-lxc.py build
25
26 forward_api_calls: forward_api_calls.c
27         $(CC) -Wall -Os -o $@ $?
28         strip $@
29
30 #################### install
31 install-lib: install-miscell install-startup
32         python setup-lib.py install \
33                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
34                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
35                 --install-scripts=$(DESTDIR)/$(bindir)
36
37 # might be better in setup.py ?
38 # NOTE: the sliver-initscripts/ and sliver-systemd stuff, being, well, for slivers,
39 # need to ship on all nodes regardless of WITH_INIT and WITH_SYSTEMD that 
40 # impacts how nodemanager itself gets started
41 install-miscell:
42         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
43         install -D -m 444 README $(DESTDIR)/$(datadir)/NodeManager/README
44         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
45         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
46         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
47         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
48         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd
49         rsync -av sliver-systemd/ $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
50         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
51
52 # this now is for the startup of nodemanager itself
53 ifneq "$(WITH_SYSTEMD)" ""
54 install-startup: install-systemd
55 endif
56 ifneq "$(WITH_INIT)" ""
57 install-startup: install-init
58 endif
59
60 install-init:
61         mkdir -p $(DESTDIR)$(initdir)
62         chmod 755 initscripts/*
63         rsync -av initscripts/ $(DESTDIR)$(initdir)/
64
65 install-systemd:
66         mkdir -p $(DESTDIR)/$(systemddir)
67         rsync -av systemd/ $(DESTDIR)/$(systemddir)
68
69 install-vs:
70         python setup-vs.py install \
71                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
72                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
73                 --install-scripts=$(DESTDIR)/$(bindir)
74         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
75
76 install-lxc:
77         python setup-lxc.py install \
78                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
79                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
80                 --install-scripts=$(DESTDIR)/$(bindir)
81         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
82
83 #################### clean
84 clean:
85         python setup-lib.py clean
86         python setup-vs.py clean
87         python setup-lxc.py clean
88         rm -f forward_api_calls *.pyc build
89
90 .PHONY: all install clean
91
92 ##########
93 tags:
94         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
95
96 .PHONY: tags
97
98 ########## sync
99 # for use with the test framework; push local stuff on a test node
100 # howto use: go on testmaster in the build you want to use and just run
101 # $ exp
102 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
103 # $ export BUILD=2013.07.02--lxc18
104 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
105 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
106 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
107 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
108 # $ export NODE=vnode01.pl.sophia.inria.fr
109 # and then just run
110 # $ make sync
111
112 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
113 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
114 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
115 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
116
117 ifdef NODE
118 NODEURL:=root@$(NODE):/
119 endif
120
121 # this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
122 # keep this in sync with setup-vs.spec
123 LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py
124
125 sync:synclxc
126
127 synclxc: $(NODE).key.rsa
128 ifeq (,$(NODEURL))
129         @echo "sync: You must define NODE on the command line"
130         @echo "  e.g. make sync NODE=vnode01.inria.fr"
131         @exit 1
132 else
133         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
134         @echo WARNING : this target might not be very reliable - use with care
135         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
136         +$(RSYNC) --exclude sshsh $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
137         +$(RSYNC) ./sshsh $(NODEURL)/bin/
138 #       +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
139         +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
140 #       ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
141 endif
142
143 ### fetching the key
144
145 TESTMASTER ?= testmaster.onelab.eu
146
147 ifdef BUILD
148 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
149 endif
150
151 key: $(NODE).key.rsa
152
153 $(NODE).key.rsa:
154 ifeq (,$(KEYURL))
155         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
156         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
157         @echo "  note that for now all test builds use the same key, so any BUILD would do"
158         @exit 1
159 else
160         @echo "FETCHING key"
161         +scp $(KEYURL) $@
162 endif