diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-08-21 17:39:47 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-21 08:30:32 +0100 |
commit | 2de8ba89ef10fefcc97246dfeb4b8d1e48ee8232 (patch) | |
tree | 2a414961a61a25be0ddb8d78647e8bd5d464ad84 /scripts/lib/devtool/__init__.py | |
parent | f958c5cba3b0d24ca696b2b707857009c9a7b5b8 (diff) | |
download | openembedded-core-2de8ba89ef10fefcc97246dfeb4b8d1e48ee8232.tar.gz openembedded-core-2de8ba89ef10fefcc97246dfeb4b8d1e48ee8232.tar.bz2 openembedded-core-2de8ba89ef10fefcc97246dfeb4b8d1e48ee8232.zip |
devtool: import: new plugin to import the devtool workspace
Takes a tar archive created by 'devtool export' and imports (untars) it
into the workspace. Currently the whole tar archive is imported, there
is no way to limit what is imported.
https://bugzilla.yoctoproject.org/show_bug.cgi?id=10510
[YOCTO #10510]
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r-- | scripts/lib/devtool/__init__.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py index b231e46b16..14170cb69e 100644 --- a/scripts/lib/devtool/__init__.py +++ b/scripts/lib/devtool/__init__.py @@ -261,3 +261,39 @@ def get_bbclassextend_targets(recipefile, pn): targets.append('%s-%s' % (pn, variant)) return targets +def replace_from_file(path, old, new): + """Replace strings on a file""" + + def read_file(path): + data = None + with open(path) as f: + data = f.read() + return data + + def write_file(path, data): + if data is None: + return + wdata = data.rstrip() + "\n" + with open(path, "w") as f: + f.write(wdata) + + # In case old is None, return immediately + if old is None: + return + try: + rdata = read_file(path) + except IOError as e: + # if file does not exit, just quit, otherwise raise an exception + if e.errno == errno.ENOENT: + return + else: + raise + + old_contents = rdata.splitlines() + new_contents = [] + for old_content in old_contents: + try: + new_contents.append(old_content.replace(old, new)) + except ValueError: + pass + write_file(path, "\n".join(new_contents)) |