# adt_... variables and some other useful ones.
set -e${ADT_SHELLX}
+set -o pipefail
#---------- useful general functions ----------
adt_nominum=adt
adt_testbed_ram=256
adt_freeze_ram=32
-adt_fs_size=1G
-adt_fs_snapsize=100M
+adt_fs_size=3072M
+adt_fs_snapsize=2560M
adt_fs_cowchunk=8
adt_playbase=/var/lib/autopkgtest/xenlvm
adt_fs_type=ext3
adt_guest_macaddr=00:16:3e:7c:aa:7f
adt_net_vifscript=/etc/xen/scripts/vif-route-adt
+adt_normaluser=adtxenu
#---------- arguments and config file ----------
*) fail "unknown configuration variable \`$var'" ;;
esac
- eval "$var=\"\$value\""
+ eval "adt_$var=\"\$value\""
shift ;;
--) shift; break ;;
;;
esac
-case "$adt_kernel" in
-'')
+if [ "$adt_readconfig_needkernel" ]; then
+ case "$adt_kernel" in
+ '')
printf "searching for kernel ... "
- for f in /boot/xen*"`uname -r`"; do
+ for f in /boot/*"`uname -r`"*; do
test -e "$f" || continue
+ printf "(%s:" "$f"
+ output="$(file -- "$f")"
+ case "$output" in
+ *"gzip compressed data"*) ;;
+ *) printf "!gzip) "; continue ;;
+ esac
+ trap 'rm -f -- "$tf"; exit 127' 0
+ tf=`mktemp -t`
+ zcat -- "$f" >"$tf"
+ output="$(file -- "$tf")"
+ case "$output" in
+ *"ELF "*" executable,"*) ;;
+ *) printf "!ELF) "; continue;;
+ esac
+ output="$(objdump -j __xen_guest -s -- "$tf")"
+ rm -f "$tf"; trap '' 0
+ case "$output" in
+ *" __xen_guest:"*) ;;
+ *) printf "!Xen) "; continue
+ esac
+ printf "y) "
test "x$adt_kernel" = x || \
fail 'several kernels, config must specify which'
adt_kernel="$f"
done
+ [ "x$adt_kernel" != x ] || \
+ fail 'could not find currently booted Xen kernel'
echo "using currently booted kernel: $adt_kernel"
;;
-esac
+ esac
-case "$adt_ramdisk" in
-none) echo "ramdisk \`none' specified, using static kernel"
+ case "$adt_ramdisk" in
+ none) echo "ramdisk \`none' specified, using static kernel"
adt_ramdisk='' ;;
-'') adt_ramdisk="$adt_kernel.initrd.img"
- echo "using default ramdisk <kernel>.initrd.img: $adt_ramdisk" ;;
-*) ;;
-esac
+ '') adt_ramdisk="${adt_kernel/\/vmlinuz-//initrd.img-}"
+ test -e "$adt_ramdisk" || \
+ fail "calculated default ramdisk initrd.img \`$adt_ramdisk' does not exist"
+ echo "using calculated default ramdisk initrd.img: $adt_ramdisk" ;;
+ *) ;;
+ esac
+fi
case "$adt_modules" in
'') adt_modules="/lib/modules/`uname -r`" ;;
ipaddr_from_hostname guest
ipaddr_from_hostname host
-printf "looking for firewall hook ... "
-case "$adt_fw_hook" in
-'')
- case "$adt_config" in
- *_config)
- adt_fw_hook=${adt_config%_config}_fwhook
- if test -e "$adt_fw_hook"; then
- echo "default exists: $adt_fw_hook"
- else
- echo "default $adt_fw_hook is not a file, so: none"
- adt_fw_hook=''
- fi
- ;;
- *)
- echo "not specified, not computable from config, so: none"
- adt_fw_hook=''
- ;;
- esac
- ;;
-*)
- if test -e "$adt_fw_hook"; then
- echo "exists: $adt_fw_hook"
- else
- echo "specified as $adt_fw_hook, but not a file, so: none"
- adt_fw_hook=''
- fi
- ;;
-esac
+search_hook () {
+ eval '
+ printf "looking for '$2' hook ... "
+ case "$adt_'$1'_hook" in
+ "")
+ case "$adt_config" in
+ *_config)
+ adt_'$1'_hook=${adt_config%_config}_'$3'
+ if test -e "$adt_'$1'_hook"; then
+ echo "default exists: $adt_'$1'_hook"
+ else
+ echo "default $adt_'$1'_hook is not a file, so: none"
+ adt_'$1'_hook=""
+ fi
+ ;;
+ *)
+ echo "not specified, not computable from config, so: none"
+ adt_'$1'_hook=""
+ ;;
+ esac
+ ;;
+ *)
+ if test -e "$adt_'$1'_hook"; then
+ echo "exists: $adt_'$1'_hook"
+ else
+ echo "specified as $adt_'$1'_hook, but not a file, so: none"
+ adt_'$1'_hook=""
+ fi
+ ;;
+ esac
+ '
+}
+
+search_hook fw firewall fwhook
+search_hook setup setup setuphook
boolean_config () {
eval '