chiark / gitweb /
Initial work on configuration arrangements
authorIan Jackson <ian@anarres>
Wed, 27 Sep 2006 15:35:06 +0000 (16:35 +0100)
committerIan Jackson <ian@anarres>
Wed, 27 Sep 2006 15:35:06 +0000 (16:35 +0100)
14 files changed:
Makefile
debian/control
settings.make [new file with mode: 0644]
xen/Makefile [new file with mode: 0644]
xen/README.config-processing [new file with mode: 0644]
xen/config
xen/default-config [new file with mode: 0644]
xen/example-config [new file with mode: 0644]
xen/fixups
xen/fixups-inside
xen/on-testbed
xen/setup
xen/tail-config [new file with mode: 0644]
xen/vif-common.sh [deleted symlink]

index cdb2c0cf9bf06a376b042cccbd9bd2415fbc7a8d..d747249dbdcef3ff1897b8a624e6caa4a45a2d81 100644 (file)
--- a/Makefile
+++ b/Makefile
 # See the file CREDITS for a full list of credits information (often
 # installed as /usr/share/doc/autopkgtest/CREDITS).
 
-prefix =       /usr/local
-share =                $(prefix)/share
-bindir =       $(prefix)/bin
-mandir =       $(share)/man
-man1dir =      $(mandir)/man1
-docdir =       $(share)/doc/autopkgtest
-
-INSTALL =              install
-INSTALL_DIRS =         $(INSTALL) -d
-INSTALL_PROGRAM =      $(INSTALL) -m 0755
-INSTALL_DOC =          $(INSTALL)
+include settings.make
 
 programs =     virt-chroot/adt-virt-chroot \
                runner/adt-run
@@ -41,4 +31,5 @@ install:
                $(INSTALL_PROGRAM) $$f $(bindir); \
                test ! -f $$f.1 || $(INSTALL_DOC) $$f.1 $(man1dir); \
                done
+       cd xen && $(MAKE) install
        $(INSTALL_DOC) CREDITS debian/changelog $(docdir)
index 863d5be5f148b7c8347a53ee29e4d74617f7e544..211ab21e89307ab3fcd3e47c4b52d7a5949eb17d 100644 (file)
@@ -18,3 +18,7 @@ Description: automatic as-installed testing for Debian packages
  and /usr/share/doc/autopkgtest.
  .
  Status: this release is still pretty much a proof of concept.
+
+Package: autopkgtest-xen
+Architecture: all
+Depends: pbuilder, libadns1-bin, chiark-utils-bin
diff --git a/settings.make b/settings.make
new file mode 100644 (file)
index 0000000..1a817cb
--- /dev/null
@@ -0,0 +1,12 @@
+prefix =       /usr/local
+share =                $(prefix)/share
+bindir =       $(prefix)/bin
+mandir =       $(share)/man
+man1dir =      $(mandir)/man1
+docdir =       $(share)/doc/autopkgtest
+
+INSTALL =              install
+INSTALL_DIRS =         $(INSTALL) -d
+INSTALL_PROGRAM =      $(INSTALL) -m 0755
+INSTALL_DOC =          $(INSTALL)
+
diff --git a/xen/Makefile b/xen/Makefile
new file mode 100644 (file)
index 0000000..73d2580
--- /dev/null
@@ -0,0 +1,34 @@
+# This file is part of autopkgtest
+# autopkgtest is a tool for testing Debian binary packages
+#
+# autopkgtest is Copyright (C) 2006 Canonical Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# See the file CREDITS for a full list of credits information (often
+# installed as /usr/share/doc/autopkgtest/CREDITS).
+
+include ../settings.make
+
+install:
+       
+
+       $(INSTALL_DIRS) -d $(bindir) $(docdir) $(man1dir)
+       set -e; for f in $(programs); do \
+               $(INSTALL_PROGRAM) $$f $(bindir); \
+               test ! -f $$f.1 || $(INSTALL_DOC) $$f.1 $(man1dir); \
+               done
+       cd xen && $(MAKE) install
+       $(INSTALL_DOC) CREDITS debian/changelog $(docdir)
diff --git a/xen/README.config-processing b/xen/README.config-processing
new file mode 100644 (file)
index 0000000..bf524e8
--- /dev/null
@@ -0,0 +1,5 @@
+1. read config-defaults
+2. process command line args
+3. read user config
+4. process command line args again
+5. process tail-config
index 61f000a86cde49b4a2ff250f43fb1f4091aaa81a..ef6c52e978cb378b88d05b900f6018ba81c9aeee 100644 (file)
@@ -6,46 +6,3 @@
 # /etc/default/adt-xen
 # /etc/init.d/adt-xen and links
 #----------
-
-#kernel=/boot/boot/vmlinuz-2.6-xen
-kernel=/boot/xen0-linux-2.6.16-1-686
-ramdisk=/boot/xen-initrd
-
-tbmem=256
-frzmem=32
-fssize=1G
-snapsize=100M
-cowchunk=8
-
-vg=glalonde
-#distro=dapper
-distro=edgy
-pbuilderopts='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early'
-domain=adt.relativity.greenend.org.uk
-sshkey=/root/.ssh/id_dsa_adt
-
-pfx=adt
-guesthname=$distro.$domain
-playbase=/var/lib/autopkgtest/xenlvm-play
-#hosthname=`hostname -f`
-hosthname=samual.relativity.greenend.org.uk
-xmname=${pfx}_${distro}
-
-play=${playbase}/${distro}
-
-nbase=${pfx}_${distro}_base
-lvbaserhs=$vg/$nbase
-lvbase=/dev/$lvbaserhs
-
-nsnap=${pfx}_${distro}_snap
-lvsnap=/dev/mapper/$nsnap
-
-ncowdata=${pfx}_${distro}_cowdata
-lvcowdatarhs=$vg/$ncowdata
-lvcowdata=/dev/$lvcowdatarhs
-
-lvfsptrrhs=${pfx}_fs/${distro}
-lvfsptr=/dev/$lvfsptrrhs
-xmdomain=$play/xmdomain
-
-guestaddr=`adnshost -t a +Do +Dt +Dc $guesthname`
diff --git a/xen/default-config b/xen/default-config
new file mode 100644 (file)
index 0000000..31e80c6
--- /dev/null
@@ -0,0 +1,10 @@
+tbmem=256
+frzmem=32
+fssize=1G
+snapsize=100M
+cowchunk=8
+
+adt_nominum=${adt_nominum}
+
+sshkey=/root/.ssh/id_dsa_${adt_nominum}
+playbase=/var/lib/autopkgtest/xenlvm-play
diff --git a/xen/example-config b/xen/example-config
new file mode 100644 (file)
index 0000000..b95bed0
--- /dev/null
@@ -0,0 +1,3 @@
+adt_pbuilderopts='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early'
+adt_guests_domain=.relativity.greenend.org.uk
+adt_host_hostname=samual.relativity.greenend.org.uk
index 55cb0699d16aefb2e15da814a76853e8c5b658a2..9c9c83dd438171ef0cf9e029481e9aea0c006454 100755 (executable)
@@ -2,11 +2,8 @@
 set -ex
 
 dest=$1
-hosthname=$2
-guesthname=$3; shift
-
-hostaddr=`adnshost -t a +Do +Dt +Dc $hosthname`
-guestaddr=`adnshost -t a +Do +Dt +Dc $guesthname`
+adt_host_hostname=$2
+adt_guest_hostname=$3; shift
 
 echo '---fixups:'
 
@@ -35,12 +32,12 @@ END
 chmod +x $dest/etc/init.d/xenethtoolk
 ln -s ../init.d/xenethtoolk $dest/etc/rc2.d/S21xenethtoolk
 
-chroot $dest root/fixups-inside "$@" "$hostaddr" "$guestaddr"
+chroot $dest root/fixups-inside "$@" "$adt_host_ipaddr" "$adt_guest_ipaddr"
 
 kh=/etc/ssh/ssh_known_hosts
 test ! -f $kh || cp $kh $kh.new
 exec 3>$kh.new
-pfx="$guesthname,$guestaddr"
+pfx="$adt_guest_hostname,$adt_guest_ipaddr"
 test ! -f $kh || perl -pe '$_="" if m/^(\S+)\s/ && $1 eq "'$pfx'";' $kh >&3
 for f in $dest/etc/ssh/ssh_host_*_key.pub; do
     perl -pe '$_= "'$pfx' ".$_;' $f >&3
index a4d4bf4ece9cd004ee4e6522419e44b6f864b478..4bee8d8cc8e8c0ee460d8a505c67a4d3be5efced 100755 (executable)
@@ -1,10 +1,10 @@
 #!/bin/sh
 set -ex
 
-hosthname=$1
-guesthname=$2
-hostaddr=$3
-guestaddr=$4
+adt_host_hostname=$1
+adt_guest_hostname=$2
+adt_host_ipaddr=$3
+adt_guest_ipaddr=$4
 
 echo '(---'
 
@@ -29,14 +29,14 @@ iface lo inet loopback
 
 auto eth0
 iface eth0 inet static
-       address $guestaddr
-       broadcast $guestaddr
+       address $adt_guest_ipaddr
+       broadcast $adt_guest_ipaddr
        netmask 255.255.255.255
-       pointopoint $hostaddr
-       gateway $hostaddr
+       pointopoint $adt_host_ipaddr
+       gateway $adt_host_ipaddr
 END
 
-echo $guesthname >/etc/hostname
+echo $adt_guest_hostname >/etc/hostname
 
 apt-get -y --force-yes install \
        openssh-server ed build-essential
index 7a34c8f438e3dee80df4e37f04425f43bb407142..59671504262dee7f9cdf730b9ebce20d9e642019 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/sh
 set -e
 . ./config
-ssh -i $sshkey $guestaddr "$@"
+ssh -i $sshkey $adt_guest_ipaddr "$@"
index 64c5403fcd7a05d90edee53694f1d5027845d9e3..b3c9b697decb433383b01128627e8f801cf5885d 100755 (executable)
--- a/xen/setup
+++ b/xen/setup
@@ -20,28 +20,28 @@ pbuilder create --configfile ./pbuilderrc --distribution $distro    \
        --no-targz --buildplace $play/base                              \
        $pbuilderopts   --debootstrapopts --variant=''
 
-./fixups $play/base $hosthname $guesthname
+./fixups $play/base $adt_host_hostname $adt_guest_hostname
 
 echo "
---- writing $xmdomain ---
+--- writing $adt_xmconfig ---
 "
 
-hostaddr=`adnshost -t a +Do +Dt +Dc $hosthname`
+adt_host_ipaddr=`adnshost -t a +Do +Dt +Dc $adt_host_hostname`
 
-cat <<END >$xmdomain
+cat <<END >$adt_xmconfig
 kernel = "$kernel"
 memory = $tbmem
 root = "/dev/hda1"
 extra = "ro console=tty0"
 disk = [ "phy:$lvfsptrrhs,hda1,w" ]
-vif = [ "bridge=none,mac=00:16:3e:7c:aa:7f,ip=$guestaddr,script=/etc/xen/scripts/vif-route-adt" ]
+vif = [ "bridge=none,mac=00:16:3e:7c:aa:7f,ip=$adt_guest_ipaddr,script=/etc/xen/scripts/vif-route-adt" ]
 on_crash = "preserve"
 on_reboot = "preserve"
 on_shutdown = "preserve"
 END
 
 if [ "x$ramdisk" != x ]; then
-cat <<END >>$xmdomain
+cat <<END >>$adt_xmconfig
 ramdisk = "$ramdisk"
 END
 fi
@@ -50,11 +50,11 @@ umount $lvbase
 
 mkdir -p /dev/${pfx}_fs
 ln -sf ../$lvbaserhs $lvfsptr
-xm create $xmdomain name=$xmname
+xm create $adt_xmconfig name=$xmname
 retries=10
 
 while true; do
-       if ping -c 1 $guestaddr && ./on-testbed id; then break; fi
+       if ping -c 1 $adt_guest_ipaddr && ./on-testbed id; then break; fi
        if [ $retries -le 0 ]; then 
                echo >&2 'no response from guest'
                xm console $xmname
diff --git a/xen/tail-config b/xen/tail-config
new file mode 100644 (file)
index 0000000..ea4acf8
--- /dev/null
@@ -0,0 +1,111 @@
+case "$adt_vg" in
+'')
+       echo "searching for default volume group ..."
+       vgdisplay_out=`vgdisplay -c`
+       case "$vgdisplay_out" in
+       "")     fail 'no volume groups found';;
+       *"
+"*)            fail 'several volume groups, config must specify which';;
+       esac
+       $adt_vg=${vgdisplay_out%%:*}
+       echo "system has one volume group, $adt_vg, using that."
+       ;;
+esac
+
+case "$adt_kernel" in
+'')
+       echo "searching for kernel ..."
+       for f in /boot/xen*"`uname -r`"; do
+               test -f "$f" || continue
+               test "x$adt_kernel" = x || \
+                       fail 'several kernels, config must specify which'
+               adt_kernel="$f"
+       done
+       echo "... using currently booted kernel $adt_kernel"
+       ;;
+esac
+
+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
+
+case "$adt_distro" in
+'')
+       echo "considering which distro to use ..."
+       test -f /etc/lsb-release || \
+               fail 'no /etc/lsb-version, config must specify adt_distro'
+       . /etc/lsb-release
+       $adt_distro=$DISTRIB_CODENAME
+       ;;
+esac
+
+hostname_from_ipaddr () {
+ eval '
+  if [ x"$adt_'$1'_hostname" = x ] && \
+     [ x"$adt_'$1'_ipaddr" != x ]; then
+   echo "finding '$1' hostname from IP address $adt_'$1'_ipaddr"
+   adt_'$1'_hostname=`adnshost -t ptr +Do +Dt +Dc -i $adt_'$1'_ipaddr`
+  fi
+ '
+}
+
+hostname_from_ipaddr guest
+hostname_from_ipaddr host
+
+if [ x"$adt_host_hostname" = x ]; then
+       echo "finding host hostname, supposely our own FQDN ..."
+       adt_host_hostname=`hostname -f`
+fi
+
+if [ x"$adt_guest_hostname" = x ]; then
+       case "$adt_guests_domain" in
+       '')     echo "guessing guest hostname from host hostname ..."
+ adt_guest_hostname=$adt_distro.$adt_nominum.${adt_host_hostname#*.} ;;
+       .*)     echo "setting guest hostname using distro and nominum ..."
+ adt_guest_hostname=$adt_distro.$adt_nominum$adt_guests_domain ;;
+       *)      echo "setting guest hostname using distro and domain ..."
+ adt_guest_hostname=$adt_distro.$adt_guests_domain ;;
+       esac
+fi
+
+ipaddr_from_hostname () {
+ eval '
+  if [ x"$adt_'$1'_ipaddr" = x ] && \
+     [ x"$adt_'$1'_hostname" != x ]; then
+   echo "finding '$1' IP address from hostname $adt_'$1'_hostname"
+   adt_'$1'_ipaddr=`adnshost -t a +Do +Dt +Dc -i - "$adt_'$1'_hostname"`
+  fi
+ '
+}
+
+ipaddr_from_hostname guest
+ipaddr_from_hostname host
+
+# SSH
+: ${adt_sshkey:=/root/.ssh/id_dsa_${adt_nominum}}
+
+# Xen
+: ${adt_xmname:=${adt_nominum}_${adt_distro}}
+
+# In-host-file-system playground
+: ${adt_play:=${adt_playbase}/${adt_distro}}
+: ${adt_xmconfig:=${adt_play}/xmconfig}
+
+# LVM
+: ${adt_nbase:=${adt_nominum}_${adt_distro}_base}
+: ${adt_lvbaserhs:=${adt_vg}/${adt_nbase}}
+: ${adt_lvbase:=/dev/${adt_lvbaserhs}}
+
+: ${adt_nsnap:=${adt_nominum}_${adt_distro}_snap}
+: ${adt_lvsnap:=/dev/mapper/${adt_nsnap}}
+
+: ${adt_ncowdata:=${adt_nominum}_${adt_distro}_cowdata}
+: ${adt_lvcowdatarhs:=${adt_vg}/${adt_ncowdata}}
+: ${adt_lvcowdata:=/dev/${adt_lvcowdatarhs}}
+
+: ${adt_lvfsptrrhs:=${adt_nominum}_fs/${adt_distro}}
+: ${adt_lvfsptr:=/dev/${adt_lvfsptrrhs}}
diff --git a/xen/vif-common.sh b/xen/vif-common.sh
deleted file mode 120000 (symlink)
index 044e402..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/etc/xen/scripts/vif-common.sh
\ No newline at end of file