aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-01-18 14:33:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-20 09:20:05 +0000
commit25725e6e5fff8017aaf3a6fcd9b1b893c22630b5 (patch)
treefd60432e89c3e176559cf9f005cf2802d7a86195
parent6cbb144a86a8188fad102bb281fd9e8d0a4b9142 (diff)
downloadopenembedded-core-contrib-25725e6e5fff8017aaf3a6fcd9b1b893c22630b5.tar.gz
lib/oe/utils: Add function format_pkg_list()
The class PkgsList returns a dictionary with all the installed packages, because the data structure is a dictionary there is needed to format the data in order to write to a file. The function format_pkg_list returns a formated sting with all packages installed. The output will depend on the requested format when calling the function. [YOCTO #7427] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta/lib/oe/utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index cee087fdfa..9a86410b15 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -208,6 +208,28 @@ def squashspaces(string):
import re
return re.sub("\s+", " ", string).strip()
+def format_pkg_list(pkg_dict, ret_format=None):
+ output = []
+
+ if ret_format == "arch":
+ for pkg in sorted(pkg_dict):
+ output.append("%s %s" % (pkg, pkg_dict[pkg]["arch"]))
+ elif ret_format == "file":
+ for pkg in sorted(pkg_dict):
+ output.append("%s %s %s" % (pkg, pkg_dict[pkg]["filename"], pkg_dict[pkg]["arch"]))
+ elif ret_format == "ver":
+ for pkg in sorted(pkg_dict):
+ output.append("%s %s %s" % (pkg, pkg_dict[pkg]["arch"], pkg_dict[pkg]["ver"]))
+ elif ret_format == "deps":
+ for pkg in sorted(pkg_dict):
+ for dep in pkg_dict[pkg]["deps"]:
+ output.append("%s|%s" % (pkg, dep))
+ else:
+ for pkg in sorted(pkg_dict):
+ output.append(pkg)
+
+ return '\n'.join(output)
+
#
# Python 2.7 doesn't have threaded pools (just multiprocessing)
# so implement a version here