diff mbox

[autobuild,1/4] autobuild-run: prevent send_result from failing when gathering config files

Message ID 1428849285-21092-1-git-send-email-s.martin49@gmail.com
State Superseded
Headers show

Commit Message

Samuel Martin April 12, 2015, 2:34 p.m. UTC
- Make sure using absolute paths in os.path.relpath();
- os.makedirs() can fail if the directory already exists, so only create it
  when needed.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 scripts/autobuild-run | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Thomas Petazzoni April 12, 2015, 5:20 p.m. UTC | #1
Dear Samuel Martin,

On Sun, 12 Apr 2015 16:34:42 +0200, Samuel Martin wrote:
> - Make sure using absolute paths in os.path.relpath();
> - os.makedirs() can fail if the directory already exists, so only create it
>   when needed.
> 
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>
> ---
>  scripts/autobuild-run | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/autobuild-run b/scripts/autobuild-run
> index 0e12080..a19d51b 100755
> --- a/scripts/autobuild-run
> +++ b/scripts/autobuild-run
> @@ -653,15 +653,16 @@ def send_results(result, **kwargs):
>          if not reason:
>              return
>  
> -        srcroot = os.path.join(outputdir, "build", '-'.join(reason))
> -        destroot = os.path.join(resultdir, '-'.join(reason))
> +        srcroot = os.path.abspath(os.path.join(outputdir, "build", '-'.join(reason)))
> +        destroot = os.path.abspath(os.path.join(resultdir, '-'.join(reason)))

Can you explain why this is needed?

Thanks,

Thomas
Samuel Martin April 12, 2015, 6:15 p.m. UTC | #2
On Sun, Apr 12, 2015 at 7:20 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Samuel Martin,
>
> On Sun, 12 Apr 2015 16:34:42 +0200, Samuel Martin wrote:
>> - Make sure using absolute paths in os.path.relpath();
>> - os.makedirs() can fail if the directory already exists, so only create it
>>   when needed.
>>
>> Signed-off-by: Samuel Martin <s.martin49@gmail.com>
>> ---
>>  scripts/autobuild-run | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/scripts/autobuild-run b/scripts/autobuild-run
>> index 0e12080..a19d51b 100755
>> --- a/scripts/autobuild-run
>> +++ b/scripts/autobuild-run
>> @@ -653,15 +653,16 @@ def send_results(result, **kwargs):
>>          if not reason:
>>              return
>>
>> -        srcroot = os.path.join(outputdir, "build", '-'.join(reason))
>> -        destroot = os.path.join(resultdir, '-'.join(reason))
>> +        srcroot = os.path.abspath(os.path.join(outputdir, "build", '-'.join(reason)))
>> +        destroot = os.path.abspath(os.path.join(resultdir, '-'.join(reason)))
>
> Can you explain why this is needed?

During my tests, I ran into some weird errors because it was trying to
mkdir some directories in the package builddir itself instead of in
the result location.
I certainly messed up something, I'll check again.
And... indeed after a close look at code, it should not be necessary...

Reagrds,

>
> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
diff mbox

Patch

diff --git a/scripts/autobuild-run b/scripts/autobuild-run
index 0e12080..a19d51b 100755
--- a/scripts/autobuild-run
+++ b/scripts/autobuild-run
@@ -653,15 +653,16 @@  def send_results(result, **kwargs):
         if not reason:
             return
 
-        srcroot = os.path.join(outputdir, "build", '-'.join(reason))
-        destroot = os.path.join(resultdir, '-'.join(reason))
+        srcroot = os.path.abspath(os.path.join(outputdir, "build", '-'.join(reason)))
+        destroot = os.path.abspath(os.path.join(resultdir, '-'.join(reason)))
 
         for root, dirs, files in os.walk(srcroot):
             dest = os.path.join(destroot, os.path.relpath(root, srcroot))
 
             for fname in files:
                 if fname == 'config.log':
-                    os.makedirs(dest)
+                    if not os.path.exists(dest):
+                        os.makedirs(dest)
                     shutil.copy(os.path.join(root, fname), os.path.join(dest, fname))
 
     copy_config_log_files()