[oe-commits] [bitbake] 03/10: cooker: ensure monkey-patching in collect_bbfiles() gets undone on error

git at git.openembedded.org git at git.openembedded.org
Thu Sep 21 15:56:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch 1.34
in repository bitbake.

commit 021e0eda63bd629af56b5e1c380c5f98868f7332
Author: Paul Eggleton <paul.eggleton at linux.intel.com>
AuthorDate: Thu Sep 14 16:09:42 2017 +1200

    cooker: ensure monkey-patching in collect_bbfiles() gets undone on error
    
    In collect_bbfiles() we're monkey-patching os.listdir in order to find
    which directories to watch, and then undoing that when we're finished -
    however if an exception occurred for any reason there was nothing to
    ensure the latter occurred. This may not have caused any issues, but as
    this kind of thing really ought to be secured using try...finally just
    in case, so do that.
    
    Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/cooker.py | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index bdd9112..d254bd2 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1894,25 +1894,25 @@ class CookerCollectFiles(object):
             return origlistdir(d)
 
         os.listdir = ourlistdir
-
-        # Can't use set here as order is important
-        newfiles = []
-        for f in files:
-            if os.path.isdir(f):
-                dirfiles = self.find_bbfiles(f)
-                for g in dirfiles:
-                    if g not in newfiles:
-                        newfiles.append(g)
-            else:
-                globbed = glob.glob(f)
-                if not globbed and os.path.exists(f):
-                    globbed = [f]
-                # glob gives files in order on disk. Sort to be deterministic.
-                for g in sorted(globbed):
-                    if g not in newfiles:
-                        newfiles.append(g)
-
-        os.listdir = origlistdir
+        try:
+            # Can't use set here as order is important
+            newfiles = []
+            for f in files:
+                if os.path.isdir(f):
+                    dirfiles = self.find_bbfiles(f)
+                    for g in dirfiles:
+                        if g not in newfiles:
+                            newfiles.append(g)
+                else:
+                    globbed = glob.glob(f)
+                    if not globbed and os.path.exists(f):
+                        globbed = [f]
+                    # glob gives files in order on disk. Sort to be deterministic.
+                    for g in sorted(globbed):
+                        if g not in newfiles:
+                            newfiles.append(g)
+        finally:
+            os.listdir = origlistdir
 
         bbmask = config.getVar('BBMASK')
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list