summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package_rpm.bbclass18
1 files changed, 16 insertions, 2 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index df5a2db8a1..2679e9f480 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -471,6 +471,16 @@ python write_specfile () {
471 else: 471 else:
472 target.append(path + "/" + file) 472 target.append(path + "/" + file)
473 473
474 # Prevent the prerm/postrm scripts from being run during an upgrade
475 def wrap_uninstall(scriptvar):
476 scr = scriptvar.strip()
477 if scr.startswith("#!"):
478 pos = scr.find("\n") + 1
479 else:
480 pos = 0
481 scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi'
482 return scr
483
474 packages = bb.data.getVar('PACKAGES', d, True) 484 packages = bb.data.getVar('PACKAGES', d, True)
475 if not packages or packages == '': 485 if not packages or packages == '':
476 bb.debug(1, "No packages; nothing to do") 486 bb.debug(1, "No packages; nothing to do")
@@ -671,8 +681,10 @@ python write_specfile () {
671 spec_scriptlets_bottom.append('%%post -n %s' % splitname) 681 spec_scriptlets_bottom.append('%%post -n %s' % splitname)
672 elif script == 'prerm': 682 elif script == 'prerm':
673 spec_scriptlets_bottom.append('%%preun -n %s' % splitname) 683 spec_scriptlets_bottom.append('%%preun -n %s' % splitname)
684 scriptvar = wrap_uninstall(scriptvar)
674 elif script == 'postrm': 685 elif script == 'postrm':
675 spec_scriptlets_bottom.append('%%postun -n %s' % splitname) 686 spec_scriptlets_bottom.append('%%postun -n %s' % splitname)
687 scriptvar = wrap_uninstall(scriptvar)
676 spec_scriptlets_bottom.append(scriptvar) 688 spec_scriptlets_bottom.append(scriptvar)
677 spec_scriptlets_bottom.append('') 689 spec_scriptlets_bottom.append('')
678 690
@@ -758,11 +770,13 @@ python write_specfile () {
758 spec_scriptlets_top.append('') 770 spec_scriptlets_top.append('')
759 if srcprerm: 771 if srcprerm:
760 spec_scriptlets_top.append('%preun') 772 spec_scriptlets_top.append('%preun')
761 spec_scriptlets_top.append(srcprerm) 773 scriptvar = wrap_uninstall(srcprerm)
774 spec_scriptlets_top.append(scriptvar)
762 spec_scriptlets_top.append('') 775 spec_scriptlets_top.append('')
763 if srcpostrm: 776 if srcpostrm:
764 spec_scriptlets_top.append('%postun') 777 spec_scriptlets_top.append('%postun')
765 spec_scriptlets_top.append(srcpostrm) 778 scriptvar = wrap_uninstall(srcpostrm)
779 spec_scriptlets_top.append(scriptvar)
766 spec_scriptlets_top.append('') 780 spec_scriptlets_top.append('')
767 781
768 # Write the SPEC file 782 # Write the SPEC file