summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@openedhand.com>2008-09-10 21:21:23 +0000
committerSamuel Ortiz <sameo@openedhand.com>2008-09-10 21:21:23 +0000
commit9bdc5a0129276ccb9c3458ddc2351c9db2f11a62 (patch)
treecf6032adb16262207a318898d88dd6a929dbb4ab
parent71a2e0d41d783d79873052f7999a7b6f7b039d2d (diff)
downloadpoky-9bdc5a0129276ccb9c3458ddc2351c9db2f11a62.tar.gz
initrdscripts: Simple init files for initrd/initramfs images
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5173 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r--meta/packages/initrdscripts/files/init-live.sh70
-rw-r--r--meta/packages/initrdscripts/initramfs-live-boot_1.0.bb12
2 files changed, 82 insertions, 0 deletions
diff --git a/meta/packages/initrdscripts/files/init-live.sh b/meta/packages/initrdscripts/files/init-live.sh
new file mode 100644
index 0000000000..e081d44dd0
--- /dev/null
+++ b/meta/packages/initrdscripts/files/init-live.sh
@@ -0,0 +1,70 @@
1#!/bin/sh
2
3ROOT_MOUNT="/rootfs/"
4ROOT_IMAGE=rootfs.img
5MOUNT="/bin/mount"
6UMOUNT="/bin/umount"
7
8early_setup() {
9 mkdir /proc
10 mount -t proc proc /proc
11 udevd --daemon
12}
13
14read_args() {
15 [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline`
16 for arg in $CMDLINE; do
17 optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
18 case $arg in
19 root=*)
20 ROOT_DEVICE=$optarg ;;
21 rootfstype=*)
22 ROOT_FSTYPE=$optarg ;;
23 rootdelay=*)
24 rootdelay=$optarg ;;
25 esac
26 done
27}
28
29boot_live_root() {
30 killall udevd
31 cd $ROOT_MOUNT
32 exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init
33}
34
35fatal() {
36 echo $1 >$CONSOLE
37 echo >$CONSOLE
38 exec sh
39}
40
41echo "Starting initramfs boot..."
42early_setup
43
44[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
45
46read_args
47
48echo "Waiting for Live image to show up..."
49while true
50do
51 for i in `ls /media 2>/dev/null`; do
52 if [ -f /media/$i/$ROOT_IMAGE ] ; then
53 found="yes"
54 fi
55 done
56 if [ "$found" = "yes" ]; then
57 break;
58 fi
59 sleep 1
60done
61
62mkdir $ROOT_MOUNT
63mknod /dev/loop0 b 7 0
64
65if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ROOT_IMAGE $ROOT_MOUNT
66then
67 fatal "Couldnt mount rootfs image"
68else
69 boot_live_root
70fi
diff --git a/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb b/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb
new file mode 100644
index 0000000000..0ca962f03e
--- /dev/null
+++ b/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb
@@ -0,0 +1,12 @@
1DESCRIPTON = "A live image init script"
2
3SRC_URI = "file://init-live.sh"
4
5PR = "r0"
6
7do_install() {
8 install -m 0755 ${WORKDIR}/init-live.sh ${D}/init
9}
10
11PACKAGE_ARCH = "all"
12FILES_${PN} += " /init "