From 3d700e6647bedae4e5a2dd71efa030422b4a8913 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 17:26:10 +0000 Subject: initrdscripts: module-initfs: Be silent on loading non-existent module. * Use -q for modprobe, and as that apparently doesn't help bitbake's modprobe, redirect output to /dev/null. --- packages/initrdscripts/files/10-initfs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 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 -- cgit v1.2.3 From cb561eb11cc765d2314c30bb861c9187315d9efc Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 17:29:37 +0000 Subject: initramfs-module-loopboot: Allow to use absolute path for loop file location. --- packages/initrdscripts/files/80-loopboot.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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" -- cgit v1.2.3 From efaf4ed8c1b358d20e3738bd4bac2701f5f7a56f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 17:31:23 +0000 Subject: initramfs-uniboot & modules: Bump PRs for latest changes. --- packages/initrdscripts/initramfs-module-initfs_1.0.bb | 2 +- packages/initrdscripts/initramfs-module-loop_1.0.bb | 4 ++-- packages/initrdscripts/initramfs-uniboot_0.2.bb | 11 ----------- packages/initrdscripts/initramfs-uniboot_1.0.bb | 11 +++++++++++ 4 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 packages/initrdscripts/initramfs-uniboot_0.2.bb create mode 100644 packages/initrdscripts/initramfs-uniboot_1.0.bb 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_0.2.bb deleted file mode 100644 index 46ba06ff9a..0000000000 --- a/packages/initrdscripts/initramfs-uniboot_0.2.bb +++ /dev/null @@ -1,11 +0,0 @@ -SRC_URI = "file://init.sh" -PR = "r1" -DESCRIPTON = "A modular initramfs init script system." -RDEPENDS = "busybox-static" -RRECOMMENDS = "kernel-module-uinput" - -do_install() { - install -m 0755 ${WORKDIR}/init.sh ${D}/init -} - -FILES_${PN} += " /init " diff --git a/packages/initrdscripts/initramfs-uniboot_1.0.bb b/packages/initrdscripts/initramfs-uniboot_1.0.bb new file mode 100644 index 0000000000..f8d9d76936 --- /dev/null +++ b/packages/initrdscripts/initramfs-uniboot_1.0.bb @@ -0,0 +1,11 @@ +SRC_URI = "file://init.sh" +PR = "r0" +DESCRIPTON = "A modular initramfs init script system." +RDEPENDS = "busybox-static" +RRECOMMENDS = "kernel-module-uinput" + +do_install() { + install -m 0755 ${WORKDIR}/init.sh ${D}/init +} + +FILES_${PN} += " /init " -- cgit v1.2.3 From 05bfd48554e5a46039a0b7370dae0deed6f0c2d6 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 17:34:24 +0000 Subject: initramfs-module-bootmenu: Interactive boot location selection for initramfs-uniboot. * For now, supports booting from ext2/ext3 partitions and from ext2/ext3 loopback images placed on vfat partition. --- packages/initrdscripts/files/30-bootmenu.sh | 154 +++++++++++++++++++++ .../initrdscripts/initramfs-module-bootmenu_1.0.bb | 11 ++ 2 files changed, 165 insertions(+) create mode 100644 packages/initrdscripts/files/30-bootmenu.sh create mode 100644 packages/initrdscripts/initramfs-module-bootmenu_1.0.bb 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/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/* " -- cgit v1.2.3