Skip to content

Commit

Permalink
scripts/gen_initramfs_list.sh: Convert to a /bin/sh script
Browse files Browse the repository at this point in the history
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: Jamey Sharp <[email protected]>
Signed-off-by: Josh Triplett <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
jameysharp authored and michal42 committed May 12, 2011
1 parent 43f67c9 commit 153f011
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/gen_initramfs_list.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Copyright (C) Martin Schlemmer <[email protected]>
# Copyright (C) 2006 Sam Ravnborg <[email protected]>
#
Expand Down Expand Up @@ -105,9 +105,9 @@ list_parse() {
# for links, devices etc the format differs. See gen_init_cpio for details
parse() {
local location="$1"
local name="${location/${srcdir}//}"
local name="/${location#${srcdir}}"
# change '//' into '/'
name="${name//\/\///}"
name=$(echo "$name" | sed -e 's://*:/:g')
local mode="$2"
local uid="$3"
local gid="$4"
Expand All @@ -117,8 +117,8 @@ parse() {
[ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
local str="${mode} ${uid} ${gid}"

[ "${ftype}" == "invalid" ] && return 0
[ "${location}" == "${srcdir}" ] && return 0
[ "${ftype}" = "invalid" ] && return 0
[ "${location}" = "${srcdir}" ] && return 0

case "${ftype}" in
"file")
Expand Down Expand Up @@ -192,7 +192,7 @@ input_file() {
if [ -f "$1" ]; then
${dep_list}header "$1"
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
echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed"
[ ! -z ${dep_list} ] && echo "$1"
Expand All @@ -204,7 +204,7 @@ input_file() {
else
echo "$1 \\"
cat "$1" | while read type dir file perm ; do
if [ "$type" == "file" ]; then
if [ "$type" = "file" ]; then
echo "$file \\";
fi
done
Expand Down

0 comments on commit 153f011

Please sign in to comment.