The critical-extension scenarios need the old private keys
[strongswan.git] / testing / scripts / build-strongswan
1 #!/bin/bash
2
3 echo "Preparing root image"
4
5 DIR=$(dirname `readlink -f $0`)
6 . $DIR/../testing.conf
7 . $DIR/function.sh
8
9 SWANDIR=${1:+$(readlink -f $1)}
10 : ${SWANDIR:=$(readlink -f $DIR/../..)}
11
12 [ `id -u` -eq 0 ] || die "You must be root to run $0"
13 [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
14 [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
15
16 [ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
17
18 SRCUID=${SUDO_UID:-$(id -u)}
19 SRCGID=${SUDO_GID:-$(id -g)}
20
21 check_commands partprobe qemu-img qemu-nbd bindfs
22
23 load_qemu_nbd
24
25 mkdir -p $LOOPDIR
26 mkdir -p $IMGDIR
27
28 log_action "Connecting root image to NBD device $NBDEV"
29 execute "qemu-nbd -c $NBDEV $ROOTIMG"
30 do_on_exit qemu-nbd -d $NBDEV
31 partprobe $NBDEV
32
33 log_action "Mounting $NBDPARTITION to $LOOPDIR"
34 execute "mount $NBDPARTITION $LOOPDIR"
35 do_on_exit umount $LOOPDIR
36
37 log_action "Mounting proc filesystem to $LOOPDIR/proc"
38 execute "mount -t proc none $LOOPDIR/proc"
39 do_on_exit umount $LOOPDIR/proc
40
41 mkdir -p $LOOPDIR/root/shared
42 log_action "Mounting $SHAREDDIR as /root/shared"
43 execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
44 do_on_exit umount $LOOPDIR/root/shared
45
46 mkdir -p $LOOPDIR/root/strongswan
47 log_action "Mounting $SWANDIR as /root/strongswan"
48 execute "bindfs -u $SRCUID -g $SRCGID $SWANDIR $LOOPDIR/root/strongswan"
49 do_on_exit umount $LOOPDIR/root/strongswan
50
51 echo "Building and installing strongSwan"
52 log_action "Preparing source tree"
53 execute_chroot 'autoreconf -i /root/strongswan'
54
55 RECPDIR=$DIR/recipes
56 RECIPE=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
57 mkdir -p $SHAREDDIR/build-strongswan
58 cp $RECPDIR/$RECIPE $SHAREDDIR/build-strongswan
59 log_action "Installing from recipe $RECIPE"
60 execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$RECIPE"
61
62 # cleanup before mounting guest images
63 on_exit
64
65 $DIR/build-guestimages