]> git.ipfire.org Git - thirdparty/strongswan.git/blame - testing/scripts/build-strongswan
swanctl: Fix documentation of default value of hostaccess
[thirdparty/strongswan.git] / testing / scripts / build-strongswan
CommitLineData
82136aa2
TB
1#!/bin/bash
2
82136aa2
TB
3DIR=$(dirname `readlink -f $0`)
4. $DIR/../testing.conf
5. $DIR/function.sh
6
7SWANDIR=${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"
83efded3 13running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
82136aa2
TB
14
15[ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
16
17SRCUID=${SUDO_UID:-$(id -u)}
18SRCGID=${SUDO_GID:-$(id -g)}
19
20check_commands partprobe qemu-img qemu-nbd bindfs
21
22load_qemu_nbd
23
24mkdir -p $LOOPDIR
25mkdir -p $IMGDIR
26
75214fab
TB
27case "$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 ;;
39esac
40
82136aa2
TB
41do_on_exit qemu-nbd -d $NBDEV
42partprobe $NBDEV
43
44log_action "Mounting $NBDPARTITION to $LOOPDIR"
45execute "mount $NBDPARTITION $LOOPDIR"
46do_on_exit umount $LOOPDIR
47
48log_action "Mounting proc filesystem to $LOOPDIR/proc"
49execute "mount -t proc none $LOOPDIR/proc"
50do_on_exit umount $LOOPDIR/proc
51
52mkdir -p $LOOPDIR/root/shared
53log_action "Mounting $SHAREDDIR as /root/shared"
54execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
55do_on_exit umount $LOOPDIR/root/shared
56
57mkdir -p $LOOPDIR/root/strongswan
58log_action "Mounting $SWANDIR as /root/strongswan"
59execute "bindfs -u $SRCUID -g $SRCGID $SWANDIR $LOOPDIR/root/strongswan"
60do_on_exit umount $LOOPDIR/root/strongswan
61
f7234e5e 62log_action "Remove SWID tags of previous versions"
936db031 63execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
f7234e5e 64
82136aa2 65echo "Building and installing strongSwan"
aee35392
TB
66
67log_action "Determine strongSwan version"
68desc=`git -C $SWANDIR describe --dirty`
69if [ $? -eq 0 ]; then
70 SWANVERSION="$desc (`git -C $SWANDIR rev-parse --abbrev-ref HEAD`)"
71else
72 SWANVERSION="`cat $SWANDIR/configure.ac | sed -n '/^AC_INIT/{ s/.*,\[\(.*\)\])$/\1/p }'`"
73fi
74echo "$SWANVERSION" > $SHAREDDIR/.strongswan-version
75log_status 0
76
82136aa2
TB
77log_action "Preparing source tree"
78execute_chroot 'autoreconf -i /root/strongswan'
79
80RECPDIR=$DIR/recipes
81RECIPE=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
82mkdir -p $SHAREDDIR/build-strongswan
83cp $RECPDIR/$RECIPE $SHAREDDIR/build-strongswan
84log_action "Installing from recipe $RECIPE"
85execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$RECIPE"
86
75214fab
TB
87# requild the guest images if we modified the root image
88if [ -z "$2" ]; then
89 # cleanup before mounting guest images
90 on_exit
91 $DIR/build-guestimages
92fi