Patchwork package.bbclass: Call os.chmod after os.mkdir

login
register
mail settings
Submitter Martin Jansa
Date Sept. 8, 2013, 3:01 p.m.
Message ID <1378652471-27278-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/57629/
State Superseded, archived
Headers show

Comments

Martin Jansa - Sept. 8, 2013, 3:01 p.m.
* in 556dee0c4d6d8a87c0cddbd2f60fe5917d009f18 os.chmod was replaced by 2nd param
  to os.mkdir:
  -      bb.utils.mkdirhier(dest)
  -      fstat = os.stat(src)
  -      os.chmod(dest, fstat.st_mode)
  +      fstat = cpath.stat(src)
  +      os.mkdir(dest, fstat.st_mode)

  but fstat in os.mkdir, doesn't work the same as good old os.chmod:
  >>> p='test-p'
  >>> os.mkdir(p, 041777)
  >>> oct(os.stat(p).st_mode)
  '041775'
  >>> os.chmod(p, 041777)
  >>> oct(os.stat(p).st_mode)
  '041777'

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/package.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Richard Purdie - Sept. 8, 2013, 11:03 p.m.
On Sun, 2013-09-08 at 17:01 +0200, Martin Jansa wrote:
> * in 556dee0c4d6d8a87c0cddbd2f60fe5917d009f18 os.chmod was replaced by 2nd param
>   to os.mkdir:
>   -      bb.utils.mkdirhier(dest)
>   -      fstat = os.stat(src)
>   -      os.chmod(dest, fstat.st_mode)
>   +      fstat = cpath.stat(src)
>   +      os.mkdir(dest, fstat.st_mode)
> 
>   but fstat in os.mkdir, doesn't work the same as good old os.chmod:
>   >>> p='test-p'
>   >>> os.mkdir(p, 041777)
>   >>> oct(os.stat(p).st_mode)
>   '041775'
>   >>> os.chmod(p, 041777)
>   >>> oct(os.stat(p).st_mode)
>   '041777'
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/classes/package.bbclass | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index bdac2bd..c96acd2 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -988,8 +988,9 @@ python populate_packages () {
>              def mkdir(src, dest, p):
>                  src = os.path.join(src, p)
>                  dest = os.path.join(dest, p)
> +                bb.utils.mkdirhier(dest)
>                  fstat = cpath.stat(src)
> -                os.mkdir(dest, fstat.st_mode)
> +                os.chmod(dest, fstat.st_mode)
>                  os.chown(dest, fstat.st_uid, fstat.st_gid)
>                  if p not in seen:
>                      seen.append(p)

Can we set and then restore the umask to avoid having to do this? I ask
since from what I remember, changing things like this is quite expensive
performance wise :(

Cheers,

Richard

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index bdac2bd..c96acd2 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -988,8 +988,9 @@  python populate_packages () {
             def mkdir(src, dest, p):
                 src = os.path.join(src, p)
                 dest = os.path.join(dest, p)
+                bb.utils.mkdirhier(dest)
                 fstat = cpath.stat(src)
-                os.mkdir(dest, fstat.st_mode)
+                os.chmod(dest, fstat.st_mode)
                 os.chown(dest, fstat.st_uid, fstat.st_gid)
                 if p not in seen:
                     seen.append(p)