summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2011-11-09 11:12:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-10 11:37:10 +0000
commit7b645cac3f7e89c20918e83d61352ccc5f8b63be (patch)
tree3bb41fae3c817f2c3f794c611d231dafdfb16581 /meta/classes
parent23d2eaf9d283cae47e52d1151f0d4ad53bbbe8a0 (diff)
downloadpoky-7b645cac3f7e89c20918e83d61352ccc5f8b63be.tar.gz
classes/package_rpm: disable uninstall scripts for upgrades
Our current assumption (based on the behaviour of opkg) when writing recipes is that prerm and postrm do not get called during an upgrade. When using rpm however, these are mapped to the rpm "preun" and "postun" events which occur after postinst for upgrades, and when these contain removal type operations (such as update-alternatives --remove) this causes problems. This patch wraps each preun and postun script for rpm in a check that determines whether or not the script is being called during an upgrade, and skips the entire script if it is, which mimics the behaviour of opkg under the same conditions. Fixes [YOCTO #1760] (From OE-Core rev: 1d3f37dc9a43ba6d6beb7b4530c077f239032b99) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-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