diff options
| -rw-r--r-- | meta/lib/oe/package_manager.py | 104 |
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 | """ | ||
| 31 | This method parse the output from the package managerand return | ||
| 32 | a dictionary with the information of the packages. This is used | ||
| 33 | when the packages are in deb or ipk format. | ||
| 34 | """ | ||
| 35 | def 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 | ||
| 31 | class Indexer(object): | 80 | class 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 | |||
| 347 | class RpmPkgsList(PkgsList): | 345 | class 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 | ||
| 485 | class DpkgPkgsList(PkgsList): | 483 | class 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 | ||
| 503 | class PackageManager(object): | 501 | class PackageManager(object): |
