summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/buildhistory_analysis.py4
-rw-r--r--meta/lib/oe/classutils.py17
-rw-r--r--meta/lib/oe/copy_buildsystem.py4
-rw-r--r--meta/lib/oe/data.py7
-rw-r--r--meta/lib/oe/distro_check.py8
-rw-r--r--meta/lib/oe/license.py10
-rw-r--r--meta/lib/oe/lsb.py4
-rw-r--r--meta/lib/oe/maketype.py10
-rw-r--r--meta/lib/oe/manifest.py7
-rw-r--r--meta/lib/oe/package.py6
-rw-r--r--meta/lib/oe/package_manager.py51
-rw-r--r--meta/lib/oe/packagedata.py4
-rw-r--r--meta/lib/oe/packagegroup.py4
-rw-r--r--meta/lib/oe/patch.py4
-rw-r--r--meta/lib/oe/prservice.py6
-rw-r--r--meta/lib/oe/qa.py14
-rw-r--r--meta/lib/oe/recipeutils.py22
-rw-r--r--meta/lib/oe/rootfs.py15
-rw-r--r--meta/lib/oe/sdk.py8
-rw-r--r--meta/lib/oe/sstatesig.py4
-rw-r--r--meta/lib/oe/terminal.py6
-rw-r--r--meta/lib/oe/tests/test_path.py2
-rw-r--r--meta/lib/oe/types.py4
-rw-r--r--meta/lib/oe/utils.py16
24 files changed, 118 insertions, 119 deletions
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index 5395c768a3..0dcd49f4f1 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -62,7 +62,7 @@ class ChangeRecord:
62 62
63 def pkglist_combine(depver): 63 def pkglist_combine(depver):
64 pkglist = [] 64 pkglist = []
65 for k,v in depver.iteritems(): 65 for k,v in depver.items():
66 if v: 66 if v:
67 pkglist.append("%s (%s)" % (k,v)) 67 pkglist.append("%s (%s)" % (k,v))
68 else: 68 else:
@@ -220,7 +220,7 @@ def compare_file_lists(alines, blines):
220 adict = file_list_to_dict(alines) 220 adict = file_list_to_dict(alines)
221 bdict = file_list_to_dict(blines) 221 bdict = file_list_to_dict(blines)
222 filechanges = [] 222 filechanges = []
223 for path, splitv in adict.iteritems(): 223 for path, splitv in adict.items():
224 newsplitv = bdict.pop(path, None) 224 newsplitv = bdict.pop(path, None)
225 if newsplitv: 225 if newsplitv:
226 # Check type 226 # Check type
diff --git a/meta/lib/oe/classutils.py b/meta/lib/oe/classutils.py
index 58188fdd6e..e7856c86f2 100644
--- a/meta/lib/oe/classutils.py
+++ b/meta/lib/oe/classutils.py
@@ -1,4 +1,11 @@
1class ClassRegistry(type): 1
2class ClassRegistryMeta(type):
3 """Give each ClassRegistry their own registry"""
4 def __init__(cls, name, bases, attrs):
5 cls.registry = {}
6 type.__init__(cls, name, bases, attrs)
7
8class ClassRegistry(type, metaclass=ClassRegistryMeta):
2 """Maintain a registry of classes, indexed by name. 9 """Maintain a registry of classes, indexed by name.
3 10
4Note that this implementation requires that the names be unique, as it uses 11Note that this implementation requires that the names be unique, as it uses
@@ -12,12 +19,6 @@ Subclasses of ClassRegistry may define an 'implemented' property to exert
12control over whether the class will be added to the registry (e.g. to keep 19control over whether the class will be added to the registry (e.g. to keep
13abstract base classes out of the registry).""" 20abstract base classes out of the registry)."""
14 priority = 0 21 priority = 0
15 class __metaclass__(type):
16 """Give each ClassRegistry their own registry"""
17 def __init__(cls, name, bases, attrs):
18 cls.registry = {}
19 type.__init__(cls, name, bases, attrs)
20
21 def __init__(cls, name, bases, attrs): 22 def __init__(cls, name, bases, attrs):
22 super(ClassRegistry, cls).__init__(name, bases, attrs) 23 super(ClassRegistry, cls).__init__(name, bases, attrs)
23 try: 24 try:
@@ -34,7 +35,7 @@ abstract base classes out of the registry)."""
34 35
35 @classmethod 36 @classmethod
36 def prioritized(tcls): 37 def prioritized(tcls):
37 return sorted(tcls.registry.values(), 38 return sorted(list(tcls.registry.values()),
38 key=lambda v: v.priority, reverse=True) 39 key=lambda v: v.priority, reverse=True)
39 40
40 def unregister(cls): 41 def unregister(cls):
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
index 7b9a0ee065..eddf5bb2da 100644
--- a/meta/lib/oe/copy_buildsystem.py
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -124,7 +124,7 @@ class BuildSystem(object):
124def generate_locked_sigs(sigfile, d): 124def generate_locked_sigs(sigfile, d):
125 bb.utils.mkdirhier(os.path.dirname(sigfile)) 125 bb.utils.mkdirhier(os.path.dirname(sigfile))
126 depd = d.getVar('BB_TASKDEPDATA', False) 126 depd = d.getVar('BB_TASKDEPDATA', False)
127 tasks = ['%s.%s' % (v[2], v[1]) for v in depd.itervalues()] 127 tasks = ['%s.%s' % (v[2], v[1]) for v in depd.values()]
128 bb.parse.siggen.dump_lockedsigs(sigfile, tasks) 128 bb.parse.siggen.dump_lockedsigs(sigfile, tasks)
129 129
130def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, pruned_output): 130def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, pruned_output):
@@ -195,7 +195,7 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
195 fulltypes.append(typename) 195 fulltypes.append(typename)
196 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes)) 196 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes))
197 197
198 write_sigs_file(copy_output, tocopy.keys(), tocopy) 198 write_sigs_file(copy_output, list(tocopy.keys()), tocopy)
199 if merged_output: 199 if merged_output:
200 write_sigs_file(merged_output, arch_order, merged) 200 write_sigs_file(merged_output, arch_order, merged)
201 201
diff --git a/meta/lib/oe/data.py b/meta/lib/oe/data.py
index e49572177b..58e764699d 100644
--- a/meta/lib/oe/data.py
+++ b/meta/lib/oe/data.py
@@ -1,17 +1,20 @@
1import oe.maketype 1import oe.maketype
2 2
3def typed_value(key, d): 3def typed_value(key, d):
4 #return d.getVar(key, True).split()
5
4 """Construct a value for the specified metadata variable, using its flags 6 """Construct a value for the specified metadata variable, using its flags
5 to determine the type and parameters for construction.""" 7 to determine the type and parameters for construction."""
6 var_type = d.getVarFlag(key, 'type', True) 8 var_type = d.getVarFlag(key, 'type', True)
7 flags = d.getVarFlags(key) 9 flags = d.getVarFlags(key)
8 if flags is not None: 10 if flags is not None:
9 flags = dict((flag, d.expand(value)) 11 flags = dict((flag, d.expand(value))
10 for flag, value in flags.iteritems()) 12 for flag, value in list(flags.items()))
11 else: 13 else:
12 flags = {} 14 flags = {}
13 15
14 try: 16 try:
15 return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags) 17 return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags)
16 except (TypeError, ValueError), exc: 18 except (TypeError, ValueError) as exc:
17 bb.msg.fatal("Data", "%s: %s" % (key, str(exc))) 19 bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
20
diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py
index 8655a6fc14..746e242f5d 100644
--- a/meta/lib/oe/distro_check.py
+++ b/meta/lib/oe/distro_check.py
@@ -1,8 +1,8 @@
1from contextlib import contextmanager 1from contextlib import contextmanager
2@contextmanager 2@contextmanager
3def create_socket(url, d): 3def create_socket(url, d):
4 import urllib 4 import urllib.request, urllib.parse, urllib.error
5 socket = urllib.urlopen(url, proxies=get_proxies(d)) 5 socket = urllib.request.urlopen(url, proxies=get_proxies(d))
6 try: 6 try:
7 yield socket 7 yield socket
8 finally: 8 finally:
@@ -104,8 +104,8 @@ def get_source_package_list_from_url(url, section, d):
104 104
105 bb.note("Reading %s: %s" % (url, section)) 105 bb.note("Reading %s: %s" % (url, section))
106 links = get_links_from_url(url, d) 106 links = get_links_from_url(url, d)
107 srpms = filter(is_src_rpm, links) 107 srpms = list(filter(is_src_rpm, links))
108 names_list = map(package_name_from_srpm, srpms) 108 names_list = list(map(package_name_from_srpm, srpms))
109 109
110 new_pkgs = [] 110 new_pkgs = []
111 for pkgs in names_list: 111 for pkgs in names_list:
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index f0f661c3ba..39ef9654fc 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -47,7 +47,7 @@ class LicenseVisitor(ast.NodeVisitor):
47 """Get elements based on OpenEmbedded license strings""" 47 """Get elements based on OpenEmbedded license strings"""
48 def get_elements(self, licensestr): 48 def get_elements(self, licensestr):
49 new_elements = [] 49 new_elements = []
50 elements = filter(lambda x: x.strip(), license_operator.split(licensestr)) 50 elements = list([x for x in license_operator.split(licensestr) if x.strip()])
51 for pos, element in enumerate(elements): 51 for pos, element in enumerate(elements):
52 if license_pattern.match(element): 52 if license_pattern.match(element):
53 if pos > 0 and license_pattern.match(elements[pos-1]): 53 if pos > 0 and license_pattern.match(elements[pos-1]):
@@ -118,8 +118,8 @@ def is_included(licensestr, whitelist=None, blacklist=None):
118 def choose_licenses(alpha, beta): 118 def choose_licenses(alpha, beta):
119 """Select the option in an OR which is the 'best' (has the most 119 """Select the option in an OR which is the 'best' (has the most
120 included licenses).""" 120 included licenses)."""
121 alpha_weight = len(filter(include_license, alpha)) 121 alpha_weight = len(list(filter(include_license, alpha)))
122 beta_weight = len(filter(include_license, beta)) 122 beta_weight = len(list(filter(include_license, beta)))
123 if alpha_weight > beta_weight: 123 if alpha_weight > beta_weight:
124 return alpha 124 return alpha
125 else: 125 else:
@@ -132,8 +132,8 @@ def is_included(licensestr, whitelist=None, blacklist=None):
132 blacklist = [] 132 blacklist = []
133 133
134 licenses = flattened_licenses(licensestr, choose_licenses) 134 licenses = flattened_licenses(licensestr, choose_licenses)
135 excluded = filter(lambda lic: exclude_license(lic), licenses) 135 excluded = [lic for lic in licenses if exclude_license(lic)]
136 included = filter(lambda lic: include_license(lic), licenses) 136 included = [lic for lic in licenses if include_license(lic)]
137 if excluded: 137 if excluded:
138 return False, excluded 138 return False, excluded
139 else: 139 else:
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py
index e0bdfba255..b7e142387c 100644
--- a/meta/lib/oe/lsb.py
+++ b/meta/lib/oe/lsb.py
@@ -9,9 +9,9 @@ def release_dict():
9 9
10 data = {} 10 data = {}
11 for line in output.splitlines(): 11 for line in output.splitlines():
12 if line.startswith("-e"): line = line[3:] 12 if line.startswith(b"-e"): line = line[3:]
13 try: 13 try:
14 key, value = line.split(":\t", 1) 14 key, value = line.decode().split(":\t", 1)
15 except ValueError: 15 except ValueError:
16 continue 16 continue
17 else: 17 else:
diff --git a/meta/lib/oe/maketype.py b/meta/lib/oe/maketype.py
index 139f333691..de344a802c 100644
--- a/meta/lib/oe/maketype.py
+++ b/meta/lib/oe/maketype.py
@@ -6,7 +6,8 @@ the arguments of the type's factory for details.
6""" 6"""
7 7
8import inspect 8import inspect
9import types 9import oe.types as types
10import collections
10 11
11available_types = {} 12available_types = {}
12 13
@@ -53,7 +54,9 @@ def get_callable_args(obj):
53 if type(obj) is type: 54 if type(obj) is type:
54 obj = obj.__init__ 55 obj = obj.__init__
55 56
56 args, varargs, keywords, defaults = inspect.getargspec(obj) 57 sig = inspect.signature(obj)
58 args = list(sig.parameters.keys())
59 defaults = list(s for s in sig.parameters.keys() if sig.parameters[s].default != inspect.Parameter.empty)
57 flaglist = [] 60 flaglist = []
58 if args: 61 if args:
59 if len(args) > 1 and args[0] == 'self': 62 if len(args) > 1 and args[0] == 'self':
@@ -93,7 +96,8 @@ for name in dir(types):
93 continue 96 continue
94 97
95 obj = getattr(types, name) 98 obj = getattr(types, name)
96 if not callable(obj): 99 if not isinstance(obj, collections.Callable):
97 continue 100 continue
98 101
99 register(name, obj) 102 register(name, obj)
103
diff --git a/meta/lib/oe/manifest.py b/meta/lib/oe/manifest.py
index 42832f15d2..95f8eb2df3 100644
--- a/meta/lib/oe/manifest.py
+++ b/meta/lib/oe/manifest.py
@@ -4,11 +4,10 @@ import re
4import bb 4import bb
5 5
6 6
7class Manifest(object): 7class Manifest(object, metaclass=ABCMeta):
8 """ 8 """
9 This is an abstract class. Do not instantiate this directly. 9 This is an abstract class. Do not instantiate this directly.
10 """ 10 """
11 __metaclass__ = ABCMeta
12 11
13 PKG_TYPE_MUST_INSTALL = "mip" 12 PKG_TYPE_MUST_INSTALL = "mip"
14 PKG_TYPE_MULTILIB = "mlp" 13 PKG_TYPE_MULTILIB = "mlp"
@@ -219,7 +218,7 @@ class RpmManifest(Manifest):
219 if var in self.vars_to_split: 218 if var in self.vars_to_split:
220 split_pkgs = self._split_multilib(self.d.getVar(var, True)) 219 split_pkgs = self._split_multilib(self.d.getVar(var, True))
221 if split_pkgs is not None: 220 if split_pkgs is not None:
222 pkgs = dict(pkgs.items() + split_pkgs.items()) 221 pkgs = dict(list(pkgs.items()) + list(split_pkgs.items()))
223 else: 222 else:
224 pkg_list = self.d.getVar(var, True) 223 pkg_list = self.d.getVar(var, True)
225 if pkg_list is not None: 224 if pkg_list is not None:
@@ -269,7 +268,7 @@ class OpkgManifest(Manifest):
269 if var in self.vars_to_split: 268 if var in self.vars_to_split:
270 split_pkgs = self._split_multilib(self.d.getVar(var, True)) 269 split_pkgs = self._split_multilib(self.d.getVar(var, True))
271 if split_pkgs is not None: 270 if split_pkgs is not None:
272 pkgs = dict(pkgs.items() + split_pkgs.items()) 271 pkgs = dict(list(pkgs.items()) + list(split_pkgs.items()))
273 else: 272 else:
274 pkg_list = self.d.getVar(var, True) 273 pkg_list = self.d.getVar(var, True)
275 if pkg_list is not None: 274 if pkg_list is not None:
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 252e32d1df..faa0ab2edb 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -8,7 +8,7 @@ def runstrip(arg):
8 # 8 - shared library 8 # 8 - shared library
9 # 16 - kernel module 9 # 16 - kernel module
10 10
11 import commands, stat, subprocess 11 import stat, subprocess
12 12
13 (file, elftype, strip) = arg 13 (file, elftype, strip) = arg
14 14
@@ -64,8 +64,8 @@ def filedeprunner(arg):
64 64
65 def process_deps(pipe, pkg, pkgdest, provides, requires): 65 def process_deps(pipe, pkg, pkgdest, provides, requires):
66 for line in pipe: 66 for line in pipe:
67 f = line.split(" ", 1)[0].strip() 67 f = line.decode("utf-8").split(" ", 1)[0].strip()
68 line = line.split(" ", 1)[1].strip() 68 line = line.decode("utf-8").split(" ", 1)[1].strip()
69 69
70 if line.startswith("Requires:"): 70 if line.startswith("Requires:"):
71 i = requires 71 i = requires
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 1eedeb8526..0ea17f8153 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -17,7 +17,7 @@ def create_index(arg):
17 17
18 try: 18 try:
19 bb.note("Executing '%s' ..." % index_cmd) 19 bb.note("Executing '%s' ..." % index_cmd)
20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True) 20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
21 except subprocess.CalledProcessError as e: 21 except subprocess.CalledProcessError as e:
22 return("Index creation command '%s' failed with return code %d:\n%s" % 22 return("Index creation command '%s' failed with return code %d:\n%s" %
23 (e.cmd, e.returncode, e.output)) 23 (e.cmd, e.returncode, e.output))
@@ -89,9 +89,7 @@ def opkg_query(cmd_output):
89 return output 89 return output
90 90
91 91
92class Indexer(object): 92class Indexer(object, metaclass=ABCMeta):
93 __metaclass__ = ABCMeta
94
95 def __init__(self, d, deploy_dir): 93 def __init__(self, d, deploy_dir):
96 self.d = d 94 self.d = d
97 self.deploy_dir = deploy_dir 95 self.deploy_dir = deploy_dir
@@ -342,9 +340,7 @@ class DpkgIndexer(Indexer):
342 340
343 341
344 342
345class PkgsList(object): 343class PkgsList(object, metaclass=ABCMeta):
346 __metaclass__ = ABCMeta
347
348 def __init__(self, d, rootfs_dir): 344 def __init__(self, d, rootfs_dir):
349 self.d = d 345 self.d = d
350 self.rootfs_dir = rootfs_dir 346 self.rootfs_dir = rootfs_dir
@@ -367,7 +363,7 @@ class RpmPkgsList(PkgsList):
367 # Determine rpm version 363 # Determine rpm version
368 cmd = "%s --version" % self.rpm_cmd 364 cmd = "%s --version" % self.rpm_cmd
369 try: 365 try:
370 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 366 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
371 except subprocess.CalledProcessError as e: 367 except subprocess.CalledProcessError as e:
372 bb.fatal("Getting rpm version failed. Command '%s' " 368 bb.fatal("Getting rpm version failed. Command '%s' "
373 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 369 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -411,7 +407,7 @@ class RpmPkgsList(PkgsList):
411 "-t", self.image_rpmlib] 407 "-t", self.image_rpmlib]
412 408
413 try: 409 try:
414 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 410 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
415 except subprocess.CalledProcessError as e: 411 except subprocess.CalledProcessError as e:
416 bb.fatal("Cannot get the package dependencies. Command '%s' " 412 bb.fatal("Cannot get the package dependencies. Command '%s' "
417 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 413 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
@@ -425,7 +421,7 @@ class RpmPkgsList(PkgsList):
425 421
426 try: 422 try:
427 # bb.note(cmd) 423 # bb.note(cmd)
428 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 424 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
429 except subprocess.CalledProcessError as e: 425 except subprocess.CalledProcessError as e:
430 bb.fatal("Cannot get the installed packages list. Command '%s' " 426 bb.fatal("Cannot get the installed packages list. Command '%s' "
431 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 427 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -485,6 +481,8 @@ class OpkgPkgsList(PkgsList):
485 # output streams separately and check for empty stderr. 481 # output streams separately and check for empty stderr.
486 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) 482 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
487 cmd_output, cmd_stderr = p.communicate() 483 cmd_output, cmd_stderr = p.communicate()
484 cmd_output = cmd_output.decode("utf-8")
485 cmd_stderr = cmd_stderr.decode("utf-8")
488 if p.returncode or cmd_stderr: 486 if p.returncode or cmd_stderr:
489 bb.fatal("Cannot get the installed packages list. Command '%s' " 487 bb.fatal("Cannot get the installed packages list. Command '%s' "
490 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr)) 488 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr))
@@ -502,7 +500,7 @@ class DpkgPkgsList(PkgsList):
502 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") 500 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n")
503 501
504 try: 502 try:
505 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 503 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
506 except subprocess.CalledProcessError as e: 504 except subprocess.CalledProcessError as e:
507 bb.fatal("Cannot get the installed packages list. Command '%s' " 505 bb.fatal("Cannot get the installed packages list. Command '%s' "
508 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 506 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
@@ -510,11 +508,10 @@ class DpkgPkgsList(PkgsList):
510 return opkg_query(cmd_output) 508 return opkg_query(cmd_output)
511 509
512 510
513class PackageManager(object): 511class PackageManager(object, metaclass=ABCMeta):
514 """ 512 """
515 This is an abstract class. Do not instantiate this directly. 513 This is an abstract class. Do not instantiate this directly.
516 """ 514 """
517 __metaclass__ = ABCMeta
518 515
519 def __init__(self, d): 516 def __init__(self, d):
520 self.d = d 517 self.d = d
@@ -608,7 +605,7 @@ class PackageManager(object):
608 try: 605 try:
609 bb.note("Installing complementary packages ...") 606 bb.note("Installing complementary packages ...")
610 bb.note('Running %s' % cmd) 607 bb.note('Running %s' % cmd)
611 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT) 608 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8")
612 except subprocess.CalledProcessError as e: 609 except subprocess.CalledProcessError as e:
613 bb.fatal("Could not compute complementary packages list. Command " 610 bb.fatal("Could not compute complementary packages list. Command "
614 "'%s' returned %d:\n%s" % 611 "'%s' returned %d:\n%s" %
@@ -641,8 +638,8 @@ class PackageManager(object):
641 def construct_uris(self, uris, base_paths): 638 def construct_uris(self, uris, base_paths):
642 def _append(arr1, arr2, sep='/'): 639 def _append(arr1, arr2, sep='/'):
643 res = [] 640 res = []
644 narr1 = map(lambda a: string.rstrip(a, sep), arr1) 641 narr1 = [string.rstrip(a, sep) for a in arr1]
645 narr2 = map(lambda a: string.lstrip(string.rstrip(a, sep), sep), arr2) 642 narr2 = [string.lstrip(string.rstrip(a, sep), sep) for a in arr2]
646 for a1 in narr1: 643 for a1 in narr1:
647 if arr2: 644 if arr2:
648 for a2 in narr2: 645 for a2 in narr2:
@@ -784,7 +781,7 @@ class RpmPM(PackageManager):
784 try: 781 try:
785 complementary_pkgs = subprocess.check_output(cmd, 782 complementary_pkgs = subprocess.check_output(cmd,
786 stderr=subprocess.STDOUT, 783 stderr=subprocess.STDOUT,
787 shell=True) 784 shell=True).decode("utf-8")
788 # bb.note(complementary_pkgs) 785 # bb.note(complementary_pkgs)
789 return complementary_pkgs 786 return complementary_pkgs
790 except subprocess.CalledProcessError as e: 787 except subprocess.CalledProcessError as e:
@@ -808,7 +805,7 @@ class RpmPM(PackageManager):
808 (self.smart_cmd, self.smart_opt, pkg) 805 (self.smart_cmd, self.smart_opt, pkg)
809 cmd += " | sed -ne 's/ *Provides://p'" 806 cmd += " | sed -ne 's/ *Provides://p'"
810 bb.note('cmd: %s' % cmd) 807 bb.note('cmd: %s' % cmd)
811 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 808 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
812 # Found a provider 809 # Found a provider
813 if output: 810 if output:
814 bb.note('Found providers for %s: %s' % (pkg, output)) 811 bb.note('Found providers for %s: %s' % (pkg, output))
@@ -1091,7 +1088,7 @@ class RpmPM(PackageManager):
1091 open(self.scriptlet_wrapper, 'w+').write(scriptlet_content) 1088 open(self.scriptlet_wrapper, 'w+').write(scriptlet_content)
1092 1089
1093 bb.note("Note: configuring RPM cross-install scriptlet_wrapper") 1090 bb.note("Note: configuring RPM cross-install scriptlet_wrapper")
1094 os.chmod(self.scriptlet_wrapper, 0755) 1091 os.chmod(self.scriptlet_wrapper, 0o755)
1095 cmd = 'config --set rpm-extra-macros._cross_scriptlet_wrapper=%s' % \ 1092 cmd = 'config --set rpm-extra-macros._cross_scriptlet_wrapper=%s' % \
1096 self.scriptlet_wrapper 1093 self.scriptlet_wrapper
1097 self._invoke_smart(cmd) 1094 self._invoke_smart(cmd)
@@ -1109,7 +1106,7 @@ class RpmPM(PackageManager):
1109 sub_rdep = sub_data.get("RDEPENDS_" + pkg) 1106 sub_rdep = sub_data.get("RDEPENDS_" + pkg)
1110 if not sub_rdep: 1107 if not sub_rdep:
1111 continue 1108 continue
1112 done = bb.utils.explode_dep_versions2(sub_rdep).keys() 1109 done = list(bb.utils.explode_dep_versions2(sub_rdep).keys())
1113 next = done 1110 next = done
1114 # Find all the rdepends on dependency chain 1111 # Find all the rdepends on dependency chain
1115 while next: 1112 while next:
@@ -1203,7 +1200,7 @@ class RpmPM(PackageManager):
1203 cmd = "%s %s install --attempt -y %s" % \ 1200 cmd = "%s %s install --attempt -y %s" % \
1204 (self.smart_cmd, self.smart_opt, ' '.join(pkgs)) 1201 (self.smart_cmd, self.smart_opt, ' '.join(pkgs))
1205 try: 1202 try:
1206 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1203 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1207 bb.note(output) 1204 bb.note(output)
1208 except subprocess.CalledProcessError as e: 1205 except subprocess.CalledProcessError as e:
1209 bb.fatal("Unable to install packages. Command '%s' " 1206 bb.fatal("Unable to install packages. Command '%s' "
@@ -1233,7 +1230,7 @@ class RpmPM(PackageManager):
1233 1230
1234 try: 1231 try:
1235 bb.note(cmd) 1232 bb.note(cmd)
1236 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1233 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
1237 bb.note(output) 1234 bb.note(output)
1238 except subprocess.CalledProcessError as e: 1235 except subprocess.CalledProcessError as e:
1239 bb.note("Unable to remove packages. Command '%s' " 1236 bb.note("Unable to remove packages. Command '%s' "
@@ -1379,9 +1376,9 @@ class RpmPM(PackageManager):
1379 1376
1380 try: 1377 try:
1381 bb.note(cmd) 1378 bb.note(cmd)
1382 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 1379 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
1383 bb.note(output) 1380 bb.note(output)
1384 os.chmod(saved_dir, 0755) 1381 os.chmod(saved_dir, 0o755)
1385 except subprocess.CalledProcessError as e: 1382 except subprocess.CalledProcessError as e:
1386 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' " 1383 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' "
1387 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1384 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1753,7 +1750,7 @@ class OpkgPM(OpkgDpkgPM):
1753 try: 1750 try:
1754 bb.note("Installing the following packages: %s" % ' '.join(pkgs)) 1751 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
1755 bb.note(cmd) 1752 bb.note(cmd)
1756 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1753 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1757 bb.note(output) 1754 bb.note(output)
1758 except subprocess.CalledProcessError as e: 1755 except subprocess.CalledProcessError as e:
1759 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 1756 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
@@ -1770,7 +1767,7 @@ class OpkgPM(OpkgDpkgPM):
1770 1767
1771 try: 1768 try:
1772 bb.note(cmd) 1769 bb.note(cmd)
1773 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1770 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1774 bb.note(output) 1771 bb.note(output)
1775 except subprocess.CalledProcessError as e: 1772 except subprocess.CalledProcessError as e:
1776 bb.fatal("Unable to remove packages. Command '%s' " 1773 bb.fatal("Unable to remove packages. Command '%s' "
@@ -1817,7 +1814,7 @@ class OpkgPM(OpkgDpkgPM):
1817 pkg_info = cmd + pkg 1814 pkg_info = cmd + pkg
1818 1815
1819 try: 1816 try:
1820 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip() 1817 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip().decode("utf-8")
1821 except subprocess.CalledProcessError as e: 1818 except subprocess.CalledProcessError as e:
1822 bb.fatal("Cannot get package info. Command '%s' " 1819 bb.fatal("Cannot get package info. Command '%s' "
1823 "returned %d:\n%s" % (pkg_info, e.returncode, e.output)) 1820 "returned %d:\n%s" % (pkg_info, e.returncode, e.output))
diff --git a/meta/lib/oe/packagedata.py b/meta/lib/oe/packagedata.py
index bc0fd06bce..21d4de914f 100644
--- a/meta/lib/oe/packagedata.py
+++ b/meta/lib/oe/packagedata.py
@@ -8,7 +8,7 @@ def read_pkgdatafile(fn):
8 pkgdata = {} 8 pkgdata = {}
9 9
10 def decode(str): 10 def decode(str):
11 c = codecs.getdecoder("string_escape") 11 c = codecs.getdecoder("unicode_escape")
12 return c(str)[0] 12 return c(str)[0]
13 13
14 if os.access(fn, os.R_OK): 14 if os.access(fn, os.R_OK):
@@ -66,7 +66,7 @@ def _pkgmap(d):
66 bb.warn("No files in %s?" % pkgdatadir) 66 bb.warn("No files in %s?" % pkgdatadir)
67 files = [] 67 files = []
68 68
69 for pn in filter(lambda f: not os.path.isdir(os.path.join(pkgdatadir, f)), files): 69 for pn in [f for f in files if not os.path.isdir(os.path.join(pkgdatadir, f))]:
70 try: 70 try:
71 pkgdata = read_pkgdatafile(os.path.join(pkgdatadir, pn)) 71 pkgdata = read_pkgdatafile(os.path.join(pkgdatadir, pn))
72 except OSError: 72 except OSError:
diff --git a/meta/lib/oe/packagegroup.py b/meta/lib/oe/packagegroup.py
index a6fee5f950..97819279b7 100644
--- a/meta/lib/oe/packagegroup.py
+++ b/meta/lib/oe/packagegroup.py
@@ -16,11 +16,11 @@ def packages(features, d):
16 yield pkg 16 yield pkg
17 17
18def required_packages(features, d): 18def required_packages(features, d):
19 req = filter(lambda feature: not is_optional(feature, d), features) 19 req = [feature for feature in features if not is_optional(feature, d)]
20 return packages(req, d) 20 return packages(req, d)
21 21
22def optional_packages(features, d): 22def optional_packages(features, d):
23 opt = filter(lambda feature: is_optional(feature, d), features) 23 opt = [feature for feature in features if is_optional(feature, d)]
24 return packages(opt, d) 24 return packages(opt, d)
25 25
26def active_packages(features, d): 26def active_packages(features, d):
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index add41045f3..a25fd527f6 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -434,7 +434,7 @@ class GitApplyTree(PatchTree):
434 # change other places which read it back 434 # change other places which read it back
435 f.write('echo >> $1\n') 435 f.write('echo >> $1\n')
436 f.write('echo "%s: $PATCHFILE" >> $1\n' % GitApplyTree.patch_line_prefix) 436 f.write('echo "%s: $PATCHFILE" >> $1\n' % GitApplyTree.patch_line_prefix)
437 os.chmod(commithook, 0755) 437 os.chmod(commithook, 0o755)
438 shutil.copy2(commithook, applyhook) 438 shutil.copy2(commithook, applyhook)
439 try: 439 try:
440 patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file']) 440 patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file'])
@@ -672,7 +672,7 @@ class UserResolver(Resolver):
672 f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n") 672 f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n")
673 f.write("echo ''\n") 673 f.write("echo ''\n")
674 f.write(" ".join(patchcmd) + "\n") 674 f.write(" ".join(patchcmd) + "\n")
675 os.chmod(rcfile, 00775) 675 os.chmod(rcfile, 0o775)
676 676
677 self.terminal("bash --rcfile " + rcfile, 'Patch Rejects: Please fix patch rejects manually', self.patchset.d) 677 self.terminal("bash --rcfile " + rcfile, 'Patch Rejects: Please fix patch rejects manually', self.patchset.d)
678 678
diff --git a/meta/lib/oe/prservice.py b/meta/lib/oe/prservice.py
index b0cbcb1fbc..0054f954cc 100644
--- a/meta/lib/oe/prservice.py
+++ b/meta/lib/oe/prservice.py
@@ -1,7 +1,7 @@
1 1
2def prserv_make_conn(d, check = False): 2def prserv_make_conn(d, check = False):
3 import prserv.serv 3 import prserv.serv
4 host_params = filter(None, (d.getVar("PRSERV_HOST", True) or '').split(':')) 4 host_params = list([_f for _f in (d.getVar("PRSERV_HOST", True) or '').split(':') if _f])
5 try: 5 try:
6 conn = None 6 conn = None
7 conn = prserv.serv.PRServerConnection(host_params[0], int(host_params[1])) 7 conn = prserv.serv.PRServerConnection(host_params[0], int(host_params[1]))
@@ -9,7 +9,7 @@ def prserv_make_conn(d, check = False):
9 if not conn.ping(): 9 if not conn.ping():
10 raise Exception('service not available') 10 raise Exception('service not available')
11 d.setVar("__PRSERV_CONN",conn) 11 d.setVar("__PRSERV_CONN",conn)
12 except Exception, exc: 12 except Exception as exc:
13 bb.fatal("Connecting to PR service %s:%s failed: %s" % (host_params[0], host_params[1], str(exc))) 13 bb.fatal("Connecting to PR service %s:%s failed: %s" % (host_params[0], host_params[1], str(exc)))
14 14
15 return conn 15 return conn
@@ -114,7 +114,7 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False):
114 bb.utils.unlockfile(lf) 114 bb.utils.unlockfile(lf)
115 115
116def prserv_check_avail(d): 116def prserv_check_avail(d):
117 host_params = filter(None, (d.getVar("PRSERV_HOST", True) or '').split(':')) 117 host_params = list([_f for _f in (d.getVar("PRSERV_HOST", True) or '').split(':') if _f])
118 try: 118 try:
119 if len(host_params) != 2: 119 if len(host_params) != 2:
120 raise TypeError 120 raise TypeError
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 3cfeee737b..ff0c87a383 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -43,17 +43,17 @@ class ELFFile:
43 if not os.path.isfile(self.name): 43 if not os.path.isfile(self.name):
44 raise NotELFFileError("%s is not a normal file" % self.name) 44 raise NotELFFileError("%s is not a normal file" % self.name)
45 45
46 self.file = file(self.name, "r") 46 with open(self.name, "rb") as f:
47 # Read 4k which should cover most of the headers we're after 47 # Read 4k which should cover most of the headers we're after
48 self.data = self.file.read(4096) 48 self.data = f.read(4096)
49 49
50 if len(self.data) < ELFFile.EI_NIDENT + 4: 50 if len(self.data) < ELFFile.EI_NIDENT + 4:
51 raise NotELFFileError("%s is not an ELF" % self.name) 51 raise NotELFFileError("%s is not an ELF" % self.name)
52 52
53 self.my_assert(self.data[0], chr(0x7f) ) 53 self.my_assert(self.data[0], chr(0x7f) )
54 self.my_assert(self.data[1], 'E') 54 self.my_assert(self.data[1], b'E')
55 self.my_assert(self.data[2], 'L') 55 self.my_assert(self.data[2], b'L')
56 self.my_assert(self.data[3], 'F') 56 self.my_assert(self.data[3], b'F')
57 if self.bits == 0: 57 if self.bits == 0:
58 if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32): 58 if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32):
59 self.bits = 32 59 self.bits = 32
@@ -148,4 +148,4 @@ if __name__ == "__main__":
148 import sys 148 import sys
149 elf = ELFFile(sys.argv[1]) 149 elf = ELFFile(sys.argv[1])
150 elf.open() 150 elf.open()
151 print elf.isDynamic() 151 print(elf.isDynamic())
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index 6c7adb5bdb..c183f71d3c 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -11,7 +11,7 @@ import os.path
11import tempfile 11import tempfile
12import textwrap 12import textwrap
13import difflib 13import difflib
14import utils 14from . import utils
15import shutil 15import shutil
16import re 16import re
17import fnmatch 17import fnmatch
@@ -318,7 +318,7 @@ def patch_recipe(d, fn, varvalues, patch=False, relpath=''):
318 varfiles = get_var_files(fn, varlist, d) 318 varfiles = get_var_files(fn, varlist, d)
319 locs = localise_file_vars(fn, varfiles, varlist) 319 locs = localise_file_vars(fn, varfiles, varlist)
320 patches = [] 320 patches = []
321 for f,v in locs.iteritems(): 321 for f,v in locs.items():
322 vals = {k: varvalues[k] for k in v} 322 vals = {k: varvalues[k] for k in v}
323 patchdata = patch_recipe_file(f, vals, patch, relpath) 323 patchdata = patch_recipe_file(f, vals, patch, relpath)
324 if patch: 324 if patch:
@@ -536,7 +536,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
536 bbappendlines = [] 536 bbappendlines = []
537 if extralines: 537 if extralines:
538 if isinstance(extralines, dict): 538 if isinstance(extralines, dict):
539 for name, value in extralines.iteritems(): 539 for name, value in extralines.items():
540 bbappendlines.append((name, '=', value)) 540 bbappendlines.append((name, '=', value))
541 else: 541 else:
542 # Do our best to split it 542 # Do our best to split it
@@ -550,14 +550,14 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
550 raise Exception('Invalid extralines value passed') 550 raise Exception('Invalid extralines value passed')
551 551
552 def popline(varname): 552 def popline(varname):
553 for i in xrange(0, len(bbappendlines)): 553 for i in range(0, len(bbappendlines)):
554 if bbappendlines[i][0] == varname: 554 if bbappendlines[i][0] == varname:
555 line = bbappendlines.pop(i) 555 line = bbappendlines.pop(i)
556 return line 556 return line
557 return None 557 return None
558 558
559 def appendline(varname, op, value): 559 def appendline(varname, op, value):
560 for i in xrange(0, len(bbappendlines)): 560 for i in range(0, len(bbappendlines)):
561 item = bbappendlines[i] 561 item = bbappendlines[i]
562 if item[0] == varname: 562 if item[0] == varname:
563 bbappendlines[i] = (item[0], item[1], item[2] + ' ' + value) 563 bbappendlines[i] = (item[0], item[1], item[2] + ' ' + value)
@@ -576,7 +576,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
576 copyfiles = {} 576 copyfiles = {}
577 if srcfiles: 577 if srcfiles:
578 instfunclines = [] 578 instfunclines = []
579 for newfile, origsrcfile in srcfiles.iteritems(): 579 for newfile, origsrcfile in srcfiles.items():
580 srcfile = origsrcfile 580 srcfile = origsrcfile
581 srcurientry = None 581 srcurientry = None
582 if not srcfile: 582 if not srcfile:
@@ -644,7 +644,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
644 644
645 if removevar in removevalues: 645 if removevar in removevalues:
646 remove = removevalues[removevar] 646 remove = removevalues[removevar]
647 if isinstance(remove, basestring): 647 if isinstance(remove, str):
648 if remove in splitval: 648 if remove in splitval:
649 splitval.remove(remove) 649 splitval.remove(remove)
650 changed = True 650 changed = True
@@ -674,7 +674,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
674 674
675 varnames = [item[0] for item in bbappendlines] 675 varnames = [item[0] for item in bbappendlines]
676 if removevalues: 676 if removevalues:
677 varnames.extend(removevalues.keys()) 677 varnames.extend(list(removevalues.keys()))
678 678
679 with open(appendpath, 'r') as f: 679 with open(appendpath, 'r') as f:
680 (updated, newlines) = bb.utils.edit_metadata(f, varnames, appendfile_varfunc) 680 (updated, newlines) = bb.utils.edit_metadata(f, varnames, appendfile_varfunc)
@@ -699,7 +699,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
699 if copyfiles: 699 if copyfiles:
700 if machine: 700 if machine:
701 destsubdir = os.path.join(destsubdir, machine) 701 destsubdir = os.path.join(destsubdir, machine)
702 for newfile, srcfile in copyfiles.iteritems(): 702 for newfile, srcfile in copyfiles.items():
703 filedest = os.path.join(appenddir, destsubdir, os.path.basename(srcfile)) 703 filedest = os.path.join(appenddir, destsubdir, os.path.basename(srcfile))
704 if os.path.abspath(newfile) != os.path.abspath(filedest): 704 if os.path.abspath(newfile) != os.path.abspath(filedest):
705 bb.note('Copying %s to %s' % (newfile, filedest)) 705 bb.note('Copying %s to %s' % (newfile, filedest))
@@ -725,12 +725,12 @@ def replace_dir_vars(path, d):
725 """Replace common directory paths with appropriate variable references (e.g. /etc becomes ${sysconfdir})""" 725 """Replace common directory paths with appropriate variable references (e.g. /etc becomes ${sysconfdir})"""
726 dirvars = {} 726 dirvars = {}
727 # Sort by length so we get the variables we're interested in first 727 # Sort by length so we get the variables we're interested in first
728 for var in sorted(d.keys(), key=len): 728 for var in sorted(list(d.keys()), key=len):
729 if var.endswith('dir') and var.lower() == var: 729 if var.endswith('dir') and var.lower() == var:
730 value = d.getVar(var, True) 730 value = d.getVar(var, True)
731 if value.startswith('/') and not '\n' in value and value not in dirvars: 731 if value.startswith('/') and not '\n' in value and value not in dirvars:
732 dirvars[value] = var 732 dirvars[value] = var
733 for dirpath in sorted(dirvars.keys(), reverse=True): 733 for dirpath in sorted(list(dirvars.keys()), reverse=True):
734 path = path.replace(dirpath, '${%s}' % dirvars[dirpath]) 734 path = path.replace(dirpath, '${%s}' % dirvars[dirpath])
735 return path 735 return path
736 736
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 95fd3ab7f1..528f50c0df 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -10,11 +10,10 @@ import subprocess
10import re 10import re
11 11
12 12
13class Rootfs(object): 13class Rootfs(object, metaclass=ABCMeta):
14 """ 14 """
15 This is an abstract class. Do not instantiate this directly. 15 This is an abstract class. Do not instantiate this directly.
16 """ 16 """
17 __metaclass__ = ABCMeta
18 17
19 def __init__(self, d): 18 def __init__(self, d):
20 self.d = d 19 self.d = d
@@ -51,8 +50,8 @@ class Rootfs(object):
51 m = r.search(line) 50 m = r.search(line)
52 if m: 51 if m:
53 bb.warn('[log_check] %s: found a warning message in the logfile (keyword \'%s\'):\n[log_check] %s' 52 bb.warn('[log_check] %s: found a warning message in the logfile (keyword \'%s\'):\n[log_check] %s'
54 % (self.d.getVar('PN', True), m.group(), line)) 53 % (self.d.getVar('PN', True), m.group(), line))
55 54
56 def _log_check_error(self): 55 def _log_check_error(self):
57 r = re.compile(self.log_check_regex) 56 r = re.compile(self.log_check_regex)
58 log_path = self.d.expand("${T}/log.do_rootfs") 57 log_path = self.d.expand("${T}/log.do_rootfs")
@@ -77,7 +76,7 @@ class Rootfs(object):
77 found_error = 1 76 found_error = 1
78 bb.warn('[log_check] In line: [%s]' % line) 77 bb.warn('[log_check] In line: [%s]' % line)
79 bb.warn('[log_check] %s: found an error message in the logfile (keyword \'%s\'):\n[log_check] %s' 78 bb.warn('[log_check] %s: found an error message in the logfile (keyword \'%s\'):\n[log_check] %s'
80 % (self.d.getVar('PN', True), m.group(), line)) 79 % (self.d.getVar('PN', True), m.group(), line))
81 80
82 if found_error >= 1 and found_error <= 5: 81 if found_error >= 1 and found_error <= 5:
83 message += line + '\n' 82 message += line + '\n'
@@ -485,7 +484,7 @@ class RpmRootfs(Rootfs):
485 continue 484 continue
486 # sh -x may emit code which isn't actually executed 485 # sh -x may emit code which isn't actually executed
487 if line.startswith('+'): 486 if line.startswith('+'):
488 continue 487 continue
489 488
490 m = r.search(line) 489 m = r.search(line)
491 if m: 490 if m:
@@ -565,7 +564,7 @@ class DpkgOpkgRootfs(Rootfs):
565 pkg_depends = m_depends.group(1) 564 pkg_depends = m_depends.group(1)
566 565
567 # remove package dependencies not in postinsts 566 # remove package dependencies not in postinsts
568 pkg_names = pkgs.keys() 567 pkg_names = list(pkgs.keys())
569 for pkg_name in pkg_names: 568 for pkg_name in pkg_names:
570 deps = pkgs[pkg_name][:] 569 deps = pkgs[pkg_name][:]
571 570
@@ -598,7 +597,7 @@ class DpkgOpkgRootfs(Rootfs):
598 pkgs = self._get_pkgs_postinsts(status_file) 597 pkgs = self._get_pkgs_postinsts(status_file)
599 if pkgs: 598 if pkgs:
600 root = "__packagegroup_postinst__" 599 root = "__packagegroup_postinst__"
601 pkgs[root] = pkgs.keys() 600 pkgs[root] = list(pkgs.keys())
602 _dep_resolve(pkgs, root, pkg_list, []) 601 _dep_resolve(pkgs, root, pkg_list, [])
603 pkg_list.remove(root) 602 pkg_list.remove(root)
604 603
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py
index f1bbef6f58..c74525f929 100644
--- a/meta/lib/oe/sdk.py
+++ b/meta/lib/oe/sdk.py
@@ -8,9 +8,7 @@ import glob
8import traceback 8import traceback
9 9
10 10
11class Sdk(object): 11class Sdk(object, metaclass=ABCMeta):
12 __metaclass__ = ABCMeta
13
14 def __init__(self, d, manifest_dir): 12 def __init__(self, d, manifest_dir):
15 self.d = d 13 self.d = d
16 self.sdk_output = self.d.getVar('SDK_OUTPUT', True) 14 self.sdk_output = self.d.getVar('SDK_OUTPUT', True)
@@ -251,12 +249,12 @@ class OpkgSdk(Sdk):
251 self.mkdirhier(target_sysconfdir) 249 self.mkdirhier(target_sysconfdir)
252 shutil.copy(self.target_conf, target_sysconfdir) 250 shutil.copy(self.target_conf, target_sysconfdir)
253 os.chmod(os.path.join(target_sysconfdir, 251 os.chmod(os.path.join(target_sysconfdir,
254 os.path.basename(self.target_conf)), 0644) 252 os.path.basename(self.target_conf)), 0o644)
255 253
256 self.mkdirhier(host_sysconfdir) 254 self.mkdirhier(host_sysconfdir)
257 shutil.copy(self.host_conf, host_sysconfdir) 255 shutil.copy(self.host_conf, host_sysconfdir)
258 os.chmod(os.path.join(host_sysconfdir, 256 os.chmod(os.path.join(host_sysconfdir,
259 os.path.basename(self.host_conf)), 0644) 257 os.path.basename(self.host_conf)), 0o644)
260 258
261 native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, 259 native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path,
262 self.d.getVar('localstatedir_nativesdk', True).strip('/'), 260 self.d.getVar('localstatedir_nativesdk', True).strip('/'),
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index 01dce660cf..a58f03a342 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -210,7 +210,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash):
210 continue 210 continue
211 f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.taskhash[k] + " \\\n") 211 f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.taskhash[k] + " \\\n")
212 f.write(' "\n') 212 f.write(' "\n')
213 f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(types.keys()))) 213 f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(list(types.keys()))))
214 214
215 def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): 215 def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d):
216 warn_msgs = [] 216 warn_msgs = []
@@ -220,7 +220,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash):
220 for task in range(len(sq_fn)): 220 for task in range(len(sq_fn)):
221 if task not in ret: 221 if task not in ret:
222 for pn in self.lockedsigs: 222 for pn in self.lockedsigs:
223 if sq_hash[task] in self.lockedsigs[pn].itervalues(): 223 if sq_hash[task] in iter(self.lockedsigs[pn].values()):
224 if sq_task[task] == 'do_shared_workdir': 224 if sq_task[task] == 'do_shared_workdir':
225 continue 225 continue
226 sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" 226 sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?"
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 634daa9033..dc25d14ff6 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -25,9 +25,7 @@ class Registry(oe.classutils.ClassRegistry):
25 return bool(cls.command) 25 return bool(cls.command)
26 26
27 27
28class Terminal(Popen): 28class Terminal(Popen, metaclass=Registry):
29 __metaclass__ = Registry
30
31 def __init__(self, sh_cmd, title=None, env=None, d=None): 29 def __init__(self, sh_cmd, title=None, env=None, d=None):
32 fmt_sh_cmd = self.format_command(sh_cmd, title) 30 fmt_sh_cmd = self.format_command(sh_cmd, title)
33 try: 31 try:
@@ -41,7 +39,7 @@ class Terminal(Popen):
41 39
42 def format_command(self, sh_cmd, title): 40 def format_command(self, sh_cmd, title):
43 fmt = {'title': title or 'Terminal', 'command': sh_cmd} 41 fmt = {'title': title or 'Terminal', 'command': sh_cmd}
44 if isinstance(self.command, basestring): 42 if isinstance(self.command, str):
45 return shlex.split(self.command.format(**fmt)) 43 return shlex.split(self.command.format(**fmt))
46 else: 44 else:
47 return [element.format(**fmt) for element in self.command] 45 return [element.format(**fmt) for element in self.command]
diff --git a/meta/lib/oe/tests/test_path.py b/meta/lib/oe/tests/test_path.py
index 3d41ce157a..5aa024d393 100644
--- a/meta/lib/oe/tests/test_path.py
+++ b/meta/lib/oe/tests/test_path.py
@@ -85,5 +85,5 @@ class TestRealPath(unittest.TestCase):
85 85
86 def test_loop(self): 86 def test_loop(self):
87 for e in self.EXCEPTIONS: 87 for e in self.EXCEPTIONS:
88 self.assertRaisesRegexp(OSError, r'\[Errno %u\]' % e[1], 88 self.assertRaisesRegex(OSError, r'\[Errno %u\]' % e[1],
89 self.__realpath, e[0], False, False) 89 self.__realpath, e[0], False, False)
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py
index 7f47c17d0e..4ae58acfac 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -33,7 +33,7 @@ def choice(value, choices):
33 Acts as a multiple choice for the user. To use this, set the variable 33 Acts as a multiple choice for the user. To use this, set the variable
34 type flag to 'choice', and set the 'choices' flag to a space separated 34 type flag to 'choice', and set the 'choices' flag to a space separated
35 list of valid values.""" 35 list of valid values."""
36 if not isinstance(value, basestring): 36 if not isinstance(value, str):
37 raise TypeError("choice accepts a string, not '%s'" % type(value)) 37 raise TypeError("choice accepts a string, not '%s'" % type(value))
38 38
39 value = value.lower() 39 value = value.lower()
@@ -106,7 +106,7 @@ def boolean(value):
106 Valid values for false: 'no', 'n', 'false', 'f', '0' 106 Valid values for false: 'no', 'n', 'false', 'f', '0'
107 """ 107 """
108 108
109 if not isinstance(value, basestring): 109 if not isinstance(value, str):
110 raise TypeError("boolean accepts a string, not '%s'" % type(value)) 110 raise TypeError("boolean accepts a string, not '%s'" % type(value))
111 111
112 value = value.lower() 112 value = value.lower()
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 30d30629f1..cecddc657f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -46,7 +46,7 @@ def both_contain(variable1, variable2, checkvalue, d):
46 val2 = d.getVar(variable2, True) 46 val2 = d.getVar(variable2, True)
47 val1 = set(val1.split()) 47 val1 = set(val1.split())
48 val2 = set(val2.split()) 48 val2 = set(val2.split())
49 if isinstance(checkvalue, basestring): 49 if isinstance(checkvalue, str):
50 checkvalue = set(checkvalue.split()) 50 checkvalue = set(checkvalue.split())
51 else: 51 else:
52 checkvalue = set(checkvalue) 52 checkvalue = set(checkvalue)
@@ -85,11 +85,11 @@ def prune_suffix(var, suffixes, d):
85 85
86def str_filter(f, str, d): 86def str_filter(f, str, d):
87 from re import match 87 from re import match
88 return " ".join(filter(lambda x: match(f, x, 0), str.split())) 88 return " ".join([x for x in str.split() if match(f, x, 0)])
89 89
90def str_filter_out(f, str, d): 90def str_filter_out(f, str, d):
91 from re import match 91 from re import match
92 return " ".join(filter(lambda x: not match(f, x, 0), str.split())) 92 return " ".join([x for x in str.split() if not match(f, x, 0)])
93 93
94def param_bool(cfg, field, dflt = None): 94def param_bool(cfg, field, dflt = None):
95 """Lookup <field> in <cfg> map and convert it to a boolean; take 95 """Lookup <field> in <cfg> map and convert it to a boolean; take
@@ -134,7 +134,7 @@ def packages_filter_out_system(d):
134 PN-dbg PN-doc PN-locale-eb-gb removed. 134 PN-dbg PN-doc PN-locale-eb-gb removed.
135 """ 135 """
136 pn = d.getVar('PN', True) 136 pn = d.getVar('PN', True)
137 blacklist = map(lambda suffix: pn + suffix, ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev')) 137 blacklist = [pn + suffix for suffix in ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev')]
138 localepkg = pn + "-locale-" 138 localepkg = pn + "-locale-"
139 pkgs = [] 139 pkgs = []
140 140
@@ -235,7 +235,7 @@ def format_pkg_list(pkg_dict, ret_format=None):
235# so implement a version here 235# so implement a version here
236# 236#
237 237
238from Queue import Queue 238from queue import Queue
239from threading import Thread 239from threading import Thread
240 240
241class ThreadedWorker(Thread): 241class ThreadedWorker(Thread):
@@ -249,7 +249,7 @@ class ThreadedWorker(Thread):
249 self.worker_end = worker_end 249 self.worker_end = worker_end
250 250
251 def run(self): 251 def run(self):
252 from Queue import Empty 252 from queue import Empty
253 253
254 if self.worker_init is not None: 254 if self.worker_init is not None:
255 self.worker_init(self) 255 self.worker_init(self)
@@ -264,8 +264,8 @@ class ThreadedWorker(Thread):
264 264
265 try: 265 try:
266 func(self, *args, **kargs) 266 func(self, *args, **kargs)
267 except Exception, e: 267 except Exception as e:
268 print e 268 print(e)
269 finally: 269 finally:
270 self.tasks.task_done() 270 self.tasks.task_done()
271 271