indent=4
[lxc-userspace.git] / Makefile
1 all: vsh setns
2
3 vsh: vsh.c
4         gcc vsh.c -o vsh
5
6 setns: setns.c
7         python setup.py build
8
9 ########## sync
10 # for use with the test framework; push local stuff on a test node
11 # howto use: go on testmaster in the build you want to use and just run
12 # $ exp
13 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
14 # $ export BUILD=2013.07.02--lxc18
15 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
16 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
17 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
18 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
19 # $ export NODE=vnode01.pl.sophia.inria.fr
20 # and then just run
21 # $ make sync
22 # this will attempt to compile vsh from vsh.c (and will push Makefile.vsh in /usr/sbin/)
23 # so you might have to yum install gcc
24
25 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
26 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
27 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
28 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
29
30 ifdef NODE
31 NODEURL:=root@$(NODE):/
32 endif
33
34 sync: $(NODE).key.rsa
35 ifeq (,$(NODEURL))
36         @echo "sync: You must define NODE on the command line"
37         @echo "  e.g. make sync NODE=vnode01.inria.fr"
38         @exit 1
39 else
40         +$(RSYNC) ./lxcsu ./lxcsu-internal ./vsh.c ./Makefile.vsh $(NODEURL)/usr/sbin/
41         ssh -i $(NODE).key.rsa root@$(NODE) make -C /usr/sbin -f Makefile.vsh vsh
42         ssh -i $(NODE).key.rsa root@$(NODE) chown root:root /usr/sbin/lxcsu /usr/sbin/vsh
43         ssh -i $(NODE).key.rsa root@$(NODE) chmod u+s /usr/sbin/lxcsu /usr/sbin/vsh
44 endif
45
46 ### fetching the key
47
48 TESTMASTER ?= testmaster.onelab.eu
49
50 ifdef BUILD
51 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
52 endif
53
54 key: $(NODE).key.rsa
55
56 $(NODE).key.rsa:
57 ifeq (,$(KEYURL))
58         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
59         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
60         @echo "  note that for now all test builds use the same key, so any BUILD would do"
61         @exit 1
62 else
63         @echo "FETCHING key"
64         +scp $(KEYURL) $@
65 endif
66
67 ### poor man's install
68
69 install: setns vsh
70         mkdir -p /usr/sbin
71         install -D -m 755 vsh /usr/sbin/vsh
72         install -D -m 755 lxcsu /usr/sbin/lxcsu
73         install -D -m 755 lxcsu-internal /usr/sbin/lxcsu-internal
74         chmod u+s /usr/sbin/lxcsu
75         chmod u+s /usr/sbin/vsh
76         cp build/lib*/setns.so /usr/sbin