From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Patches and discussions about the oe-core layer
<openembedded-core@lists.openembedded.org>
Subject: Re: [RFC PATCH 1/3] lib/bb/utils.py: add optional mode parameter to bb.utils.mkdirhier()
Date: Thu, 10 May 2012 12:19:19 +0100 [thread overview]
Message-ID: <1336648759.2494.127.camel@ted> (raw)
In-Reply-To: <85fc58ba361854e47f2cd078ab62b8f28ca95324.1336608479.git.josh@linux.intel.com>
On Wed, 2012-05-09 at 17:22 -0700, Joshua Lock wrote:
> The optional parameter should be an octal file mode representing the
> desired permissions of the created directory. If mode isn;t specified
> use 0777. This is the default of os.makedirs() yet is not often what
> the created directory ends up with due to umask affecting the call.
>
> The use of chmod() in this patch ensures that whatever octal is
> passed are the permissions the directory will have after creation.
> This is a behaviour change...
>
> Signed-off-by: Joshua Lock <josh@linux.intel.com>
> ---
> bitbake/lib/bb/utils.py | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
> index 7a73419..33206fe 100644
> --- a/bitbake/lib/bb/utils.py
> +++ b/bitbake/lib/bb/utils.py
> @@ -531,13 +531,16 @@ def prune_suffix(var, suffixes, d):
> return var.replace(suffix, "")
> return var
>
> -def mkdirhier(directory):
> +def mkdirhier(directory, mode=0777):
> """Create a directory like 'mkdir -p', but does not complain if
> directory already exists like os.makedirs
> """
>
> try:
> - os.makedirs(directory)
> + os.makedirs(directory, mode)
> + # We can't rely on makedirs having set the mode correctly as it is
> + # affected by umask
> + os.chmod(directory, mode)
> except OSError as e:
> if e.errno != errno.EEXIST:
> raise e
I'm afraid there are a few holes here. mkdirhier can create parents and
your chmod doesn't change these. I also agree with the comments, I think
this needs to remain unchanged behaviour wise, respecting the umask and
only set a mode if its specified.
Cheers,
Richard
next prev parent reply other threads:[~2012-05-10 11:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-10 0:22 [RFC PATCH 0/3] Shared state for all ! Joshua Lock
2012-05-10 0:22 ` [RFC PATCH 1/3] lib/bb/utils.py: add optional mode parameter to bb.utils.mkdirhier() Joshua Lock
2012-05-10 11:19 ` Richard Purdie [this message]
2012-05-10 0:22 ` [RFC PATCH 2/3] lib/bb/siggen.py: create permissive files and directories Joshua Lock
2012-05-10 11:22 ` Richard Purdie
2012-05-10 16:10 ` Joshua Lock
2012-05-10 0:22 ` [RFC PATCH 3/3] sstate.bbclass: ensure sstate files are easily shared Joshua Lock
2012-05-10 0:27 ` Saul Wold
2012-05-10 1:01 ` Joshua Lock
2012-05-10 0:50 ` [RFC PATCH 0/3] Shared state for all ! Chris Larson
2012-05-10 1:05 ` Joshua Lock
2012-05-10 2:15 ` Chris Larson
2012-05-10 2:32 ` Joshua Lock
2012-05-10 3:10 ` Joshua Lock
2012-05-10 3:14 ` Joshua Lock
2012-05-10 5:16 ` Khem Raj
2012-05-10 16:12 ` Joshua Lock
2012-05-10 16:31 ` Khem Raj
2012-05-10 7:25 ` Koen Kooi
2012-05-10 16:05 ` Joshua Lock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336648759.2494.127.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox