summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2014-03-03 18:36:39 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-07 14:45:21 +0000
commita820b3f78ebcded07a81da3905c1bcdd4f173a23 (patch)
tree89865616fd0aa3a7728fcd0f24dde697272fd2d1 /meta/lib
parent7b70586a31e3df0ba35a7766b3b9d48e0d5d75b9 (diff)
downloadpoky-a820b3f78ebcded07a81da3905c1bcdd4f173a23.tar.gz
image.py, rootfs.py, package_manager.py: redirect stderr to stdout when calling check_output()
If a command executed with subprocess.check_output() fails, the subprocess.CalledProcessError.output contains only STDOUT and the user needs to check the log.do_rootfs to see any other details. This commit forwards stderr to stdout so that, in case of failure, the entire error output will be displayed in terminal. [YOCTO #5902] (From OE-Core rev: 4661f1441429952f30e19cebd93dc42ce31fd868) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/image.py2
-rw-r--r--meta/lib/oe/package_manager.py48
-rw-r--r--meta/lib/oe/rootfs.py2
3 files changed, 27 insertions, 25 deletions
diff --git a/meta/lib/oe/image.py b/meta/lib/oe/image.py
index 488683e42a..a03b73e4c0 100644
--- a/meta/lib/oe/image.py
+++ b/meta/lib/oe/image.py
@@ -11,7 +11,7 @@ def generate_image(arg):
11 (type, create_img_cmd)) 11 (type, create_img_cmd))
12 12
13 try: 13 try:
14 subprocess.check_output(create_img_cmd) 14 subprocess.check_output(create_img_cmd, stderr=subprocess.STDOUT)
15 except subprocess.CalledProcessError as e: 15 except subprocess.CalledProcessError as e:
16 return("Error: The image creation script '%s' returned %d:\n%s" % 16 return("Error: The image creation script '%s' returned %d:\n%s" %
17 (e.cmd, e.returncode, e.output)) 17 (e.cmd, e.returncode, e.output))
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index ee42952046..d7cbbbe652 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -14,7 +14,7 @@ def create_index(arg):
14 14
15 try: 15 try:
16 bb.note("Executing '%s' ..." % index_cmd) 16 bb.note("Executing '%s' ..." % index_cmd)
17 subprocess.check_output(index_cmd, shell=True) 17 subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True)
18 except subprocess.CalledProcessError as e: 18 except subprocess.CalledProcessError as e:
19 return("Index creation command '%s' failed with return code %d:\n%s" % 19 return("Index creation command '%s' failed with return code %d:\n%s" %
20 (e.cmd, e.returncode, e.output)) 20 (e.cmd, e.returncode, e.output))
@@ -298,7 +298,7 @@ class PackageManager(object):
298 globs] 298 globs]
299 try: 299 try:
300 bb.note("Installing complementary packages ...") 300 bb.note("Installing complementary packages ...")
301 complementary_pkgs = subprocess.check_output(cmd) 301 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
302 except subprocess.CalledProcessError as e: 302 except subprocess.CalledProcessError as e:
303 bb.fatal("Could not compute complementary packages list. Command " 303 bb.fatal("Could not compute complementary packages list. Command "
304 "'%s' returned %d:\n%s" % 304 "'%s' returned %d:\n%s" %
@@ -388,7 +388,9 @@ class RpmPM(PackageManager):
388 cmd = "%s %s %s" % (self.smart_cmd, self.smart_opt, args) 388 cmd = "%s %s %s" % (self.smart_cmd, self.smart_opt, args)
389 # bb.note(cmd) 389 # bb.note(cmd)
390 try: 390 try:
391 complementary_pkgs = subprocess.check_output(cmd, shell=True) 391 complementary_pkgs = subprocess.check_output(cmd,
392 stderr=subprocess.STDOUT,
393 shell=True)
392 # bb.note(complementary_pkgs) 394 # bb.note(complementary_pkgs)
393 return complementary_pkgs 395 return complementary_pkgs
394 except subprocess.CalledProcessError as e: 396 except subprocess.CalledProcessError as e:
@@ -570,7 +572,7 @@ class RpmPM(PackageManager):
570 self.rpm_cmd, 572 self.rpm_cmd,
571 self.target_rootfs) 573 self.target_rootfs)
572 try: 574 try:
573 subprocess.check_output(cmd, shell=True) 575 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
574 except subprocess.CalledProcessError as e: 576 except subprocess.CalledProcessError as e:
575 bb.fatal("Create rpm database failed. Command '%s' " 577 bb.fatal("Create rpm database failed. Command '%s' "
576 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 578 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -694,7 +696,7 @@ class RpmPM(PackageManager):
694 cmd = "%s %s install --attempt -y %s" % \ 696 cmd = "%s %s install --attempt -y %s" % \
695 (self.smart_cmd, self.smart_opt, ' '.join(pkgs)) 697 (self.smart_cmd, self.smart_opt, ' '.join(pkgs))
696 try: 698 try:
697 output = subprocess.check_output(cmd.split()) 699 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
698 bb.note(output) 700 bb.note(output)
699 except subprocess.CalledProcessError as e: 701 except subprocess.CalledProcessError as e:
700 bb.fatal("Unable to install packages. Command '%s' " 702 bb.fatal("Unable to install packages. Command '%s' "
@@ -724,7 +726,7 @@ class RpmPM(PackageManager):
724 726
725 try: 727 try:
726 bb.note(cmd) 728 bb.note(cmd)
727 output = subprocess.check_output(cmd, shell=True) 729 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
728 bb.note(output) 730 bb.note(output)
729 except subprocess.CalledProcessError as e: 731 except subprocess.CalledProcessError as e:
730 bb.note("Unable to remove packages. Command '%s' " 732 bb.note("Unable to remove packages. Command '%s' "
@@ -775,7 +777,7 @@ class RpmPM(PackageManager):
775 777
776 try: 778 try:
777 # bb.note(cmd) 779 # bb.note(cmd)
778 tmp_output = subprocess.check_output(cmd, shell=True).strip() 780 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip()
779 self._unlock_rpm_db() 781 self._unlock_rpm_db()
780 except subprocess.CalledProcessError as e: 782 except subprocess.CalledProcessError as e:
781 bb.fatal("Cannot get the installed packages list. Command '%s' " 783 bb.fatal("Cannot get the installed packages list. Command '%s' "
@@ -827,7 +829,7 @@ class RpmPM(PackageManager):
827 # Disable rpmsys channel for the fake install 829 # Disable rpmsys channel for the fake install
828 self._invoke_smart('channel --disable rpmsys') 830 self._invoke_smart('channel --disable rpmsys')
829 831
830 subprocess.check_output(cmd, shell=True) 832 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
831 with open(self.solution_manifest, 'r') as manifest: 833 with open(self.solution_manifest, 'r') as manifest:
832 for pkg in manifest.read().split('\n'): 834 for pkg in manifest.read().split('\n'):
833 if '@' in pkg: 835 if '@' in pkg:
@@ -869,7 +871,7 @@ class RpmPM(PackageManager):
869 cmd = "%s %s query --output %s" % \ 871 cmd = "%s %s query --output %s" % \
870 (self.smart_cmd, self.smart_opt, available_manifest) 872 (self.smart_cmd, self.smart_opt, available_manifest)
871 try: 873 try:
872 subprocess.check_output(cmd, shell=True) 874 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
873 with open(available_manifest, 'r') as manifest: 875 with open(available_manifest, 'r') as manifest:
874 for pkg in manifest.read().split('\n'): 876 for pkg in manifest.read().split('\n'):
875 if '@' in pkg: 877 if '@' in pkg:
@@ -903,7 +905,7 @@ class RpmPM(PackageManager):
903 905
904 try: 906 try:
905 bb.note(cmd) 907 bb.note(cmd)
906 output = subprocess.check_output(cmd, shell=True).strip() 908 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip()
907 bb.note(output) 909 bb.note(output)
908 os.chmod(saved_dir, 0755) 910 os.chmod(saved_dir, 0755)
909 self._unlock_rpm_db() 911 self._unlock_rpm_db()
@@ -1059,7 +1061,7 @@ class OpkgPM(PackageManager):
1059 cmd = "%s %s update" % (self.opkg_cmd, self.opkg_args) 1061 cmd = "%s %s update" % (self.opkg_cmd, self.opkg_args)
1060 1062
1061 try: 1063 try:
1062 subprocess.check_output(cmd.split()) 1064 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1063 except subprocess.CalledProcessError as e: 1065 except subprocess.CalledProcessError as e:
1064 self.deploy_dir_unlock() 1066 self.deploy_dir_unlock()
1065 bb.fatal("Unable to update the package index files. Command '%s' " 1067 bb.fatal("Unable to update the package index files. Command '%s' "
@@ -1084,7 +1086,7 @@ class OpkgPM(PackageManager):
1084 try: 1086 try:
1085 bb.note("Installing the following packages: %s" % ' '.join(pkgs)) 1087 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
1086 bb.note(cmd) 1088 bb.note(cmd)
1087 output = subprocess.check_output(cmd.split()) 1089 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1088 bb.note(output) 1090 bb.note(output)
1089 except subprocess.CalledProcessError as e: 1091 except subprocess.CalledProcessError as e:
1090 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 1092 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
@@ -1101,7 +1103,7 @@ class OpkgPM(PackageManager):
1101 1103
1102 try: 1104 try:
1103 bb.note(cmd) 1105 bb.note(cmd)
1104 output = subprocess.check_output(cmd.split()) 1106 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1105 bb.note(output) 1107 bb.note(output)
1106 except subprocess.CalledProcessError as e: 1108 except subprocess.CalledProcessError as e:
1107 bb.fatal("Unable to remove packages. Command '%s' " 1109 bb.fatal("Unable to remove packages. Command '%s' "
@@ -1139,7 +1141,7 @@ class OpkgPM(PackageManager):
1139 (self.opkg_cmd, self.opkg_args) 1141 (self.opkg_cmd, self.opkg_args)
1140 1142
1141 try: 1143 try:
1142 output = subprocess.check_output(cmd, shell=True).strip() 1144 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip()
1143 except subprocess.CalledProcessError as e: 1145 except subprocess.CalledProcessError as e:
1144 bb.fatal("Cannot get the installed packages list. Command '%s' " 1146 bb.fatal("Cannot get the installed packages list. Command '%s' "
1145 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1147 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1177,7 +1179,7 @@ class OpkgPM(PackageManager):
1177 pkg_info = cmd + pkg 1179 pkg_info = cmd + pkg
1178 1180
1179 try: 1181 try:
1180 output = subprocess.check_output(pkg_info.split()).strip() 1182 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip()
1181 except subprocess.CalledProcessError as e: 1183 except subprocess.CalledProcessError as e:
1182 bb.fatal("Cannot get package info. Command '%s' " 1184 bb.fatal("Cannot get package info. Command '%s' "
1183 "returned %d:\n%s" % (pkg_info, e.returncode, e.output)) 1185 "returned %d:\n%s" % (pkg_info, e.returncode, e.output))
@@ -1210,7 +1212,7 @@ class OpkgPM(PackageManager):
1210 1212
1211 cmd = "%s %s update" % (self.opkg_cmd, opkg_args) 1213 cmd = "%s %s update" % (self.opkg_cmd, opkg_args)
1212 try: 1214 try:
1213 subprocess.check_output(cmd, shell=True) 1215 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1214 except subprocess.CalledProcessError as e: 1216 except subprocess.CalledProcessError as e:
1215 bb.fatal("Unable to update. Command '%s' " 1217 bb.fatal("Unable to update. Command '%s' "
1216 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1218 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1220,7 +1222,7 @@ class OpkgPM(PackageManager):
1220 opkg_args, 1222 opkg_args,
1221 ' '.join(pkgs)) 1223 ' '.join(pkgs))
1222 try: 1224 try:
1223 output = subprocess.check_output(cmd, shell=True) 1225 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1224 except subprocess.CalledProcessError as e: 1226 except subprocess.CalledProcessError as e:
1225 bb.fatal("Unable to dummy install packages. Command '%s' " 1227 bb.fatal("Unable to dummy install packages. Command '%s' "
1226 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1228 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1330,7 +1332,7 @@ class DpkgPM(PackageManager):
1330 try: 1332 try:
1331 bb.note("Executing %s for package: %s ..." % 1333 bb.note("Executing %s for package: %s ..." %
1332 (suffix[1].lower(), pkg_name)) 1334 (suffix[1].lower(), pkg_name))
1333 subprocess.check_output(p_full) 1335 subprocess.check_output(p_full, stderr=subprocess.STDOUT)
1334 except subprocess.CalledProcessError as e: 1336 except subprocess.CalledProcessError as e:
1335 bb.note("%s for package %s failed with %d:\n%s" % 1337 bb.note("%s for package %s failed with %d:\n%s" %
1336 (suffix[1], pkg_name, e.returncode, e.output)) 1338 (suffix[1], pkg_name, e.returncode, e.output))
@@ -1348,7 +1350,7 @@ class DpkgPM(PackageManager):
1348 cmd = "%s update" % self.apt_get_cmd 1350 cmd = "%s update" % self.apt_get_cmd
1349 1351
1350 try: 1352 try:
1351 subprocess.check_output(cmd.split()) 1353 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1352 except subprocess.CalledProcessError as e: 1354 except subprocess.CalledProcessError as e:
1353 bb.fatal("Unable to update the package index files. Command '%s' " 1355 bb.fatal("Unable to update the package index files. Command '%s' "
1354 "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 1356 "returned %d:\n%s" % (e.cmd, e.returncode, e.output))
@@ -1366,7 +1368,7 @@ class DpkgPM(PackageManager):
1366 1368
1367 try: 1369 try:
1368 bb.note("Installing the following packages: %s" % ' '.join(pkgs)) 1370 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
1369 subprocess.check_output(cmd.split()) 1371 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1370 except subprocess.CalledProcessError as e: 1372 except subprocess.CalledProcessError as e:
1371 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 1373 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
1372 "Command '%s' returned %d:\n%s" % 1374 "Command '%s' returned %d:\n%s" %
@@ -1398,7 +1400,7 @@ class DpkgPM(PackageManager):
1398 self.target_rootfs, self.target_rootfs, ' '.join(pkgs)) 1400 self.target_rootfs, self.target_rootfs, ' '.join(pkgs))
1399 1401
1400 try: 1402 try:
1401 subprocess.check_output(cmd.split()) 1403 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1402 except subprocess.CalledProcessError as e: 1404 except subprocess.CalledProcessError as e:
1403 bb.fatal("Unable to remove packages. Command '%s' " 1405 bb.fatal("Unable to remove packages. Command '%s' "
1404 "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 1406 "returned %d:\n%s" % (e.cmd, e.returncode, e.output))
@@ -1481,7 +1483,7 @@ class DpkgPM(PackageManager):
1481 cmd = "%s %s -f install" % (self.apt_get_cmd, self.apt_args) 1483 cmd = "%s %s -f install" % (self.apt_get_cmd, self.apt_args)
1482 1484
1483 try: 1485 try:
1484 subprocess.check_output(cmd.split()) 1486 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
1485 except subprocess.CalledProcessError as e: 1487 except subprocess.CalledProcessError as e:
1486 bb.fatal("Cannot fix broken dependencies. Command '%s' " 1488 bb.fatal("Cannot fix broken dependencies. Command '%s' "
1487 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1489 "returned %d:\n%s" % (cmd, e.returncode, e.output))
@@ -1501,7 +1503,7 @@ class DpkgPM(PackageManager):
1501 cmd.append("-f=${Package}\n") 1503 cmd.append("-f=${Package}\n")
1502 1504
1503 try: 1505 try:
1504 output = subprocess.check_output(cmd).strip() 1506 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip()
1505 except subprocess.CalledProcessError as e: 1507 except subprocess.CalledProcessError as e:
1506 bb.fatal("Cannot get the installed packages list. Command '%s' " 1508 bb.fatal("Cannot get the installed packages list. Command '%s' "
1507 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 1509 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output))
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index be0afa6d74..90c0504b31 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -57,7 +57,7 @@ class Rootfs(object):
57 exec_cmd = cmd 57 exec_cmd = cmd
58 58
59 try: 59 try:
60 subprocess.check_output(exec_cmd) 60 subprocess.check_output(exec_cmd, stderr=subprocess.STDOUT)
61 except subprocess.CalledProcessError as e: 61 except subprocess.CalledProcessError as e:
62 return("Command '%s' returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 62 return("Command '%s' returned %d:\n%s" % (e.cmd, e.returncode, e.output))
63 63