[OE-core] [PATCH 2/8] initscripts: add setup-commands.sh

Qi.Chen at windriver.com Qi.Chen at windriver.com
Sat Nov 9 05:28:52 UTC 2013


From: Chen Qi <qi.chen at windriver.com>

The purpose of this script is to set up commands that busybox provides
if /usr is missing. In this way, the system can still boot into single
user mode for recovery or repair if the /usr partition is broken.

For normal use case, that is, /usr is on the same partition as /, or
/usr is correctly mounted at boot time, this script has no real effect.

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 .../initscripts/initscripts-1.0/setup-commands.sh  |   24 ++++++++++++++++++++
 meta/recipes-core/initscripts/initscripts_1.0.bb   |    3 +++
 2 files changed, 27 insertions(+)
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/setup-commands.sh

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/setup-commands.sh b/meta/recipes-core/initscripts/initscripts-1.0/setup-commands.sh
new file mode 100644
index 0000000..5133780
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/setup-commands.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# set up necessary links to busybox if fundamental command from /usr
+# are not available.
+
+[ -e /etc/default/rcS ] && . /etc/default/rcS
+
+for dir in /usr/bin /usr/sbin; do
+    if [ ! -e $dir ]; then
+	if [ "$VERBOSE" != "no" ]; then
+	    echo "WARN: $dir missing, setting up links to busybox"
+	fi
+	mkdir -p $dir
+	for suffix in ".nosuid" ".suid" ""; do
+	    if [ ! -e /etc/busybox.links${suffix} ]; then
+		continue
+	    fi
+	    usr_commands=`grep "$dir" /etc/busybox.links${suffix}`
+	    for command in $usr_commands; do
+		ln -sf /bin/busybox${suffix} $command
+	    done
+	done
+    fi
+done
diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 2d58266..b3c898f 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -33,6 +33,7 @@ SRC_URI = "file://functions \
            file://GPLv2.patch \
            file://dmesg.sh \
            file://logrotate-dmesg.conf \
+           file://setup-commands.sh \
 "
 
 SRC_URI_append_arm = " file://alignment.sh"
@@ -93,6 +94,7 @@ do_install () {
 	install -m 0644    ${WORKDIR}/volatiles		${D}${sysconfdir}/default/volatiles/00_core
 	install -m 0755    ${WORKDIR}/dmesg.sh		${D}${sysconfdir}/init.d
 	install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
+	install -m 0755    ${WORKDIR}/setup-commands.sh	${D}${sysconfdir}/init.d
 
 	if [ "${TARGET_ARCH}" = "arm" ]; then
 		install -m 0755 ${WORKDIR}/alignment.sh	${D}${sysconfdir}/init.d
@@ -123,6 +125,7 @@ do_install () {
 	update-rc.d -r ${D} populate-volatile.sh start 37 S .
 	update-rc.d -r ${D} read-only-rootfs-hook.sh start 29 S .
 	update-rc.d -r ${D} devpts.sh start 38 S .
+	update-rc.d -r ${D} setup-commands.sh start 03 S .
 	if [ "${TARGET_ARCH}" = "arm" ]; then
 	        update-rc.d -r ${D} alignment.sh start 06 S .
 	fi
-- 
1.7.9.5




More information about the Openembedded-core mailing list