diff options
author | Samuel Ortiz <sameo@openedhand.com> | 2008-09-10 21:21:23 +0000 |
---|---|---|
committer | Samuel Ortiz <sameo@openedhand.com> | 2008-09-10 21:21:23 +0000 |
commit | 9bdc5a0129276ccb9c3458ddc2351c9db2f11a62 (patch) | |
tree | cf6032adb16262207a318898d88dd6a929dbb4ab /meta | |
parent | 71a2e0d41d783d79873052f7999a7b6f7b039d2d (diff) | |
download | poky-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
Diffstat (limited to 'meta')
-rw-r--r-- | meta/packages/initrdscripts/files/init-live.sh | 70 | ||||
-rw-r--r-- | meta/packages/initrdscripts/initramfs-live-boot_1.0.bb | 12 |
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 | |||
3 | ROOT_MOUNT="/rootfs/" | ||
4 | ROOT_IMAGE=rootfs.img | ||
5 | MOUNT="/bin/mount" | ||
6 | UMOUNT="/bin/umount" | ||
7 | |||
8 | early_setup() { | ||
9 | mkdir /proc | ||
10 | mount -t proc proc /proc | ||
11 | udevd --daemon | ||
12 | } | ||
13 | |||
14 | read_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 | |||
29 | boot_live_root() { | ||
30 | killall udevd | ||
31 | cd $ROOT_MOUNT | ||
32 | exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init | ||
33 | } | ||
34 | |||
35 | fatal() { | ||
36 | echo $1 >$CONSOLE | ||
37 | echo >$CONSOLE | ||
38 | exec sh | ||
39 | } | ||
40 | |||
41 | echo "Starting initramfs boot..." | ||
42 | early_setup | ||
43 | |||
44 | [ -z "$CONSOLE" ] && CONSOLE="/dev/console" | ||
45 | |||
46 | read_args | ||
47 | |||
48 | echo "Waiting for Live image to show up..." | ||
49 | while true | ||
50 | do | ||
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 | ||
60 | done | ||
61 | |||
62 | mkdir $ROOT_MOUNT | ||
63 | mknod /dev/loop0 b 7 0 | ||
64 | |||
65 | if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ROOT_IMAGE $ROOT_MOUNT | ||
66 | then | ||
67 | fatal "Couldnt mount rootfs image" | ||
68 | else | ||
69 | boot_live_root | ||
70 | fi | ||
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 @@ | |||
1 | DESCRIPTON = "A live image init script" | ||
2 | |||
3 | SRC_URI = "file://init-live.sh" | ||
4 | |||
5 | PR = "r0" | ||
6 | |||
7 | do_install() { | ||
8 | install -m 0755 ${WORKDIR}/init-live.sh ${D}/init | ||
9 | } | ||
10 | |||
11 | PACKAGE_ARCH = "all" | ||
12 | FILES_${PN} += " /init " | ||