Setting tag lxc-userspace-2.0-0
[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         python3 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
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) ./slicesu ./lxcsu ./lxcsu-internal ./vsh.c $(NODEURL)/usr/sbin/
41         ssh -i $(NODE).key.rsa root@$(NODE) chown root:root /usr/sbin/lxcsu
42         ssh -i $(NODE).key.rsa root@$(NODE) chown root:root /usr/sbin/slicesu
43         ssh -i $(NODE).key.rsa root@$(NODE) chmod u+s /usr/sbin/lxcsu
44         ssh -i $(NODE).key.rsa root@$(NODE) chmod u+s /usr/sbin/slicesu
45         ssh -i $(NODE).key.rsa root@$(NODE) gcc -o /usr/sbin/vsh /usr/sbin/vsh.c
46         ssh -i $(NODE).key.rsa root@$(NODE) chown root:root /usr/sbin/vsh
47         ssh -i $(NODE).key.rsa root@$(NODE) chmod u+s /usr/sbin/vsh
48 endif
49
50 ### fetching the key
51
52 TESTMASTER ?= testmaster.onelab.eu
53
54 ifdef BUILD
55 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
56 endif
57
58 key: $(NODE).key.rsa
59
60 $(NODE).key.rsa:
61 ifeq (,$(KEYURL))
62         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
63         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
64         @echo "  note that for now all test builds use the same key, so any BUILD would do"
65         @exit 1
66 else
67         @echo "FETCHING key"
68         +scp $(KEYURL) $@
69 endif
70
71 ### poor man's install
72
73 install: setns vsh
74         mkdir -p /usr/sbin
75         install -D -m 755 vsh /usr/sbin/vsh
76         install -D -m 755 lxcsu /usr/sbin/lxcsu
77         install -D -m 755 slicesu /usr/sbin/slicesu
78         install -D -m 755 lxcsu-internal /usr/sbin/lxcsu-internal
79         chmod u+s /usr/sbin/lxcsu
80         chmod u+s /usr/sbin/slicesu
81         chmod u+s /usr/sbin/vsh
82         cp build/lib*/setns.*.so /usr/sbin/setns.so