mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] Semicolon in filenames
@ 2016-01-22  0:31 Ladislav Michl
  2016-01-22  7:18 ` Uwe Kleine-König
  2016-01-22  8:06 ` [ptxdist] Semicolon " Michael Olbrich
  0 siblings, 2 replies; 7+ messages in thread
From: Ladislav Michl @ 2016-01-22  0:31 UTC (permalink / raw)
  To: ptxdist

Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
Patch bellow escapes semicolon on producer side, anyone cares about consumer?

	ladis

diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
index 5ba404e..8e6664b 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -209,6 +209,7 @@ install directory:
 
     install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
     install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
+    dir="$(echo ${dir} | sed -e 's/[:]/\\:/g')" &&
 
     echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
     ptxd_install_error "install_dir failed!"
@@ -343,6 +344,9 @@ Usually, just remove the 6th parameter and everything works fine.
     # now change to requested user and group
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
+    # escape semicolon
+    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
+
     echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_file_impl
@@ -413,6 +417,7 @@ install device node:
 	mknod -m "${mod}" "${d}" "${type}" ${major} ${minor} || return
     done &&
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
+    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
 
     echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
 }

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] Semicolon in filenames
  2016-01-22  0:31 [ptxdist] Semicolon in filenames Ladislav Michl
@ 2016-01-22  7:18 ` Uwe Kleine-König
  2016-01-22  8:10   ` [ptxdist] Colons " Ladislav Michl
  2016-01-22  8:06 ` [ptxdist] Semicolon " Michael Olbrich
  1 sibling, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2016-01-22  7:18 UTC (permalink / raw)
  To: ptxdist

Hello,

On Fri, Jan 22, 2016 at 01:31:37AM +0100, Ladislav Michl wrote:
> Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
> break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
> Patch bellow escapes semicolon on producer side, anyone cares about consumer?
> 
> 	ladis
> 
> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index 5ba404e..8e6664b 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -209,6 +209,7 @@ install directory:
>  
>      install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
>      install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
> +    dir="$(echo ${dir} | sed -e 's/[:]/\\:/g')" &&

why do you need the brackets? Doesn't s/:/\\:/g have the same effect?

As this is a bash script I assume you might save a few forks by using:

	${dir//:/\\:}

(untested) instead.

>  
>      echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
>      ptxd_install_error "install_dir failed!"
> @@ -343,6 +344,9 @@ Usually, just remove the 6th parameter and everything works fine.
>      # now change to requested user and group
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
>  
> +    # escape semicolon

semicolon?

> +    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
> +
>      echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
>  }
>  export -f ptxd_install_file_impl
> @@ -413,6 +417,7 @@ install device node:
>  	mknod -m "${mod}" "${d}" "${type}" ${major} ${minor} || return
>      done &&
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
> +    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
>  
>      echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
>  }

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] Semicolon in filenames
  2016-01-22  0:31 [ptxdist] Semicolon in filenames Ladislav Michl
  2016-01-22  7:18 ` Uwe Kleine-König
@ 2016-01-22  8:06 ` Michael Olbrich
  2016-02-03 22:05   ` [ptxdist] [RFC] Colons " Ladislav Michl
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Olbrich @ 2016-01-22  8:06 UTC (permalink / raw)
  To: ptxdist

On Fri, Jan 22, 2016 at 01:31:37AM +0100, Ladislav Michl wrote:
> Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
> break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
> Patch bellow escapes semicolon on producer side, anyone cares about consumer?

This does not work well with IFS in bash and FS in awk. but I think we can
switch different character. Maybe a vertical tab?

> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index 5ba404e..8e6664b 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -209,6 +209,7 @@ install directory:
>  
>      install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
>      install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
> +    dir="$(echo ${dir} | sed -e 's/[:]/\\:/g')" &&
>  
>      echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
>      ptxd_install_error "install_dir failed!"
> @@ -343,6 +344,9 @@ Usually, just remove the 6th parameter and everything works fine.
>      # now change to requested user and group
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
>  
> +    # escape semicolon
> +    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
> +
>      echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
>  }
>  export -f ptxd_install_file_impl
> @@ -413,6 +417,7 @@ install device node:
>  	mknod -m "${mod}" "${d}" "${type}" ${major} ${minor} || return
>      done &&
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
> +    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
>  
>      echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"

	sep=$'\v'
	echo "n${sep}${dst}${sep}${usr}${sep}${grp}${sep}${mod}${sep}${type}${sep}${major}${sep}${minor}" >> "${pkg_xpkg_perms}"

And then use IFS=$'\v' in bash and FS="\v" in awk

Michael

>  }

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ptxdist] Colons in filenames
  2016-01-22  7:18 ` Uwe Kleine-König
@ 2016-01-22  8:10   ` Ladislav Michl
  0 siblings, 0 replies; 7+ messages in thread
From: Ladislav Michl @ 2016-01-22  8:10 UTC (permalink / raw)
  To: ptxdist

On Fri, Jan 22, 2016 at 08:18:05AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Fri, Jan 22, 2016 at 01:31:37AM +0100, Ladislav Michl wrote:
> > Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
> > break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
> > Patch bellow escapes semicolon on producer side, anyone cares about consumer?
> > 
> > 	ladis
> > 
> > diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
> > index 5ba404e..8e6664b 100644
> > --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> > +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> > @@ -209,6 +209,7 @@ install directory:
> >  
> >      install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
> >      install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
> > +    dir="$(echo ${dir} | sed -e 's/[:]/\\:/g')" &&
> 
> why do you need the brackets? Doesn't s/:/\\:/g have the same effect?

Yes, it is the same and I probably shouldn't do anything at late night.

> As this is a bash script I assume you might save a few forks by using:
> 
> 	${dir//:/\\:}
> 
> (untested) instead.

Tested, patch bellow.

> >      echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
> >      ptxd_install_error "install_dir failed!"
> > @@ -343,6 +344,9 @@ Usually, just remove the 6th parameter and everything works fine.
> >      # now change to requested user and group
> >      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
> >  
> > +    # escape semicolon
> 
> semicolon?

Oops, your right. Colon, actually.
So this fixes .perms files and now what about the other side? So far we have two concurent
implementations of 'make images'. Fix both, or drop one, fix another?

diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
index 5ba404e..630e085 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -210,7 +210,7 @@ install directory:
     install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
     install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
 
-    echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
+    echo "f:${dir//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
     ptxd_install_error "install_dir failed!"
 }
 export -f ptxd_install_dir
@@ -343,7 +343,7 @@ Usually, just remove the 6th parameter and everything works fine.
     # now change to requested user and group
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
-    echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
+    echo "f:${dst//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_file_impl
 
@@ -413,8 +413,9 @@ install device node:
 	mknod -m "${mod}" "${d}" "${type}" ${major} ${minor} || return
     done &&
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
+    dst="$(echo ${dst} | sed -e 's/[:]/\\:/g')" &&
 
-    echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
+    echo "n:${dst//:/\\:}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_mknod
 

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ptxdist] [RFC] Colons in filenames
  2016-01-22  8:06 ` [ptxdist] Semicolon " Michael Olbrich
@ 2016-02-03 22:05   ` Ladislav Michl
  2016-02-10 17:23     ` Michael Olbrich
  0 siblings, 1 reply; 7+ messages in thread
From: Ladislav Michl @ 2016-02-03 22:05 UTC (permalink / raw)
  To: ptxdist

On Fri, Jan 22, 2016 at 09:06:36AM +0100, Michael Olbrich wrote:
> On Fri, Jan 22, 2016 at 01:31:37AM +0100, Ladislav Michl wrote:
> > Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
> > break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
> > Patch bellow escapes semicolon on producer side, anyone cares about consumer?
> 
> This does not work well with IFS in bash and FS in awk. but I think we can
> switch different character. Maybe a vertical tab?

Well, I did not give up 'escaping idea' yet. What about something like this?
(awk part could be done better)

diff --git a/scripts/lib/ptxd_lib_dopermissions.awk b/scripts/lib/ptxd_lib_dopermissions.awk
index 336948c..17ee1b6 100755
--- a/scripts/lib/ptxd_lib_dopermissions.awk
+++ b/scripts/lib/ptxd_lib_dopermissions.awk
@@ -5,13 +5,29 @@ BEGIN {
 }
 
 $1 ~ "f" {
-	printf("chmod %s	'.%s' &&\n" \
-	       "chown %s.%s	'.%s' &&\n", \
-	       $5, $2, $3, $4, $2);
+	path = $2;
+	for (i = 3; i <= NF; i++) {
+		if (substr(path, length(path), 1) == "\\")
+			path = substr(path, 1, length(path) - 1) ":" $i;
+		else {
+			printf("chmod %s	'.%s' &&\n" \
+			       "chown %s.%s	'.%s' &&\n", \
+			       $(i+2), path, $i, $(i+1), path);
+			break;
+		}
+	}
 }
 
 $1 ~ "n" {
-	printf("mknod -m %s	'.%s'	%s %s %s &&\n" \
-	       "chown %s.%s	'.%s' &&\n", \
-	       $5, $2, $6, $7, $8, $3, $4, $2);
+	path = $2;
+	for (i = 3; i <= NF; i++) {
+		if (substr(path, length(path), 1) == "\\")
+			path = substr(path, 1, length(path) - 1) ":" $i;
+		else {
+			printf("mknod -m %s	'.%s'	%s %s %s &&\n" \
+			       "chown %s.%s	'.%s' &&\n", \
+			       $(i+2), path, $(i+3), $(i+4), $(i+5), $i, $(i+1), path);
+			break;
+		}
+	}
 }
diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
index 5ba404e..01ce361 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -210,7 +210,7 @@ install directory:
     install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
     install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
 
-    echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
+    echo "f:${dir//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
     ptxd_install_error "install_dir failed!"
 }
 export -f ptxd_install_dir
@@ -343,7 +343,7 @@ Usually, just remove the 6th parameter and everything works fine.
     # now change to requested user and group
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
-    echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
+    echo "f:${dst//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_file_impl
 
@@ -414,7 +414,7 @@ install device node:
     done &&
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
-    echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
+    echo "n:${dst//:/\\:}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_mknod
 

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] [RFC] Colons in filenames
  2016-02-03 22:05   ` [ptxdist] [RFC] Colons " Ladislav Michl
@ 2016-02-10 17:23     ` Michael Olbrich
  2016-07-13 10:24       ` Ladislav Michl
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Olbrich @ 2016-02-10 17:23 UTC (permalink / raw)
  To: ptxdist

On Wed, Feb 03, 2016 at 11:05:02PM +0100, Ladislav Michl wrote:
> On Fri, Jan 22, 2016 at 09:06:36AM +0100, Michael Olbrich wrote:
> > On Fri, Jan 22, 2016 at 01:31:37AM +0100, Ladislav Michl wrote:
> > > Now I'm going to be honest. Previous patch 'Add usb-modeswitch-data package'
> > > break things - 'ptxdist images' fails as ':' is used as delimiter in perms file.
> > > Patch bellow escapes semicolon on producer side, anyone cares about consumer?
> > 
> > This does not work well with IFS in bash and FS in awk. but I think we can
> > switch different character. Maybe a vertical tab?
> 
> Well, I did not give up 'escaping idea' yet. What about something like this?
> (awk part could be done better)

I think the most readable would be replace the escaping:

'\:' -> 0x1
':'  -> 0x2
0x1  -> ':'

and then use 0x2 as separator.

Well there is also DOPERMISSIONS in rules/post/ptxd_make_image_common.make
which ist mostly but not exactly the same. But I suppose we could merge
that. It will require some testing and careful review. This stuff is rather
tricky.
And then there is scripts/lib/ptxd_make_image_fix_permissions.sh...

Michael

> diff --git a/scripts/lib/ptxd_lib_dopermissions.awk b/scripts/lib/ptxd_lib_dopermissions.awk
> index 336948c..17ee1b6 100755
> --- a/scripts/lib/ptxd_lib_dopermissions.awk
> +++ b/scripts/lib/ptxd_lib_dopermissions.awk
> @@ -5,13 +5,29 @@ BEGIN {
>  }
>  
>  $1 ~ "f" {
> -	printf("chmod %s	'.%s' &&\n" \
> -	       "chown %s.%s	'.%s' &&\n", \
> -	       $5, $2, $3, $4, $2);
> +	path = $2;
> +	for (i = 3; i <= NF; i++) {
> +		if (substr(path, length(path), 1) == "\\")
> +			path = substr(path, 1, length(path) - 1) ":" $i;
> +		else {
> +			printf("chmod %s	'.%s' &&\n" \
> +			       "chown %s.%s	'.%s' &&\n", \
> +			       $(i+2), path, $i, $(i+1), path);
> +			break;
> +		}
> +	}
>  }
>  
>  $1 ~ "n" {
> -	printf("mknod -m %s	'.%s'	%s %s %s &&\n" \
> -	       "chown %s.%s	'.%s' &&\n", \
> -	       $5, $2, $6, $7, $8, $3, $4, $2);
> +	path = $2;
> +	for (i = 3; i <= NF; i++) {
> +		if (substr(path, length(path), 1) == "\\")
> +			path = substr(path, 1, length(path) - 1) ":" $i;
> +		else {
> +			printf("mknod -m %s	'.%s'	%s %s %s &&\n" \
> +			       "chown %s.%s	'.%s' &&\n", \
> +			       $(i+2), path, $(i+3), $(i+4), $(i+5), $i, $(i+1), path);
> +			break;
> +		}
> +	}
>  }
> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index 5ba404e..01ce361 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -210,7 +210,7 @@ install directory:
>      install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
>      install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
>  
> -    echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
> +    echo "f:${dir//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
>      ptxd_install_error "install_dir failed!"
>  }
>  export -f ptxd_install_dir
> @@ -343,7 +343,7 @@ Usually, just remove the 6th parameter and everything works fine.
>      # now change to requested user and group
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
>  
> -    echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
> +    echo "f:${dst//:/\\:}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
>  }
>  export -f ptxd_install_file_impl
>  
> @@ -414,7 +414,7 @@ install device node:
>      done &&
>      chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
>  
> -    echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
> +    echo "n:${dst//:/\\:}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
>  }
>  export -f ptxd_install_mknod
>  
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] [RFC] Colons in filenames
  2016-02-10 17:23     ` Michael Olbrich
@ 2016-07-13 10:24       ` Ladislav Michl
  0 siblings, 0 replies; 7+ messages in thread
From: Ladislav Michl @ 2016-07-13 10:24 UTC (permalink / raw)
  To: ptxdist

On Wed, Feb 10, 2016 at 06:23:47PM +0100, Michael Olbrich wrote:
> I think the most readable would be replace the escaping:
> 
> '\:' -> 0x1
> ':'  -> 0x2
> 0x1  -> ':'
> 
> and then use 0x2 as separator.
> 
> Well there is also DOPERMISSIONS in rules/post/ptxd_make_image_common.make
> which ist mostly but not exactly the same. But I suppose we could merge
> that. It will require some testing and careful review. This stuff is rather
> tricky.
> And then there is scripts/lib/ptxd_make_image_fix_permissions.sh...

I used ASCII 31 (unit separator), after all this is whole purpose
of its sole existence. So what about something like following patch?

diff --git a/rules/post/image_cpio.make b/rules/post/image_cpio.make
index 573faee..200b283 100644
--- a/rules/post/image_cpio.make
+++ b/rules/post/image_cpio.make
@@ -15,7 +15,7 @@ $(IMAGEDIR)/root.cpio: $(STATEDIR)/image_working_dir
 	@echo -n "Creating '$(notdir $(@))' from working dir..."
 	@cd $(image/work_dir) && \
 	( \
-		awk -F: $(DOPERMISSIONS) $(image/permissions) && \
+		awk $(DOPERMISSIONS) $(image/permissions) && \
 		echo "find . | cpio --quiet -H newc -o > '$(@)'" \
 	) | $(FAKEROOT) --
 	@echo "done."
diff --git a/rules/post/image_ext2.make b/rules/post/image_ext2.make
index 3e3423b..0dbcafd 100644
--- a/rules/post/image_ext2.make
+++ b/rules/post/image_ext2.make
@@ -15,7 +15,7 @@ ifdef PTXCONF_IMAGE_EXT2
 $(IMAGEDIR)/root.ext2: $(STATEDIR)/image_working_dir
 	@echo -n "Creating root.ext2 from working dir..."
 	@cd $(image/work_dir);						\
-	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&		\
+	(awk $(DOPERMISSIONS) $(image/permissions) &&			\
 	(								\
 		echo -n "$(PTXCONF_SYSROOT_HOST)/bin/genext2fs ";	\
 		echo -n "-b $(PTXCONF_IMAGE_EXT2_SIZE) ";		\
diff --git a/rules/post/image_jffs2.make b/rules/post/image_jffs2.make
index 5e448f5..7f12883 100644
--- a/rules/post/image_jffs2.make
+++ b/rules/post/image_jffs2.make
@@ -17,7 +17,7 @@ $(IMAGEDIR)/root.jffs2: $(STATEDIR)/image_working_dir $(STATEDIR)/host-mtd-utils
 	@echo -n "(--eraseblock=$(PTXCONF_IMAGE_JFFS2_BLOCKSIZE) "
 	@echo "$(call remove_quotes,$(PTXCONF_IMAGE_JFFS2_EXTRA_ARGS)))"
 	@cd $(image/work_dir);						\
-	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&		\
+	(awk $(DOPERMISSIONS) $(image/permissions) &&			\
 	(								\
 		echo -n "$(PTXCONF_SYSROOT_HOST)/sbin/mkfs.jffs2 ";	\
 		echo -n "-d $(image/work_dir) ";			\
diff --git a/rules/post/image_squashfs.make b/rules/post/image_squashfs.make
index 6d02255..69dc721 100644
--- a/rules/post/image_squashfs.make
+++ b/rules/post/image_squashfs.make
@@ -19,7 +19,7 @@ ifdef PTXCONF_IMAGE_SQUASHFS
 $(IMAGEDIR)/root.squashfs: $(STATEDIR)/image_working_dir $(STATEDIR)/host-squashfs-tools.install.post
 	@echo -n "Creating root.squashfs from working dir..."
 	@cd $(image/work_dir);							\
-	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&		\
+	(awk $(DOPERMISSIONS) $(image/permissions) &&			\
 	(								\
 		echo -n "$(PTXCONF_SYSROOT_HOST)/sbin/mksquashfs ";	\
 		echo -n "$(image/work_dir) ";					\
diff --git a/rules/post/image_tgz.make b/rules/post/image_tgz.make
index 57f69f4..a8e129a 100644
--- a/rules/post/image_tgz.make
+++ b/rules/post/image_tgz.make
@@ -19,7 +19,7 @@ endif
 $(IMAGEDIR)/root.tgz: $(STATEDIR)/image_working_dir
 	@echo -n 'Creating root.tgz from working dir$(if $(IMAGE_TGZ_LABEL), with label "$(IMAGE_TGZ_LABEL)",)... '
 	@cd $(image/work_dir);							\
-	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&		\
+	(awk -F\x1F $(DOPERMISSIONS) $(image/permissions) &&		\
 	(	echo -n "tar ${IMAGE_TGZ_LABEL_ARGS} -zcf ";	\
 		echo -n "$@ ." )					\
 	) | $(FAKEROOT) --
diff --git a/rules/post/image_ubi.make b/rules/post/image_ubi.make
index edfae1d..17321dc 100644
--- a/rules/post/image_ubi.make
+++ b/rules/post/image_ubi.make
@@ -22,7 +22,7 @@ $(IMAGEDIR)/root.ubifs: $(STATEDIR)/image_working_dir $(STATEDIR)/host-mtd-utils
 	@echo -n "-e $(PTXCONF_IMAGE_UBIFS_LEB_SIZE) -c $(PTXCONF_IMAGE_UBIFS_ROOT_MAX_LEB_COUNT) "
 	@echo -n "$(PTXCONF_IMAGE_UBIFS_EXTRA_ARGS))"
 	@cd $(image/work_dir);								\
-	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&			\
+	(awk $(DOPERMISSIONS) $(image/permissions) &&				\
 	(									\
 		echo -n "$(PTXCONF_SYSROOT_HOST)/sbin/mkfs.ubifs ";		\
 		echo -n "-d $(image/work_dir) ";					\
diff --git a/rules/post/ptxd_make_image_common.make b/rules/post/ptxd_make_image_common.make
index 7ccb501..0f274bf 100644
--- a/rules/post/ptxd_make_image_common.make
+++ b/rules/post/ptxd_make_image_common.make
@@ -8,7 +8,7 @@
 # see the README file.
 #
 
-DOPERMISSIONS := '{	\
+DOPERMISSIONS := '{ FS = "\x1F";	\
 	if ($$1 == "f")	\
 		printf("chmod %s \".%s\"; chown %s.%s \".%s\";\n", $$5, $$2, $$3, $$4, $$2);	\
 	if ($$1 == "n")	\
diff --git a/scripts/lib/ptxd_lib_dopermissions.awk b/scripts/lib/ptxd_lib_dopermissions.awk
index 336948c..3596121 100755
--- a/scripts/lib/ptxd_lib_dopermissions.awk
+++ b/scripts/lib/ptxd_lib_dopermissions.awk
@@ -1,7 +1,7 @@
 #!/usr/bin/awk -f
 
 BEGIN {
-	FS = ":";
+	FS = "\x1F";
 }
 
 $1 ~ "f" {
diff --git a/scripts/lib/ptxd_make_image_fix_permissions.sh b/scripts/lib/ptxd_make_image_fix_permissions.sh
index eae2ab3..7bc10c0 100644
--- a/scripts/lib/ptxd_make_image_fix_permissions.sh
+++ b/scripts/lib/ptxd_make_image_fix_permissions.sh
@@ -32,10 +32,10 @@ export -f ptxd_make_image_fix_permissions_generate
 ptxd_make_image_fix_permissions_check() {
     local workdir="${1}"
     local ifs_orig="${IFS}"
-    IFS=":"
+    IFS="\x1F"
 
     # just care about dev-nodes, for now
-    egrep -h "^[n]:" "${ptxd_reply_perm_files[@]}" |
+    egrep -h "^[n]\x1F" "${ptxd_reply_perm_files[@]}" |
     while read kind file uid_should gid_should prm_should type major_should minor_should; do
 	local fixup=false
 	file="${workdir}/${file#/}"
diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
index ba9094b..f6c63ea 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -210,7 +210,7 @@ install directory:
     install -m "${mod_nfs}" -d "${ndirs[@]/%/${dir}}" &&
     install -m "${mod}" -o "${usr}" -g "${grp}" -d "${pdirs[@]/%/${dir}}" &&
 
-    echo "f:${dir}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}" ||
+    echo -e "f\x1F${dir}\x1F${usr}\x1F${grp}\x1F${mod}" >> "${pkg_xpkg_perms}" ||
     ptxd_install_error "install_dir failed!"
 }
 export -f ptxd_install_dir
@@ -350,7 +350,7 @@ Usually, just remove the 6th parameter and everything works fine.
     # now change to requested user and group
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
-    echo "f:${dst}:${usr}:${grp}:${mod}" >> "${pkg_xpkg_perms}"
+    echo -e "f\x1F${dst}\x1F${usr}\x1F${grp}\x1F${mod}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_file_impl
 
@@ -421,7 +421,7 @@ install device node:
     done &&
     chown "${usr}:${grp}" "${pdirs[@]/%/${dst}}" &&
 
-    echo "n:${dst}:${usr}:${grp}:${mod}:${type}:${major}:${minor}" >> "${pkg_xpkg_perms}"
+    echo -e "n\x1F${dst}\x1F${usr}\x1F${grp}\x1F${mod}\x1F${type}\x1F${major}\x1F${minor}" >> "${pkg_xpkg_perms}"
 }
 export -f ptxd_install_mknod
 

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-13 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-22  0:31 [ptxdist] Semicolon in filenames Ladislav Michl
2016-01-22  7:18 ` Uwe Kleine-König
2016-01-22  8:10   ` [ptxdist] Colons " Ladislav Michl
2016-01-22  8:06 ` [ptxdist] Semicolon " Michael Olbrich
2016-02-03 22:05   ` [ptxdist] [RFC] Colons " Ladislav Michl
2016-02-10 17:23     ` Michael Olbrich
2016-07-13 10:24       ` Ladislav Michl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox