summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2015-12-09 18:48:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-28 09:25:19 +0000
commitc91078954e9f183412456d04c8261a0198a063c1 (patch)
treefe256f257261d263325ca9fccaf484d950415115 /meta/lib
parent8dd27efecf3f156e4013b41e33d9bfcd4126024c (diff)
downloadpoky-c91078954e9f183412456d04c8261a0198a063c1.tar.gz
package_manager.py: add debugging support for rpm scriptlet execution
By default, smart is invoked with --log-level=warning, which hides all output from pre/post install scriptlets. That makes it hard to debug scriptlet failure or why they get postponed to first-boot via /etc/rpm-postinst. The new ROOTFS_RPM_DEBUG variabled is expected to be set to an integer in local.conf an incrementally adds more output: 0 = default, only warnings 1 = --log-level=info (includes information about executing scriptlets and their output) 2 = --log-level=debug 3 = --log-level=debug plus dumps of scriplet content and command invocation The default behavior is not changed yet, but it seems that level 1 would be a better default. (From OE-Core rev: 5cb597a19dbfe825e5b26d828e18644c9ee58f86) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/package_manager.py35
1 files changed, 30 insertions, 5 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index fd9caa31c8..32afeaf514 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -685,8 +685,16 @@ class RpmPM(PackageManager):
685 self.install_dir_path = os.path.join(self.target_rootfs, self.install_dir_name) 685 self.install_dir_path = os.path.join(self.target_rootfs, self.install_dir_name)
686 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm") 686 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
687 self.smart_cmd = bb.utils.which(os.getenv('PATH'), "smart") 687 self.smart_cmd = bb.utils.which(os.getenv('PATH'), "smart")
688 self.smart_opt = "--log-level=warning --data-dir=" + os.path.join(target_rootfs, 688 # 0 = default, only warnings
689 'var/lib/smart') 689 # 1 = --log-level=info (includes information about executing scriptlets and their output)
690 # 2 = --log-level=debug
691 # 3 = --log-level=debug plus dumps of scriplet content and command invocation
692 self.debug_level = int(d.getVar('ROOTFS_RPM_DEBUG', True) or "0")
693 self.smart_opt = "--log-level=%s --data-dir=%s" % \
694 ("warning" if self.debug_level == 0 else
695 "info" if self.debug_level == 1 else
696 "debug",
697 os.path.join(target_rootfs, 'var/lib/smart'))
690 self.scriptlet_wrapper = self.d.expand('${WORKDIR}/scriptlet_wrapper') 698 self.scriptlet_wrapper = self.d.expand('${WORKDIR}/scriptlet_wrapper')
691 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' % 699 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
692 self.task_name) 700 self.task_name)
@@ -1051,6 +1059,17 @@ class RpmPM(PackageManager):
1051 scriptletcmd = "$2 $1/$3 $4\n" 1059 scriptletcmd = "$2 $1/$3 $4\n"
1052 scriptpath = "$1/$3" 1060 scriptpath = "$1/$3"
1053 1061
1062 # When self.debug_level >= 3, also dump the content of the
1063 # executed scriptlets and how they get invoked. We have to
1064 # replace "exit 1" and "ERR" because printing those as-is
1065 # would trigger a log analysis failure.
1066 if self.debug_level >= 3:
1067 dump_invocation = 'echo "Executing ${name} ${kind} with: ' + scriptletcmd + '"\n'
1068 dump_script = 'cat ' + scriptpath + '| sed -e "s/exit 1/exxxit 1/g" -e "s/ERR/IRR/g"; echo\n'
1069 else:
1070 dump_invocation = 'echo "Executing ${name} ${kind}"\n'
1071 dump_script = ''
1072
1054 SCRIPTLET_FORMAT = "#!/bin/bash\n" \ 1073 SCRIPTLET_FORMAT = "#!/bin/bash\n" \
1055 "\n" \ 1074 "\n" \
1056 "export PATH=%s\n" \ 1075 "export PATH=%s\n" \
@@ -1061,19 +1080,25 @@ class RpmPM(PackageManager):
1061 "export INTERCEPT_DIR=%s\n" \ 1080 "export INTERCEPT_DIR=%s\n" \
1062 "export NATIVE_ROOT=%s\n" \ 1081 "export NATIVE_ROOT=%s\n" \
1063 "\n" \ 1082 "\n" \
1083 "name=`head -1 " + scriptpath + " | cut -d\' \' -f 2`\n" \
1084 "kind=`head -1 " + scriptpath + " | cut -d\' \' -f 4`\n" \
1085 + dump_invocation \
1086 + dump_script \
1064 + scriptletcmd + \ 1087 + scriptletcmd + \
1065 "if [ $? -ne 0 ]; then\n" \ 1088 "ret=$?\n" \
1089 "echo Result of ${name} ${kind}: ${ret}\n" \
1090 "if [ ${ret} -ne 0 ]; then\n" \
1066 " if [ $4 -eq 1 ]; then\n" \ 1091 " if [ $4 -eq 1 ]; then\n" \
1067 " mkdir -p $1/etc/rpm-postinsts\n" \ 1092 " mkdir -p $1/etc/rpm-postinsts\n" \
1068 " num=100\n" \ 1093 " num=100\n" \
1069 " while [ -e $1/etc/rpm-postinsts/${num}-* ]; do num=$((num + 1)); done\n" \ 1094 " while [ -e $1/etc/rpm-postinsts/${num}-* ]; do num=$((num + 1)); done\n" \
1070 " name=`head -1 " + scriptpath + " | cut -d\' \' -f 2`\n" \
1071 ' echo "#!$2" > $1/etc/rpm-postinsts/${num}-${name}\n' \ 1095 ' echo "#!$2" > $1/etc/rpm-postinsts/${num}-${name}\n' \
1072 ' echo "# Arg: $4" >> $1/etc/rpm-postinsts/${num}-${name}\n' \ 1096 ' echo "# Arg: $4" >> $1/etc/rpm-postinsts/${num}-${name}\n' \
1073 " cat " + scriptpath + " >> $1/etc/rpm-postinsts/${num}-${name}\n" \ 1097 " cat " + scriptpath + " >> $1/etc/rpm-postinsts/${num}-${name}\n" \
1074 " chmod +x $1/etc/rpm-postinsts/${num}-${name}\n" \ 1098 " chmod +x $1/etc/rpm-postinsts/${num}-${name}\n" \
1099 ' echo "Info: deferring ${name} ${kind} install scriptlet to first boot"\n' \
1075 " else\n" \ 1100 " else\n" \
1076 ' echo "Error: pre/post remove scriptlet failed"\n' \ 1101 ' echo "Error: ${name} ${kind} remove scriptlet failed"\n' \
1077 " fi\n" \ 1102 " fi\n" \
1078 "fi\n" 1103 "fi\n"
1079 1104