All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] tools: buildman: Don't use the working dir as build dir
Date: Sun, 8 Apr 2018 19:15:50 +0800	[thread overview]
Message-ID: <CAPnjgZ2WXnmbuLGLBYo0joJHBoV0bJOVYY6HJzDm9uZiicHeCg@mail.gmail.com> (raw)
In-Reply-To: <20180403101627.590d375c@karo-electronics.de>

Hi Lothar,

On 3 April 2018 at 16:16, Lothar Waßmann <LW@karo-electronics.de> wrote:
> Hi,
>
> On Mon,  2 Apr 2018 02:43:12 -0600 Simon Glass wrote:
>> From: Lothar Waßmann <LW@KARO-electronics.de>
>>
>> When the U-Boot base directory happens to have the same name as the branch
>> that buildman is directed to use via the '-b' option and no output
>> directory is specified with '-o', buildman happily starts removing the
>> whole U-Boot sources eventually only stopped with the error message:
>>
>> OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg
>>
>> Add a check to avoid this and also deal with the case where '-o' points
>> to the source directory, or any subdirectory of it.
>>
>> Finally, tidy up the confusing logic for removing the old tree when using
>> -b. This is only done when building a branch.
>>
>> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v2:
>> - Updated to check directories on start-up as per comments on v1 patch
>> - Added a test
>> - Expanded check to handle subdirectories
>>
>>  tools/buildman/builderthread.py |  4 ++++
>>  tools/buildman/control.py       | 28 +++++++++++++++++++++++++---
>>  tools/buildman/func_test.py     |  9 +++++++++
>>  3 files changed, 38 insertions(+), 3 deletions(-)
>>
> [...]
[...]

>> +def CheckOutputDir(output_dir):
>> +    """Make sure that the output directory is not within the current directory
>> +
>> +    If we try to use an output directory which is within the current directory
>> +    (which is assumed to hold the U-Boot source) we may end up deleting the
>> +    U-Boot source code. Detect this and print an error in this case.
>> +
>> +    Args:
>> +        output_dir: Output directory path to check
>> +    """
>> +    path = os.path.realpath(output_dir)
>> +    cwd_path = os.path.realpath('.')
>> +    while True:
>> +        if os.path.realpath(path) == cwd_path:
>> +            Print("Cannot use output directory '%s' since it is within the "
>> +                  "current directtory '%s'" % (path, cwd_path))
> s/directtory/directory/
> NB: IMO its a bad habit to split format strings across multiple lines,
>     since it makes it harder to grep the source code for a message
>     that was printed on the terminal.
>
> Otherwise, looks good to me.
>
> Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

Yes I agree although for some reason I have tended to stick strictly
to 80 columns in Python. I'm not sure why though, so will change it.

Regards,
Simon

      reply	other threads:[~2018-04-08 11:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02  8:43 [U-Boot] [PATCH v2] tools: buildman: Don't use the working dir as build dir Simon Glass
2018-04-03  8:16 ` Lothar Waßmann
2018-04-08 11:15   ` Simon Glass [this message]

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=CAPnjgZ2WXnmbuLGLBYo0joJHBoV0bJOVYY6HJzDm9uZiicHeCg@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.