@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -212,4 +212,4 @@ class SystemStats:
b'\n')
self.last_disk_monitor = now
retval = True
- return retval
+ return retval
\ No newline at end of file
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -1,5 +1,5 @@
#
-# Imported from openembedded-core
+# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -7,6 +7,7 @@
import subprocess
import multiprocessing
import traceback
+import errno
def read_file(filename):
try:
@@ -258,16 +259,23 @@ def execute_pre_post_process(d, cmds):
if cmds is None:
return
- for cmd in cmds.strip().split(';'):
- cmd = cmd.strip()
- if cmd != '':
- bb.note("Executing %s ..." % cmd)
- bb.build.exec_func(cmd, d)
+ cmds = cmds.replace(";", " ")
-# For each item in items, call the function 'target' with item as the first
+ for cmd in cmds.split():
+ bb.note("Executing %s ..." % cmd)
+ bb.build.exec_func(cmd, d)
+
+def get_bb_number_threads(d):
+ return int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
+
+def multiprocess_launch(target, items, d, extraargs=None):
+ max_process = get_bb_number_threads(d)
+ return multiprocess_launch_mp(target, items, max_process, extraargs)
+
+# For each item in items, call the function 'target' with item as the first
# argument, extraargs as the other arguments and handle any exceptions in the
# parent thread
-def multiprocess_launch(target, items, d, extraargs=None):
+def multiprocess_launch_mp(target, items, max_process, extraargs=None):
class ProcessLaunch(multiprocessing.Process):
def __init__(self, *args, **kwargs):
@@ -302,7 +310,6 @@ def multiprocess_launch(target, items, d, extraargs=None):
self.update()
return self._result
- max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
launched = []
errors = []
results = []
@@ -475,70 +482,6 @@ def get_multilib_datastore(variant, d):
localdata.setVar("MLPREFIX", "")
return localdata
-#
-# Python 2.7 doesn't have threaded pools (just multiprocessing)
-# so implement a version here
-#
-
-from queue import Queue
-from threading import Thread
-
-class ThreadedWorker(Thread):
- """Thread executing tasks from a given tasks queue"""
- def __init__(self, tasks, worker_init, worker_end, name=None):
- Thread.__init__(self, name=name)
- self.tasks = tasks
- self.daemon = True
-
- self.worker_init = worker_init
- self.worker_end = worker_end
-
- def run(self):
- from queue import Empty
-
- if self.worker_init is not None:
- self.worker_init(self)
-
- while True:
- try:
- func, args, kargs = self.tasks.get(block=False)
- except Empty:
- if self.worker_end is not None:
- self.worker_end(self)
- break
-
- try:
- func(self, *args, **kargs)
- except Exception as e:
- # Eat all exceptions
- bb.mainlogger.debug("Worker task raised %s" % e, exc_info=e)
- finally:
- self.tasks.task_done()
-
-class ThreadedPool:
- """Pool of threads consuming tasks from a queue"""
- def __init__(self, num_workers, num_tasks, worker_init=None, worker_end=None, name="ThreadedPool-"):
- self.tasks = Queue(num_tasks)
- self.workers = []
-
- for i in range(num_workers):
- worker = ThreadedWorker(self.tasks, worker_init, worker_end, name=name + str(i))
- self.workers.append(worker)
-
- def start(self):
- for worker in self.workers:
- worker.start()
-
- def add_task(self, func, *args, **kargs):
- """Add a task to the queue"""
- self.tasks.put((func, args, kargs))
-
- def wait_completion(self):
- """Wait for completion of all the tasks in the queue"""
- self.tasks.join()
- for worker in self.workers:
- worker.join()
-
class ImageQAFailed(Exception):
def __init__(self, description, name=None, logfile=None):
self.description = description
@@ -586,3 +529,14 @@ def directory_size(root, blocksize=4096):
total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
total += roundup(getsize(root))
return total
+
+# Update the mtime of a file, skip if permission/read-only issues
+def touch(filename):
+ try:
+ os.utime(filename, None)
+ except PermissionError:
+ pass
+ except OSError as e:
+ # Handle read-only file systems gracefully
+ if e.errno != errno.EROFS:
+ raise e
OE-core Revision: 236ac1b43308df722a78d3aa20aef065dfae5b2b. Following changes are left because they are still needed in Isar: 9a714f6e patch: Set dummy credentials for git notes 68f299d0 devshell: Use different termination test to avoid warnings Signed-off-by: Anton Mikanovich <amikan@ilbers.de> --- meta/lib/buildstats.py | 4 +- meta/lib/oe/classutils.py | 2 +- meta/lib/oe/data.py | 2 +- meta/lib/oe/gpg_sign.py | 2 +- meta/lib/oe/maketype.py | 2 +- meta/lib/oe/patch.py | 2 +- meta/lib/oe/path.py | 2 +- meta/lib/oe/reproducible.py | 2 +- meta/lib/oe/sstatesig.py | 2 +- meta/lib/oe/terminal.py | 2 +- meta/lib/oe/types.py | 2 +- meta/lib/oe/utils.py | 100 ++++++++++-------------------------- 12 files changed, 39 insertions(+), 85 deletions(-)