Test availability of required commands
authorReto Buerki <reet@codelabs.ch>
Sun, 9 Dec 2012 08:49:04 +0000 (09:49 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 17 Jan 2013 15:54:54 +0000 (16:54 +0100)
testing/scripts/build-baseimage
testing/scripts/build-guestkernel
testing/scripts/build-umlhostfs
testing/scripts/build-umlrootfs
testing/scripts/function.sh

index c73c454..31205bf 100755 (executable)
@@ -6,6 +6,8 @@ echo "Building base image"
 
 [ `id -u` -eq 0 ] || die "You must be root to run $0"
 
+check_commands debootstrap mkfs.ext3 qemu-img qemu-nbd sfdisk
+
 # additional packages
 EXTRAS=build-essential,gperf,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,libxml2-dev,libtspi-dev,libsqlite3-dev,openssh-server,tcpdump,psmisc,openssl,vim,sqlite3,conntrack,gdb,cmake,libxerces-c2-dev,libltdl-dev,liblog4cxx10-dev,libboost-thread-dev,libboost-system-dev,git-core
 SERVICES="isc-dhcp-server apache2 slapd"
index 2fbe658..84633bc 100755 (executable)
@@ -6,6 +6,8 @@ echo "Building guest kernel version $KERNELVERSION"
 
 [ -f "$KERNELCONFIG" ] || die "Kernel config $KERNELCONFIG not found"
 
+check_commands bunzip2 bzcat make wget
+
 mkdir -p $BUILDDIR
 cd $BUILDDIR
 
index 1028ef2..f534103 100755 (executable)
@@ -26,6 +26,8 @@ HOSTSDIR=$PWD/hosts
 [ -f $BASE ] || die "Base image $BASE not found"
 [ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found"
 
+check_commands qemu-img qemu-nbd
+
 load_qemu_nbd
 
 mkdir -p $BUILDDIR
index c67e4d5..0f8781c 100755 (executable)
@@ -22,6 +22,8 @@ echo "Building root image"
 
 [ -f "$ROOTFS" ] || die "Root image $ROOTFS not found"
 
+check_commands qemu-nbd
+
 load_qemu_nbd
 
 mkdir -p $ROOTFSDIR
index d727082..2a801a7 100755 (executable)
@@ -148,6 +148,16 @@ load_qemu_nbd()
        fi
 }
 
+# check if given commands exist in $PATH
+# $* - commands to check
+check_commands()
+{
+       for i in $*
+       do
+               command -v $i >/dev/null || { die "Required command $i not found"; exit 1; }
+       done
+}
+
 #############################################
 # search and replace strings throughout a
 # whole directory