* tentative merge of the onelab build, be sure to run
[build.git] / planetlab-install.mk
1 #XXX We need to rethink this installation support for several reasons:
2 # 1) it is pldistro specific
3 # 2) may involve installing files for different node groups (e.g., alpha, beta, etc.)
4 # 3) may involve N rpm repositories to where it should be uploaded
5 #
6 # Not clear to me at all that this should be incorporated into a
7 # Makefile at all.  Instead it should be something that gets wrapped
8 # into a myplc (sub) rpm package and then is installed by that way.
9
10 #
11 # Installation rules
12
13
14 # Upload packages to boot server
15 SERVERA := build@boot1.planet-lab.org
16 SERVERB := build@boot2.planet-lab.org
17 ARCHIVE := /plc/data/var/www/html/install-rpms/archive
18
19 # Put nightly alpha builds in a subdirectory
20 ifeq ($(TAG),HEAD)
21 ARCHIVE := $(ARCHIVE)/planetlab-alpha
22 REPOS := /plc/data/var/www/html/install-rpms/planetlab-alpha
23 endif
24
25 install:
26 ifeq ($(BASE),)
27         @echo make install is only meant to be called from ./build.sh
28 else
29 ifneq ($(wildcard /etc/planetlab/secring.gpg),)
30         # Sign all RPMS. setsid detaches rpm from the terminal,
31         # allowing the (hopefully blank) GPG password to be entered
32         # from stdin instead of /dev/tty. Obviously, the build server
33         # should be secure.
34         echo | setsid rpm \
35         --define "_signature gpg" \
36         --define "_gpg_path /etc/planetlab" \
37         --define "_gpg_name PlanetLab <info@planet-lab.org>" \
38         --resign RPMS/*/*.rpm
39 endif
40 ifneq ($(BUILDS),)
41         # Remove old runs
42         echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERA) /bin/bash -s
43         echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERB) /bin/bash -s
44 endif
45         # Create package manifest
46         sh ./packages.sh -b "http://build.planet-lab.org/$(subst $(HOME)/,,$(shell pwd))/RPMS" RPMS > packages.xml
47         # Update yum metadata
48         yum-arch RPMS >/dev/null
49         createrepo -g yumgroups.xml RPMS >/dev/null
50         # Populate repository
51         rsync \
52         --exclude '*-debuginfo-*' \
53         --recursive --links --perms --times --group --compress --rsh=ssh \
54         RPMS/ $(SERVERA):$(ARCHIVE)/$(BASE)
55         rsync \
56         --exclude '*-debuginfo-*' \
57         --recursive --links --perms --times --group --compress --rsh=ssh \
58         RPMS/ $(SERVERB):$(ARCHIVE)/$(BASE)
59 ifeq ($(TAG),HEAD)
60         # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
61         if ! ssh $(SERVERA) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
62             ssh $(SERVERA) ln -nsf archive/$(BASE) $(REPOS) ; \
63         fi
64         # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
65         if ! ssh $(SERVERB) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
66             ssh $(SERVERB) ln -nsf archive/$(BASE) $(REPOS) ; \
67         fi
68
69 endif
70 endif
71
72 .PHONY: install