b04e2f56f5050c61bc2bc9b5943420dbf46079eb
[build.git] / planetlab.mk
1 #
2 # PlanetLab standard components list
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2003-2006 The Trustees of Princeton University
6 #
7 # $Id: planetlab.mk,v 1.71 2007/09/25 18:38:47 faiyaza Exp $
8 #
9
10 #
11 # Required:
12 #
13 # CVSROOT or package-CVSROOT: CVSROOT to use
14 # TAG or package-TAG: CVS tag to use
15 # package-MODULE: CVS module name to use
16 # package-SPEC: RPM spec file template
17 #
18 # Optional:
19 #
20 # package-RPMFLAGS: Miscellaneous RPM flags
21 # package-RPMBUILD: If not rpmbuild
22 # package-CVS_RSH: If not ssh
23 #
24 # Add to ALL if you want the package built as part of the default set.
25 #
26
27 #
28 # Default values
29 #
30
31 CVSROOT := :pserver:anon@cvs.planet-lab.org:/cvs
32 TAG := HEAD
33
34 # Check if a tag has been checked out
35 ifneq ($(wildcard CVS/Root),)
36 # Check if we are able to access CVS
37 CVSTAG := $(shell cvs status planetlab.mk 2>/dev/null | sed -ne 's/[[:space:]]*Sticky Tag:[[:space:]]*\([^[:space:]]*\).*/\1/p')
38 ifneq ($(CVSTAG),)
39 CVSROOT := $(shell cat CVS/Root)
40 ifeq ($(CVSTAG),(none))
41 TAG := HEAD
42 else
43 TAG := $(CVSTAG)
44 endif
45 endif
46 endif
47
48 #
49 # kernel
50 #
51
52 # Figure out whether we are building on i386 or x86_64 host
53 HOSTARCH := $(shell uname -i)
54
55 kernel-$(HOSTARCH)-MODULE := linux-2.6
56 kernel-$(HOSTARCH)-SPEC := linux-2.6/scripts/kernel-2.6-planetlab.spec
57 ifeq ($(HOSTARCH),i386)
58 kernel-$(HOSTARCH)-RPMFLAGS:= --target i686
59 else
60 kernel-$(HOSTARCH)-RPMFLAGS:= --target $(HOSTARCH)
61 endif
62
63 ALL += kernel-$(HOSTARCH)
64
65 kernel-clean: kernel-$(HOSTARCH)-clean
66 kernel: kernel-$(HOSTARCH)
67
68 #
69 # madwifi
70 #
71
72 madwifi-ng-MODULE := madwifi-ng
73 madwifi-ng-SPEC := madwifi-ng/madwifi.spec
74 #ALL += madwifi-ng
75
76 # Build kernel first so we can bootstrap off of its build
77 madwifi-ng: kernel
78
79 #
80 # ivtv 
81 #
82
83 ivtv-MODULE := ivtv
84 ivtv-SPEC := ivtv/ivtv.spec
85 #ALL += ivtv
86
87 #
88 # util-vserver
89 #
90
91 util-vserver-MODULE := util-vserver
92 util-vserver-SPEC := util-vserver/util-vserver.spec
93 util-vserver-RPMFLAGS:= --without dietlibc
94 ALL += util-vserver
95
96 #
97 # NodeUpdate
98 #
99
100 NodeUpdate-MODULE := NodeUpdate
101 NodeUpdate-SPEC := NodeUpdate/NodeUpdate.spec
102 ALL += NodeUpdate
103
104 #
105 # PlanetLabConf
106 #
107
108 PlanetLabConf-MODULE := PlanetLabConf
109 PlanetLabConf-SPEC := PlanetLabConf/PlanetLabConf.spec
110 ALL += PlanetLabConf
111
112 #
113 # ipod
114 #
115
116 ipod-MODULE := ipod
117 ipod-SPEC := ipod/ipod.spec
118 ALL += ipod
119
120 #
121 # sudo
122 #
123
124 sudo-MODULE := sudo
125 sudo-SPEC := sudo/planetlab_sudo.spec
126 ALL += sudo
127
128 #
129 # pycurl
130 #
131
132 curl_vernum := $(shell printf %d 0x$(shell curl-config --vernum))
133 pycurl_vernum := $(shell printf %d 0x070d01) # 7.13.1
134 pycurl_incompatnum := $(shell printf %d 0x071000) # 7.16.0
135 ifeq ($(shell test $(curl_vernum) -ge $(pycurl_vernum) && echo 1),1)
136 ifeq ($(shell test $(curl_vernum) -ge $(pycurl_incompatnum) && echo 0),1)
137 pycurl-MODULE := pycurl
138 pycurl-SPEC := pycurl/pycurl.spec
139 ALL += pycurl
140 endif
141 endif
142
143 #
144 # BootServerRequest
145 #
146
147 BootServerRequest-MODULE := BootServerRequest
148 BootServerRequest-SPEC := BootServerRequest/PLBootServerRequest.spec
149 ALL += BootServerRequest
150
151 #
152 # Node Manager
153 #
154
155 NodeManager-MODULE := NodeManager
156 NodeManager-SPEC := NodeManager/NodeManager.spec
157 ALL += NodeManager
158
159 #
160 # pl_sshd
161 #
162
163 pl_sshd-MODULE := pl_sshd
164 pl_sshd-SPEC := pl_sshd/pl_sshd.spec
165 ALL += pl_sshd
166
167 #
168 # libhttpd++: 
169 #
170
171 libhttpd++-MODULE := libhttpd++
172 libhttpd++-SPEC := libhttpd++/libhttpd++.spec
173 ALL += libhttpd++
174
175 #
176 # Proper: Privileged Operations Service
177 #
178
179 proper-MODULE := proper
180 proper-SPEC := proper/proper.spec
181 proper-RPMBUILD := sudo bash ./rpmbuild.sh
182 ALL += proper
183
184 proper: libhttpd++
185
186 #
187 # CoDemux: Port 80 demux
188 #
189
190 codemux-MODULE := codemux
191 codemux-SPEC   := codemux/codemux.spec
192 #ALL += codemux
193
194 #
195 # MySQL
196 #
197
198 mysql-MODULE := mysql
199 mysql-SPEC := mysql/mysql.spec
200 #ALL += mysql
201
202 #
203 # ulogd
204 #
205
206 ulogd-MODULE := ulogd
207 ulogd-SPEC := ulogd/ulogd.spec
208 ALL += ulogd
209
210 ulogd: kernel proper #mysql
211
212 #
213 # netflow
214 #
215
216 netflow-MODULE := netflow
217 netflow-SPEC := netflow/netflow.spec
218 ALL += netflow
219
220 netflow: #mysql
221
222 #
223 # PlanetLab Mom: Cleans up your mess
224 #
225
226 pl_mom-MODULE := pl_mom
227 pl_mom-SPEC := pl_mom/pl_mom.spec
228 ALL += pl_mom
229
230 #
231 # iptables
232 #
233
234 iptables-MODULE := iptables
235 iptables-SPEC := iptables/iptables.spec
236 ALL += iptables
237
238 iptables: kernel
239
240 #
241 # iproute
242 #
243
244 iproute-MODULE := iproute2
245 iproute-SPEC := iproute2/iproute.spec
246 ALL += iproute
247
248 #
249 # kexec-tools
250 #
251
252 kexec-tools-MODULE := kexec-tools
253 kexec-tools-SPEC := kexec-tools/kexec-tools.spec
254 ALL += kexec-tools
255
256 #
257 # util-python
258 #
259
260 util-python-MODULE := util-python
261 util-python-SPEC := util-python/util-python.spec
262 ALL += util-python
263
264 # proper and util-vserver both use scripts in util-python for building
265 proper: util-python
266 util-vserver: util-python
267 PlanetLabAuth: util-python
268
269 #
270 # PLCAPI
271 #
272
273 PLCAPI-MODULE := new_plc_api
274 PLCAPI-SPEC := new_plc_api/PLCAPI.spec
275 ALL += PLCAPI
276
277 #
278 # PLCWWW
279 #
280
281 PLCWWW-MODULE := new_plc_www
282 PLCWWW-SPEC := new_plc_www/PLCWWW.spec
283 ALL += PLCWWW
284
285 #
286 # vserver-reference
287 #
288
289 vserver-reference-MODULE := vserver-reference build
290 vserver-reference-SPEC := vserver-reference/vserver-reference.spec
291 # Package must be built as root
292 vserver-reference-RPMBUILD := sudo bash ./rpmbuild.sh
293 ALL += vserver-reference
294
295 # vserver-reference may require current packages
296 vserver-reference: $(filter-out vserver-reference,$(ALL))
297
298 #
299 # bootmanager
300 #
301
302 bootmanager-MODULE := bootmanager build
303 bootmanager-SPEC := bootmanager/bootmanager.spec
304 bootmanager-RPMBUILD := sudo bash ./rpmbuild.sh
305 ALL += bootmanager
306
307 # bootmanager requires current packages
308 bootmanager: $(filter-out bootmanager,$(ALL))
309
310 # ...and the yum manifest
311 bootmanager: RPMS/yumgroups.xml
312
313 #
314 # bootcd
315 #
316
317 bootcd-MODULE := bootcd build bootmanager
318 bootcd-SPEC := bootcd/bootcd.spec
319 bootcd-RPMBUILD := sudo bash ./rpmbuild.sh
320 ALL += bootcd
321
322 # bootcd requires current packages
323 bootcd: $(filter-out bootcd,$(ALL))
324
325 #
326 # MyPLC
327 #
328
329 myplc-MODULE := build myplc new_plc_www plc/scripts
330 myplc-SPEC := myplc/myplc.spec
331 # Package must be built as root
332 myplc-RPMBUILD := sudo bash ./rpmbuild.sh
333 ALL += myplc
334
335 # MyPLC may require current packages
336 myplc: $(filter-out myplc,$(ALL))
337
338 # ...and the yum manifest
339 myplc: RPMS/yumgroups.xml
340
341 #
342 # MyPLC development environment
343 #
344
345 myplc-devel-MODULE := build myplc
346 myplc-devel-SPEC := myplc/myplc-devel.spec
347 # Package must be built as root
348 myplc-devel-RPMBUILD := sudo bash ./rpmbuild.sh
349 ALL += myplc-devel
350
351 #
352 # MyPLC native
353 #
354
355 myplc-native-MODULE := build myplc plc/scripts
356 myplc-native-SPEC := myplc/myplc-native.spec
357 # Package must be built as root
358 myplc-native-RPMBUILD := sudo bash ./rpmbuild.sh
359 ALL += myplc-native
360
361 # MyPLC may require current packages
362 myplc-native: $(filter-out myplc,$(ALL))
363
364 # ...and the yum manifest
365 myplc-native: RPMS/yumgroups.xml
366 #
367 # libnl
368 #
369
370 libnl-MODULE := libnl
371 libnl-SPEC := libnl/libnl.spec
372 ALL += libnl
373
374 util-vserver: libnl
375
376 #
377 # Installation rules
378
379
380 # Upload packages to boot server
381 SERVERA := build@boot1.planet-lab.org
382 SERVERB := build@boot2.planet-lab.org
383 ARCHIVE := /plc/data/var/www/html/install-rpms/archive
384
385 # Put nightly alpha builds in a subdirectory
386 ifeq ($(TAG),HEAD)
387 ARCHIVE := $(ARCHIVE)/planetlab-alpha
388 REPOS := /plc/data/var/www/html/install-rpms/planetlab-alpha
389 endif
390
391 RPMS/yumgroups.xml:
392         install -D -m 644 groups/v4_yumgroups.xml RPMS/yumgroups.xml
393
394 install:
395 ifeq ($(BASE),)
396         @echo make install is only meant to be called from ./build.sh
397 else
398 ifneq ($(wildcard /etc/planetlab/secring.gpg),)
399         # Sign all RPMS. setsid detaches rpm from the terminal,
400         # allowing the (hopefully blank) GPG password to be entered
401         # from stdin instead of /dev/tty. Obviously, the build server
402         # should be secure.
403         echo | setsid rpm \
404         --define "_signature gpg" \
405         --define "_gpg_path /etc/planetlab" \
406         --define "_gpg_name PlanetLab <info@planet-lab.org>" \
407         --resign RPMS/*/*.rpm
408 endif
409 ifneq ($(BUILDS),)
410         # Remove old runs
411         echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERA) /bin/bash -s
412         echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERB) /bin/bash -s
413 endif
414         # Create package manifest
415         sh ./packages.sh -b "http://build.planet-lab.org/$(subst $(HOME)/,,$(shell pwd))/RPMS" RPMS > packages.xml
416         # Update yum metadata
417         yum-arch RPMS >/dev/null
418         createrepo -g yumgroups.xml RPMS >/dev/null
419         # Populate repository
420         rsync \
421         --exclude '*-debuginfo-*' \
422         --recursive --links --perms --times --group --compress --rsh=ssh \
423         RPMS/ $(SERVERA):$(ARCHIVE)/$(BASE)
424         rsync \
425         --exclude '*-debuginfo-*' \
426         --recursive --links --perms --times --group --compress --rsh=ssh \
427         RPMS/ $(SERVERB):$(ARCHIVE)/$(BASE)
428 ifeq ($(TAG),HEAD)
429         # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
430         if ! ssh $(SERVERA) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
431             ssh $(SERVERA) ln -nsf archive/$(BASE) $(REPOS) ; \
432         fi
433         # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
434         if ! ssh $(SERVERB) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
435             ssh $(SERVERB) ln -nsf archive/$(BASE) $(REPOS) ; \
436         fi
437
438 endif
439 endif
440
441 .PHONY: install