Annotation of embedaddon/strongswan/testing/scripts/build-strongswan, revision 1.1.1.1
1.1 misho 1: #!/bin/bash
2:
3: DIR=$(dirname `readlink -f $0`)
4: . $DIR/../testing.conf
5: . $DIR/function.sh
6:
7: SWANDIR=${1:+$(readlink -f $1)}
8: : ${SWANDIR:=$(readlink -f $DIR/../..)}
9:
10: [ `id -u` -eq 0 ] || die "You must be root to run $0"
11: [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
12: [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
13: running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
14:
15: [ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
16:
17: SRCUID=${SUDO_UID:-$(id -u)}
18: SRCGID=${SUDO_GID:-$(id -g)}
19:
20: check_commands partprobe qemu-img qemu-nbd bindfs
21:
22: load_qemu_nbd
23:
24: mkdir -p $LOOPDIR
25: mkdir -p $IMGDIR
26:
27: case "$2" in
28: "")
29: log_action "Connecting root image to NBD device $NBDEV"
30: execute "qemu-nbd -c $NBDEV $ROOTIMG"
31: ;;
32: *)
33: echo $STRONGSWANHOSTS | grep -q "\b$2\b" || die "Guest $2 not found"
34: GUESTIMG="$IMGDIR/$2.$IMGEXT"
35: [ -f "$GUESTIMG" ] || die "Guest image $GUESTIMG not found"
36: log_action "Connecting guest image to NBD device $NBDEV"
37: execute "qemu-nbd -c $NBDEV $GUESTIMG"
38: ;;
39: esac
40:
41: do_on_exit qemu-nbd -d $NBDEV
42: partprobe $NBDEV
43:
44: log_action "Mounting $NBDPARTITION to $LOOPDIR"
45: execute "mount $NBDPARTITION $LOOPDIR"
46: do_on_exit umount $LOOPDIR
47:
48: log_action "Mounting proc filesystem to $LOOPDIR/proc"
49: execute "mount -t proc none $LOOPDIR/proc"
50: do_on_exit umount $LOOPDIR/proc
51:
52: mkdir -p $LOOPDIR/root/shared
53: log_action "Mounting $SHAREDDIR as /root/shared"
54: execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
55: do_on_exit umount $LOOPDIR/root/shared
56:
57: mkdir -p $LOOPDIR/root/strongswan
58: log_action "Mounting $SWANDIR as /root/strongswan"
59: execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID $SWANDIR $LOOPDIR/root/strongswan"
60: do_on_exit umount $LOOPDIR/root/strongswan
61:
62: log_action "Copy /etc/resolv.conf"
63: execute "cp /etc/resolv.conf $LOOPDIR/etc/resolv.conf"
64: do_on_exit rm $LOOPDIR/etc/resolv.conf
65:
66: log_action "Remove SWID tags of previous versions"
67: execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
68:
69: echo "Building and installing strongSwan"
70:
71: log_action "Determine strongSwan version"
72: desc=`git -C $SWANDIR describe --dirty`
73: if [ $? -eq 0 ]; then
74: SWANVERSION="$desc (`git -C $SWANDIR rev-parse --abbrev-ref HEAD`)"
75: else
76: SWANVERSION="`cat $SWANDIR/configure.ac | sed -n '/^AC_INIT/{ s/.*,\[\(.*\)\])$/\1/p }'`"
77: fi
78: echo "$SWANVERSION" > $SHAREDDIR/.strongswan-version
79: log_status 0
80:
81: log_action "Preparing source tree"
82: execute_chroot 'autoreconf -i /root/strongswan'
83:
84: RECPDIR=$DIR/recipes
85: RECIPE=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
86: mkdir -p $SHAREDDIR/build-strongswan
87: cp $RECPDIR/$RECIPE $SHAREDDIR/build-strongswan
88: log_action "Installing from recipe $RECIPE"
89: execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$RECIPE"
90:
91: # rebuild the guest images after we modified the root image
92: if [ -z "$2" ]; then
93: # cleanup before mounting guest images
94: on_exit
95: # building the guest images without certificates fails on winnetou
96: if [ ! -f "$DIR/../hosts/winnetou/etc/ca/strongswanCert.pem" ]; then
97: # this also re-builds the guest images
98: $DIR/build-certs
99: else
100: $DIR/build-guestimages
101: fi
102: fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>