diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2016-01-18 14:33:05 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-20 17:07:15 +0000 |
commit | 03075f671c5425f08669f10f30330c4880c0d60a (patch) | |
tree | 3f25d14c4f9f4b14b109a04591881a8677d2bc32 /meta | |
parent | c708411f20f8944eaabce40121b61e17d26e8a15 (diff) | |
download | poky-03075f671c5425f08669f10f30330c4880c0d60a.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]
(From OE-Core rev: 25725e6e5fff8017aaf3a6fcd9b1b893c22630b5)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/utils.py | 22 |
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): | |||
208 | import re | 208 | import re |
209 | return re.sub("\s+", " ", string).strip() | 209 | return re.sub("\s+", " ", string).strip() |
210 | 210 | ||
211 | def format_pkg_list(pkg_dict, ret_format=None): | ||
212 | output = [] | ||
213 | |||
214 | if ret_format == "arch": | ||
215 | for pkg in sorted(pkg_dict): | ||
216 | output.append("%s %s" % (pkg, pkg_dict[pkg]["arch"])) | ||
217 | elif ret_format == "file": | ||
218 | for pkg in sorted(pkg_dict): | ||
219 | output.append("%s %s %s" % (pkg, pkg_dict[pkg]["filename"], pkg_dict[pkg]["arch"])) | ||
220 | elif ret_format == "ver": | ||
221 | for pkg in sorted(pkg_dict): | ||
222 | output.append("%s %s %s" % (pkg, pkg_dict[pkg]["arch"], pkg_dict[pkg]["ver"])) | ||
223 | elif ret_format == "deps": | ||
224 | for pkg in sorted(pkg_dict): | ||
225 | for dep in pkg_dict[pkg]["deps"]: | ||
226 | output.append("%s|%s" % (pkg, dep)) | ||
227 | else: | ||
228 | for pkg in sorted(pkg_dict): | ||
229 | output.append(pkg) | ||
230 | |||
231 | return '\n'.join(output) | ||
232 | |||
211 | # | 233 | # |
212 | # Python 2.7 doesn't have threaded pools (just multiprocessing) | 234 | # Python 2.7 doesn't have threaded pools (just multiprocessing) |
213 | # so implement a version here | 235 | # so implement a version here |