summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-03-12 18:49:41 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-15 06:27:18 -0700
commitc64a57d2ecad041e2eea7bde46aab8269b31fc15 (patch)
tree7f1f199a008e225dc3b0762a0ac68610d769d1d4 /meta
parent6d71fdbf204837846b2f29f048f9215a3433f3ec (diff)
downloadpoky-c64a57d2ecad041e2eea7bde46aab8269b31fc15.tar.gz
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 <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package.bbclass12
-rw-r--r--meta/classes/package_rpm.bbclass8
2 files changed, 16 insertions, 4 deletions
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
1343 postinst += postinst_ontarget 1343 postinst += postinst_ontarget
1344 d.setVar('pkg_postinst_%s' % pkg, postinst) 1344 d.setVar('pkg_postinst_%s' % pkg, postinst)
1345 1345
1346 def add_set_e_to_scriptlets(pkg):
1347 for scriptlet_name in ('pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm'):
1348 scriptlet = d.getVar('%s_%s' % (scriptlet_name, pkg))
1349 if scriptlet:
1350 scriptlet_split = scriptlet.split('\n')
1351 if scriptlet_split[0].startswith("#!"):
1352 scriptlet = scriptlet_split[0] + "\nset -e\n" + "\n".join(scriptlet_split[1:])
1353 else:
1354 scriptlet = "set -e\n" + "\n".join(scriptlet_split[0:])
1355 d.setVar('%s_%s' % (scriptlet_name, pkg), scriptlet)
1356
1346 def write_if_exists(f, pkg, var): 1357 def write_if_exists(f, pkg, var):
1347 def encode(str): 1358 def encode(str):
1348 import codecs 1359 import codecs
@@ -1439,6 +1450,7 @@ fi
1439 write_if_exists(sf, pkg, 'FILES') 1450 write_if_exists(sf, pkg, 'FILES')
1440 write_if_exists(sf, pkg, 'CONFFILES') 1451 write_if_exists(sf, pkg, 'CONFFILES')
1441 process_postinst_on_target(pkg, d.getVar("MLPREFIX")) 1452 process_postinst_on_target(pkg, d.getVar("MLPREFIX"))
1453 add_set_e_to_scriptlets(pkg)
1442 write_if_exists(sf, pkg, 'pkg_postinst') 1454 write_if_exists(sf, pkg, 'pkg_postinst')
1443 write_if_exists(sf, pkg, 'pkg_postrm') 1455 write_if_exists(sf, pkg, 'pkg_postrm')
1444 write_if_exists(sf, pkg, 'pkg_preinst') 1456 write_if_exists(sf, pkg, 'pkg_preinst')
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index e26b2ad662..af64ef62c5 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -470,12 +470,12 @@ python write_specfile () {
470 470
471 # Now process scriptlets 471 # Now process scriptlets
472 if splitrpreinst: 472 if splitrpreinst:
473 spec_scriptlets_bottom.append('%%pre -n %s -p "/bin/sh -e"' % splitname) 473 spec_scriptlets_bottom.append('%%pre -n %s' % splitname)
474 spec_scriptlets_bottom.append('# %s - preinst' % splitname) 474 spec_scriptlets_bottom.append('# %s - preinst' % splitname)
475 spec_scriptlets_bottom.append(splitrpreinst) 475 spec_scriptlets_bottom.append(splitrpreinst)
476 spec_scriptlets_bottom.append('') 476 spec_scriptlets_bottom.append('')
477 if splitrpostinst: 477 if splitrpostinst:
478 spec_scriptlets_bottom.append('%%post -n %s -p "/bin/sh -e"' % splitname) 478 spec_scriptlets_bottom.append('%%post -n %s' % splitname)
479 spec_scriptlets_bottom.append('# %s - postinst' % splitname) 479 spec_scriptlets_bottom.append('# %s - postinst' % splitname)
480 spec_scriptlets_bottom.append(splitrpostinst) 480 spec_scriptlets_bottom.append(splitrpostinst)
481 spec_scriptlets_bottom.append('') 481 spec_scriptlets_bottom.append('')
@@ -564,12 +564,12 @@ python write_specfile () {
564 spec_preamble_top.append('') 564 spec_preamble_top.append('')
565 565
566 if srcrpreinst: 566 if srcrpreinst:
567 spec_scriptlets_top.append('%pre -p "/bin/sh -e"') 567 spec_scriptlets_top.append('%pre')
568 spec_scriptlets_top.append('# %s - preinst' % srcname) 568 spec_scriptlets_top.append('# %s - preinst' % srcname)
569 spec_scriptlets_top.append(srcrpreinst) 569 spec_scriptlets_top.append(srcrpreinst)
570 spec_scriptlets_top.append('') 570 spec_scriptlets_top.append('')
571 if srcrpostinst: 571 if srcrpostinst:
572 spec_scriptlets_top.append('%post -p "/bin/sh -e"') 572 spec_scriptlets_top.append('%post')
573 spec_scriptlets_top.append('# %s - postinst' % srcname) 573 spec_scriptlets_top.append('# %s - postinst' % srcname)
574 spec_scriptlets_top.append(srcrpostinst) 574 spec_scriptlets_top.append(srcrpostinst)
575 spec_scriptlets_top.append('') 575 spec_scriptlets_top.append('')