b5422d9092fb9f039435da6dbb1b7842b405e7b8
[build.git] / onelab-install.mk
1 #
2 # Thierry Parmentelat - INRIA Sophia Antipolis 
3 #
4 ### $Id$
5
6 # Installation rules
7
8
9 # make install :
10 #       uses $(PLCSSH) as an ssh address for the destination host
11 #       first copies everything on a separate rpm repo, prepares it, 
12 #       and then renames it into planetlab
13
14 # Upload packages to boot server
15
16 # use PLCHOST if set
17 ifdef PLCHOST
18 PLCSSH:=root@$(PLCHOST)
19 endif
20 # if nothing's defined : use this default
21 ifndef PLCSSH
22 PLCSSH          := root@private.one-lab.org
23 endif
24
25 RPMSAREA        := /var/www/html/install-rpms/
26
27 BUILD_BASE      := $(shell cat .base 2> /dev/null || echo base-undefined)
28 BASENEW         := build-$(BUILD_BASE)
29 BASEBAK         := planetlab-bak
30 BASE            := planetlab
31
32 ##########
33 # if make is invoked with -n, run rsync, but with --dry-run
34 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
35 RSYNC                   := rsync $(RSYNC_COND_DRY_RUN) 
36
37 INSTALL-TARGETS := install-rpms install-index install-adopt install-bootstrap
38 install: $(INSTALL-TARGETS)
39 .PHONY: install $(INSTALL-TARGETS)
40
41 install-help:
42         @echo install: $(INSTALL-TARGETS)
43
44 # compute the exact set of rpms to install - we do not need bootstrapfs nor myplc here
45 node_packages=$(sort $(IN_VSERVER) $(IN_BOOTSTRAPFS))
46 node_rpms=$(foreach package,$(node_packages),$($(package).rpms))
47
48 install-rpms:RPMS/yumgroups.xml
49         # create repository
50         ssh $(PLCSSH) mkdir -p /plc/data/$(RPMSAREA)/$(BASENEW)
51         # populate
52         +$(RSYNC) -v --perms --times --group --compress --rsh=ssh \
53            RPMS/yumgroups.xml $(node_rpms) $(PLCSSH):/plc/data/$(RPMSAREA)/$(BASENEW)/
54
55 install-index:
56         # sign and index new repository
57         ssh $(PLCSSH) chroot /plc/root /etc/plc.d/packages start $(RPMSAREA)/$(BASENEW)/ 2>> install-index.log
58
59 install-clean-index:
60         # sign and index new repository
61         ssh $(PLCSSH) chroot /plc/root /etc/plc.d/packages clean $(RPMSAREA)/$(BASENEW)/ 2>> install-index.log
62
63 install-adopt:
64         # cleanup former bak
65         ssh $(PLCSSH) rm -rf /plc/data/$(RPMSAREA)/$(BASEBAK)
66         # bak previous repo
67         ssh $(PLCSSH) mv /plc/data/$(RPMSAREA)/$(BASE) /plc/data/$(RPMSAREA)/$(BASEBAK)
68         # install new repo
69         ssh $(PLCSSH) mv /plc/data/$(RPMSAREA)/$(BASENEW) /plc/data/$(RPMSAREA)/$(BASE)
70
71 install-bootstrap:
72         # install node image
73         ssh $(PLCSSH) chroot /plc/root yum -y update bootstrapfs