summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/copy_buildsystem.py6
-rw-r--r--meta/lib/oe/cve_check.py65
-rw-r--r--meta/lib/oe/package_manager/__init__.py2
-rw-r--r--meta/lib/oe/package_manager/deb/__init__.py6
-rw-r--r--meta/lib/oe/package_manager/deb/sdk.py4
-rw-r--r--meta/lib/oe/patch.py14
-rw-r--r--meta/lib/oe/path.py21
-rw-r--r--meta/lib/oe/prservice.py4
-rw-r--r--meta/lib/oe/recipeutils.py2
-rw-r--r--meta/lib/oe/reproducible.py2
-rw-r--r--meta/lib/oe/sstatesig.py8
-rw-r--r--meta/lib/oe/terminal.py16
-rw-r--r--meta/lib/oe/utils.py2
13 files changed, 130 insertions, 22 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
index 31a84f5b06..d97bf9d1b9 100644
--- a/meta/lib/oe/copy_buildsystem.py
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -20,7 +20,7 @@ def _smart_copy(src, dest):
20 mode = os.stat(src).st_mode 20 mode = os.stat(src).st_mode
21 if stat.S_ISDIR(mode): 21 if stat.S_ISDIR(mode):
22 bb.utils.mkdirhier(dest) 22 bb.utils.mkdirhier(dest)
23 cmd = "tar --exclude='.git' --xattrs --xattrs-include='*' -chf - -C %s -p . \ 23 cmd = "tar --exclude='.git' --exclude='__pycache__' --xattrs --xattrs-include='*' -chf - -C %s -p . \
24 | tar --xattrs --xattrs-include='*' -xf - -C %s" % (src, dest) 24 | tar --xattrs --xattrs-include='*' -xf - -C %s" % (src, dest)
25 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) 25 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
26 else: 26 else:
@@ -259,7 +259,7 @@ def create_locked_sstate_cache(lockedsigs, input_sstate_cache, output_sstate_cac
259 bb.note('Generating sstate-cache...') 259 bb.note('Generating sstate-cache...')
260 260
261 nativelsbstring = d.getVar('NATIVELSBSTRING') 261 nativelsbstring = d.getVar('NATIVELSBSTRING')
262 bb.process.run("gen-lockedsig-cache %s %s %s %s %s" % (lockedsigs, input_sstate_cache, output_sstate_cache, nativelsbstring, filterfile or '')) 262 bb.process.run("PYTHONDONTWRITEBYTECODE=1 gen-lockedsig-cache %s %s %s %s %s" % (lockedsigs, input_sstate_cache, output_sstate_cache, nativelsbstring, filterfile or ''))
263 if fixedlsbstring and nativelsbstring != fixedlsbstring: 263 if fixedlsbstring and nativelsbstring != fixedlsbstring:
264 nativedir = output_sstate_cache + '/' + nativelsbstring 264 nativedir = output_sstate_cache + '/' + nativelsbstring
265 if os.path.isdir(nativedir): 265 if os.path.isdir(nativedir):
@@ -286,7 +286,7 @@ def check_sstate_task_list(d, targets, filteroutfile, cmdprefix='', cwd=None, lo
286 logparam = '-l %s' % logfile 286 logparam = '-l %s' % logfile
287 else: 287 else:
288 logparam = '' 288 logparam = ''
289 cmd = "%sBB_SETSCENE_ENFORCE=1 PSEUDO_DISABLED=1 oe-check-sstate %s -s -o %s %s" % (cmdprefix, targets, filteroutfile, logparam) 289 cmd = "%sPYTHONDONTWRITEBYTECODE=1 BB_SETSCENE_ENFORCE=1 PSEUDO_DISABLED=1 oe-check-sstate %s -s -o %s %s" % (cmdprefix, targets, filteroutfile, logparam)
290 env = dict(d.getVar('BB_ORIGENV', False)) 290 env = dict(d.getVar('BB_ORIGENV', False))
291 env.pop('BUILDDIR', '') 291 env.pop('BUILDDIR', '')
292 env.pop('BBPATH', '') 292 env.pop('BBPATH', '')
diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
new file mode 100644
index 0000000000..a1d7c292af
--- /dev/null
+++ b/meta/lib/oe/cve_check.py
@@ -0,0 +1,65 @@
1import collections
2import re
3import itertools
4import functools
5
6_Version = collections.namedtuple(
7 "_Version", ["release", "patch_l", "pre_l", "pre_v"]
8)
9
10@functools.total_ordering
11class Version():
12
13 def __init__(self, version, suffix=None):
14
15 suffixes = ["alphabetical", "patch"]
16
17 if str(suffix) == "alphabetical":
18 version_pattern = r"""r?v?(?:(?P<release>[0-9]+(?:[-\.][0-9]+)*)(?P<patch>[-_\.]?(?P<patch_l>[a-z]))?(?P<pre>[-_\.]?(?P<pre_l>(rc|alpha|beta|pre|preview|dev))[-_\.]?(?P<pre_v>[0-9]+)?)?)(.*)?"""
19 elif str(suffix) == "patch":
20 version_pattern = r"""r?v?(?:(?P<release>[0-9]+(?:[-\.][0-9]+)*)(?P<patch>[-_\.]?(p|patch)(?P<patch_l>[0-9]+))?(?P<pre>[-_\.]?(?P<pre_l>(rc|alpha|beta|pre|preview|dev))[-_\.]?(?P<pre_v>[0-9]+)?)?)(.*)?"""
21 else:
22 version_pattern = r"""r?v?(?:(?P<release>[0-9]+(?:[-\.][0-9]+)*)(?P<pre>[-_\.]?(?P<pre_l>(rc|alpha|beta|pre|preview|dev))[-_\.]?(?P<pre_v>[0-9]+)?)?)(.*)?"""
23 regex = re.compile(r"^\s*" + version_pattern + r"\s*$", re.VERBOSE | re.IGNORECASE)
24
25 match = regex.search(version)
26 if not match:
27 raise Exception("Invalid version: '{0}'".format(version))
28
29 self._version = _Version(
30 release=tuple(int(i) for i in match.group("release").replace("-",".").split(".")),
31 patch_l=match.group("patch_l") if str(suffix) in suffixes and match.group("patch_l") else "",
32 pre_l=match.group("pre_l"),
33 pre_v=match.group("pre_v")
34 )
35
36 self._key = _cmpkey(
37 self._version.release,
38 self._version.patch_l,
39 self._version.pre_l,
40 self._version.pre_v
41 )
42
43 def __eq__(self, other):
44 if not isinstance(other, Version):
45 return NotImplemented
46 return self._key == other._key
47
48 def __gt__(self, other):
49 if not isinstance(other, Version):
50 return NotImplemented
51 return self._key > other._key
52
53def _cmpkey(release, patch_l, pre_l, pre_v):
54 # remove leading 0
55 _release = tuple(
56 reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(release))))
57 )
58
59 _patch = patch_l.upper()
60
61 if pre_l is None and pre_v is None:
62 _pre = float('inf')
63 else:
64 _pre = float(pre_v) if pre_v else float('-inf')
65 return _release, _patch, _pre
diff --git a/meta/lib/oe/package_manager/__init__.py b/meta/lib/oe/package_manager/__init__.py
index 42225a3b2e..26f9f82aaa 100644
--- a/meta/lib/oe/package_manager/__init__.py
+++ b/meta/lib/oe/package_manager/__init__.py
@@ -189,7 +189,7 @@ class PackageManager(object, metaclass=ABCMeta):
189 bb.utils.remove(self.intercepts_dir, True) 189 bb.utils.remove(self.intercepts_dir, True)
190 bb.utils.mkdirhier(self.intercepts_dir) 190 bb.utils.mkdirhier(self.intercepts_dir)
191 for intercept in postinst_intercepts: 191 for intercept in postinst_intercepts:
192 bb.utils.copyfile(intercept, os.path.join(self.intercepts_dir, os.path.basename(intercept))) 192 shutil.copy(intercept, os.path.join(self.intercepts_dir, os.path.basename(intercept)))
193 193
194 @abstractmethod 194 @abstractmethod
195 def _handle_intercept_failure(self, failed_script): 195 def _handle_intercept_failure(self, failed_script):
diff --git a/meta/lib/oe/package_manager/deb/__init__.py b/meta/lib/oe/package_manager/deb/__init__.py
index 26157f591a..0f9b27f831 100644
--- a/meta/lib/oe/package_manager/deb/__init__.py
+++ b/meta/lib/oe/package_manager/deb/__init__.py
@@ -312,6 +312,12 @@ class DpkgPM(OpkgDpkgPM):
312 if not pkgs: 312 if not pkgs:
313 return 313 return
314 314
315 os.environ['D'] = self.target_rootfs
316 os.environ['OFFLINE_ROOT'] = self.target_rootfs
317 os.environ['IPKG_OFFLINE_ROOT'] = self.target_rootfs
318 os.environ['OPKG_OFFLINE_ROOT'] = self.target_rootfs
319 os.environ['INTERCEPT_DIR'] = self.intercepts_dir
320
315 if with_dependencies: 321 if with_dependencies:
316 os.environ['APT_CONFIG'] = self.apt_conf_file 322 os.environ['APT_CONFIG'] = self.apt_conf_file
317 cmd = "%s purge %s" % (self.apt_get_cmd, ' '.join(pkgs)) 323 cmd = "%s purge %s" % (self.apt_get_cmd, ' '.join(pkgs))
diff --git a/meta/lib/oe/package_manager/deb/sdk.py b/meta/lib/oe/package_manager/deb/sdk.py
index b25eb70b00..76548b06f0 100644
--- a/meta/lib/oe/package_manager/deb/sdk.py
+++ b/meta/lib/oe/package_manager/deb/sdk.py
@@ -65,6 +65,8 @@ class DpkgSdk(Sdk):
65 65
66 self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) 66 self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY'))
67 67
68 self.target_pm.run_pre_post_installs()
69
68 self.target_pm.run_intercepts(populate_sdk='target') 70 self.target_pm.run_intercepts(populate_sdk='target')
69 71
70 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) 72 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND"))
@@ -78,6 +80,8 @@ class DpkgSdk(Sdk):
78 self._populate_sysroot(self.host_pm, self.host_manifest) 80 self._populate_sysroot(self.host_pm, self.host_manifest)
79 self.install_locales(self.host_pm) 81 self.install_locales(self.host_pm)
80 82
83 self.host_pm.run_pre_post_installs()
84
81 self.host_pm.run_intercepts(populate_sdk='host') 85 self.host_pm.run_intercepts(populate_sdk='host')
82 86
83 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) 87 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND"))
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 40755fbb03..8ad70f53f1 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -38,15 +38,19 @@ def runcmd(args, dir = None):
38 args = [ pipes.quote(str(arg)) for arg in args ] 38 args = [ pipes.quote(str(arg)) for arg in args ]
39 cmd = " ".join(args) 39 cmd = " ".join(args)
40 # print("cmd: %s" % cmd) 40 # print("cmd: %s" % cmd)
41 (exitstatus, output) = subprocess.getstatusoutput(cmd) 41 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
42 stdout, stderr = proc.communicate()
43 stdout = stdout.decode('utf-8')
44 stderr = stderr.decode('utf-8')
45 exitstatus = proc.returncode
42 if exitstatus != 0: 46 if exitstatus != 0:
43 raise CmdError(cmd, exitstatus >> 8, output) 47 raise CmdError(cmd, exitstatus >> 8, "stdout: %s\nstderr: %s" % (stdout, stderr))
44 if " fuzz " in output and "Hunk " in output: 48 if " fuzz " in stdout and "Hunk " in stdout:
45 # Drop patch fuzz info with header and footer to log file so 49 # Drop patch fuzz info with header and footer to log file so
46 # insane.bbclass can handle to throw error/warning 50 # insane.bbclass can handle to throw error/warning
47 bb.note("--- Patch fuzz start ---\n%s\n--- Patch fuzz end ---" % format(output)) 51 bb.note("--- Patch fuzz start ---\n%s\n--- Patch fuzz end ---" % format(stdout))
48 52
49 return output 53 return stdout
50 54
51 finally: 55 finally:
52 if dir: 56 if dir:
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 082972457b..c8d8ad05b9 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -320,3 +320,24 @@ def which_wild(pathname, path=None, mode=os.F_OK, *, reverse=False, candidates=F
320 320
321 return files 321 return files
322 322
323def canonicalize(paths, sep=','):
324 """Given a string with paths (separated by commas by default), expand
325 each path using os.path.realpath() and return the resulting paths as a
326 string (separated using the same separator a the original string).
327 """
328 # Ignore paths containing "$" as they are assumed to be unexpanded bitbake
329 # variables. Normally they would be ignored, e.g., when passing the paths
330 # through the shell they would expand to empty strings. However, when they
331 # are passed through os.path.realpath(), it will cause them to be prefixed
332 # with the absolute path to the current directory and thus not be empty
333 # anymore.
334 #
335 # Also maintain trailing slashes, as the paths may actually be used as
336 # prefixes in sting compares later on, where the slashes then are important.
337 canonical_paths = []
338 for path in (paths or '').split(sep):
339 if '$' not in path:
340 trailing_slash = path.endswith('/') and '/' or ''
341 canonical_paths.append(os.path.realpath(path) + trailing_slash)
342
343 return sep.join(canonical_paths)
diff --git a/meta/lib/oe/prservice.py b/meta/lib/oe/prservice.py
index 2d3c9c7e50..fcdbe66c19 100644
--- a/meta/lib/oe/prservice.py
+++ b/meta/lib/oe/prservice.py
@@ -3,10 +3,6 @@
3# 3#
4 4
5def prserv_make_conn(d, check = False): 5def prserv_make_conn(d, check = False):
6 # Otherwise this fails when called from recipes which e.g. inherit python3native (which sets _PYTHON_SYSCONFIGDATA_NAME) with:
7 # No module named '_sysconfigdata'
8 if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
9 del os.environ['_PYTHON_SYSCONFIGDATA_NAME']
10 import prserv.serv 6 import prserv.serv
11 host_params = list([_f for _f in (d.getVar("PRSERV_HOST") or '').split(':') if _f]) 7 host_params = list([_f for _f in (d.getVar("PRSERV_HOST") or '').split(':') if _f])
12 try: 8 try:
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index ef69ef207f..407d168894 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -409,7 +409,7 @@ def copy_recipe_files(d, tgt_dir, whole_dir=False, download=True, all_variants=F
409 fetch.download() 409 fetch.download()
410 for pth in fetch.localpaths(): 410 for pth in fetch.localpaths():
411 if pth not in localpaths: 411 if pth not in localpaths:
412 localpaths.append(pth) 412 localpaths.append(os.path.abspath(pth))
413 uri_values.append(srcuri) 413 uri_values.append(srcuri)
414 414
415 fetch_urls(d) 415 fetch_urls(d)
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index 421bb12f54..0fb02ccdb0 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -47,7 +47,7 @@ def find_git_folder(d, sourcedir):
47 return None 47 return None
48 48
49def get_source_date_epoch_from_git(d, sourcedir): 49def get_source_date_epoch_from_git(d, sourcedir):
50 if not "git://" in d.getVar('SRC_URI'): 50 if not "git://" in d.getVar('SRC_URI') and not "gitsm://" in d.getVar('SRC_URI'):
51 return None 51 return None
52 52
53 gitpath = find_git_folder(d, sourcedir) 53 gitpath = find_git_folder(d, sourcedir)
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index 64fb84ec92..31a6140984 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -439,7 +439,7 @@ def find_sstate_manifest(taskdata, taskdata2, taskname, d, multilibcache):
439 d2 = multilibcache[variant] 439 d2 = multilibcache[variant]
440 440
441 if taskdata.endswith("-native"): 441 if taskdata.endswith("-native"):
442 pkgarchs = ["${BUILD_ARCH}"] 442 pkgarchs = ["${BUILD_ARCH}", "${BUILD_ARCH}_${ORIGNATIVELSBSTRING}"]
443 elif taskdata.startswith("nativesdk-"): 443 elif taskdata.startswith("nativesdk-"):
444 pkgarchs = ["${SDK_ARCH}_${SDK_OS}", "allarch"] 444 pkgarchs = ["${SDK_ARCH}_${SDK_OS}", "allarch"]
445 elif "-cross-canadian" in taskdata: 445 elif "-cross-canadian" in taskdata:
@@ -557,9 +557,11 @@ def OEOuthashBasic(path, sigfile, task, d):
557 try: 557 try:
558 update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name) 558 update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name)
559 update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name) 559 update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name)
560 except KeyError: 560 except KeyError as e:
561 bb.warn("KeyError in %s" % path) 561 bb.warn("KeyError in %s" % path)
562 raise 562 msg = ("KeyError: %s\nPath %s is owned by uid %d, gid %d, which doesn't match "
563 "any user/group on target. This may be due to host contamination." % (e, path, s.st_uid, s.st_gid))
564 raise Exception(msg).with_traceback(e.__traceback__)
563 565
564 if include_timestamps: 566 if include_timestamps:
565 update_hash(" %10d" % s.st_mtime) 567 update_hash(" %10d" % s.st_mtime)
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index eb10a6e33e..2ac39df9e1 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -163,7 +163,12 @@ class Tmux(Terminal):
163 # devshells, if it's already there, add a new window to it. 163 # devshells, if it's already there, add a new window to it.
164 window_name = 'devshell-%i' % os.getpid() 164 window_name = 'devshell-%i' % os.getpid()
165 165
166 self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name) 166 self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'
167 if not check_tmux_version('1.9'):
168 # `tmux new-session -c` was added in 1.9;
169 # older versions fail with that flag
170 self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'
171 self.command = self.command.format(window_name)
167 Terminal.__init__(self, sh_cmd, title, env, d) 172 Terminal.__init__(self, sh_cmd, title, env, d)
168 173
169 attach_cmd = 'tmux att -t {0}'.format(window_name) 174 attach_cmd = 'tmux att -t {0}'.format(window_name)
@@ -253,13 +258,18 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
253 except OSError: 258 except OSError:
254 return 259 return
255 260
261def check_tmux_version(desired):
262 vernum = check_terminal_version("tmux")
263 if vernum and LooseVersion(vernum) < desired:
264 return False
265 return vernum
266
256def check_tmux_pane_size(tmux): 267def check_tmux_pane_size(tmux):
257 import subprocess as sub 268 import subprocess as sub
258 # On older tmux versions (<1.9), return false. The reason 269 # On older tmux versions (<1.9), return false. The reason
259 # is that there is no easy way to get the height of the active panel 270 # is that there is no easy way to get the height of the active panel
260 # on current window without nested formats (available from version 1.9) 271 # on current window without nested formats (available from version 1.9)
261 vernum = check_terminal_version("tmux") 272 if not check_tmux_version('1.9'):
262 if vernum and LooseVersion(vernum) < '1.9':
263 return False 273 return False
264 try: 274 try:
265 p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, 275 p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 468c76f30f..9a2187e36f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -193,7 +193,7 @@ def parallel_make(d, makeinst=False):
193 193
194 return int(v) 194 return int(v)
195 195
196 return None 196 return ''
197 197
198def parallel_make_argument(d, fmt, limit=None, makeinst=False): 198def parallel_make_argument(d, fmt, limit=None, makeinst=False):
199 """ 199 """