xen-create-image frobbing for deboostrap-commands
authorTao Ben Schardl <neboat@mit.edu>
Sun, 4 May 2008 07:52:53 +0000 (03:52 -0400)
committerTao Ben Schardl <neboat@mit.edu>
Sun, 4 May 2008 07:52:53 +0000 (03:52 -0400)
svn path=/trunk/packages/sipb-xen-guest-installer/; revision=496

partial/xen-create-image-mods/90-make-fstab [new file with mode: 0755]
partial/xen-create-image-mods/97-setup-grub [new file with mode: 0755]
partial/xen-create-image-mods/patches/inittab.patch [new file with mode: 0755]
partial/xen-create-image-mods/patches/menu.lst.patch [new file with mode: 0755]
partial/xen-create-image-mods/patches/update-grub.patch [new file with mode: 0755]

diff --git a/partial/xen-create-image-mods/90-make-fstab b/partial/xen-create-image-mods/90-make-fstab
new file mode 100755 (executable)
index 0000000..fca0527
--- /dev/null
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+#  This script is responsible for setting up /etc/fstab upon the
+# new instance.
+#
+#  This should be a simple job, but it is complicated by some of the
+# differences between filesystems - some root filesystems will require
+# the installation of new packages, and we have to handle that here.
+#
+# Steve
+# --
+# http://www.steve.org.uk/
+
+prefix=$1
+
+#
+#  Source our common functions
+#
+if [ -e /usr/lib/xen-tools/common.sh ]; then
+    . /usr/lib/xen-tools/common.sh
+else
+    . ./hooks/common.sh
+fi
+
+
+#
+# Log our start
+#
+logMessage Script $0 starting
+
+
+#
+# Make sure we use ide style device names if required
+#
+device=sda
+if [ "${ide}" ]; then
+    device=hda
+fi
+
+#
+#  Now we have the options we can create the fstab.
+#
+has_xfs=0
+has_reiserfs=0
+cat <<E_O_FSTAB > ${prefix}/etc/fstab
+# /etc/fstab: static file system information.
+#
+# <file system> <mount point>   <type>  <options>       <dump>  <pass>
+proc            /proc           proc    defaults        0       0
+E_O_FSTAB
+for part in `seq 1 ${NUMPARTITIONS}`; do
+    eval "PARTITION=\"\${PARTITION${part}}\""
+    OLDIFS="${IFS}"
+    IFS=:
+    x=0
+    for partdata in ${PARTITION}; do
+        eval "partdata${x}=\"${partdata}\""
+        x=$(( $x+1 ))
+    done
+    IFS="${OLDIFS}"
+    
+    case "${partdata2}" in
+        xfs)
+            has_xfs=1
+            ;;
+        reiserfs)
+            has_reiserfs=1
+            ;;
+    esac
+    
+    # This assumes a particular partition table for our ParaVM's (SIPB)
+    if [ "${partdata2}" = "swap" ]; then
+        echo "/dev/${device}2 none swap sw 0 0" >> ${prefix}/etc/fstab
+    else
+        echo "/dev/${device}1 ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab
+    fi
+done
+
+
+#
+#  Finally we can install any required packages for the given root
+# filesystem
+#
+if [ $has_xfs -eq 1 ]; then
+    installDebianPackage ${prefix} xfsprogs
+fi
+if [ $has_reiserfs -eq 1 ]; then
+    installDebianPackage ${prefix} reiserfsprogs
+fi
+
+
+#
+#  Log our finish
+#
+logMessage Script $0 finished
diff --git a/partial/xen-create-image-mods/97-setup-grub b/partial/xen-create-image-mods/97-setup-grub
new file mode 100755 (executable)
index 0000000..f01ebec
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+#  This script sets up the ParaVM to use pygrub
+#
+
+
+prefix=$1
+
+
+#
+#  Source our common functions
+#
+if [ -e /usr/lib/xen-tools/common.sh ]; then
+    . /usr/lib/xen-tools/common.sh
+else
+    . ./hooks/common.sh
+fi
+
+
+#
+# Log our start
+#
+logMessage Script $0 starting
+
+#
+# Install the xen kernel
+#
+installDebianPackage ${prefix} linux-image-xen-amd64
+
+#
+# Install grub package
+#
+installDebianPackage ${prefix} grub
+
+#
+# Make the /boot/grub directory
+#
+mkdir -p ${prefix}/boot/grub
+
+#
+# Patch update-grub to see xen kernels
+#
+patch -l ${prefix}/usr/sbin/update-grub </usr/lib/xen-tools/etch.d/patches/update-grub.patch
+
+#
+# Update Grub
+#
+chroot ${prefix} /usr/sbin/update-grub -y
+
+#
+# Patch Grub menu
+#
+patch -l ${prefix}/boot/grub/menu.lst </usr/lib/xen-tools/etch.d/patches/menu.lst.patch
+# --- menu.lst.orig2008-04-22 05:41:32.000000000 -0400
+# +++ menu.lst2008-04-22 05:42:15.000000000 -0400
+# @@ -59,7 +59,7 @@
+#  ## e.g. kopt=root=/dev/hda1 ro
+#  ##      kopt_2_6_8=root=/dev/hdc1 ro
+#  ##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
+# -# kopt=root=/dev/hda1 ro
+# +# kopt=root=/dev/hda1 ro console=ttyS0,9600,8n1
+#  ## default grub root device
+#  ## e.g. groot=(hd0,0)
+# EOF
+
+#
+# Patch inittab
+#
+patch -l ${prefix}/etc/inittab </usr/lib/xen-tools/etch.d/patches/inittab.patch
+# --- inittab.orig2008-04-22 05:42:50.000000000 -0400
+# +++ inittab2008-04-22 05:43:04.000000000 -0400
+# @@ -60,7 +60,7 @@
+#  # Example how to put a getty on a serial line (for a terminal)
+#  #
+# -#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
+# +T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
+#  #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
+#  # Example how to put a getty on a modem line.
+# EOF
+
+#
+# Log our finish
+#
+logMessage Script $0 finished
+
diff --git a/partial/xen-create-image-mods/patches/inittab.patch b/partial/xen-create-image-mods/patches/inittab.patch
new file mode 100755 (executable)
index 0000000..c44788e
--- /dev/null
@@ -0,0 +1,11 @@
+--- temp/etc/inittab   2008-05-04 02:48:09.000000000 -0400
++++ inittab    2008-05-04 02:52:09.000000000 -0400
+@@ -60,7 +60,7 @@
+ # Example how to put a getty on a serial line (for a terminal)
+ #
+-#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
++T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
+ #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
+ # Example how to put a getty on a modem line.
diff --git a/partial/xen-create-image-mods/patches/menu.lst.patch b/partial/xen-create-image-mods/patches/menu.lst.patch
new file mode 100755 (executable)
index 0000000..a25aeca
--- /dev/null
@@ -0,0 +1,11 @@
+--- temp/boot/grub/menu.lst    2008-05-04 03:17:31.000000000 -0400
++++ menu.lst   2008-05-04 03:19:09.000000000 -0400
+@@ -59,7 +59,7 @@
+ ## e.g. kopt=root=/dev/hda1 ro
+ ##      kopt_2_6_8=root=/dev/hdc1 ro
+ ##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
+-# kopt=root=/dev/hda1 ro
++# kopt=root=/dev/hda1 ro console=ttyS0,9600,8n1
+ ## default grub root device
+ ## e.g. groot=(hd0,0)
diff --git a/partial/xen-create-image-mods/patches/update-grub.patch b/partial/xen-create-image-mods/patches/update-grub.patch
new file mode 100755 (executable)
index 0000000..02f2aa1
--- /dev/null
@@ -0,0 +1,16 @@
+--- update-grub.orig   2008-05-03 23:30:37.000000000 -0400
++++ update-grub        2008-05-03 23:30:55.000000000 -0400
+@@ -911,13 +911,6 @@
+               is_xen=
+       fi
+-      if [ ! "$in_domU" ] && [ "$is_xen" ]; then
+-        # skip xen kernels
+-          continue
+-        elif [ "$in_domU" ] && ! [ "$is_xen" ]; then
+-        # skip non-xen kernels
+-        continue
+-        fi
+         kern="/boot/$kern"
+       newerKernels=""
+       for i in $sortedKernels ; do