From: Alexander Kanavin <alexander.kanavin@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 01/15] package.bbclass: run pre/post installation/removal scriptlets using sh -e
Date: Thu, 1 Mar 2018 16:00:38 +0200 [thread overview]
Message-ID: <20180301140052.1388-1-alexander.kanavin@linux.intel.com> (raw)
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.
Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
meta/classes/package.bbclass | 12 ++++++++++++
meta/classes/package_rpm.bbclass | 8 ++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index e7e93a067a6..56b3beb2e65 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')
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index e26b2ad6625..af64ef62c58 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -470,12 +470,12 @@ python write_specfile () {
# Now process scriptlets
if splitrpreinst:
- spec_scriptlets_bottom.append('%%pre -n %s -p "/bin/sh -e"' % splitname)
+ spec_scriptlets_bottom.append('%%pre -n %s' % splitname)
spec_scriptlets_bottom.append('# %s - preinst' % splitname)
spec_scriptlets_bottom.append(splitrpreinst)
spec_scriptlets_bottom.append('')
if splitrpostinst:
- spec_scriptlets_bottom.append('%%post -n %s -p "/bin/sh -e"' % splitname)
+ spec_scriptlets_bottom.append('%%post -n %s' % splitname)
spec_scriptlets_bottom.append('# %s - postinst' % splitname)
spec_scriptlets_bottom.append(splitrpostinst)
spec_scriptlets_bottom.append('')
@@ -564,12 +564,12 @@ python write_specfile () {
spec_preamble_top.append('')
if srcrpreinst:
- spec_scriptlets_top.append('%pre -p "/bin/sh -e"')
+ spec_scriptlets_top.append('%pre')
spec_scriptlets_top.append('# %s - preinst' % srcname)
spec_scriptlets_top.append(srcrpreinst)
spec_scriptlets_top.append('')
if srcrpostinst:
- spec_scriptlets_top.append('%post -p "/bin/sh -e"')
+ spec_scriptlets_top.append('%post')
spec_scriptlets_top.append('# %s - postinst' % srcname)
spec_scriptlets_top.append(srcrpostinst)
spec_scriptlets_top.append('')
--
2.15.1
next reply other threads:[~2018-03-01 14:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 14:00 Alexander Kanavin [this message]
2018-03-01 14:00 ` [PATCH 02/15] meta/lib/oe/package_manager.py: warn about failing scriptlets for all package types Alexander Kanavin
2018-03-01 14:00 ` [PATCH 03/15] oe-selftest: add a test for failing package post-installation scriptlets Alexander Kanavin
2018-03-01 14:00 ` [PATCH 04/15] latencytop: remove recipe Alexander Kanavin
2018-03-01 14:00 ` [PATCH 05/15] lsbinitscripts: update to 9.79 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 06/15] btrfs-tools: update to 4.15.1 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 07/15] gtk-doc.bbclass: inherit python3native Alexander Kanavin
2018-03-01 23:34 ` Burton, Ross
2018-03-02 8:55 ` Alexander Kanavin
2018-03-01 14:00 ` [PATCH 08/15] strace: use strace.io as the tarball location Alexander Kanavin
2018-03-01 14:00 ` [PATCH 09/15] mpg123: upgrade 1.25.8 -> 1.25.10 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 10/15] ffmpeg: upgrade 3.4.1 -> 3.4.2 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 11/15] epiphany: upgrade 3.26.5.1 -> 3.26.6 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 12/15] vala: upgrade 0.38.6 -> 0.38.8 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 13/15] meson: upgrade 0.44.0 -> 0.44.1 Alexander Kanavin
2018-03-01 14:00 ` [PATCH 14/15] expect: upgrade 5.45.3 -> 5.45.4 Alexander Kanavin
2018-03-02 14:12 ` Burton, Ross
2018-03-02 18:14 ` Denys Dmytriyenko
2018-03-02 20:56 ` Burton, Ross
2018-03-02 22:40 ` Richard Purdie
2018-03-01 14:00 ` [PATCH 15/15] trace-cmd: update to 2.7 Alexander Kanavin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180301140052.1388-1-alexander.kanavin@linux.intel.com \
--to=alexander.kanavin@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox