summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Oberritter <obi@opendreambox.org>2014-08-28 20:58:45 +0200
committerAndreas Oberritter <obi@opendreambox.org>2015-02-23 17:15:51 +0100
commitd83a2db49cd9cd178487e76d120509d8ccd9a3ca (patch)
tree5572504dceec48ea47d0d3a3bcfe093d4f7018e6
parentb3707ffbd850994fd0be7916d24f3cfab918b87e (diff)
downloadopenembedded-core-contrib-d83a2db49cd9cd178487e76d120509d8ccd9a3ca.tar.gz
openembedded-core-contrib-d83a2db49cd9cd178487e76d120509d8ccd9a3ca.tar.bz2
openembedded-core-contrib-d83a2db49cd9cd178487e76d120509d8ccd9a3ca.zip
package_deb: skip pre/postrm scripts on upgrade, write only one shebang
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
-rw-r--r--meta/classes/package_deb.bbclass17
1 files changed, 15 insertions, 2 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 6a5f206488..9aaa4ad64f 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -398,13 +398,26 @@ python do_package_deb () {
scriptvar = localdata.getVar('pkg_%s' % script, True)
if not scriptvar:
continue
+ scriptvar = scriptvar.strip()
try:
scriptfile = open(os.path.join(controldir, script), 'w')
except OSError:
bb.utils.unlockfile(lf)
raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
- scriptfile.write("#!/bin/sh\n")
- scriptfile.write(scriptvar)
+
+ if scriptvar.startswith("#!"):
+ pos = scriptvar.find("\n") + 1
+ scriptfile.write(scriptvar[:pos])
+ else:
+ pos = 0
+ scriptfile.write("#!/bin/sh\n")
+
+ # Prevent the prerm/postrm scripts from being run during an upgrade
+ if script in ('prerm', 'postrm'):
+ scriptfile.write('[ "$1" != "upgrade" ] || exit 0\n')
+
+ scriptfile.write(scriptvar[pos:])
+ scriptfile.write('\n')
scriptfile.close()
os.chmod(os.path.join(controldir, script), 0755)