testing: Optionally build strongSwan from a release tarball
This will allow us to replace the build-rootimage script.
This commit is contained in:
@@ -11,7 +11,7 @@ running_any $STRONGSWANHOSTS && die "Please stop test environment before running
|
|||||||
SRCUID=${SUDO_UID:-$(id -u)}
|
SRCUID=${SUDO_UID:-$(id -u)}
|
||||||
SRCGID=${SUDO_GID:-$(id -g)}
|
SRCGID=${SUDO_GID:-$(id -g)}
|
||||||
|
|
||||||
check_commands partprobe qemu-img qemu-nbd bindfs
|
check_commands partprobe qemu-img qemu-nbd
|
||||||
|
|
||||||
load_qemu_nbd
|
load_qemu_nbd
|
||||||
|
|
||||||
@@ -20,12 +20,15 @@ mkdir -p $IMGDIR
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage: ${0##*/} [--all] [--clean] [--guest NAME] [--replace] [SRCDIR]
|
Usage:
|
||||||
|
${0##*/} [--all] [--guest NAME] [--replace] [--clean] [SRCDIR]
|
||||||
|
${0##*/} [--all] [--guest NAME] [--replace] [--tarball VERSION]
|
||||||
--help (-h) show usage information
|
--help (-h) show usage information
|
||||||
--all (-a) build/install all software, not only strongSwan
|
--all (-a) build/install all software, not only strongSwan
|
||||||
--clean (-c) use a new strongSwan build directory
|
--clean (-c) use a new strongSwan build directory
|
||||||
--guest NAME (-g) only install in a specific guest image
|
--guest NAME (-g) only install in a specific guest image
|
||||||
--replace (-r) replace the root image (implies --all)
|
--replace (-r) replace the root image (implies --all)
|
||||||
|
--tarball (-t) build strongSwan from a release tarball
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +36,7 @@ ALL_RECIPES=
|
|||||||
CLEAN=
|
CLEAN=
|
||||||
GUEST=
|
GUEST=
|
||||||
REPLACE=
|
REPLACE=
|
||||||
|
TARBALL=
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -57,6 +61,14 @@ while :; do
|
|||||||
-r|--replace)
|
-r|--replace)
|
||||||
REPLACE=1
|
REPLACE=1
|
||||||
;;
|
;;
|
||||||
|
-t|--tarball)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
TARBALL=$2
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
die "Release version missing"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
esac
|
esac
|
||||||
@@ -64,10 +76,16 @@ while :; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
SWANDIR=${1:+$(readlink -f $1)}
|
SWANDIR=
|
||||||
: ${SWANDIR:=$(readlink -f $DIR/../..)}
|
|
||||||
|
|
||||||
[ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
|
if [ -z "$TARBALL" ]; then
|
||||||
|
check_commands bindfs
|
||||||
|
|
||||||
|
SWANDIR=${1:+$(readlink -f $1)}
|
||||||
|
: ${SWANDIR:=$(readlink -f $DIR/../..)}
|
||||||
|
|
||||||
|
[ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
|
||||||
|
fi
|
||||||
|
|
||||||
case "$GUEST" in
|
case "$GUEST" in
|
||||||
"")
|
"")
|
||||||
@@ -105,30 +123,32 @@ log_action "Mounting $SHAREDDIR as /root/shared"
|
|||||||
execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
|
execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
|
||||||
do_on_exit umount $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 --create-for-user=$SRCUID --create-for-group=$SRCGID $SWANDIR $LOOPDIR/root/strongswan"
|
|
||||||
do_on_exit umount $LOOPDIR/root/strongswan
|
|
||||||
|
|
||||||
log_action "Copy /etc/resolv.conf"
|
log_action "Copy /etc/resolv.conf"
|
||||||
execute "cp /etc/resolv.conf $LOOPDIR/etc/resolv.conf"
|
execute "cp /etc/resolv.conf $LOOPDIR/etc/resolv.conf"
|
||||||
do_on_exit rm $LOOPDIR/etc/resolv.conf
|
do_on_exit rm $LOOPDIR/etc/resolv.conf
|
||||||
|
|
||||||
log_action "Remove SWID tags of previous versions"
|
log_action "Remove SWID tags of previous strongSwan versions"
|
||||||
execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
|
execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
|
||||||
|
|
||||||
log_action "Determine strongSwan version"
|
if [ -z "$TARBALL" ]; then
|
||||||
desc=`git -C $SWANDIR describe --dirty`
|
mkdir -p $LOOPDIR/root/strongswan
|
||||||
if [ $? -eq 0 ]; then
|
log_action "Mounting $SWANDIR as /root/strongswan"
|
||||||
SWANVERSION="$desc (`git -C $SWANDIR rev-parse --abbrev-ref HEAD`)"
|
execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID $SWANDIR $LOOPDIR/root/strongswan"
|
||||||
else
|
do_on_exit umount $LOOPDIR/root/strongswan
|
||||||
SWANVERSION="`cat $SWANDIR/configure.ac | sed -n '/^AC_INIT/{ s/.*,\[\(.*\)\])$/\1/p }'`"
|
|
||||||
fi
|
|
||||||
echo "$SWANVERSION" > $SHAREDDIR/.strongswan-version
|
|
||||||
log_status 0
|
|
||||||
|
|
||||||
log_action "Preparing source tree"
|
log_action "Determine strongSwan version"
|
||||||
execute_chroot 'autoreconf -i /root/strongswan'
|
desc=`git -C $SWANDIR describe --dirty`
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
version="$desc (`git -C $SWANDIR rev-parse --abbrev-ref HEAD`)"
|
||||||
|
else
|
||||||
|
version="`cat $SWANDIR/configure.ac | sed -n '/^AC_INIT/{ s/.*,\[\(.*\)\])$/\1/p }'`"
|
||||||
|
fi
|
||||||
|
echo "$version" > $SHAREDDIR/.strongswan-version
|
||||||
|
log_status 0
|
||||||
|
|
||||||
|
log_action "Preparing source tree"
|
||||||
|
execute_chroot 'autoreconf -i /root/strongswan'
|
||||||
|
fi
|
||||||
|
|
||||||
RECPDIR=$DIR/recipes
|
RECPDIR=$DIR/recipes
|
||||||
if [ "$ALL_RECIPES" ]; then
|
if [ "$ALL_RECIPES" ]; then
|
||||||
@@ -152,12 +172,12 @@ mkdir -p $SHAREDDIR/compile
|
|||||||
for r in $RECIPES
|
for r in $RECIPES
|
||||||
do
|
do
|
||||||
log_action "Installing from recipe $r"
|
log_action "Installing from recipe $r"
|
||||||
if [[ $r == *strongswan.mk ]]; then
|
if [[ $r == *strongswan.mk && -z "$TARBALL" ]]; then
|
||||||
cp $RECPDIR/$r $SHAREDDIR/build-strongswan
|
cp $RECPDIR/$r $SHAREDDIR/build-strongswan
|
||||||
execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$r"
|
execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$r"
|
||||||
else
|
else
|
||||||
cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile
|
cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile
|
||||||
execute_chroot "make -C /root/shared/compile -f $r"
|
execute_chroot "make SWANVERSION=$TARBALL -C /root/shared/compile -f $r"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user