diff options
Diffstat (limited to 'scripts/lib/scriptutils.py')
-rw-r--r-- | scripts/lib/scriptutils.py | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index f92255d8dc..81f0b01fa5 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py @@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0-only # -import argparse import glob import logging import os @@ -18,13 +17,14 @@ import sys import tempfile import threading import importlib -from importlib import machinery +import importlib.machinery +import importlib.util class KeepAliveStreamHandler(logging.StreamHandler): def __init__(self, keepalive=True, **kwargs): super().__init__(**kwargs) if keepalive is True: - keepalive = 5000 # default timeout + keepalive = 5000 # default timeout self._timeout = threading.Condition() self._stop = False @@ -35,9 +35,9 @@ class KeepAliveStreamHandler(logging.StreamHandler): with self._timeout: if not self._timeout.wait(keepalive): self.emit(logging.LogRecord("keepalive", logging.INFO, - None, None, "Keepalive message", None, None)) + None, None, "Keepalive message", None, None)) - self._thread = threading.Thread(target = thread, daemon = True) + self._thread = threading.Thread(target=thread, daemon=True) self._thread.start() def close(self): @@ -71,18 +71,19 @@ def logger_setup_color(logger, color='auto'): for handler in logger.handlers: if (isinstance(handler, logging.StreamHandler) and - isinstance(handler.formatter, BBLogFormatter)): + isinstance(handler.formatter, BBLogFormatter)): if color == 'always' or (color == 'auto' and handler.stream.isatty()): handler.formatter.enable_color() def load_plugins(logger, plugins, pluginpath): - def load_plugin(name): logger.debug('Loading plugin %s' % name) - spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) + spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath]) if spec: - return spec.loader.load_module() + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod def plugin_name(filename): return os.path.splitext(os.path.basename(filename))[0] @@ -176,7 +177,10 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr f.write('BB_STRICT_CHECKSUM = "ignore"\n') f.write('SRC_URI = "%s"\n' % srcuri) f.write('SRCREV = "%s"\n' % srcrev) + f.write('PV = "0.0+"\n') f.write('WORKDIR = "%s"\n' % tmpworkdir) + f.write('UNPACKDIR = "%s"\n' % destdir) + # Set S out of the way so it doesn't get created under the workdir f.write('S = "%s"\n' % os.path.join(tmpdir, 'emptysrc')) if not mirrors: @@ -215,7 +219,8 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr pathvars = ['T', 'RECIPE_SYSROOT', 'RECIPE_SYSROOT_NATIVE'] for pathvar in pathvars: path = rd.getVar(pathvar) - shutil.rmtree(path) + if os.path.exists(path): + shutil.rmtree(path) finally: if fetchrecipe: try: @@ -229,10 +234,6 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr if e.errno != errno.ENOTEMPTY: raise - bb.utils.mkdirhier(destdir) - for fn in os.listdir(tmpworkdir): - shutil.move(os.path.join(tmpworkdir, fn), destdir) - finally: if not preserve_tmp: shutil.rmtree(tmpdir) @@ -268,12 +269,3 @@ def is_src_url(param): return True return False -def filter_src_subdirs(pth): - """ - Filter out subdirectories of initial unpacked source trees that we do not care about. - Used by devtool and recipetool. - """ - dirlist = os.listdir(pth) - filterout = ['git.indirectionsymlink', 'source-date-epoch'] - dirlist = [x for x in dirlist if x not in filterout] - return dirlist |