summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/package_manager.py')
-rw-r--r--meta/lib/oe/package_manager.py51
1 files changed, 24 insertions, 27 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 1eedeb8526..0ea17f8153 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -17,7 +17,7 @@ def create_index(arg):
17 17
18 try: 18 try:
19 bb.note("Executing '%s' ..." % index_cmd) 19 bb.note("Executing '%s' ..." % index_cmd)
20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True) 20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
21 except subprocess.CalledProcessError as e: 21 except subprocess.CalledProcessError as e:
22 return("Index creation command '%s' failed with return code %d:\n%s" % 22 return("Index creation command '%s' failed with return code %d:\n%s" %
23 (e.cmd, e.returncode, e.output)) 23 (e.cmd, e.returncode, e.output))
@@ -89,9 +89,7 @@ def opkg_query(cmd_output):
89 return output 89 return output
90 90
91 91
92class Indexer(object): 92class Indexer(object, metaclass=ABCMeta):
93 __metaclass__ = ABCMeta
94
95 def __init__(self, d, deploy_dir): 93 def __init__(self, d, deploy_dir):
96 self.d = d 94 self.d = d
97 self.deploy_dir = deploy_dir 95 self.deploy_dir = deploy_dir
@@ -342,9 +340,7 @@ class DpkgIndexer(Indexer):
342 340
343 341
344 342
345class PkgsList(object): 343class PkgsList(object, metaclass=ABCMeta):
346 __metaclass__ = ABCMeta
347
348 def __init__(self, d, rootfs_dir): 344 def __init__(self, d, rootfs_dir):
349 self.d = d 345 self.d = d
350 self.rootfs_dir = rootfs_dir 346 self.rootfs_dir = rootfs_dir
@@ -367,7 +363,7 @@ class RpmPkgsList(PkgsList):
367 # Determine rpm version 363 # Determine rpm version
368 cmd = "%s --version" % self.rpm_cmd 364 cmd = "%s --version" % self.rpm_cmd
369 try: 365 try:
370 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 366 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
371 except subprocess.CalledProcessError as e: 367 except subprocess.CalledProcessError as e:
372 bb.fatal("Getting rpm version failed. Command '%s' " 368 bb.fatal("Getting rpm version failed. Command '%s' "
373 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 369 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -411,7 +407,7 @@ class RpmPkgsList(PkgsList):
411 "-t", self.image_rpmlib] 407 "-t", self.image_rpmlib]
412 408
413 try: 409 try:
414 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 410 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
415 except subprocess.CalledProcessError as e: 411 except subprocess.CalledProcessError as e:
416 bb.fatal("Cannot get the package dependencies. Command '%s' " 412 bb.fatal("Cannot get the package dependencies. Command '%s' "
417 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 413 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
@@ -425,7 +421,7 @@ class RpmPkgsList(PkgsList):
425 421
426 try: 422 try:
427 # bb.note(cmd) 423 # bb.note(cmd)
428 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 424 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
429 except subprocess.CalledProcessError as e: 425 except subprocess.CalledProcessError as e:
430 bb.fatal("Cannot get the installed packages list. Command '%s' " 426 bb.fatal("Cannot get the installed packages list. Command '%s' "
431 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 427 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -485,6 +481,8 @@ class OpkgPkgsList(PkgsList):
485 # output streams separately and check for empty stderr. 481 # output streams separately and check for empty stderr.
486 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) 482 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
487 cmd_output, cmd_stderr = p.communicate() 483 cmd_output, cmd_stderr = p.communicate()
484 cmd_output = cmd_output.decode("utf-8")
485 cmd_stderr = cmd_stderr.decode("utf-8")
488 if p.returncode or cmd_stderr: 486 if p.returncode or cmd_stderr:
489 bb.fatal("Cannot get the installed packages list. Command '%s' " 487 bb.fatal("Cannot get the installed packages list. Command '%s' "
490 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr)) 488 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr))
@@ -502,7 +500,7 @@ class DpkgPkgsList(PkgsList):
502 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") 500 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n")
503 501
504 try: 502 try:
505 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 503 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
506 except subprocess.CalledProcessError as e: 504 except subprocess.CalledProcessError as e:
507 bb.fatal("Cannot get the installed packages list. Command '%s' " 505 bb.fatal("Cannot get the installed packages list. Command '%s' "
508 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 506 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
@@ -510,11 +508,10 @@ class DpkgPkgsList(PkgsList):
510 return opkg_query(cmd_output) 508 return opkg_query(cmd_output)
511 509
512 510
513class PackageManager(object): 511class PackageManager(object, metaclass=ABCMeta):
514 """ 512 """
515 This is an abstract class. Do not instantiate this directly. 513 This is an abstract class. Do not instantiate this directly.
516 """ 514 """
517 __metaclass__ = ABCMeta
518 515
519 def __init__(self, d): 516 def __init__(self, d):
520 self.d = d 517 self.d = d
@@ -608,7 +605,7 @@ class PackageManager(object):
608 try: 605 try:
609 bb.note("Installing complementary packages ...") 606 bb.note("Installing complementary packages ...")
610 bb.note('Running %s' % cmd) 607 bb.note('Running %s' % cmd)
611 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT) 608 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8")
612 except subprocess.CalledProcessError as e: 609 except subprocess.CalledProcessError as e:
613 bb.fatal("Could not compute complementary packages list. Command " 610 bb.fatal("Could not compute complementary packages list. Command "
614 "'%s' returned %d:\n%s" % 611 "'%s' returned %d:\n%s" %
@@ -641,8 +638,8 @@ class PackageManager(object):
641 def construct_uris(self, uris, base_paths): 638 def construct_uris(self, uris, base_paths):
642 def _append(arr1, arr2, sep='/'): 639 def _append(arr1, arr2, sep='/'):
643 res = [] 640 res = []
644 narr1 = map(lambda a: string.rstrip(a, sep), arr1) 641 narr1 = [string.rstrip(a, sep) for a in arr1]
645 narr2 = map(lambda a: string.lstrip(string.rstrip(a, sep), sep), arr2) 642 narr2 = [string.lstrip(string.rstrip(a, sep), sep) for a in arr2]
646 for a1 in narr1: 643 for a1 in narr1:
647 if arr2: 644 if arr2:
648 for a2 in narr2: 645 for a2 in narr2:
@@ -784,7 +781,7 @@ class RpmPM(PackageManager):
784 try: 781 try:
785 complementary_pkgs = subprocess.check_output(cmd, 782 complementary_pkgs = subprocess.check_output(cmd,
786 stderr=subprocess.STDOUT, 783 stderr=subprocess.STDOUT,
787 shell=True) 784 shell=True).decode("utf-8")
788 # bb.note(complementary_pkgs) 785 # bb.note(complementary_pkgs)
789 return complementary_pkgs 786 return complementary_pkgs
790 except subprocess.CalledProcessError as e: 787 except subprocess.CalledProcessError as e:
@@ -808,7 +805,7 @@ class RpmPM(PackageManager):
808 (self.smart_cmd, self.smart_opt, pkg) 805 (self.smart_cmd, self.smart_opt, pkg)
809 cmd += " | sed -ne 's/ *Provides://p'" 806 cmd += " | sed -ne 's/ *Provides://p'"
810 bb.note('cmd: %s' % cmd) 807 bb.note('cmd: %s' % cmd)
811 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 808 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
812 # Found a provider 809 # Found a provider
813 if output: 810 if output:
814 bb.note('Found providers for %s: %s' % (pkg, output)) 811 bb.note('Found providers for %s: %s' % (pkg, output))
@@ -1091,7 +1088,7 @@ class RpmPM(PackageManager):
1091 open(self.scriptlet_wrapper, 'w+').write(scriptlet_content) 1088 open(self.scriptlet_wrapper, 'w+').write(scriptlet_content)
1092 1089
1093 bb.note("Note: configuring RPM cross-install scriptlet_wrapper") 1090 bb.note("Note: configuring RPM cross-install scriptlet_wrapper")
1094 os.chmod(self.scriptlet_wrapper, 0755) 1091 os.chmod(self.scriptlet_wrapper, 0o755)
1095 cmd = 'config --set rpm-extra-macros._cross_scriptlet_wrapper=%s' % \ 1092 cmd = 'config --set rpm-extra-macros._cross_scriptlet_wrapper=%s' % \
1096 self.scriptlet_wrapper 1093 self.scriptlet_wrapper
1097 self._invoke_smart(cmd) 1094 self._invoke_smart(cmd)
@@ -1109,7 +1106,7 @@ class RpmPM(PackageManager):
1109 sub_rdep = sub_data.get("RDEPENDS_" + pkg) 1106 sub_rdep = sub_data.get("RDEPENDS_" + pkg)
1110 if not sub_rdep: 1107 if not sub_rdep:
1111 continue 1108 continue
1112 done = bb.utils.explode_dep_versions2(sub_rdep).keys() 1109 done = list(bb.utils.explode_dep_versions2(sub_rdep).keys())
1113 next = done 1110 next = done
1114 # Find all the rdepends on dependency chain 1111 # Find all the rdepends on dependency chain
1115 while next: 1112 while next:
@@ -1203,7 +1200,7 @@ class RpmPM(PackageManager):
1203 cmd = "%s %s install --attempt -y %s" % \ 1200 cmd = "%s %s install --attempt -y %s" % \
1204 (self.smart_cmd, self.smart_opt, ' '.join(pkgs)) 1201 (self.smart_cmd, self.smart_opt, ' '.join(pkgs))
1205 try: 1202 try:
1206 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1203 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1207 bb.note(output) 1204 bb.note(output)
1208 except subprocess.CalledProcessError as e: 1205 except subprocess.CalledProcessError as e:
1209 bb.fatal("Unable to install packages. Command '%s' " 1206 bb.fatal("Unable to install packages. Command '%s' "
@@ -1233,7 +1230,7 @@ class RpmPM(PackageManager):
1233 1230
1234 try: 1231 try:
1235 bb.note(cmd) 1232 bb.note(cmd)
1236 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1233 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
1237 bb.note(output) 1234 bb.note(output)
1238 except subprocess.CalledProcessError as e: 1235 except subprocess.CalledProcessError as e:
1239 bb.note("Unable to remove packages. Command '%s' " 1236 bb.note("Unable to remove packages. Command '%s' "
@@ -1379,9 +1376,9 @@ class RpmPM(PackageManager):
1379 1376
1380 try: 1377 try:
1381 bb.note(cmd) 1378 bb.note(cmd)
1382 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 1379 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
1383 bb.note(output) 1380 bb.note(output)
1384 os.chmod(saved_dir, 0755) 1381 os.chmod(saved_dir, 0o755)
1385 except subprocess.CalledProcessError as e: 1382 except subprocess.CalledProcessError as e:
1386 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' " 1383 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' "
1387 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1384 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1753,7 +1750,7 @@ class OpkgPM(OpkgDpkgPM):
1753 try: 1750 try:
1754 bb.note("Installing the following packages: %s" % ' '.join(pkgs)) 1751 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
1755 bb.note(cmd) 1752 bb.note(cmd)
1756 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1753 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1757 bb.note(output) 1754 bb.note(output)
1758 except subprocess.CalledProcessError as e: 1755 except subprocess.CalledProcessError as e:
1759 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 1756 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
@@ -1770,7 +1767,7 @@ class OpkgPM(OpkgDpkgPM):
1770 1767
1771 try: 1768 try:
1772 bb.note(cmd) 1769 bb.note(cmd)
1773 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1770 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1774 bb.note(output) 1771 bb.note(output)
1775 except subprocess.CalledProcessError as e: 1772 except subprocess.CalledProcessError as e:
1776 bb.fatal("Unable to remove packages. Command '%s' " 1773 bb.fatal("Unable to remove packages. Command '%s' "
@@ -1817,7 +1814,7 @@ class OpkgPM(OpkgDpkgPM):
1817 pkg_info = cmd + pkg 1814 pkg_info = cmd + pkg
1818 1815
1819 try: 1816 try:
1820 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip() 1817 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip().decode("utf-8")
1821 except subprocess.CalledProcessError as e: 1818 except subprocess.CalledProcessError as e:
1822 bb.fatal("Cannot get package info. Command '%s' " 1819 bb.fatal("Cannot get package info. Command '%s' "
1823 "returned %d:\n%s" % (pkg_info, e.returncode, e.output)) 1820 "returned %d:\n%s" % (pkg_info, e.returncode, e.output))