summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager.py
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-05-12 11:28:12 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-14 23:05:11 +0100
commitc5aa5246e0177e2a7c08891c690479d94cf04c0d (patch)
treed38dd7d633dcc6b0723bbb93a8cb5469f53c361b /meta/lib/oe/package_manager.py
parente81c8fc1b67e5775db0097e2983cb23192f88904 (diff)
downloadpoky-c5aa5246e0177e2a7c08891c690479d94cf04c0d.tar.gz
package_manager.py: Move opkg_query() outside of Indexer class
When using the opkg and apt-get package managers the function opkg_query() can be useful when query for package information. This change moves the function outside the Indexer class so the Indexer, OpkgPM, DpkgPM can benefit from it. [YOCTO #9569] (From OE-Core rev: 799bc1d1c747aad02b6d844bf55abfbd3ecc034c) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/package_manager.py')
-rw-r--r--meta/lib/oe/package_manager.py104
1 files changed, 51 insertions, 53 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index b4b359a8c6..427518da68 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -27,6 +27,55 @@ def create_index(arg):
27 27
28 return None 28 return None
29 29
30"""
31This method parse the output from the package managerand return
32a dictionary with the information of the packages. This is used
33when the packages are in deb or ipk format.
34"""
35def opkg_query(cmd_output):
36 verregex = re.compile(' \([=<>]* [^ )]*\)')
37 output = dict()
38 filename = ""
39 dep = []
40 pkg = ""
41 for line in cmd_output.splitlines():
42 line = line.rstrip()
43 if ':' in line:
44 if line.startswith("Package: "):
45 pkg = line.split(": ")[1]
46 elif line.startswith("Architecture: "):
47 arch = line.split(": ")[1]
48 elif line.startswith("Version: "):
49 ver = line.split(": ")[1]
50 elif line.startswith("File: "):
51 filename = line.split(": ")[1]
52 elif line.startswith("Depends: "):
53 depends = verregex.sub('', line.split(": ")[1])
54 for depend in depends.split(", "):
55 dep.append(depend)
56 elif line.startswith("Recommends: "):
57 recommends = verregex.sub('', line.split(": ")[1])
58 for recommend in recommends.split(", "):
59 dep.append("%s [REC]" % recommend)
60 else:
61 # IPK doesn't include the filename
62 if not filename:
63 filename = "%s_%s_%s.ipk" % (pkg, ver, arch)
64 if pkg:
65 output[pkg] = {"arch":arch, "ver":ver,
66 "filename":filename, "deps": dep }
67 pkg = ""
68 filename = ""
69 dep = []
70
71 if pkg:
72 if not filename:
73 filename = "%s_%s_%s.ipk" % (pkg, ver, arch)
74 output[pkg] = {"arch":arch, "ver":ver,
75 "filename":filename, "deps": dep }
76
77 return output
78
30 79
31class Indexer(object): 80class Indexer(object):
32 __metaclass__ = ABCMeta 81 __metaclass__ = ABCMeta
@@ -293,57 +342,6 @@ class PkgsList(object):
293 pass 342 pass
294 343
295 344
296 """
297 This method parse the output from the package manager
298 and return a dictionary with the information of the
299 installed packages. This is used whne the packages are
300 in deb or ipk format
301 """
302 def opkg_query(self, cmd_output):
303 verregex = re.compile(' \([=<>]* [^ )]*\)')
304 output = dict()
305 filename = ""
306 dep = []
307 pkg = ""
308 for line in cmd_output.splitlines():
309 line = line.rstrip()
310 if ':' in line:
311 if line.startswith("Package: "):
312 pkg = line.split(": ")[1]
313 elif line.startswith("Architecture: "):
314 arch = line.split(": ")[1]
315 elif line.startswith("Version: "):
316 ver = line.split(": ")[1]
317 elif line.startswith("File: "):
318 filename = line.split(": ")[1]
319 elif line.startswith("Depends: "):
320 depends = verregex.sub('', line.split(": ")[1])
321 for depend in depends.split(", "):
322 dep.append(depend)
323 elif line.startswith("Recommends: "):
324 recommends = verregex.sub('', line.split(": ")[1])
325 for recommend in recommends.split(", "):
326 dep.append("%s [REC]" % recommend)
327 else:
328 # IPK doesn't include the filename
329 if not filename:
330 filename = "%s_%s_%s.ipk" % (pkg, ver, arch)
331 if pkg:
332 output[pkg] = {"arch":arch, "ver":ver,
333 "filename":filename, "deps": dep }
334 pkg = ""
335 filename = ""
336 dep = []
337
338 if pkg:
339 if not filename:
340 filename = "%s_%s_%s.ipk" % (pkg, ver, arch)
341 output[pkg] = {"arch":arch, "ver":ver,
342 "filename":filename, "deps": dep }
343
344 return output
345
346
347class RpmPkgsList(PkgsList): 345class RpmPkgsList(PkgsList):
348 def __init__(self, d, rootfs_dir, arch_var=None, os_var=None): 346 def __init__(self, d, rootfs_dir, arch_var=None, os_var=None):
349 super(RpmPkgsList, self).__init__(d, rootfs_dir) 347 super(RpmPkgsList, self).__init__(d, rootfs_dir)
@@ -479,7 +477,7 @@ class OpkgPkgsList(PkgsList):
479 bb.fatal("Cannot get the installed packages list. Command '%s' " 477 bb.fatal("Cannot get the installed packages list. Command '%s' "
480 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr)) 478 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr))
481 479
482 return self.opkg_query(cmd_output) 480 return opkg_query(cmd_output)
483 481
484 482
485class DpkgPkgsList(PkgsList): 483class DpkgPkgsList(PkgsList):
@@ -497,7 +495,7 @@ class DpkgPkgsList(PkgsList):
497 bb.fatal("Cannot get the installed packages list. Command '%s' " 495 bb.fatal("Cannot get the installed packages list. Command '%s' "
498 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 496 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
499 497
500 return self.opkg_query(cmd_output) 498 return opkg_query(cmd_output)
501 499
502 500
503class PackageManager(object): 501class PackageManager(object):