[harmonize-boot-options
timo.lindfors@iki.fi**20080202144454
 Harmomize names of ramroot boot options:
 ramroot_uuid
 ramroot_snapshot
 ramroot_fs
 ramroot_jffs2size
 
 For simplicity add all options starting with "ramroot_" are to environment.
 
 Make size of jffs2 configurable (ramroot_jffs2size)
 
 Move commands that generate snapshot/0/boot/grub/menu.lst to one place
 (create-flash-image)
 
 Prepare to support also tmpfs
 
 Rename etc/ramroot/last-boot-uuid to etc/ramroot/boot-info with variables
 boot_uuid and boot_snapshot
 
] {
hunk ./configure-initial-snapshot 21
-sudo mkdir -p fs/snapshot/0/boot/grub
-echo y | sudo chroot fs/snapshot/0 update-grub
-sudo sed -i s@/boot@/snapshot/0/boot@ fs/snapshot/0/boot/grub/menu.lst
-sudo sed -i '/^kernel/s@ro $@ro snapshot=0 @' fs/snapshot/0/boot/grub/menu.lst
-
hunk ./create-flash-image 32
-rootuuid="`uuidgen`"
-sudo tune2fs -U $rootuuid "${loopdev}"
+ramroot_uuid="`uuidgen`"
+sudo tune2fs -U $ramroot_uuid "${loopdev}"
hunk ./create-flash-image 35
-sudo sed -i "/^kernel/s@ro snapshot@ro rootuuid=${rootuuid} snapshot@" fs/snapshot/0/boot/grub/menu.lst
+
+sudo mkdir -p fs/snapshot/0/boot/grub
+echo y | sudo chroot fs/snapshot/0 update-grub
+sudo sed -i s@/boot@/snapshot/0/boot@ fs/snapshot/0/boot/grub/menu.lst
+sudo sed -i "/^kernel/s@ro \$@ro ramroot_uuid=${ramroot_uuid} ramroot_snapshot=0 ramroot_fs=jffs2 ramroot_jffs2size=90000 @" fs/snapshot/0/boot/grub/menu.lst
hunk ./scripts/local-bottom 3
-prereqs)
+    prereqs)
hunk ./scripts/local-bottom 8
-
hunk ./scripts/local-bottom 10
-snapshot=""
-rootuuid=""
-for x in $(cat /proc/cmdline); do
-    case $x in
-	snapshot=*)
-	    snapshot=${x#snapshot=}
-	    ;;
-	rootuuid=*)
-	    rootuuid=${x#rootuuid=}
-	    ;;
-    esac
-done
-
-if [ "${snapshot}" = "" ]; then
-    echo "no snapshot parameter given! dropping to shell"
-    /bin/sh
-    . /conf/param.conf
-fi
-
-if [ "${rootuuid}" = "" ]; then
-    echo "no rootuuid parameter given! dropping to shell"
-    /bin/sh
-    . /conf/param.conf
-fi
-
hunk ./scripts/local-bottom 11
-while ! mount -n /dev/disk/by-uuid/${rootuuid} /fs; do
+while ! mount -n /dev/disk/by-uuid/${ramroot_uuid} /fs; do
hunk ./scripts/local-bottom 13
-    echo "== Waiting for ${rootuuid}"
+    echo "== Waiting for ${ramroot_uuid}"
hunk ./scripts/local-bottom 16
-
-echo "snapshot=$snapshot"
-cp -a /fs/snapshot/${snapshot}/* ${rootmnt}
-echo "last_boot_uuid=${rootuuid}" > ${rootmnt}/etc/ramroot/last-boot-uuid
+cp -a /fs/snapshot/${ramroot_snapshot}/* ${rootmnt}
+echo "boot_uuid=${ramroot_uuid}" > ${rootmnt}/etc/ramroot/boot-info
+echo "boot_snapshot=${ramroot_snapshot}" >> ${rootmnt}/etc/ramroot/boot-info
hunk ./scripts/local-bottom 21
+#/bin/sh
hunk ./scripts/local-premount 3
-prereqs)
+    prereqs)
hunk ./scripts/local-premount 10
-echo FSTYPE=jffs2 > /conf/param.conf
-echo ROOTFLAGS="" >> /conf/param.conf
-echo ROOT=/dev/mtdblock0 >> /conf/param.conf
-echo readonly=n >> /conf/param.conf
-rmmod mtdram
-modprobe mtdram total_size=90000 erase_size=128
-modprobe mtdblock
+echo > /conf/param.conf
+if [ "$ramroot_fs" = "jffs2" ]; then
+    echo FSTYPE=jffs2 > /conf/param.conf
+    echo ROOTFLAGS="" >> /conf/param.conf
+    echo ROOT=/dev/mtdblock0 >> /conf/param.conf
+    echo readonly=n >> /conf/param.conf
+    rmmod mtdram
+    modprobe mtdram total_size=$ramroot_jffs2size erase_size=128
+    modprobe mtdblock
+fi
+#/bin/sh
hunk ./scripts/local-top 3
-prereqs)
+    prereqs)
hunk ./scripts/local-top 10
-echo ROOT=/dev/mtdblock0 > /conf/param.conf
-
+echo > /conf/param.conf
+for x in $(cat /proc/cmdline); do
+    case $x in
+	ramroot_*=*)
+	    echo "$x" >> /conf/param.conf
+	    ;;
+    esac
+done
+echo ROOT=/dev/null >> /conf/param.conf
+#/bin/sh
hunk ./scripts/ramroot-snapshot 14
-. /etc/ramroot/last-boot-uuid
-if [ "${last_boot_uuid}" = "" ]; then
-    echo "/etc/ramroot/last-boot-uuid empty?"
-    cleanup
-fi
+. /etc/ramroot/boot-info
hunk ./scripts/ramroot-snapshot 18
-mount -n -U "${last_boot_uuid}" /flash
+mount -n -U "${boot_uuid}" /flash
hunk ./scripts/ramroot-snapshot 30
-sed -i "s@snapshot=[0-9]*@snapshot=${new}@" /flash/snapshot/${new}/boot/grub/menu.lst
+sed -i "s@ramroot_snapshot=[0-9]*@ramroot_snapshot=${new}@" /flash/snapshot/${new}/boot/grub/menu.lst
hunk ./scripts/ramroot-update-grub 11
-. /etc/ramroot/last-boot-uuid
-if [ "${last_boot_uuid}" = "" ]; then
-    echo "/etc/ramroot/last-boot-uuid empty?"
-    cleanup
-fi
-mount -n -U "${last_boot_uuid}" /flash
+. /etc/ramroot/boot-info
+mount -n -U "${boot_uuid}" /flash
}
