summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pmiscml@gmail.com>2007-11-22 17:55:24 +0000
committerPaul Sokolovsky <pmiscml@gmail.com>2007-11-22 17:55:24 +0000
commit4c61b72bdc3280fd0bf6289db187e21b4377fec3 (patch)
tree163ad2c595389afebcea44f5a275c39ed72cc073
parentfaa9fb3f06813ac8cdcd14da28ae9463fe0ad68a (diff)
parent05bfd48554e5a46039a0b7370dae0deed6f0c2d6 (diff)
merge of '1caa2b8988bc7d01766f1668314bf16b821b2ff6'
and 'b4fb0e02c0de82a5593a04d6a92a465545d17e15'
-rw-r--r--packages/initrdscripts/files/10-initfs.sh6
-rw-r--r--packages/initrdscripts/files/30-bootmenu.sh154
-rw-r--r--packages/initrdscripts/files/80-loopboot.sh3
-rw-r--r--packages/initrdscripts/initramfs-module-bootmenu_1.0.bb11
-rw-r--r--packages/initrdscripts/initramfs-module-initfs_1.0.bb2
-rw-r--r--packages/initrdscripts/initramfs-module-loop_1.0.bb4
-rw-r--r--packages/initrdscripts/initramfs-uniboot_1.0.bb (renamed from packages/initrdscripts/initramfs-uniboot_0.2.bb)2
7 files changed, 173 insertions, 9 deletions
diff --git a/packages/initrdscripts/files/10-initfs.sh b/packages/initrdscripts/files/10-initfs.sh
index b336af6bbb..bad649e5c2 100644
--- a/packages/initrdscripts/files/10-initfs.sh
+++ b/packages/initrdscripts/files/10-initfs.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-modprobe vfat
-modprobe ext2
-modprobe ext3
+modprobe -q vfat >/dev/null 2>&1
+modprobe -q ext2 >/dev/null 2>&1
+modprobe -q ext3 >/dev/null 2>&1
diff --git a/packages/initrdscripts/files/30-bootmenu.sh b/packages/initrdscripts/files/30-bootmenu.sh
new file mode 100644
index 0000000000..5b3e7782f4
--- /dev/null
+++ b/packages/initrdscripts/files/30-bootmenu.sh
@@ -0,0 +1,154 @@
+# If root is explicitly specified, skip interactive selection
+if [ -z "$ROOT_DEVICE" ]; then
+##############################
+
+E="\033["
+MOUNTLOC="tmp"
+LOOP_IMG_MASK='*.img'
+
+if ! (echo " " | read -n1 foo) >/dev/null 2>&1; then
+ echo "'read' command lacks -n switch support, aborting"
+ exit 1
+fi
+
+mkdir -p $MOUNTLOC
+
+list=""
+
+add_menu_item()
+{
+ if [ -n "$list" ]; then
+ list="$list\n"
+ fi
+
+ list="$list$1"
+}
+
+show_menu() {
+ echo -e -n "${E}3;0H"
+ cnt=0
+ echo -e $list | \
+ while read l; do
+ if [ $cnt == $num ]; then
+ echo -e -n "${E}1m"
+ fi
+ echo -e "$cnt: $l${E}0m"
+ cnt=$((cnt + 1))
+ done
+}
+
+get_menu_selection()
+{
+ cnt=0
+ sel=`echo -e $list | \
+ while read l; do
+ if [ $cnt == $num ]; then
+ echo $l
+ break
+ fi
+ cnt=$((cnt + 1))
+ done`
+}
+
+get_partition_type()
+{
+ fstype=`mount -f --guess-fstype /dev/$dev $MOUNTLOC`
+}
+
+scan_for_loopimgs()
+{
+# Scan a device for loopback images, add to the list if found
+ mount /dev/$dev $MOUNTLOC
+ p=$PWD
+ cd $MOUNTLOC
+ for img in `ls -1 $LOOP_IMG_MASK 2>/dev/null`; do
+ add_menu_item "$dev/$img (loop img on vfat)"
+ done
+ cd $p
+ umount $MOUNTLOC
+}
+
+# Scan all available device/partitions
+while read maj min nblk dev; do
+ if [ -z "$maj" -o "$maj" == "major" ]; then
+ continue;
+ fi
+
+ get_partition_type
+ if [ "$fstype" != "ext2" -a "$fstype" != "ext3" -a "$fstype" != "vfat" ]; then
+# continue
+ true
+ fi
+
+ if [ "$fstype" == "vfat" ]; then
+ scan_for_loopimgs
+ continue
+ fi
+
+ add_menu_item "$dev ($fstype)"
+done < /proc/partitions
+
+add_menu_item "NFS (nfsroot=192.168.2.200:/nfs/image)"
+
+total=`echo -e $list | wc -l`
+num=0
+
+# Draw UI
+stty -echo
+echo -e -n "${E}2J"
+echo -e -n "${E}0;0H"
+echo "Select boot image:"
+
+# Main loop
+show_menu
+while read -n1 i; do
+ case "$i" in
+ "A")
+ num=$((num - 1))
+ if [ $num -lt 0 ]; then
+ num=$(($total - 1))
+ fi
+ ;;
+ ["B"-"Z"])
+ num=$((num + 1))
+ if [ $num -ge $total ]; then
+ num=0
+ fi
+ ;;
+ "q")
+ exec sh
+ ;;
+ "")
+ break
+ ;;
+ esac
+ show_menu
+# echo "*$esc$i"
+done
+
+stty echo
+
+# Process results of user selection, prepare input arguments
+# for boot modules
+
+get_menu_selection
+echo Selected: $sel
+
+dev=`expr "$sel" : '\([^ /]*\)'`
+path=`expr "$sel" : '[^/]*\([^ ]*\).*'`
+
+if [ "$dev" == "NFS" ]; then
+ ROOT_DEVICE="/dev/nfs"
+ CMDLINE="$CMDLINE nfsroot=192.168.2.200:/nfs/image"
+elif [ -n "$path" ]; then
+ ROOT_DEVICE="/dev/loop"
+ CMDLINE="looproot=/dev/$dev:$path"
+else
+ ROOT_DEVICE="/dev/$dev"
+fi
+
+echo ROOT_DEVICE=$ROOT_DEVICE
+echo CMDLINE=$CMDLINE
+
+##############################
+fi
diff --git a/packages/initrdscripts/files/80-loopboot.sh b/packages/initrdscripts/files/80-loopboot.sh
index 7fbf69a202..d84244428e 100644
--- a/packages/initrdscripts/files/80-loopboot.sh
+++ b/packages/initrdscripts/files/80-loopboot.sh
@@ -21,11 +21,10 @@ if [ "$ROOT_DEVICE" = "/dev/loop" ]; then
echo "Mounting $dev on $hostpt"
mkdir $hostpt
mount $dev $hostpt
- cd $hostpt
fi
echo "Loopback setup of $path (offset $offset)"
- losetup -o "$offset" "$loopdev" "$path"
+ losetup -o "$offset" "$loopdev" "$hostpt/$path"
echo "Mounting $loopdev on $mountpt"
mkdir "$mountpt"
diff --git a/packages/initrdscripts/initramfs-module-bootmenu_1.0.bb b/packages/initrdscripts/initramfs-module-bootmenu_1.0.bb
new file mode 100644
index 0000000000..3fc8647f6c
--- /dev/null
+++ b/packages/initrdscripts/initramfs-module-bootmenu_1.0.bb
@@ -0,0 +1,11 @@
+SRC_URI = "file://30-bootmenu.sh"
+PR = "r1"
+RDEPENDS = "util-linux-mount initramfs-uniboot initramfs-module-block initramfs-module-loop"
+DESCRIPTION = "An initramfs module with UI for selection of boot device."
+
+do_install() {
+ install -d ${D}/initrd.d
+ install -m 0755 ${WORKDIR}/30-bootmenu.sh ${D}/initrd.d/
+}
+
+FILES_${PN} += " /initrd.d/* "
diff --git a/packages/initrdscripts/initramfs-module-initfs_1.0.bb b/packages/initrdscripts/initramfs-module-initfs_1.0.bb
index f085dcd0bc..48ae6c2160 100644
--- a/packages/initrdscripts/initramfs-module-initfs_1.0.bb
+++ b/packages/initrdscripts/initramfs-module-initfs_1.0.bb
@@ -1,5 +1,5 @@
SRC_URI = "file://10-initfs.sh"
-PR = "r0"
+PR = "r1"
DESCRIPTION = "An initramfs module for initializing filesystems."
RDEPENDS = "initramfs-uniboot"
RRECOMMENDS = "kernel-module-vfat kernel-module-ext2"
diff --git a/packages/initrdscripts/initramfs-module-loop_1.0.bb b/packages/initrdscripts/initramfs-module-loop_1.0.bb
index 54e7fa29e3..5cc84bcaf8 100644
--- a/packages/initrdscripts/initramfs-module-loop_1.0.bb
+++ b/packages/initrdscripts/initramfs-module-loop_1.0.bb
@@ -1,8 +1,8 @@
SRC_URI = "file://80-loopboot.sh"
-PR = "r0"
+PR = "r1"
DESCRIPTION = "An initramfs module for booting a filesystem image by loopback \
mounting it."
-RDEPENDS = "initramfs-uniboot"
+RDEPENDS = "initramfs-uniboot initramfs-module-initfs"
RRECOMMENDS = "kernel-module-loop kernel-module-vfat"
do_install() {
diff --git a/packages/initrdscripts/initramfs-uniboot_0.2.bb b/packages/initrdscripts/initramfs-uniboot_1.0.bb
index 46ba06ff9a..f8d9d76936 100644
--- a/packages/initrdscripts/initramfs-uniboot_0.2.bb
+++ b/packages/initrdscripts/initramfs-uniboot_1.0.bb
@@ -1,5 +1,5 @@
SRC_URI = "file://init.sh"
-PR = "r1"
+PR = "r0"
DESCRIPTON = "A modular initramfs init script system."
RDEPENDS = "busybox-static"
RRECOMMENDS = "kernel-module-uinput"