Patchwork [1/1] e2fsprogs/populate-extfs.sh: fix a problem on dash

login
register
mail settings
Submitter Robert Yang
Date Jan. 20, 2014, 12:24 p.m.
Message ID <0fbf5062299128b4b654de870a54f22a7cf8633a.1390220655.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/65259/
State New
Headers show

Comments

Robert Yang - Jan. 20, 2014, 12:24 p.m.
The dash can't handle the or [[ in parameter expansion, for example:

A=/usr/bin/[[
B=[[
C="${A%$B}"

The C should be "/usr/bin" in common, but it will be /usr/bin/[[ on
dash, use dirname to fix it.

NOTE:
There are 3 lines about parameter expansion, only fix the
DIR="${DIR%$TGT}" since the other 2 works will and are very useful in
this case.

[YOCTO #5712]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Richard Purdie - Jan. 24, 2014, 1:43 p.m.
On Mon, 2014-01-20 at 20:24 +0800, Robert Yang wrote:
> The dash can't handle the or [[ in parameter expansion, for example:
> 
> A=/usr/bin/[[
> B=[[
> C="${A%$B}"
> 
> The C should be "/usr/bin" in common, but it will be /usr/bin/[[ on
> dash, use dirname to fix it.
> 
> NOTE:
> There are 3 lines about parameter expansion, only fix the
> DIR="${DIR%$TGT}" since the other 2 works will and are very useful in
> this case.
> 
> [YOCTO #5712]
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

I'm afraid I had to revert this as it caused other build failures:

http://autobuilder.yoctoproject.org/main/builders/build-appliance/builds/18/steps/BuildImages_1/logs/stdio

Can you look into why that happened and resent the patch please?

Cheers,

Richard

> diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh b/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
> index 7de720b..9b55a4b 100644
> --- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
> +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
> @@ -23,7 +23,7 @@ DEBUGFS="debugfs"
>  	find $SRCDIR | while read FILE; do
>                  TGT="${FILE##*/}"
>                  DIR="${FILE#$SRCDIR}"
> -                DIR="${DIR%$TGT}"
> +                DIR="$(dirname $DIR)"
>  
>  		# Skip the root dir
>  		[ ! -z "$DIR" ] || continue
Olof Johansson - Jan. 24, 2014, 3:17 p.m.
On 14-01-24 14:43 +0100, Richard Purdie wrote:
> On Mon, 2014-01-20 at 20:24 +0800, Robert Yang wrote:
> > The dash can't handle the or [[ in parameter expansion, for example:

Good to know. Interesting! Noting that escaping the [ would work,
but not applicable in this case.

> > 
> > A=/usr/bin/[[
> > B=[[
> > C="${A%$B}"

Would ${A%/*}/ work?

-                DIR="${DIR%$TGT}"
+                DIR="${DIR%/*}/"

It also has the advantage that it doesn't cause a fork (afaict,
the loop is being executed for every file in a rootfs directory
structure, that could cause a lot of forks).

(Disclaimer: I haven't tested this)

Patch

diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh b/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
index 7de720b..9b55a4b 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/populate-extfs.sh
@@ -23,7 +23,7 @@  DEBUGFS="debugfs"
 	find $SRCDIR | while read FILE; do
                 TGT="${FILE##*/}"
                 DIR="${FILE#$SRCDIR}"
-                DIR="${DIR%$TGT}"
+                DIR="$(dirname $DIR)"
 
 		# Skip the root dir
 		[ ! -z "$DIR" ] || continue