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