diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2011-11-09 11:12:08 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-11-09 14:58:14 +0000 |
commit | 1d3f37dc9a43ba6d6beb7b4530c077f239032b99 (patch) | |
tree | c4ac96c819f627dd5d2e9215dd7f6e3fe2be33c1 /meta/classes/package_rpm.bbclass | |
parent | 25fae81538a92e15eab3fc169ebce44505f67839 (diff) | |
download | openembedded-core-1d3f37dc9a43ba6d6beb7b4530c077f239032b99.tar.gz openembedded-core-1d3f37dc9a43ba6d6beb7b4530c077f239032b99.tar.bz2 openembedded-core-1d3f37dc9a43ba6d6beb7b4530c077f239032b99.zip |
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]
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'meta/classes/package_rpm.bbclass')
-rw-r--r-- | meta/classes/package_rpm.bbclass | 18 |
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 () { else: target.append(path + "/" + file) + # Prevent the prerm/postrm scripts from being run during an upgrade + def wrap_uninstall(scriptvar): + scr = scriptvar.strip() + if scr.startswith("#!"): + pos = scr.find("\n") + 1 + else: + pos = 0 + scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi' + return scr + packages = bb.data.getVar('PACKAGES', d, True) if not packages or packages == '': bb.debug(1, "No packages; nothing to do") @@ -671,8 +681,10 @@ python write_specfile () { spec_scriptlets_bottom.append('%%post -n %s' % splitname) elif script == 'prerm': spec_scriptlets_bottom.append('%%preun -n %s' % splitname) + scriptvar = wrap_uninstall(scriptvar) elif script == 'postrm': spec_scriptlets_bottom.append('%%postun -n %s' % splitname) + scriptvar = wrap_uninstall(scriptvar) spec_scriptlets_bottom.append(scriptvar) spec_scriptlets_bottom.append('') @@ -758,11 +770,13 @@ python write_specfile () { spec_scriptlets_top.append('') if srcprerm: spec_scriptlets_top.append('%preun') - spec_scriptlets_top.append(srcprerm) + scriptvar = wrap_uninstall(srcprerm) + spec_scriptlets_top.append(scriptvar) spec_scriptlets_top.append('') if srcpostrm: spec_scriptlets_top.append('%postun') - spec_scriptlets_top.append(srcpostrm) + scriptvar = wrap_uninstall(srcpostrm) + spec_scriptlets_top.append(scriptvar) spec_scriptlets_top.append('') # Write the SPEC file |