diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-10-19 16:32:21 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-10-31 09:09:21 +0000 |
commit | 800e9a50594d6992e1515b14fdd657afe6f7c066 (patch) | |
tree | 4590d40a3cbb70f06c4c56a0a8d75236c4dd7092 /bitbake/lib/bb/cooker.py | |
parent | 571b3830a78304969eb1cef5373c81b6088773ef (diff) | |
download | poky-800e9a50594d6992e1515b14fdd657afe6f7c066.tar.gz |
bitbake: cooker: fix watching directories with Python 3.6+
In Python 3.6, glob.glob() was reimplemented to use os.scandir() (which
itself appeared in Python 3.5), thus our monkey patching of os.listdir()
here was no longer effective. The end result was not only that bitbake
wouldn't notice added recipes or bbappends with BB_SERVER_TIMEOUT set
when being run with Python 3.6 (the shipped Python version on Fedora 26
and some other distribution versions), it also broke devtool modify,
devtool upgrade and devtool extract since they rely on the ability to
create a bbappend on the fly and have bitbake pick it up.
To fix it, do the same monkey patching for os.scandir(), which needs to
be conditional upon that actually existing since we have to support
Python 3.4 that doesn't have it. Long term we should probably look for a
better way to handle this that doesn't involve monkey patching Python
library code.
Fixes [YOCTO #12185].
(Bitbake rev: d02e90db32e7ee341c2ba3be79b0627d8796bdd6)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 73a2fef287..c7fdd72901 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1686,15 +1686,23 @@ class CookerCollectFiles(object): | |||
1686 | 1686 | ||
1687 | # We need to track where we look so that we can add inotify watches. There | 1687 | # We need to track where we look so that we can add inotify watches. There |
1688 | # is no nice way to do this, this is horrid. We intercept the os.listdir() | 1688 | # is no nice way to do this, this is horrid. We intercept the os.listdir() |
1689 | # calls while we run glob(). | 1689 | # (or os.scandir() for python 3.6+) calls while we run glob(). |
1690 | origlistdir = os.listdir | 1690 | origlistdir = os.listdir |
1691 | if hasattr(os, 'scandir'): | ||
1692 | origscandir = os.scandir | ||
1691 | searchdirs = [] | 1693 | searchdirs = [] |
1692 | 1694 | ||
1693 | def ourlistdir(d): | 1695 | def ourlistdir(d): |
1694 | searchdirs.append(d) | 1696 | searchdirs.append(d) |
1695 | return origlistdir(d) | 1697 | return origlistdir(d) |
1696 | 1698 | ||
1699 | def ourscandir(d): | ||
1700 | searchdirs.append(d) | ||
1701 | return origscandir(d) | ||
1702 | |||
1697 | os.listdir = ourlistdir | 1703 | os.listdir = ourlistdir |
1704 | if hasattr(os, 'scandir'): | ||
1705 | os.scandir = ourscandir | ||
1698 | try: | 1706 | try: |
1699 | # Can't use set here as order is important | 1707 | # Can't use set here as order is important |
1700 | newfiles = [] | 1708 | newfiles = [] |
@@ -1714,6 +1722,8 @@ class CookerCollectFiles(object): | |||
1714 | newfiles.append(g) | 1722 | newfiles.append(g) |
1715 | finally: | 1723 | finally: |
1716 | os.listdir = origlistdir | 1724 | os.listdir = origlistdir |
1725 | if hasattr(os, 'scandir'): | ||
1726 | os.scandir = origscandir | ||
1717 | 1727 | ||
1718 | bbmask = config.getVar('BBMASK') | 1728 | bbmask = config.getVar('BBMASK') |
1719 | 1729 | ||