summaryrefslogtreecommitdiff
path: root/testing/scripts
diff options
context:
space:
mode:
authorRomain Francoise <rfrancoise@debian.org>2014-10-21 19:28:38 +0200
committerRomain Francoise <rfrancoise@debian.org>2014-10-21 19:28:38 +0200
commit2b8de74ff4c334c25e89988c4a401b24b5bcf03d (patch)
tree10fb49ca94bfd0c8b8a583412281abfc0186836e /testing/scripts
parent81c63b0eed39432878f78727f60a1e7499645199 (diff)
downloadvyos-strongswan-2b8de74ff4c334c25e89988c4a401b24b5bcf03d.tar.gz
vyos-strongswan-2b8de74ff4c334c25e89988c4a401b24b5bcf03d.zip
Import upstream release 5.2.1
Diffstat (limited to 'testing/scripts')
-rwxr-xr-xtesting/scripts/build-baseimage4
-rwxr-xr-xtesting/scripts/build-guestimages1
-rwxr-xr-xtesting/scripts/build-rootimage1
-rwxr-xr-xtesting/scripts/build-strongswan66
-rwxr-xr-xtesting/scripts/function.sh12
-rw-r--r--testing/scripts/recipes/005_anet.mk10
-rw-r--r--testing/scripts/recipes/006_tkm-rpc.mk10
-rw-r--r--testing/scripts/recipes/007_x509-ada.mk12
-rw-r--r--testing/scripts/recipes/008_xfrm-ada.mk10
-rw-r--r--testing/scripts/recipes/009_xfrm-proxy.mk10
-rw-r--r--testing/scripts/recipes/010_tkm.mk10
-rw-r--r--testing/scripts/recipes/013_strongswan.mk20
12 files changed, 135 insertions, 31 deletions
diff --git a/testing/scripts/build-baseimage b/testing/scripts/build-baseimage
index 956fc93ca..075fd8e1e 100755
--- a/testing/scripts/build-baseimage
+++ b/testing/scripts/build-baseimage
@@ -7,11 +7,13 @@ DIR=$(dirname `readlink -f $0`)
. $DIR/function.sh
[ `id -u` -eq 0 ] || die "You must be root to run $0"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
check_commands debootstrap mkfs.ext3 partprobe qemu-img qemu-nbd sfdisk
# package includes/excludes
-INC=build-essential,gperf,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,ethtool
+INC=automake,autoconf,libtool,bison,flex,gperf,pkg-config,gettext
+INC=$INC,build-essential,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,ethtool
INC=$INC,libxml2-dev,libtspi-dev,libsqlite3-dev,openssh-server,tcpdump,psmisc
INC=$INC,openssl,vim,sqlite3,conntrack,gdb,cmake,libxerces-c2-dev,libltdl-dev
INC=$INC,liblog4cxx10-dev,libboost-thread-dev,libboost-system-dev,git-core
diff --git a/testing/scripts/build-guestimages b/testing/scripts/build-guestimages
index 245fc2524..3e107c062 100755
--- a/testing/scripts/build-guestimages
+++ b/testing/scripts/build-guestimages
@@ -25,6 +25,7 @@ HOSTSDIR=$DIR/../hosts
[ `id -u` -eq 0 ] || die "You must be root to run $0"
[ -f $ROOTIMG ] || die "Root image $ROOTIMG not found"
[ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
check_commands partprobe qemu-img qemu-nbd
diff --git a/testing/scripts/build-rootimage b/testing/scripts/build-rootimage
index 8e10ce5f3..a84104a90 100755
--- a/testing/scripts/build-rootimage
+++ b/testing/scripts/build-rootimage
@@ -22,6 +22,7 @@ DIR=$(dirname `readlink -f $0`)
[ `id -u` -eq 0 ] || die "You must be root to run $0"
[ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
check_commands partprobe qemu-img qemu-nbd
diff --git a/testing/scripts/build-strongswan b/testing/scripts/build-strongswan
new file mode 100755
index 000000000..c52dddda8
--- /dev/null
+++ b/testing/scripts/build-strongswan
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+echo "Preparing root image"
+
+DIR=$(dirname `readlink -f $0`)
+. $DIR/../testing.conf
+. $DIR/function.sh
+
+SWANDIR=${1:+$(readlink -f $1)}
+: ${SWANDIR:=$(readlink -f $DIR/../..)}
+
+[ `id -u` -eq 0 ] || die "You must be root to run $0"
+[ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
+[ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
+
+[ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
+
+SRCUID=${SUDO_UID:-$(id -u)}
+SRCGID=${SUDO_GID:-$(id -g)}
+
+check_commands partprobe qemu-img qemu-nbd bindfs
+
+load_qemu_nbd
+
+mkdir -p $LOOPDIR
+mkdir -p $IMGDIR
+
+log_action "Connecting root image to NBD device $NBDEV"
+execute "qemu-nbd -c $NBDEV $ROOTIMG"
+do_on_exit qemu-nbd -d $NBDEV
+partprobe $NBDEV
+
+log_action "Mounting $NBDPARTITION to $LOOPDIR"
+execute "mount $NBDPARTITION $LOOPDIR"
+do_on_exit umount $LOOPDIR
+
+log_action "Mounting proc filesystem to $LOOPDIR/proc"
+execute "mount -t proc none $LOOPDIR/proc"
+do_on_exit umount $LOOPDIR/proc
+
+mkdir -p $LOOPDIR/root/shared
+log_action "Mounting $SHAREDDIR as /root/shared"
+execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
+do_on_exit umount $LOOPDIR/root/shared
+
+mkdir -p $LOOPDIR/root/strongswan
+log_action "Mounting $SWANDIR as /root/strongswan"
+execute "bindfs -u $SRCUID -g $SRCGID $SWANDIR $LOOPDIR/root/strongswan"
+do_on_exit umount $LOOPDIR/root/strongswan
+
+echo "Building and installing strongSwan"
+log_action "Preparing source tree"
+execute_chroot 'autoreconf -i /root/strongswan'
+
+RECPDIR=$DIR/recipes
+RECIPE=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
+mkdir -p $SHAREDDIR/build-strongswan
+cp $RECPDIR/$RECIPE $SHAREDDIR/build-strongswan
+log_action "Installing from recipe $RECIPE"
+execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$RECIPE"
+
+# cleanup before mounting guest images
+on_exit
+
+$DIR/build-guestimages
diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh
index c4769678c..2dd465c85 100755
--- a/testing/scripts/function.sh
+++ b/testing/scripts/function.sh
@@ -156,6 +156,18 @@ check_commands()
done
}
+# check if any of the given virtual guests are running
+# $* - names of guests to check
+running_any()
+{
+ command -v virsh >/dev/null || return 1
+ for host in $*
+ do
+ virsh list --name | grep "^$host$" >/dev/null && return 0
+ done
+ return 1
+}
+
#############################################
# search and replace strings throughout a
# whole directory
diff --git a/testing/scripts/recipes/005_anet.mk b/testing/scripts/recipes/005_anet.mk
index 2a3023c42..2d982d091 100644
--- a/testing/scripts/recipes/005_anet.mk
+++ b/testing/scripts/recipes/005_anet.mk
@@ -8,14 +8,16 @@ PREFIX = /usr/local/ada
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make LIBRARY_KIND=static
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make PREFIX=$(PREFIX) LIBRARY_KIND=static install
diff --git a/testing/scripts/recipes/006_tkm-rpc.mk b/testing/scripts/recipes/006_tkm-rpc.mk
index 9e1d2cfc6..6c4aae0c5 100644
--- a/testing/scripts/recipes/006_tkm-rpc.mk
+++ b/testing/scripts/recipes/006_tkm-rpc.mk
@@ -10,14 +10,16 @@ export ADA_PROJECT_PATH=$(PREFIX)/lib/gnat
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make PREFIX=$(PREFIX) install
diff --git a/testing/scripts/recipes/007_x509-ada.mk b/testing/scripts/recipes/007_x509-ada.mk
index 121a14414..7899f6dec 100644
--- a/testing/scripts/recipes/007_x509-ada.mk
+++ b/testing/scripts/recipes/007_x509-ada.mk
@@ -2,20 +2,22 @@
PKG = x509-ada
SRC = http://git.codelabs.ch/git/$(PKG).git
-REV = v0.1
+REV = v0.1.1
PREFIX = /usr/local/ada
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make tests && make
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make PREFIX=$(PREFIX) install
diff --git a/testing/scripts/recipes/008_xfrm-ada.mk b/testing/scripts/recipes/008_xfrm-ada.mk
index 6ad451340..ad1cbb2bc 100644
--- a/testing/scripts/recipes/008_xfrm-ada.mk
+++ b/testing/scripts/recipes/008_xfrm-ada.mk
@@ -10,14 +10,16 @@ export ADA_PROJECT_PATH=$(PREFIX)/lib/gnat
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make PREFIX=$(PREFIX) install
diff --git a/testing/scripts/recipes/009_xfrm-proxy.mk b/testing/scripts/recipes/009_xfrm-proxy.mk
index 569fbfe3c..a7c9d31cc 100644
--- a/testing/scripts/recipes/009_xfrm-proxy.mk
+++ b/testing/scripts/recipes/009_xfrm-proxy.mk
@@ -8,14 +8,16 @@ export ADA_PROJECT_PATH=/usr/local/ada/lib/gnat
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make install
diff --git a/testing/scripts/recipes/010_tkm.mk b/testing/scripts/recipes/010_tkm.mk
index 960eba79f..12eafd6c8 100644
--- a/testing/scripts/recipes/010_tkm.mk
+++ b/testing/scripts/recipes/010_tkm.mk
@@ -8,14 +8,16 @@ export ADA_PROJECT_PATH=/usr/local/ada/lib/gnat
all: install
-.$(PKG)-cloned:
+$(PKG):
git clone $(SRC) $(PKG)
- cd $(PKG) && git checkout $(REV)
+
+.$(PKG)-cloned-$(REV): $(PKG)
+ cd $(PKG) && git fetch && git checkout $(REV)
@touch $@
-.$(PKG)-built: .$(PKG)-cloned
+.$(PKG)-built-$(REV): .$(PKG)-cloned-$(REV)
cd $(PKG) && make
@touch $@
-install: .$(PKG)-built
+install: .$(PKG)-built-$(REV)
cd $(PKG) && make install
diff --git a/testing/scripts/recipes/013_strongswan.mk b/testing/scripts/recipes/013_strongswan.mk
index c4142086f..2b7bde5a5 100644
--- a/testing/scripts/recipes/013_strongswan.mk
+++ b/testing/scripts/recipes/013_strongswan.mk
@@ -5,6 +5,15 @@ PKG = strongswan-$(PV)
TAR = $(PKG).tar.bz2
SRC = http://download.strongswan.org/$(TAR)
+# can be passed to load sources from a directory instead of a tarball
+ifneq ($(origin SRCDIR), undefined)
+DIR = $(SRCDIR)
+BUILDDIR ?= $(SRCDIR)
+endif
+DIR ?= .
+# can be passed if not building in the source directory
+BUILDDIR ?= $(PKG)
+
NUM_CPUS := $(shell getconf _NPROCESSORS_ONLN)
CONFIG_OPTS = \
@@ -82,7 +91,8 @@ CONFIG_OPTS = \
--enable-kernel-libipsec \
--enable-tkm \
--enable-ntru \
- --enable-lookip
+ --enable-lookip \
+ --enable-swanctl
export ADA_PROJECT_PATH=/usr/local/ada/lib/gnat
@@ -94,11 +104,11 @@ $(TAR):
$(PKG): $(TAR)
tar xfj $(TAR)
-configure: $(PKG)
- cd $(PKG) && ./configure $(CONFIG_OPTS)
+configure: $(BUILDDIR)
+ cd $(BUILDDIR) && $(DIR)/configure $(CONFIG_OPTS)
build: configure
- cd $(PKG) && make -j $(NUM_CPUS)
+ cd $(BUILDDIR) && make -j $(NUM_CPUS)
install: build
- cd $(PKG) && make install
+ cd $(BUILDDIR) && make -j install