summaryrefslogtreecommitdiff
path: root/packages/initrdscripts
diff options
context:
space:
mode:
authorHenning Heinold <heinold@inf.fu-berlin.de>2007-11-22 21:15:54 +0000
committerHenning Heinold <heinold@inf.fu-berlin.de>2007-11-22 21:15:54 +0000
commit255eeb9dd1af98857dc30631076bb4fae8da4e0c (patch)
tree2ef554292cd385de37e31f131be8a5ea0d7013fb /packages/initrdscripts
parentf49bb749b59a2a7bfc9105866019133831bed05c (diff)
parent2f0728d421371638542518906a4ab639198790dc (diff)
merge of '01a1687d6a3a1aa8b8ba912066a682526987fd4f'
and '74f9f9386f21c9cc7120b518b57aa3e7dee84477'
Diffstat (limited to 'packages/initrdscripts')
-rw-r--r--packages/initrdscripts/files/10-initfs.sh5
-rw-r--r--packages/initrdscripts/files/30-bootmenu.sh154
-rw-r--r--packages/initrdscripts/files/80-loopboot.sh (renamed from packages/initrdscripts/files/loopboot.sh)4
-rw-r--r--packages/initrdscripts/files/80-nfsboot.sh (renamed from packages/initrdscripts/files/nfsboot.sh)0
-rw-r--r--packages/initrdscripts/files/85-blockboot.sh (renamed from packages/initrdscripts/files/blockboot.sh)0
-rw-r--r--packages/initrdscripts/files/init.sh10
-rw-r--r--packages/initrdscripts/initramfs-module-block_1.0.bb (renamed from packages/initrdscripts/initramfs-module-block_0.1.bb)8
-rw-r--r--packages/initrdscripts/initramfs-module-bootmenu_1.0.bb11
-rw-r--r--packages/initrdscripts/initramfs-module-initfs_1.0.bb12
-rw-r--r--packages/initrdscripts/initramfs-module-loop_1.0.bb (renamed from packages/initrdscripts/initramfs-module-loop_0.1.bb)10
-rw-r--r--packages/initrdscripts/initramfs-module-nfs_1.0.bb (renamed from packages/initrdscripts/initramfs-module-nfs_0.1.bb)6
-rw-r--r--packages/initrdscripts/initramfs-uniboot_1.0.bb (renamed from packages/initrdscripts/initramfs-uniboot_0.2.bb)2
12 files changed, 204 insertions, 18 deletions
diff --git a/packages/initrdscripts/files/10-initfs.sh b/packages/initrdscripts/files/10-initfs.sh
new file mode 100644
index 0000000000..bad649e5c2
--- /dev/null
+++ b/packages/initrdscripts/files/10-initfs.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+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/loopboot.sh b/packages/initrdscripts/files/80-loopboot.sh
index 55a1948db8..d84244428e 100644
--- a/packages/initrdscripts/files/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"
@@ -35,7 +34,6 @@ if [ "$ROOT_DEVICE" = "/dev/loop" ]; then
loop_num=`expr "$loop_num" + 1`
}
- modprobe vfat
modprobe loop
loop_num=0
diff --git a/packages/initrdscripts/files/nfsboot.sh b/packages/initrdscripts/files/80-nfsboot.sh
index 5129a53ebb..5129a53ebb 100644
--- a/packages/initrdscripts/files/nfsboot.sh
+++ b/packages/initrdscripts/files/80-nfsboot.sh
diff --git a/packages/initrdscripts/files/blockboot.sh b/packages/initrdscripts/files/85-blockboot.sh
index 567f7e29b3..567f7e29b3 100644
--- a/packages/initrdscripts/files/blockboot.sh
+++ b/packages/initrdscripts/files/85-blockboot.sh
diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh
index 8c9803f21b..f8d5de9173 100644
--- a/packages/initrdscripts/files/init.sh
+++ b/packages/initrdscripts/files/init.sh
@@ -2,14 +2,17 @@
MODULE_DIR=/initrd.d
BOOT_ROOT=
-ROOT_DEVICE=/dev/null
+ROOT_DEVICE=
early_setup() {
mkdir /proc
mount -t proc proc /proc
mkdir /mnt
+}
- echo -n "creating device nodes: "
+dev_setup()
+{
+ echo -n "initramfs: Creating device nodes: "
grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev
do
if [ ! -e /dev/$dev ]; then
@@ -35,6 +38,7 @@ read_args() {
load_modules() {
for module in $MODULE_DIR/*; do
+ echo "initramfs: Loading $module module"
source $module
done
}
@@ -60,6 +64,8 @@ if [ -n "$rootdelay" ]; then
sleep $rootdelay
fi
+dev_setup
+
load_modules
[ -n "$BOOT_ROOT" ] && boot_root
boot_failed
diff --git a/packages/initrdscripts/initramfs-module-block_0.1.bb b/packages/initrdscripts/initramfs-module-block_1.0.bb
index a0cb2fd7fa..73f7a709f1 100644
--- a/packages/initrdscripts/initramfs-module-block_0.1.bb
+++ b/packages/initrdscripts/initramfs-module-block_1.0.bb
@@ -1,11 +1,11 @@
-SRC_URI = "file://blockboot.sh"
-PR = "r2"
+SRC_URI = "file://85-blockboot.sh"
+PR = "r0"
RDEPENDS = "initramfs-uniboot"
DESCRIPTION = "An initramfs module for booting off normal block devices."
do_install() {
install -d ${D}/initrd.d
- install -m 0755 ${WORKDIR}/blockboot.sh ${D}/initrd.d/block
+ install -m 0755 ${WORKDIR}/85-blockboot.sh ${D}/initrd.d/
}
-FILES_${PN} += " /initrd.d/block "
+FILES_${PN} += " /initrd.d/* "
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
new file mode 100644
index 0000000000..48ae6c2160
--- /dev/null
+++ b/packages/initrdscripts/initramfs-module-initfs_1.0.bb
@@ -0,0 +1,12 @@
+SRC_URI = "file://10-initfs.sh"
+PR = "r1"
+DESCRIPTION = "An initramfs module for initializing filesystems."
+RDEPENDS = "initramfs-uniboot"
+RRECOMMENDS = "kernel-module-vfat kernel-module-ext2"
+
+do_install() {
+ install -d ${D}/initrd.d
+ install -m 0755 ${WORKDIR}/10-initfs.sh ${D}/initrd.d/
+}
+
+FILES_${PN} += " /initrd.d/* "
diff --git a/packages/initrdscripts/initramfs-module-loop_0.1.bb b/packages/initrdscripts/initramfs-module-loop_1.0.bb
index d4e5aa038f..5cc84bcaf8 100644
--- a/packages/initrdscripts/initramfs-module-loop_0.1.bb
+++ b/packages/initrdscripts/initramfs-module-loop_1.0.bb
@@ -1,13 +1,13 @@
-SRC_URI = "file://loopboot.sh"
-PR = "r3"
+SRC_URI = "file://80-loopboot.sh"
+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() {
install -d ${D}/initrd.d
- install -m 0755 ${WORKDIR}/loopboot.sh ${D}/initrd.d/loop
+ install -m 0755 ${WORKDIR}/80-loopboot.sh ${D}/initrd.d/
}
-FILES_${PN} += " /initrd.d/loop "
+FILES_${PN} += " /initrd.d/* "
diff --git a/packages/initrdscripts/initramfs-module-nfs_0.1.bb b/packages/initrdscripts/initramfs-module-nfs_1.0.bb
index 24284d6c5f..6555688fce 100644
--- a/packages/initrdscripts/initramfs-module-nfs_0.1.bb
+++ b/packages/initrdscripts/initramfs-module-nfs_1.0.bb
@@ -1,12 +1,12 @@
-SRC_URI = "file://nfsboot.sh"
-PR = "r4"
+SRC_URI = "file://80-nfsboot.sh"
+PR = "r0"
DESCRIPTION = "An initramfs module for booting via NFS."
RDEPENDS = "initramfs-uniboot"
RRECOMMENDS = "kernel-module-g-ether kernel-module-nfs"
do_install() {
install -d ${D}/initrd.d
- install -m 0755 ${WORKDIR}/nfsboot.sh ${D}/initrd.d/nfs
+ install -m 0755 ${WORKDIR}/80-nfsboot.sh ${D}/initrd.d/
}
FILES_${PN} += " /initrd.d/nfs "
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"