提交 153f0114 编写于 作者: J Jamey Sharp 提交者: Michal Marek

scripts/gen_initramfs_list.sh: Convert to a /bin/sh script

Replace bashisms with POSIX-compatible shell scripting.

Notably, de-duplicate '/' using a sed command from elsewhere in the same script
rather than "${name//\/\///}".

Commit by Jamey Sharp and Josh Triplett.
Signed-off-by: NJamey Sharp <jamey@minilop.net>
Signed-off-by: NJosh Triplett <josh@joshtriplett.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: NMichal Marek <mmarek@suse.cz>
上级 43f67c98
#!/bin/bash #!/bin/sh
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org> # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org> # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
# #
...@@ -105,9 +105,9 @@ list_parse() { ...@@ -105,9 +105,9 @@ list_parse() {
# for links, devices etc the format differs. See gen_init_cpio for details # for links, devices etc the format differs. See gen_init_cpio for details
parse() { parse() {
local location="$1" local location="$1"
local name="${location/${srcdir}//}" local name="/${location#${srcdir}}"
# change '//' into '/' # change '//' into '/'
name="${name//\/\///}" name=$(echo "$name" | sed -e 's://*:/:g')
local mode="$2" local mode="$2"
local uid="$3" local uid="$3"
local gid="$4" local gid="$4"
...@@ -117,8 +117,8 @@ parse() { ...@@ -117,8 +117,8 @@ parse() {
[ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
local str="${mode} ${uid} ${gid}" local str="${mode} ${uid} ${gid}"
[ "${ftype}" == "invalid" ] && return 0 [ "${ftype}" = "invalid" ] && return 0
[ "${location}" == "${srcdir}" ] && return 0 [ "${location}" = "${srcdir}" ] && return 0
case "${ftype}" in case "${ftype}" in
"file") "file")
...@@ -192,7 +192,7 @@ input_file() { ...@@ -192,7 +192,7 @@ input_file() {
if [ -f "$1" ]; then if [ -f "$1" ]; then
${dep_list}header "$1" ${dep_list}header "$1"
is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')"
if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then
cpio_file=$1 cpio_file=$1
echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed"
[ ! -z ${dep_list} ] && echo "$1" [ ! -z ${dep_list} ] && echo "$1"
...@@ -204,7 +204,7 @@ input_file() { ...@@ -204,7 +204,7 @@ input_file() {
else else
echo "$1 \\" echo "$1 \\"
cat "$1" | while read type dir file perm ; do cat "$1" | while read type dir file perm ; do
if [ "$type" == "file" ]; then if [ "$type" = "file" ]; then
echo "$file \\"; echo "$file \\";
fi fi
done done
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册