* [PATCH 0/2] A couple of fixes for the inotify code
@ 2017-09-14 4:09 Paul Eggleton
2017-09-14 4:09 ` [PATCH 1/2] cooker: fix watching empty directories Paul Eggleton
2017-09-14 4:09 ` [PATCH 2/2] cooker: ensure monkey-patching in collect_bbfiles() gets undone on error Paul Eggleton
0 siblings, 2 replies; 3+ messages in thread
From: Paul Eggleton @ 2017-09-14 4:09 UTC (permalink / raw)
To: bitbake-devel
A fix for bbappends created in empty directories not being picked up,
and a related patch for a separate minor issue I noticed at the same
time.
The following changes since commit f0930f3216a8358759d561d244fa280932e8bf05:
bitbake-user-manual: Edits to "inherit" section. (2017-09-13 17:19:08 +0100)
are available in the git repository at:
git://git.openembedded.org/bitbake-contrib paule/bb-watch-fixes
http://cgit.openembedded.org/bitbake-contrib/log/?h=paule/bb-watch-fixes
Paul Eggleton (2):
cooker: fix watching empty directories
cooker: ensure monkey-patching in collect_bbfiles() gets undone on error
lib/bb/cooker.py | 47 +++++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 22 deletions(-)
--
2.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] cooker: fix watching empty directories
2017-09-14 4:09 [PATCH 0/2] A couple of fixes for the inotify code Paul Eggleton
@ 2017-09-14 4:09 ` Paul Eggleton
2017-09-14 4:09 ` [PATCH 2/2] cooker: ensure monkey-patching in collect_bbfiles() gets undone on error Paul Eggleton
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2017-09-14 4:09 UTC (permalink / raw)
To: bitbake-devel
The code that was supposed to watch directories along BBFILES for
creation of new files wasn't working in the case where the directory did
not initially contain any matching files - since in updateCache() we are
passing the directory path to add_filewatch() and the latter function
calls os.path.dirname() on the path on the assumption that it is a file
path, and thus the parent of the directory got watched but not the
directory itself. (If the directory wasn't empty everything worked fine
since add_filewatch() was called elsewhere with the path to one of the
files in that directory, and thus the directory got watched). Add a
parameter to add_filewatch() to tell it we are passing it directory
path(s) rather than file path(s).
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/cooker.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 8fe36eb..6de04fc 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -266,12 +266,15 @@ class BBCooker:
self.inotify_modified_files.append(event.pathname)
self.parsecache_valid = False
- def add_filewatch(self, deps, watcher=None):
+ def add_filewatch(self, deps, watcher=None, dirs=False):
if not watcher:
watcher = self.watcher
for i in deps:
watcher.bbwatchedfiles.append(i[0])
- f = os.path.dirname(i[0])
+ if dirs:
+ f = i[0]
+ else:
+ f = os.path.dirname(i[0])
if f in watcher.bbseen:
continue
watcher.bbseen.append(f)
@@ -1512,7 +1515,7 @@ class BBCooker:
# Add inotify watches for directories searched for bb/bbappend files
for dirent in searchdirs:
- self.add_filewatch([[dirent]])
+ self.add_filewatch([[dirent]], dirs=True)
self.parser = CookerParser(self, filelist, masked)
self.parsecache_valid = True
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] cooker: ensure monkey-patching in collect_bbfiles() gets undone on error
2017-09-14 4:09 [PATCH 0/2] A couple of fixes for the inotify code Paul Eggleton
2017-09-14 4:09 ` [PATCH 1/2] cooker: fix watching empty directories Paul Eggleton
@ 2017-09-14 4:09 ` Paul Eggleton
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2017-09-14 4:09 UTC (permalink / raw)
To: bitbake-devel
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@linux.intel.com>
---
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 6de04fc..73a2fef 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1695,25 +1695,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')
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-14 4:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-14 4:09 [PATCH 0/2] A couple of fixes for the inotify code Paul Eggleton
2017-09-14 4:09 ` [PATCH 1/2] cooker: fix watching empty directories Paul Eggleton
2017-09-14 4:09 ` [PATCH 2/2] cooker: ensure monkey-patching in collect_bbfiles() gets undone on error Paul Eggleton
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.