5c49a9691df3ca0782e83a60081e9aba9b65b8ae
[myplc.git] / plc.d / bootcd-kernel
1 #!/bin/bash
2 #
3 # priority: 0999
4 #
5 # $Id$
6 # Build BootCD variants with kernels specified in /etc/planetlab/bootcd-variants
7
8 # Source function library and configuration
9 . /etc/plc.d/functions
10
11 # Be verbose
12 set -x
13
14 case "$1" in
15     start)
16         MESSAGE=$"Creating BootCD variants"
17         dialog "$MESSAGE"
18
19         success=0
20         for i in /usr/share/bootcd-*; do
21                 pushd $i
22                 basearch=$(echo $i | awk -F- '{ print $NF }')
23                 arch=$(echo $basearch | sed 's/i386/i686/')
24                 for j in /etc/planetlab/bootcd-variants/*; do
25                         name="${j##*/}"
26                         url=$(cat "$j" | sed "s!@BASEARCH@!$basearch!g;s!@ARCH@!$arch!g")
27                         if test -d "$name"; then
28                                 test build/isofs/bootcd.img -nt "$name/isofs/bootcd.img" || continue
29                         elif test "$name" = default; then
30                                 # Not ideal, but...
31                                 grep -q support@ build/isofs/kernel || continue
32                         fi
33                         if test "$url" != $(echo "$url" | sed s#[:/]##); then
34                                 ./kvariant.sh "$name" "$url"
35                         else
36                                 dir=$(mktemp -d -p /var/tmp)
37                                 yumdownloader --disablerepo='*' \
38                                         --enablerepo=base \
39                                         --enablerepo=updates \
40                                         --destdir "$dir" "$url"
41                                 ./kvariant.sh "$name" "$dir"/"$url"*
42                                 rm -fr "$dir"
43                         fi
44                         if test "$name" = default; then
45                                 rm -fr orig
46                                 mv build orig
47                                 mv default build
48                         fi
49                 done
50                 popd
51         done
52         test $success = 0
53         check
54
55         result "$MESSAGE"
56         ;;
57 esac
58
59 exit $ERRORS