summaryrefslogtreecommitdiff
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-27 11:27:01 +0000
commit5cb597a19dbfe825e5b26d828e18644c9ee58f86 (patch)
tree1c2c3861005ba214a0f9c6775324efb790e415d6 /meta/lib
parentce6f15dc3905ab0b061b20cc35fd179fdd9e070f (diff)
downloadopenembedded-core-5cb597a19dbfe825e5b26d828e18644c9ee58f86.tar.gz
openembedded-core-5cb597a19dbfe825e5b26d828e18644c9ee58f86.tar.bz2
openembedded-core-5cb597a19dbfe825e5b26d828e18644c9ee58f86.zip
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. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
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):
self.install_dir_path = os.path.join(self.target_rootfs, self.install_dir_name)
self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
self.smart_cmd = bb.utils.which(os.getenv('PATH'), "smart")
- self.smart_opt = "--log-level=warning --data-dir=" + os.path.join(target_rootfs,
- 'var/lib/smart')
+ # 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
+ self.debug_level = int(d.getVar('ROOTFS_RPM_DEBUG', True) or "0")
+ self.smart_opt = "--log-level=%s --data-dir=%s" % \
+ ("warning" if self.debug_level == 0 else
+ "info" if self.debug_level == 1 else
+ "debug",
+ os.path.join(target_rootfs, 'var/lib/smart'))
self.scriptlet_wrapper = self.d.expand('${WORKDIR}/scriptlet_wrapper')
self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
@@ -1051,6 +1059,17 @@ class RpmPM(PackageManager):
scriptletcmd = "$2 $1/$3 $4\n"
scriptpath = "$1/$3"
+ # When self.debug_level >= 3, also dump the content of the
+ # executed scriptlets and how they get invoked. We have to
+ # replace "exit 1" and "ERR" because printing those as-is
+ # would trigger a log analysis failure.
+ if self.debug_level >= 3:
+ dump_invocation = 'echo "Executing ${name} ${kind} with: ' + scriptletcmd + '"\n'
+ dump_script = 'cat ' + scriptpath + '| sed -e "s/exit 1/exxxit 1/g" -e "s/ERR/IRR/g"; echo\n'
+ else:
+ dump_invocation = 'echo "Executing ${name} ${kind}"\n'
+ dump_script = ''
+
SCRIPTLET_FORMAT = "#!/bin/bash\n" \
"\n" \
"export PATH=%s\n" \
@@ -1061,19 +1080,25 @@ class RpmPM(PackageManager):
"export INTERCEPT_DIR=%s\n" \
"export NATIVE_ROOT=%s\n" \
"\n" \
+ "name=`head -1 " + scriptpath + " | cut -d\' \' -f 2`\n" \
+ "kind=`head -1 " + scriptpath + " | cut -d\' \' -f 4`\n" \
+ + dump_invocation \
+ + dump_script \
+ scriptletcmd + \
- "if [ $? -ne 0 ]; then\n" \
+ "ret=$?\n" \
+ "echo Result of ${name} ${kind}: ${ret}\n" \
+ "if [ ${ret} -ne 0 ]; then\n" \
" if [ $4 -eq 1 ]; then\n" \
" mkdir -p $1/etc/rpm-postinsts\n" \
" num=100\n" \
" while [ -e $1/etc/rpm-postinsts/${num}-* ]; do num=$((num + 1)); done\n" \
- " name=`head -1 " + scriptpath + " | cut -d\' \' -f 2`\n" \
' echo "#!$2" > $1/etc/rpm-postinsts/${num}-${name}\n' \
' echo "# Arg: $4" >> $1/etc/rpm-postinsts/${num}-${name}\n' \
" cat " + scriptpath + " >> $1/etc/rpm-postinsts/${num}-${name}\n" \
" chmod +x $1/etc/rpm-postinsts/${num}-${name}\n" \
+ ' echo "Info: deferring ${name} ${kind} install scriptlet to first boot"\n' \
" else\n" \
- ' echo "Error: pre/post remove scriptlet failed"\n' \
+ ' echo "Error: ${name} ${kind} remove scriptlet failed"\n' \
" fi\n" \
"fi\n"