Patchwork [V4,08/10] populate-volatile.sh: use 'cp -a' to avoid potential problem

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Aug. 7, 2013, 8:08 a.m.
Message ID <3cfae481384c0c94d116273ba085dbacaf455c6d.1375862591.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/55241/
State New
Headers show

Comments

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

Previously, dead links in target directory will not be copied.
This is incorrect as dead links are not uncommon in our rootfs.
So we use '-a' option instead.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../initscripts-1.0/populate-volatile.sh           |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Qi.Chen@windriver.com - Aug. 8, 2013, 2:50 a.m.
On 08/07/2013 04:08 PM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Previously, dead links in target directory will not be copied.
> This is incorrect as dead links are not uncommon in our rootfs.
> So we use '-a' option instead.
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   .../initscripts-1.0/populate-volatile.sh           |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> index 827fd7d..b1c0245 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> @@ -76,7 +76,8 @@ link_file() {
>   	if [ -L \"$2\" ]; then
>   		[ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
>   	elif [ -d \"$2\" ]; then
> -		for f in $2/* $2/.[^.]*; do [ -e \$f ] && cp -rf \$f $1; done;
> +		cp -a $2/* $1
> +		cp -a $2/.[!.]* $1
My apologies.
The above two lines are missing colons.
They should be:
cp -a $2/* $1;
cp -a $2/.[!.]* $1;

Remote branch has been updated to fix this error.
Sorry for the inconvenience.

Best Regards,
Chen Qi

>   		rm -rf \"$2\";
>   		ln -sf \"$1\" \"$2\";
>   	else

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 827fd7d..b1c0245 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -76,7 +76,8 @@  link_file() {
 	if [ -L \"$2\" ]; then
 		[ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
 	elif [ -d \"$2\" ]; then
-		for f in $2/* $2/.[^.]*; do [ -e \$f ] && cp -rf \$f $1; done;
+		cp -a $2/* $1
+		cp -a $2/.[!.]* $1
 		rm -rf \"$2\";
 		ln -sf \"$1\" \"$2\";
 	else