aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReto Buerki <reet@codelabs.ch>2012-12-06 16:25:13 +0100
committerTobias Brunner <tobias@strongswan.org>2013-01-17 15:22:09 +0100
commit9574bf7a5e44a8ca5e77c8606683d0dc51ef3491 (patch)
tree1861b6c174d1a4d5477819a9f02492ad7f66d50b
parentc120f25e60415bda8d8cce752e34a0bfff264ff5 (diff)
downloadstrongswan-9574bf7a5e44a8ca5e77c8606683d0dc51ef3491.tar.bz2
strongswan-9574bf7a5e44a8ca5e77c8606683d0dc51ef3491.tar.xz
Use log_action, log_status in build-baseimage script
-rwxr-xr-xtesting/make-testing1
-rwxr-xr-xtesting/scripts/build-baseimage30
2 files changed, 21 insertions, 10 deletions
diff --git a/testing/make-testing b/testing/make-testing
index 7ae39eb6e..d09bb494d 100755
--- a/testing/make-testing
+++ b/testing/make-testing
@@ -35,7 +35,6 @@ fi
#
if [ $ENABLE_BUILD_BASEIMAGE = "yes" ]
then
- cecho "Building base image"
$DIR/scripts/build-baseimage
fi
diff --git a/testing/scripts/build-baseimage b/testing/scripts/build-baseimage
index 0964b6a43..7e380f80c 100755
--- a/testing/scripts/build-baseimage
+++ b/testing/scripts/build-baseimage
@@ -13,12 +13,17 @@ DIR=`dirname $0`
[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
. $DIR/../testing.conf
+# execute command
+# $1 - command to execute
+# $2 - whether or not to log command exit status
+# (0 -> disable exit status logging)
execute()
{
cmd=${1}
echo $cmd >>$LOGFILE
$cmd >>$LOGFILE 2>&1
status=$?
+ [ "$2" != 0 ] && log_status $status
if [ $status != 0 ]; then
echo "! command $cmd failed, exiting (status $status)"
echo "! check why here $LOGFILE"
@@ -26,6 +31,8 @@ execute()
fi
}
+# execute command in chroot
+# $1 - command to execute
execute_chroot()
{
execute "chroot $LOOPDIR $@"
@@ -44,28 +51,33 @@ mkdir -p $CACHEDIR
rm -f $ROOTFS
echo "`date`, building $ROOTFS" >>$LOGFILE
-echo " * Creating sparse image $ROOTFS ..."
+echo "Building base image"
+log_action "Creating image $ROOTFS"
execute "dd if=/dev/null of=$ROOTFS bs=1M seek=$ROOTFSSIZE count=1"
-echo " * Creating ext3 filesystem ..."
+
+log_action "Creating ext3 filesystem"
execute "mkfs.ext3 -F $ROOTFS"
+
+log_action "Mounting image to $LOOPDIR"
execute "mount -o loop $ROOTFS $LOOPDIR"
+
+log_action "Mounting cache to $CACHEDIR"
mkdir -p $APTCACHE
execute "mount -o bind $CACHEDIR $APTCACHE"
-echo " * Running debootstrap ..."
+log_action "Running debootstrap ($ROOTFSSUITE, $ROOTFSARCH)"
execute "debootstrap --arch=$ROOTFSARCH --include=$PACKAGES $ROOTFSSUITE $LOOPDIR $ROOTFSMIRROR"
-echo " * Disabling root password ..."
+log_action "Disabling root password"
execute_chroot "passwd -d root"
-echo " * Disabling services ..."
for service in $SERVICES
do
- echo -n " - $service ... "
+ log_action "Stopping service $service"
execute_chroot "/etc/init.d/$service stop"
+ log_action "Disabling service $service"
execute_chroot "update-rc.d -f $service remove"
- echo "done"
done
-execute "umount -l $APTCACHE"
-execute "umount -l $LOOPDIR"
+execute "umount -l $APTCACHE" 0
+execute "umount -l $LOOPDIR" 0