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