All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 1/2] classes/package_rpm: disable uninstall scripts for upgrades
Date: Wed, 9 Nov 2011 12:55:21 -0600	[thread overview]
Message-ID: <4EBACC99.6040507@windriver.com> (raw)
In-Reply-To: <80a2356434387648ef7903c88fbfa64edfeca880.1320839130.git.paul.eggleton@linux.intel.com>

On 11/9/11 6:05 AM, Paul Eggleton wrote:
> 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>

Looks like the right solution to me.  (Paul and I previously discussed how to
correct this.)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

> ---
>  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 df5a2db..2679e9f 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




  reply	other threads:[~2011-11-09 19:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 12:05 [PATCH 0/2] RPM/upgrade fixes Paul Eggleton
2011-11-09 12:05 ` [PATCH 1/2] classes/package_rpm: disable uninstall scripts for upgrades Paul Eggleton
2011-11-09 18:55   ` Mark Hatle [this message]
2023-11-02 10:20   ` vadym.yatsenko
2011-11-09 12:05 ` [PATCH 2/2] busybox: add grep to temporary links during uninstall Paul Eggleton
2011-11-09 19:28   ` Paul Menzel
2011-11-10 10:07     ` Paul Eggleton
2011-11-10 12:25 ` [PATCH 0/2] RPM/upgrade fixes Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EBACC99.6040507@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.