diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2020-04-13 21:39:40 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2020-05-05 16:30:44 +0300 |
commit | 82c905dc58a36aeae40b1b273a12f63fb1973cf4 (patch) | |
tree | 38caf00263451b5036435cdc36e035b25d32e623 /poky/bitbake/lib/bb/utils.py | |
parent | 83ecb75644b3d677c274188f9ac0b2374d6f6925 (diff) | |
download | openbmc-82c905dc58a36aeae40b1b273a12f63fb1973cf4.tar.xz |
meta-openembedded and poky: subtree updates
Squash of the following due to dependencies among them
and OpenBMC changes:
meta-openembedded: subtree update:d0748372d2..9201611135
meta-openembedded: subtree update:9201611135..17fd382f34
poky: subtree update:9052e5b32a..2e11d97b6c
poky: subtree update:2e11d97b6c..a8544811d7
The change log was too large for the jenkins plugin
to handle therefore it has been removed. Here is
the first and last commit of each subtree:
meta-openembedded:d0748372d2
cppzmq: bump to version 4.6.0
meta-openembedded:17fd382f34
mpv: Remove X11 dependency
poky:9052e5b32a
package_ipk: Remove pointless comment to trigger rebuild
poky:a8544811d7
pbzip2: Fix license warning
Change-Id: If0fc6c37629642ee207a4ca2f7aa501a2c673cd6
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'poky/bitbake/lib/bb/utils.py')
-rw-r--r-- | poky/bitbake/lib/bb/utils.py | 89 |
1 files changed, 83 insertions, 6 deletions
diff --git a/poky/bitbake/lib/bb/utils.py b/poky/bitbake/lib/bb/utils.py index 8d40bcdf8..5f5767c1d 100644 --- a/poky/bitbake/lib/bb/utils.py +++ b/poky/bitbake/lib/bb/utils.py @@ -24,7 +24,6 @@ import fnmatch import traceback import errno import signal -import ast import collections import copy from subprocess import getstatusoutput @@ -428,10 +427,11 @@ def fileslocked(files): for lockfile in files: locks.append(bb.utils.lockfile(lockfile)) - yield - - for lock in locks: - bb.utils.unlockfile(lock) + try: + yield + finally: + for lock in locks: + bb.utils.unlockfile(lock) @contextmanager def timeout(seconds): @@ -556,6 +556,20 @@ def sha1_file(filename): import hashlib return _hasher(hashlib.sha1(), filename) +def sha384_file(filename): + """ + Return the hex string representation of the SHA384 checksum of the filename + """ + import hashlib + return _hasher(hashlib.sha384(), filename) + +def sha512_file(filename): + """ + Return the hex string representation of the SHA512 checksum of the filename + """ + import hashlib + return _hasher(hashlib.sha512(), filename) + def preserved_envvars_exported(): """Variables which are taken from the environment and placed in and exported from the metadata""" @@ -850,7 +864,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]): os.unlink(dest) os.symlink(target, dest) - #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) + os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) return os.lstat(dest) except Exception as e: logger.warning("copyfile: failed to create symlink %s to %s (%s)" % (dest, target, e)) @@ -1025,6 +1039,43 @@ def filter(variable, checkvalues, d): checkvalues = set(checkvalues) return ' '.join(sorted(checkvalues & val)) + +def get_referenced_vars(start_expr, d): + """ + :return: names of vars referenced in start_expr (recursively), in quasi-BFS order (variables within the same level + are ordered arbitrarily) + """ + + seen = set() + ret = [] + + # The first entry in the queue is the unexpanded start expression + queue = collections.deque([start_expr]) + # Subsequent entries will be variable names, so we need to track whether or not entry requires getVar + is_first = True + + empty_data = bb.data.init() + while queue: + entry = queue.popleft() + if is_first: + # Entry is the start expression - no expansion needed + is_first = False + expression = entry + else: + # This is a variable name - need to get the value + expression = d.getVar(entry, False) + ret.append(entry) + + # expandWithRefs is how we actually get the referenced variables in the expression. We call it using an empty + # data store because we only want the variables directly used in the expression. It returns a set, which is what + # dooms us to only ever be "quasi-BFS" rather than full BFS. + new_vars = empty_data.expandWithRefs(expression, None).references - set(seen) + + queue.extend(new_vars) + seen.update(new_vars) + return ret + + def cpu_count(): return multiprocessing.cpu_count() @@ -1560,3 +1611,29 @@ class LogCatcher(logging.Handler): self.messages.append(bb.build.logformatter.format(record)) def contains(self, message): return (message in self.messages) + +def is_semver(version): + """ + Is the version string following the semver semantic? + + https://semver.org/spec/v2.0.0.html + """ + regex = re.compile( + r""" + ^ + (0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*) + (?:-( + (?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*) + (?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))* + ))? + (?:\+( + [0-9a-zA-Z-]+ + (?:\.[0-9a-zA-Z-]+)* + ))? + $ + """, re.VERBOSE) + + if regex.match(version) is None: + return False + + return True |