Patchwork [4/4] initramfs-framework: fix bashism

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Aug. 2, 2013, 7:52 a.m.
Message ID <3fd702c18d4043a7bfd600e64655dce94d0f1064.1375429844.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/54967/
State Accepted
Commit ca365c603b72e29fa028d6e83a8ca42b1d115f1e
Headers show

Comments

Qi.Chen@windriver.com - Aug. 2, 2013, 7:52 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../initrdscripts/initramfs-framework/finish       |    5 +++--
 .../initrdscripts/initramfs-framework/init         |   13 +++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index bedd803..325f47b 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -16,8 +16,9 @@  finish_run() {
 		if [ -n "$bootparam_root" ]; then
 			debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..."
 
-			if [ "${bootparam_root:0:5}" = "UUID=" ]; then
-				bootparam_root="/dev/disk/by-uuid/${bootparam_root/UUID=/}"
+			if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then
+				root_uuid=`echo $bootparam_root | cut -c6-`
+				bootparam_root="/dev/disk/by-uuid/$root_uuid"
 			fi
 
 			if [ -e "$bootparam_root" ]; then
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
index 0be8f4d..20774aa 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -78,12 +78,13 @@  mount -t sysfs sysfs /sys
 
 # populate bootparam environment
 for p in `cat /proc/cmdline`; do
-	opt="${p%%=*}"
-	opt=${opt/-/_}
-	if [ "${p/=/}" = "$p" ]; then
+	opt=`echo $p | cut -d'=' -f1`
+	opt=`echo $opt | sed -e 's/-/_/'`
+	if [ "`echo $p | cut -d'=' -f1`" = "$p" ]; then
 		eval "bootparam_${opt}=true"
 	else
-		eval "bootparam_${opt}=\"${p#*=}\""
+		value="`echo $p | cut -d'=' -f2-`"
+		eval "bootparam_${opt}=\"${value}\""
 	fi
 done
 
@@ -102,7 +103,7 @@  mkdir $ROOTFS_DIR
 # Load and run modules
 for m in $MODULES_DIR/*; do
 	# Skip backup files
-	if [ "${m/\~/}" != "$m" ]; then
+	if [ "`echo $m | sed -e 's/\~$//'`" = "$m" ]; then
 		continue
 	fi
 
@@ -117,7 +118,7 @@  for m in $MODULES_DIR/*; do
 	done
 
 	# process module
-	source $m
+	. $m
 
 	if ! eval "${module}_enabled"; then
 		debug "Skipping module $module"