Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH V2 0/1] sanity.bbclass: check for validity of TMPDIR
@ 2013-11-15  2:46 Qi.Chen
  2013-11-15  2:46 ` [PATCH V2 1/1] " Qi.Chen
  2013-11-25  3:04 ` [PATCH V2 0/1] " ChenQi
  0 siblings, 2 replies; 4+ messages in thread
From: Qi.Chen @ 2013-11-15  2:46 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

Changes since V1:
1. Create the directory hierarchy for TMPDIR only if TMPDIR is valid
2. Handle ABI version change only if TMPDIR has been created.
3. If we had a valid TMPDIR for last build and this time the TMPDIR hasn't
   changed location, we don't check the validity for TMPDIR. 

The following changes since commit ea92671d9823e3667d6ced7ac2af20f991da404d:

  bitbake: cooker: replace "w" file opening mode with "a" mode (2013-11-12 17:01:37 +0000)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/TMPDIR
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/TMPDIR

Chen Qi (1):
  sanity.bbclass: check for validity of TMPDIR

 meta/classes/sanity.bbclass |   27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

-- 
1.7.9.5



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

* [PATCH V2 1/1] sanity.bbclass: check for validity of TMPDIR
  2013-11-15  2:46 [PATCH V2 0/1] sanity.bbclass: check for validity of TMPDIR Qi.Chen
@ 2013-11-15  2:46 ` Qi.Chen
  2013-12-11  9:09   ` ChenQi
  2013-11-25  3:04 ` [PATCH V2 0/1] " ChenQi
  1 sibling, 1 reply; 4+ messages in thread
From: Qi.Chen @ 2013-11-15  2:46 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

TMPDIR must be an absolute path, otherwise, the build will fail.
Special characters in TMPDIR will also cause build failures.

This patch enables checking for the validity of TMPDIR.

The logic in sanity.bbclass has also been changed a little bit. For now,
we only create the directory hierarch for TMPDIR if TMPDIR is valid. And
also, we only handle ABI version change only if the TMPDIR directory hierarchy
has been created.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/sanity.bbclass |   27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 83378b0..f6292f4 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -659,6 +659,16 @@ def check_sanity_everybuild(status, d):
     if oeroot.find(' ') != -1:
         status.addresult("Error, you have a space in your COREBASE directory path. Please move the installation to a directory which doesn't include a space since autotools doesn't support this.")
 
+    # Function to check if TMPDIR contains invalid characters, and check if it is an absolute path
+    def is_tmpdir_valid(path):
+        import re
+        valid_tmpdir_regexp = "^/[a-zA-Z0-9\-_/.~]+$"
+        valid_pattern = re.compile(valid_tmpdir_regexp)
+        if valid_pattern.match(path):
+            return True
+        else:
+            return False
+
     # Check that TMPDIR hasn't changed location since the last time we were run
     tmpdir = d.getVar('TMPDIR', True)
     checkfile = os.path.join(tmpdir, "saved_tmpdir")
@@ -667,10 +677,16 @@ def check_sanity_everybuild(status, d):
             saved_tmpdir = f.read().strip()
             if (saved_tmpdir != tmpdir):
                 status.addresult("Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir)
+            if not is_tmpdir_valid(tmpdir):
+                status.addresult("Error, you have special characters in TMPDIR directory path or your TMPDIR is not an absolute path. The TMPDIR should match this regexp: ^/[a-zA-Z0-9\-_/.~]$")
     else:
-        bb.utils.mkdirhier(tmpdir)
-        with open(checkfile, "w") as f:
-            f.write(tmpdir)
+        if not is_tmpdir_valid(tmpdir):
+            status.addresult("Error, you have special characters in TMPDIR directory path or your TMPDIR is not an absolute path. The TMPDIR should match this regexp: ^/[a-zA-Z0-9\-_/.~]$")
+        else:
+            # Make directory hierarchy for TMPDIR only if TMPDIR is valid
+            bb.utils.mkdirhier(tmpdir)
+            with open(checkfile, "w") as f:
+                f.write(tmpdir)
 
 def check_sanity(sanity_data):
     import subprocess
@@ -722,7 +738,10 @@ def check_sanity(sanity_data):
             f.write("TMPDIR %s\n" % tmpdir) 
             f.write("SSTATE_DIR %s\n" % sstate_dir) 
 
-    sanity_handle_abichanges(status, sanity_data)
+    # Handle ABI version change only if TMPDIR hierarchy has been created
+    saved_tmpdir = os.path.join(tmpdir, "saved_tmpdir")
+    if os.path.exists(saved_tmpdir):
+        sanity_handle_abichanges(status, sanity_data)
 
     if status.messages != "":
         raise_sanity_error(sanity_data.expand(status.messages), sanity_data, status.network_error)
-- 
1.7.9.5



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

* Re: [PATCH V2 0/1] sanity.bbclass: check for validity of TMPDIR
  2013-11-15  2:46 [PATCH V2 0/1] sanity.bbclass: check for validity of TMPDIR Qi.Chen
  2013-11-15  2:46 ` [PATCH V2 1/1] " Qi.Chen
@ 2013-11-25  3:04 ` ChenQi
  1 sibling, 0 replies; 4+ messages in thread
From: ChenQi @ 2013-11-25  3:04 UTC (permalink / raw)
  To: openembedded-core

ping

On 11/15/2013 10:46 AM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Changes since V1:
> 1. Create the directory hierarchy for TMPDIR only if TMPDIR is valid
> 2. Handle ABI version change only if TMPDIR has been created.
> 3. If we had a valid TMPDIR for last build and this time the TMPDIR hasn't
>     changed location, we don't check the validity for TMPDIR.
>
> The following changes since commit ea92671d9823e3667d6ced7ac2af20f991da404d:
>
>    bitbake: cooker: replace "w" file opening mode with "a" mode (2013-11-12 17:01:37 +0000)
>
> are available in the git repository at:
>
>    git://git.pokylinux.org/poky-contrib ChenQi/TMPDIR
>    http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/TMPDIR
>
> Chen Qi (1):
>    sanity.bbclass: check for validity of TMPDIR
>
>   meta/classes/sanity.bbclass |   27 +++++++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
>



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

* Re: [PATCH V2 1/1] sanity.bbclass: check for validity of TMPDIR
  2013-11-15  2:46 ` [PATCH V2 1/1] " Qi.Chen
@ 2013-12-11  9:09   ` ChenQi
  0 siblings, 0 replies; 4+ messages in thread
From: ChenQi @ 2013-12-11  9:09 UTC (permalink / raw)
  To: openembedded-core

Hi Richard,

What do you think of this one?

Best Regards,
Chen Qi

On 11/15/2013 10:46 AM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> TMPDIR must be an absolute path, otherwise, the build will fail.
> Special characters in TMPDIR will also cause build failures.
>
> This patch enables checking for the validity of TMPDIR.
>
> The logic in sanity.bbclass has also been changed a little bit. For now,
> we only create the directory hierarch for TMPDIR if TMPDIR is valid. And
> also, we only handle ABI version change only if the TMPDIR directory hierarchy
> has been created.
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   meta/classes/sanity.bbclass |   27 +++++++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> index 83378b0..f6292f4 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -659,6 +659,16 @@ def check_sanity_everybuild(status, d):
>       if oeroot.find(' ') != -1:
>           status.addresult("Error, you have a space in your COREBASE directory path. Please move the installation to a directory which doesn't include a space since autotools doesn't support this.")
>   
> +    # Function to check if TMPDIR contains invalid characters, and check if it is an absolute path
> +    def is_tmpdir_valid(path):
> +        import re
> +        valid_tmpdir_regexp = "^/[a-zA-Z0-9\-_/.~]+$"
> +        valid_pattern = re.compile(valid_tmpdir_regexp)
> +        if valid_pattern.match(path):
> +            return True
> +        else:
> +            return False
> +
>       # Check that TMPDIR hasn't changed location since the last time we were run
>       tmpdir = d.getVar('TMPDIR', True)
>       checkfile = os.path.join(tmpdir, "saved_tmpdir")
> @@ -667,10 +677,16 @@ def check_sanity_everybuild(status, d):
>               saved_tmpdir = f.read().strip()
>               if (saved_tmpdir != tmpdir):
>                   status.addresult("Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir)
> +            if not is_tmpdir_valid(tmpdir):
> +                status.addresult("Error, you have special characters in TMPDIR directory path or your TMPDIR is not an absolute path. The TMPDIR should match this regexp: ^/[a-zA-Z0-9\-_/.~]$")
>       else:
> -        bb.utils.mkdirhier(tmpdir)
> -        with open(checkfile, "w") as f:
> -            f.write(tmpdir)
> +        if not is_tmpdir_valid(tmpdir):
> +            status.addresult("Error, you have special characters in TMPDIR directory path or your TMPDIR is not an absolute path. The TMPDIR should match this regexp: ^/[a-zA-Z0-9\-_/.~]$")
> +        else:
> +            # Make directory hierarchy for TMPDIR only if TMPDIR is valid
> +            bb.utils.mkdirhier(tmpdir)
> +            with open(checkfile, "w") as f:
> +                f.write(tmpdir)
>   
>   def check_sanity(sanity_data):
>       import subprocess
> @@ -722,7 +738,10 @@ def check_sanity(sanity_data):
>               f.write("TMPDIR %s\n" % tmpdir)
>               f.write("SSTATE_DIR %s\n" % sstate_dir)
>   
> -    sanity_handle_abichanges(status, sanity_data)
> +    # Handle ABI version change only if TMPDIR hierarchy has been created
> +    saved_tmpdir = os.path.join(tmpdir, "saved_tmpdir")
> +    if os.path.exists(saved_tmpdir):
> +        sanity_handle_abichanges(status, sanity_data)
>   
>       if status.messages != "":
>           raise_sanity_error(sanity_data.expand(status.messages), sanity_data, status.network_error)



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

end of thread, other threads:[~2013-12-11  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15  2:46 [PATCH V2 0/1] sanity.bbclass: check for validity of TMPDIR Qi.Chen
2013-11-15  2:46 ` [PATCH V2 1/1] " Qi.Chen
2013-12-11  9:09   ` ChenQi
2013-11-25  3:04 ` [PATCH V2 0/1] " ChenQi

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