RPM/upgrade fixes
cover RPM/upgrade fixes
This is the fix for the problem Anders reported on the Yocto mailing list (now filed as Yocto bug #1760). I've checked through usage of postrm/prerm in oe-core and meta-oe and it looks OK to me, but it would help for others to double-check it.
I considered whether or not it would be worth bumping PR on every recipe that uses prerm/postrm, however this is a *lot* of recipes.
Also included is another fix for a minor issue I discovered when uninstalling busybox.
The following changes since commit 25fae81538a92e15eab3fc169ebce44505f67839:
python: skip setup.py 'import check' when cross-compiling (2011-11-08 21:44:23 +0000)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib paule/rmscripts
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/rmscripts
Paul Eggleton (2):
classes/package_rpm: disable uninstall scripts for upgrades
busybox: add grep to temporary links during uninstall
meta/classes/package_rpm.bbclass | 18 ++++++++++++++++-- meta/recipes-core/busybox/busybox.inc | 1 + meta/recipes-core/busybox/busybox_1.18.5.bb | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/2 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]
--- meta/classes/package_rpm.bbclass | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
meta/classes/package_rpm.bbclass +16 -2
@@ -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
Signature · 1 line
1.7.5.4
Re: [PATCH 1/2] classes/package_rpm: disable uninstall scripts for upgrades
Quoted 7 lines · Paul Eggleton
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.
Quoted 8 lines
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 <[email protected]>
Looks like the right solution to me. (Paul and I previously discussed how to correct this.)
Quoted 52 lines
--- meta/classes/package_rpm.bbclass | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)meta/classes/package_rpm.bbclass +16
-2@@ -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
Re: [PATCH 1/2] classes/package_rpm: disable uninstall scripts for upgrades
In reply to Paul EggletonI understand that this patch is pretty old.
But, we having issues because of it.
According to the description it is intended to fix some problems for RPM systems.
We are using DEB packages and this patch is preventing to update rc.d scripts if new version of the package has updates in it. Particularly, the new script is intended to be run with a different boot priority: 'start' directive to update-rc.d.
The problem is that during upgrade an old symlinks to rc* directories are not removed because of this condition added by wrap_uninstall(). And as a result update-rc.d is failing to update init scripts in rc* folders. Because old are existing.
PATCH 2/2 busybox: add grep to temporary links during uninstall
In reply to Paul EggletonIn the busybox package prerm we set up some temporary links and modify PATH so that certain utilities are provided for the purpose of running update-alternatives; if grep is not among these then you get errors when removing busybox, so add a temporary link for grep as well.
--- meta/recipes-core/busybox/busybox.inc | 1 + meta/recipes-core/busybox/busybox_1.18.5.bb | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
meta/recipes-core/busybox/busybox.inc +1 -0
@@ -270,6 +270,7 @@ pkg_prerm_${PN} () { ln -s /bin/busybox $tmpdir/rm ln -s /bin/busybox $tmpdir/sed ln -s /bin/busybox $tmpdir/sort + ln -s /bin/busybox $tmpdir/grep export PATH=$PATH:$tmpdir while read link
meta/recipes-core/busybox/busybox_1.18.5.bb +1 -1
@@ -1,5 +1,5 @@ require busybox.inc -PR = "r1" +PR = "r2" SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://udhcpscript.patch \
Signature · 1 line
1.7.5.4
Re: [PATCH 2/2] busybox: add grep to temporary links during uninstall
Am Mittwoch, den 09.11.2011, 12:05 +0000 schrieb Paul Eggleton:
Quoted 16 lines
In the busybox package prerm we set up some temporary links and modify PATH so that certain utilities are provided for the purpose of running update-alternatives; if grep is not among these then you get errors when removing busybox, so add a temporary link for grep as well.
Signed-off-by Paul Eggleton <[email protected]>--- meta/recipes-core/busybox/busybox.inc | 1 + meta/recipes-core/busybox/busybox_1.18.5.bb | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)meta/recipes-core/busybox/busybox.inc +0
-0
meta/recipes-core/busybox/busybox.inc pkg_prerm_${PN} () { · line 273
Quoted 4 lines
meta/recipes-core/busybox/busybox.inc +1
-0@@ -270,6 +270,7 @@ pkg_prerm_${PN} () { ln -s /bin/busybox $tmpdir/rm ln -s /bin/busybox $tmpdir/sed ln -s /bin/busybox $tmpdir/sort + ln -s /bin/busybox $tmpdir/grep
Should it be sorted?
[…]
Thanks,
Paul
Re: [PATCH 2/2] busybox: add grep to temporary links during uninstall
Quoted 1 line · On Wednesday 09 November 2011 20:28:07 Paul Menzel wrote:
Should it be sorted?
Possibly, but that ought to be done in a separate patch.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Richard Purdie
AppliedQuoted 15 lines · Paul Eggleton
This is the fix for the problem Anders reported on the Yocto mailing list (now filed as Yocto bug #1760). I've checked through usage of postrm/prerm in oe-core and meta-oe and it looks OK to me, but it would help for others to double-check it.
I considered whether or not it would be worth bumping PR on every recipe that uses prerm/postrm, however this is a *lot* of recipes.
Also included is another fix for a minor issue I discovered when uninstalling busybox.
The following changes since commit
25fae81538a92e15eab3fc169ebce44505f67839:python: skip
setup.py'import check' when cross-compiling (2011-11-08 21:44:23 +0000)
Quoted 7 lines
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contribpaule/rmscripts
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/rmscriptsPaul Eggleton (2):
classes/package_rpm: disable uninstall scripts for upgrades
busybox: add grep to temporary links during uninstall
Merged to master, thanks.
Richard