@@ -12,11 +12,12 @@
#
# Heavily inspired of bootimg_partition.py
#
-def get_boot_files(deploy_dir, boot_files):
- import re
- import os
- from glob import glob
+import os
+import re
+import glob
+
+def get_boot_files(deploy_dir, boot_files):
if boot_files is None:
return None
@@ -45,7 +46,7 @@ def get_boot_files(deploy_dir, boot_files):
os.path.join(dst,
os.path.basename(name))
- srcs = glob(os.path.join(deploy_dir, src))
+ srcs = glob.glob(os.path.join(deploy_dir, src))
for entry in srcs:
src = os.path.relpath(entry, deploy_dir)
@@ -7,6 +7,7 @@
# Because it is a real Python module, it can hold persistent state,
# like open log files and the time of the last sampling.
+import os
import time
import re
import bb.event
@@ -12,11 +12,13 @@
# e.g.: ".*-downloads closed-.*"
#
+import os
+import re
import stat
import shutil
+import subprocess
def _smart_copy(src, dest):
- import subprocess
# smart_copy will choose the correct function depending on whether the
# source is a file or a directory.
mode = os.stat(src).st_mode
@@ -38,7 +40,6 @@ class BuildSystem(object):
self.layers_exclude_pattern = d.getVar('SDK_LAYERS_EXCLUDE_PATTERN')
def copy_bitbake_and_layers(self, destdir, workspace_name=None):
- import re
# Copy in all metadata layers + bitbake (as repositories)
copied_corebase = None
layers_copied = []
@@ -261,7 +262,6 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
write_sigs_file(merged_output, arch_order, merged)
def create_locked_sstate_cache(lockedsigs, input_sstate_cache, output_sstate_cache, d, fixedlsbstring="", filterfile=None):
- import shutil
bb.note('Generating sstate-cache...')
nativelsbstring = d.getVar('NATIVELSBSTRING')
@@ -282,8 +282,6 @@ def create_locked_sstate_cache(lockedsigs, input_sstate_cache, output_sstate_cac
shutil.move(src, dest)
def check_sstate_task_list(d, targets, filteroutfile, cmdprefix='', cwd=None, logfile=None):
- import subprocess
-
bb.note('Generating sstate task list...')
if not cwd:
@@ -4,6 +4,9 @@
# SPDX-License-Identifier: GPL-2.0-only
#
+import os
+import shutil
+
def create_socket(url, d):
import urllib
from bb.utils import export_proxies
@@ -150,8 +153,6 @@ def get_latest_released_ubuntu_source_package_list(d):
return latest, package_names
def create_distro_packages_list(distro_check_dir, d):
- import shutil
-
pkglst_dir = os.path.join(distro_check_dir, "package_lists")
bb.utils.remove(pkglst_dir, True)
bb.utils.mkdirhier(pkglst_dir)
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT
#
+import os
import re
# Return a value for the ARCH environment variable for kernel compilation (including
@@ -6,6 +6,7 @@
"""Code for parsing OpenEmbedded license strings"""
import ast
+import os
import re
import oe.qa
from fnmatch import fnmatchcase as fnmatch
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT
#
+import os
import bb
import json
import subprocess
@@ -6,6 +6,7 @@
import errno
import glob
+import os
import shutil
import subprocess
import os.path
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT
#
+import os
import oe.utils
def bblayers_conf_file(d):
@@ -8,6 +8,7 @@ import bb
import collections
import json
import oe.packagedata
+import os
import re
import shutil
@@ -7,6 +7,7 @@ import bb.parse
import bb.siggen
import bb.runqueue
import oe
+import os
import netrc
def sstate_rundepfilter(siggen, fn, recipename, task, dep, depname, dataCaches):
@@ -5,6 +5,7 @@
#
import logging
import oe.classutils
+import os
import shlex
from bb.process import Popen, ExecutionError
@@ -7,6 +7,7 @@
import subprocess
import traceback
import errno
+import os
import bb.parse
from bb import multiprocessing
@@ -3,6 +3,11 @@
#
# SPDX-License-Identifier: MIT
#
+
+import importlib
+import os
+import sys
+
# Enable other layers to have modules in the same named directory
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
@@ -24,8 +29,6 @@ def avoid_paths_in_environ(paths):
Returns new PATH without avoided PATHs.
"""
- import os
-
new_path = ''
for p in os.environ['PATH'].split(':'):
avoid = False
@@ -56,9 +59,6 @@ def make_logger_bitbake_compatible(logger):
return logger
def load_test_components(logger, executor):
- import sys
- import os
- import importlib
from oeqa.core.context import OETestContextExecutor
@@ -5,6 +5,8 @@
# Functions to get metadata from the testing host used
# for analytics of test results.
+import os
+
from collections import OrderedDict
from collections.abc import MutableMapping
from xml.dom.minidom import parseString
There are a number of places os isn't imported as in class code, bitbake has always handled this. Some external usages of the modules are triggering exceptions from missing imports after bitbake's own imports were cleaned up. Add the easily identified missing import os calls and move other imports to the start of the files whilst there. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- meta/lib/oe/bootfiles.py | 11 ++++++----- meta/lib/oe/buildstats.py | 1 + meta/lib/oe/copy_buildsystem.py | 8 +++----- meta/lib/oe/distro_check.py | 5 +++-- meta/lib/oe/kernel.py | 1 + meta/lib/oe/license.py | 1 + meta/lib/oe/npm_registry.py | 1 + meta/lib/oe/path.py | 1 + meta/lib/oe/sanity.py | 1 + meta/lib/oe/spdx_common.py | 1 + meta/lib/oe/sstatesig.py | 1 + meta/lib/oe/terminal.py | 1 + meta/lib/oe/utils.py | 1 + meta/lib/oeqa/utils/__init__.py | 10 +++++----- meta/lib/oeqa/utils/metadata.py | 2 ++ 15 files changed, 29 insertions(+), 17 deletions(-)