summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
AgeCommit message (Collapse)Author
2019-11-21bitbake: utils: also use mmap for SHA256 and SHA1, for performanceRoss Burton
md5_file() uses a mmap() window to improve performance when hashing files, so refactor the code and do the same for SHA1 and SHA256. (Bitbake rev: ecf87437ff796e17c3e4f210b5803b0136a9e8a4) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-09-19bitbake: utils: Add ionice option to prunedirRichard Purdie
Autobuilder type infrastructure can benefit from deletion of certain files as background IO due to the way Linux filesystem priority works. We have problems where build directories as part of oe-selftest being delete starves the running tasks of IO to the point builds take much longer to compelte. Having this option of running the deletion at "idle" helps a lot with that. (Bitbake rev: 797354d285f6d624d9adb52bab65823572da0e39) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-09-03bitbake: utils: Fix movefile() exception handling with python3Martin Jansa
* with python3 this fails with: File: 'bitbake/lib/bb/utils.py', lineno: 799, function: movefile 0795: try: 0796: os.rename(src, destpath) 0797: renamefailed = 0 0798: except Exception as e: *** 0799: if e[0] != errno.EXDEV: 0800: # Some random error. 0801: print("movefile: Failed to move", src, "to", dest, e) 0802: return None 0803: # Invalid cross-device-link 'bind' mounted or actually Cross-Device Exception: TypeError: 'OSError' object is not subscriptable (Bitbake rev: d6e43c443ddbbe467c4380c48d2bc28ae18504a1) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-08-06bitbake: build/utils: Drop bb.build.FuncFailedRichard Purdie
Its hard to see what this exception adds in the current codebase. The logfile attribute is effectively ignored, the exception doesn't serve a defined purpose and mostly seems to be worked around. Remove it entirely. If this does cause output problems, we'll figure out better ways to address those. (Bitbake rev: cfeffb602dd5319f071cd6bcf84139ec77f2d170) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Strip old editor directives from file headersRichard Purdie
There are much better ways to handle this and most editors shouldn't need this in modern times, drop the noise from the files. Its not consitently applied anyway. (Bitbake rev: 5e43070e3087d09aea2f459b033d035c5ef747d0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Drop duplicate license boilerplace textRichard Purdie
With the introduction of SPDX-License-Identifier headers, we don't need a ton of header boilerplate in every file. Simplify the files and rely on the top level for the full licence text. (Bitbake rev: 695d84397b68cc003186e22f395caa378b06bc75) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Add initial pass of SPDX license headers to source codeRichard Purdie
This adds the SPDX-License-Identifier license headers to the majority of our source files to make it clearer exactly which license files are under. The bulk of the files are under GPL v2.0 with one found to be under V2.0 or later, some under MIT and some have dual license. There are some files which are potentially harder to classify where we've imported upstream code and those can be handled specifically in later commits. The COPYING file is replaced with LICENSE.X files which contain the full license texts. (Bitbake rev: ff237c33337f4da2ca06c3a2c49699bc26608a6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-12bitbake: utils: Let mkdirhier fail if existing path is not a folderAndre Rosa
Let mkdirhier fail if existing path is not a folder instead of assuming a directory hierarchy already exists. (Bitbake rev: a8d9b82ccf93dcb74258693f62d88be380b1c0b7) Signed-off-by: Andre Rosa <andre.rosa@lge.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-09bitbake: utils: Make prune_suffix prune a suffixAndre Rosa
Make prune_suffix prune a suffix instead of replacing a substring that could happen more than once and not only when it ends with it. (Bitbake rev: 57e765e38c6382a9b36d5ee2a6f3fa96ac905b82) Signed-off-by: Andre Rosa <andre.rosa@lge.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-25bitbake: bitbake: fix version comparison when one of the versions ends in .Alexander Kanavin
Previously, this would happen: ====================================================================== ERROR: test_vercmpstring (bb.tests.utils.VerCmpString) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/alexander/development/poky/bitbake/lib/bb/tests/utils.py", line 45, in test_vercmpstring result = bb.utils.vercmp_string('1.', '1.1') File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 143, in vercmp_string return vercmp(ta, tb) File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 135, in vercmp r = vercmp_part(va, vb) File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 124, in vercmp_part elif ca < cb: TypeError: '<' not supported between instances of 'NoneType' and 'int' ---------------------------------------------------------------------- (Bitbake rev: fef56d28c3efec4876c379898cbc4d4c65303aee) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-14bitbake: utils: Add aarch64 support to ioprio_setRichard Purdie
With aarch64 hosts coming into use, set the syscall number to avoid ioprio warnings on that platform. (Bitbake rev: 5eaf9e7b26f09f5f106e1c3c6976d517b289450a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-08bitbake: utils: Use utils.remove() within prunedir()Richard Purdie
We've already tweaked remove() for speed and not to error if it races for deletion. Therefore use this for prunedir() which was starting to show the same bug reports. [YOCTO #13003] (Bitbake rev: 47f359f9b017f8d99d0bb2161ac0dcefcbd915de) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-19bitbake: utils: better_compile(): Fix line number when report errorsRobert Yang
Fixed: - Add an error line in base.bbclass, e.g.: 15 16 def oe_import(d): 17 import sys 18 Compile error 19 bbpath = d.getVar("BBPATH").split(":") [snip] Note the "Compile error" line, I added it for reporting errors. $ bitbake -p ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 15: The code lines resulting in this error were: 0014: import oe.data 0015: for toimport in oe.data.typed_value("OE_IMPORTS", d): 0016: imported = __import__(toimport) 0017: inject(toimport.split(".", 1)[0], imported) *** 0018: 0019: return "" 0020: SyntaxError: invalid syntax (base.bbclass, line 18) There are 2 problems: - The "line 15" is incorrect, it is a blank line, not the error line. - The "*** 0018" points to incorrect position. These two problems would mislead people a lot sometimes. - Now fix it to: $ bitbake -p ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 18: The code lines resulting in this error were: 0001:def oe_import(d): 0002: import sys *** 0003: Compile error 0004: bbpath = d.getVar("BBPATH").split(":") [snip] SyntaxError: invalid syntax (base.bbclass, line 18) Please see comments in the code for more details on how it is fixed. (Bitbake rev: bbb3d87d171da38fd8e9bce011d109fba28a75c0) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-14bitbake: utils: Avoid regex value escape warningsRichard Purdie
Avoid warnings such as: bitbake/lib/bb/utils.py:72: DeprecationWarning: invalid escape sequence \d numeric_regexp = re.compile('^(\d+)(.*)$') bitbake/lib/bb/utils.py:1165: DeprecationWarning: invalid escape sequence \( var_res[var] = re.compile('^(%s%s)[ \\t]*\([ \\t]*\)[ \\t]*{' % (var[:-2].rstrip(), override_re)) (Bitbake rev: bbf3cbae775383265292a778cd522d4e2f69a3a0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-14bitbake: utils: Avoid warnings about deprecated imp moduleRichard Purdie
The imp module is deprecated, port the code over to use importlib. bitbake/lib/bb/utils.py:30: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp (Bitbake rev: 3c2cb35588e91fbd7b136e5e2c78eeb77e126c84) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-25bitbake: utils: lockfile: Fix infinite loopIoan-Adrian Ratiu
A nasty corner case leads to a hang when utils.lockfile is called from oe-core's package-manager:deploy_dir_lock (in turn called from rootfs:_create further up the call stack) with "name" owned by root and the user running bitbake has no write access. Because this code runs under pseudo, the UID and EUID of the bitbake worker process are 0, so the os.access(dirname, os.W_OK) returns True i.e. it thinks the path is writable when in fact it's not writable. Only later when trying to open the file an Exception it thrown because the OS prohibits writing, but the Exception is ignored and the open is retried leading to an infinite loop. So this fix is to not ignore the "Permission Denied" exception. An alternative fix would be to replace the os.access() call with an try: open() except() at the beginning of the function. (Bitbake rev: 0cb64d0f85b41b2fa764baf6ff7ea1b13f95004e) Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-16bitbake: bb/utils.py: add break_hardlinks helperRasmus Villemoes
bb.utils.copyfile is called in a few places with identical src and dst in order to create an st_nlinks==1 version of the file. That that even works relies on an implementation detail of copyfile (namely, that it creates a temporary file and then does a rename). Moreover, it's a waste of time if the file already has st_nlinks==1. So create a helper that optimizes away the copy in the st_nlinks==1 case. Of course, this helper relies on the same implementation detail, but that's now contained within bb.utils itself. To test that we do at least sometimes hit the no-copy path, I tested locally with if sstat[stat.ST_NLINK] == 1: + bb.note("Woohoo, 2*%d bytes I/O avoided" % sstat[stat.ST_SIZE]) return True (and the obvious places in oe-core patched), and the do_package log files are indeed filled with woohoo notes. (Bitbake rev: 7ae93cf40ab91965147055100432961436bce46c) Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-15bitbake: utils/md5_file: don't iterate line-by-lineRoss Burton
Opening a file in binary mode and iterating it seems like the simple solution but will still break on newlines, which for binary files isn't really useful as the size of the chunks could be huge or tiny. Instead, let's be a bit more clever: we'll be MD5ing lots of files, but we don't want to fill up memory: use mmap() to open the file and read the file in 8k blocks. (Bitbake rev: a0ac8d67f1471a0c611d691b856fede67efb53f6) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-30bitbake: utils: add optional callback to edit_bblayers_conf()Paul Eggleton
Add a callback that lets you modify or remove items in addition to the current scheme where you can only add or remove. This enables you to for example replace a layer with a temporary copy (which is what we will use this for first in OE's oe-selftest). (Bitbake rev: bfedb4e85a84e817dbe5d8694b8f8fcdd6f2f22a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-04-23bitbake: lib/bb/utils: prevent movefile from changing dest dir permissionsMattias Hansson
Prevent movefile from falsely setting the source file's owner and permissions on the destination directory instead of the destination file when moving between devices. This bug caused the last file moved into a directory to dictate the directory's owner and permissions. (Bitbake rev: 82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40) Signed-off-by: Mattias Hansson <mattias.hansson@axis.com> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-03-15bitbake: utils.py: Add option for explode_dep_versions2 to return unsortedAmanda Brindle
Before, explode_dep_versions2 would sort the OrderedDict before returning. This function will still sort the OrderedDict by default, but will now have the option to return the OrderedDict unsorted. This option will allow us to check if the order of the package list has changed. (Bitbake rev: 39d6a30a28f66c599e18beddbd847f40dcff623c) Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-09-25bitbake: bitbake: lib/bb/utils: fix movefile() copy to dir fallbackMardegan, Alberto
When the destination is a directory, building the the destination file path is always needed. That's because even if the copy fallback is taken, it's always followed by a rename. (Bitbake rev: 14c17480827ced2e03c1b62dc839696421fc4de8) Signed-off-by: Alberto Mardegan <amardegan@luxoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-27bitbake: lib/bb/utils.py: Add missing debug levelMark Hatle
(Bitbake rev: a0cd748d2f830a305da086eff3462875f64f2a70) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-05bitbake: bitbake: Fix return value checks from subprocess.call()'sMikko Rapeli
Python function subprocess.call() returns the return value of the executed process. If return values are not checked, errors may go unnoticed and bad things can happen. Change all callers of subprocess.call() which do not check for the return value to use subprocess.check_call() which raises CalledProcessError if the subprocess returns with non-zero value. https://docs.python.org/2/library/subprocess.html#using-the-subprocess-module All users of the function were found with: $ git grep "subprocess\.call" | \ egrep -v 'if.*subprocess\.call|=\ +subprocess\.call|return.*subprocess\.call' Tested similar patch on top of yocto jethro. Only compile tested core-image-minimal on poky master branch. (Bitbake rev: d2cf67bcaf001acb6be8fc5884fb450649849847) Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-31bitbake: bb/utils: extend which() so it can look for just executablesRoss Burton
Normally bb.utils.which() is used by the unpack code to find a file in a variety of places, but it is useful as a slightly more powerful version of os.which(). Support this by allowing it to only return matches which are executable files, instead of just the first filename that matches. (Bitbake rev: c0b94f02f0cba7a424aaa16cf98c0f7a3f62b889) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-01bitbake: lib/bb/utils: Add filter()Peter Kjellerstedt
The bb.utils.filter() function can be used to filter a variable containing whitespace separated words based on another set of words. It has been modeled after the bb.utils.contains_any() function. A typical example of how it can be used is to simplify constructs for PACKAGECONFIG that depend on DISTRO_FEATURES: -PACKAGECONFIG ?= "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'acl', 'acl', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \ -" +PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}" (Bitbake rev: 03ae490366d2046f5b5c185fe4ec2adf1b0a902e) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-01-09bitbake: prserv/persist_data/utils: Drop obsolete python2 importsRichard Purdie
These imports were from python 2.6 and earlier, 2.4 in some cases. Drop them since we're all python3 now. (Bitbake rev: 7ef12684e8647b006bf46cae695069d4bfece1cf) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-14bitbake: lib/bb/build: enable access to logger within tasksPaul Eggleton
In certain circumstances it can be useful to get access to BitBake's logger within a task; the main example is in OpenEmbedded's image construction code where we want to be able to check the log file for errors and warnings, but we don't want to see any errors or warnings that were emitted through the logger; so we need a way to exclude those. In order to do this, pass the logger object into the task via a BB_TASK_LOGGER variable, and add a logging handler class to bb.utils that can be added to it in order to keep a list of warnings/errors that have been emitted. (Bitbake rev: f1cd6fab604f14d8686b1d783cbfe012d923ee42) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-08bitbake: utils: Avoid traceback errorsRichard Purdie
Avoid errors like: ERROR: Exception handler error: 'NoneType' object has no attribute 'decode' (Bitbake rev: 1aeb45abe56061f044c2347889c191d5256ff21f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-30bitbake: bitbake: remove True option to getVar callsJoshua Lock
getVar() now defaults to expanding by default, thus remove the True option from getVar() calls with a regex search and replace. Search made with the following regex: getVar ?\(( ?[^,()]*), True\) (Bitbake rev: 3b45c479de8640f92dd1d9f147b02e1eecfaadc8) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-08bitbake: lib/bb/utils: edit_metadata() comment tweaksPaul Eggleton
No functional changes, just make a couple of minor tweaks to the comments for edit_metadata(): * There are four elements to be returned by the callback function * Add an example return statement for when you don't want to modify the value (Bitbake rev: 99675c19375c96140bc8ae8f9fc3a1945a77cebb) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-08-17bitbake: bb/utils.py: export_proxies add GIT_PROXY_COMMANDFrancisco Pedraza
This was added to enable the usage of git through proxies. (Bitbake rev: 449fc52e483a3bf1cec1c5d8cf8c3946ec5292ab) Signed-off-by: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-29bitbake: lib/bb/utils: show subprocess output in stack tracesRoss Burton
If better_exec() throws a subprocess.CalledProcessError then show the output to the user as it likely contains useful information for solving the problem. (Bitbake rev: 8a6424ed871c3cbacd21cae8bc801197f83d67a6) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-20bitbake: bitbake: utils: add BBSERVER to the list of preserved variablesEd Bartosh
All environment variables that are not in the list returned by preserved_envvars_exported are cleaned by bb.utils.clean_environment. Added BBSERVER to the list as we need to access it in bb/main.py after the call of bb.utils.clean_environment. (Bitbake rev: 15c4ea679f4fe097a9f21cccfc82907b5f39a4e4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-20bitbake: lib/bb/utils: no need to unsetenv when manipulating os.environRoss Burton
Doing both os.unsetenv(foo) and then del os.environ[foo] is pointless as del will call unsetenv automatically. (Bitbake rev: a4463e2ff3c7d234320176d671719243292f1af0) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-19bitbake: lib/bb/utils.py: return sorted OrderedDict in explode_dep_versions2Robert Yang
The OrderedDict's item is sorted by insertion order, there might be a problem when build the same recipe again, for example: - First build of acl: Depends: libattr1 (>= 2.4.47), libc6 (>= 2.24) - Second build of acl: Depends: libc6 (>= 2.24), libattr1 (>= 2.4.47) They are exactly the same depends, but tools like "diff" doesn't think so. Return sorted OrderedDict will fix the problem. (Bitbake rev: a392f19f16ef8202ce3c12afbeb186a02438da17) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-19bitbake: lib/bb/utils: fix set_process_nameRoss Burton
With Python 3 create_string_buffer needs a bytes() not a str() but as we were catching all exceptions nobody noticed. [ YOCTO #9910 ] (Bitbake rev: 6576a9a95486c28a01d4211b4a33cc3e2c55a7cc) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-13bitbake: data_smart/utils: Add 'd' to the context used for better_eval in ↵Richard Purdie
python expansion If a line like: foo=${@' '.join([d.getVar('D', True) + x for x in (' '.join([d.getVar('FILES_bash-' + p, True) or '' for p in ['lib', 'dev', 'staticdev', 'doc', 'locale', 'ptest']])).split()])} is added to a function like do_install, it fails with Exception name 'd' is not defined. This is due to a change of behaviour in python 3 compared to python 2. Generator expressions, dict comprehensions and set comprehensions are executed in a new scope but list comprehensions in python 2.x are not. In python 3 they all use a new scope. To allow these kinds of expressions to work, the easiest approach is to add 'd' to the global context. To do this, an extra optional parameter is added to better_eval and we use that to add 'd'. (Bitbake rev: 8f74881037bb01013d3d439dc0c269909a198c1c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02bitbake: toaster: fix imports to work for python 3Ed Bartosh
Some APIs have been moved to other modules in python 3: getstatusoutput: moved from commands to subproces urlopen: moved from urllib2 to urllib.request urlparse: moved from urlparse to urllib.parse Made the imports work for both python versions by catching ImportError and importing APIs from different modules. [YOCTO #9584] (Bitbake rev: 1abaa1c6a950b327e6468192dd910549643768bb) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02bitbake: bitbake: Convert to python 3Richard Purdie
Various misc changes to convert bitbake to python3 which don't warrant separation into separate commits. (Bitbake rev: d0f904d407f57998419bd9c305ce53e5eaa36b24) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-13bitbake: utils: Force bitbake to en_US.UTF-8 locale setting everywhereRichard Purdie
Under python 3, if we spawn python processes, we need to have a UTF-8 locale, else python's file access methods will use ascii. You can't change that mode once the interpreter is started so we have to ensure a locale is set. Ideally we'd use C.UTF-8 since OE already forces the C locale but not all distros support that and we need to set something. Was tempted to choose en_GB so colour gets spelt correctly :). This is in some ways pretty nasty, forcing it into the environment everywhere however we only have a limited number of ways of making everything work correctly and this beats having to add utf-8 encoding to every file access command. A similar change will be needed to bitbake.conf in OE. (Bitbake rev: 8902c29638411d312e6fc4a197707e5742652e15) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-11bitbake: lib/bb/utils.py: Fix explode_dep_versions2() determinism issueRichard Purdie
When we pass data into explode_dep_versions2(), we need to result to be able to be processed in a deterministic way so that we end up with consistent hash values. This means we need an ordered structure rather than an unordered one. To do this, return an OrderedDict() rather than a dict(). (Bitbake rev: 0737e003ca549d08a7dfe13452ae982f2e11fecd) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-11bitbake: bitbake: Update logger.warn() -> logger.warning()Richard Purdie
python deprecated logger.warn() in favour of logger.warning(). This is only used in bitbake code so we may as well just translate everything to avoid warnings under python 3. Its safe for python 2.7. (Bitbake rev: 676a5f592e8507e81b8f748d58acfea7572f8796) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06bitbake: bb.utils: let loaded plugins provide a plugin objectChristopher Larson
This lets us avoid treating the module like an object, so no globals are needed, if one chooses to do so. (Bitbake rev: 71bfd5beb0d0ed88c7c14bbfd5ca1a1b56122bc1) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06bitbake: bb.utils: use imp.get_suffixes for load_pluginsChristopher Larson
Rather than hardcoding .py, use python's knowledge of its file extensions. (Bitbake rev: 09f838dbaefdaedc01a1f4818ed38280b38db744) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06bitbake: bb.utils: add load_plugins from scriptutilsChristopher Larson
Imported as of oe-core 184a256. (Bitbake rev: 99db61bf816d9c735032caa762aae8e6a0803402) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-18bitbake: lib/bb/utils: add docstring for contains()Ross Burton
(Bitbake rev: e9174723ea6d0dff5f7f3042009761cf42284947) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-09bitbake: lib/bb/utils.py: Fix a bug in edit_metadata() that could corrupt varsRandy Witt
edit_metadata() would corrupt a variable that was multiline, but had the ending quotes on the same line as the last value. For example: TEST_VAR = " foo \ bar" would become " foo ba" because the code would always delete the last character on the line and then do it again if the line ended in the quote. This however doesn't show up if you have: TEST_VAR = " foo \ bar \ " which is how all the test cases were written. This patch fixes that bug and adds and fixes a test that matched the bugs behavior rather than the expected behavior. (Bitbake rev: 14f05cbdc2ad8d59a94af1c8816567d93c39c88c) Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-31bitbake: build/utils: Allow python functions to execute with real exception ↵Richard Purdie
handling With the code as it stands today it not possible to execute a python function and get "normal" python exception handling behaviour. If a python function raises an exception, it forces a traceback to be printed and the exception becomes a FuncFailed exception. This adds in a parameter 'pythonexception' which allows standard python exceptions to be passed unchanged with no traceback. Ultimately we may want to change to this convention in various places but at least it means we can start to add sane functions now. (Bitbake rev: 85cf22fd0ed26bb7dc7738ef2a10441891f38ae2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-26bitbake: utils.py: Add sha1_file callBrendan Le Foll
This is useful as npm-lockdown uses sha1 because npm releases the sha1 of packages and whilst this is undocumented it seems no other algorithm is supported (Bitbake rev: fd5d9011f6dd7029895b64d8a02d33185b9aa8ae) Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>