testing: Add option to build all software recipes when building strongSwan
This is like building the root image but using a specific strongSwan source tree, which is helpful if code changes depend on other software packages (e.g. TKM-related or testing new crypto libraries). If the script is called and the root image does not exist, the new option is enabled automatically. The option to build in a specific guest image is now also moved to an explicit command line option so that the source dir path is the only remaining positional argument (see --help for details).
This commit is contained in:
@@ -4,16 +4,10 @@ DIR=$(dirname `readlink -f $0`)
|
|||||||
. $DIR/../testing.conf
|
. $DIR/../testing.conf
|
||||||
. $DIR/function.sh
|
. $DIR/function.sh
|
||||||
|
|
||||||
SWANDIR=${1:+$(readlink -f $1)}
|
|
||||||
: ${SWANDIR:=$(readlink -f $DIR/../..)}
|
|
||||||
|
|
||||||
[ `id -u` -eq 0 ] || die "You must be root to run $0"
|
[ `id -u` -eq 0 ] || die "You must be root to run $0"
|
||||||
[ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
|
[ -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"
|
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)}
|
SRCUID=${SUDO_UID:-$(id -u)}
|
||||||
SRCGID=${SUDO_GID:-$(id -g)}
|
SRCGID=${SUDO_GID:-$(id -g)}
|
||||||
|
|
||||||
@@ -24,18 +18,61 @@ load_qemu_nbd
|
|||||||
mkdir -p $LOOPDIR
|
mkdir -p $LOOPDIR
|
||||||
mkdir -p $IMGDIR
|
mkdir -p $IMGDIR
|
||||||
|
|
||||||
case "$2" in
|
usage() {
|
||||||
|
cat << EOF
|
||||||
|
Usage: ${0##*/} [--all] [--guest NAME] [SRCDIR]
|
||||||
|
--help (-h) show usage information
|
||||||
|
--all (-a) build/install all software, not only strongSwan
|
||||||
|
--guest NAME (-g) only install in a specific guest image
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
GUEST=
|
||||||
|
ALL_RECIPES=
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-a|--all)
|
||||||
|
ALL_RECIPES=1
|
||||||
|
;;
|
||||||
|
-g|--guest)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
GUEST=$2
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
die "Guest name missing"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
SWANDIR=${1:+$(readlink -f $1)}
|
||||||
|
: ${SWANDIR:=$(readlink -f $DIR/../..)}
|
||||||
|
|
||||||
|
[ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
|
||||||
|
|
||||||
|
case "$GUEST" in
|
||||||
"")
|
"")
|
||||||
if [ ! -f "$ROOTIMG" ]; then
|
if [ ! -f "$ROOTIMG" ]; then
|
||||||
log_action "Creating root image $ROOTIMG"
|
log_action "Creating root image $ROOTIMG"
|
||||||
execute "qemu-img create -b $BASEIMG -f $IMGEXT $ROOTIMG"
|
execute "qemu-img create -b $BASEIMG -f $IMGEXT $ROOTIMG"
|
||||||
|
ALL_RECIPES=1
|
||||||
fi
|
fi
|
||||||
log_action "Connecting root image to NBD device $NBDEV"
|
log_action "Connecting root image to NBD device $NBDEV"
|
||||||
|
[ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
|
||||||
execute "qemu-nbd -c $NBDEV $ROOTIMG"
|
execute "qemu-nbd -c $NBDEV $ROOTIMG"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $STRONGSWANHOSTS | grep -q "\b$2\b" || die "Guest $2 not found"
|
echo $STRONGSWANHOSTS | grep -q "\b$GUEST\b" || die "Guest $GUEST not found"
|
||||||
GUESTIMG="$IMGDIR/$2.$IMGEXT"
|
GUESTIMG="$IMGDIR/$GUEST.$IMGEXT"
|
||||||
[ -f "$GUESTIMG" ] || die "Guest image $GUESTIMG not found"
|
[ -f "$GUESTIMG" ] || die "Guest image $GUESTIMG not found"
|
||||||
log_action "Connecting guest image to NBD device $NBDEV"
|
log_action "Connecting guest image to NBD device $NBDEV"
|
||||||
execute "qemu-nbd -c $NBDEV $GUESTIMG"
|
execute "qemu-nbd -c $NBDEV $GUESTIMG"
|
||||||
@@ -70,8 +107,6 @@ do_on_exit rm $LOOPDIR/etc/resolv.conf
|
|||||||
log_action "Remove SWID tags of previous versions"
|
log_action "Remove SWID tags of previous versions"
|
||||||
execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
|
execute_chroot "find /usr/local/share -path '*strongswan*' -name *.swidtag -delete"
|
||||||
|
|
||||||
echo "Building and installing strongSwan"
|
|
||||||
|
|
||||||
log_action "Determine strongSwan version"
|
log_action "Determine strongSwan version"
|
||||||
desc=`git -C $SWANDIR describe --dirty`
|
desc=`git -C $SWANDIR describe --dirty`
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
@@ -86,14 +121,35 @@ log_action "Preparing source tree"
|
|||||||
execute_chroot 'autoreconf -i /root/strongswan'
|
execute_chroot 'autoreconf -i /root/strongswan'
|
||||||
|
|
||||||
RECPDIR=$DIR/recipes
|
RECPDIR=$DIR/recipes
|
||||||
RECIPE=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
|
if [ "$ALL_RECIPES" ]; then
|
||||||
|
echo "Building and installing strongSwan and all other software"
|
||||||
|
if [ -d "$RECPDIR/patches" ]
|
||||||
|
then
|
||||||
|
execute "cp -r $RECPDIR/patches $LOOPDIR/root/shared/compile" 0
|
||||||
|
fi
|
||||||
|
RECIPES=`ls $RECPDIR/*.mk | xargs -n1 basename`
|
||||||
|
else
|
||||||
|
echo "Building and installing strongSwan"
|
||||||
|
RECIPES=`ls $RECPDIR/*strongswan.mk | xargs -n1 basename`
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $SHAREDDIR/build-strongswan
|
mkdir -p $SHAREDDIR/build-strongswan
|
||||||
cp $RECPDIR/$RECIPE $SHAREDDIR/build-strongswan
|
mkdir -p $SHAREDDIR/compile
|
||||||
log_action "Installing from recipe $RECIPE"
|
|
||||||
execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$RECIPE"
|
for r in $RECIPES
|
||||||
|
do
|
||||||
|
log_action "Installing from recipe $r"
|
||||||
|
if [[ $r == *strongswan.mk ]]; then
|
||||||
|
cp $RECPDIR/$r $SHAREDDIR/build-strongswan
|
||||||
|
execute_chroot "make SRCDIR=/root/strongswan BUILDDIR=/root/shared/build-strongswan -f /root/shared/build-strongswan/$r"
|
||||||
|
else
|
||||||
|
cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile
|
||||||
|
execute_chroot "make -C /root/shared/compile -f $r"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# rebuild the guest images after we modified the root image
|
# rebuild the guest images after we modified the root image
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$GUEST" ]; then
|
||||||
# cleanup before mounting guest images
|
# cleanup before mounting guest images
|
||||||
on_exit
|
on_exit
|
||||||
# building the guest images without certificates fails on winnetou
|
# building the guest images without certificates fails on winnetou
|
||||||
|
|||||||
Reference in New Issue
Block a user