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