From c64a57d2ecad041e2eea7bde46aab8269b31fc15 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Mon, 12 Mar 2018 18:49:41 +0200 Subject: package.bbclass: run pre/post installation/removal scriptlets using sh -e This allows catching errors in the scriptlets which would otherwise go unnoticed, e.g. this sequence: ==== bogus_command proper_command ==== would work just fine without any visible warnings or errors. This was previously done only for rpm packages; this patch replaces the rpm-specific tweak with one that works for all package types. (From OE-Core rev: a0aa12e1d0ea9064b8dd816d4e82238df765506b) Signed-off-by: Alexander Kanavin Signed-off-by: Richard Purdie --- meta/classes/package.bbclass | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'meta/classes/package.bbclass') diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 317c77585f..83f53a49ef 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -1343,6 +1343,17 @@ fi postinst += postinst_ontarget d.setVar('pkg_postinst_%s' % pkg, postinst) + def add_set_e_to_scriptlets(pkg): + for scriptlet_name in ('pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm'): + scriptlet = d.getVar('%s_%s' % (scriptlet_name, pkg)) + if scriptlet: + scriptlet_split = scriptlet.split('\n') + if scriptlet_split[0].startswith("#!"): + scriptlet = scriptlet_split[0] + "\nset -e\n" + "\n".join(scriptlet_split[1:]) + else: + scriptlet = "set -e\n" + "\n".join(scriptlet_split[0:]) + d.setVar('%s_%s' % (scriptlet_name, pkg), scriptlet) + def write_if_exists(f, pkg, var): def encode(str): import codecs @@ -1439,6 +1450,7 @@ fi write_if_exists(sf, pkg, 'FILES') write_if_exists(sf, pkg, 'CONFFILES') process_postinst_on_target(pkg, d.getVar("MLPREFIX")) + add_set_e_to_scriptlets(pkg) write_if_exists(sf, pkg, 'pkg_postinst') write_if_exists(sf, pkg, 'pkg_postrm') write_if_exists(sf, pkg, 'pkg_preinst') -- cgit v1.2.3-54-g00ecf