summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 7bc29df165..5b5f7e2c9a 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -239,13 +239,26 @@ python do_package_deb () {
239 scriptvar = localdata.getVar('pkg_%s' % script, True) 239 scriptvar = localdata.getVar('pkg_%s' % script, True)
240 if not scriptvar: 240 if not scriptvar:
241 continue 241 continue
242 scriptvar = scriptvar.strip()
242 try: 243 try:
243 scriptfile = open(os.path.join(controldir, script), 'w') 244 scriptfile = open(os.path.join(controldir, script), 'w')
244 except OSError: 245 except OSError:
245 bb.utils.unlockfile(lf) 246 bb.utils.unlockfile(lf)
246 raise bb.build.FuncFailed("unable to open %s script file for writing." % script) 247 raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
247 scriptfile.write("#!/bin/sh\n") 248
248 scriptfile.write(scriptvar) 249 if scriptvar.startswith("#!"):
250 pos = scriptvar.find("\n") + 1
251 scriptfile.write(scriptvar[:pos])
252 else:
253 pos = 0
254 scriptfile.write("#!/bin/sh\n")
255
256 # Prevent the prerm/postrm scripts from being run during an upgrade
257 if script in ('prerm', 'postrm'):
258 scriptfile.write('[ "$1" != "upgrade" ] || exit 0\n')
259
260 scriptfile.write(scriptvar[pos:])
261 scriptfile.write('\n')
249 scriptfile.close() 262 scriptfile.close()
250 os.chmod(os.path.join(controldir, script), 0755) 263 os.chmod(os.path.join(controldir, script), 0755)
251 264