All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Oberritter <obi@opendreambox.org>
To: Peter Urbanec <openembedded-devel@urbanec.net>,
	 OE Core <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 2/2] update-rc.d.bbclass: Better handling of package upgrades.
Date: Thu, 16 Oct 2014 20:51:57 +0200	[thread overview]
Message-ID: <544013CD.9010703@opendreambox.org> (raw)
In-Reply-To: <543E5F61.2090500@urbanec.net>

On 15.10.2014 13:49, Peter Urbanec wrote:
> update-rc.d.bbclass provides default implementations of prerm, postrm,
> preinst and postinst. Unfortunately these default implementations don't
> deal with package upgrades as well as they could.
> 
> For example, if "opkg upgrade" contains init-ifupdown, in the list of
> packages to upgrade, the default prerm and preinst scripts will stop
> networking while all the packages are being downloaded, unpacked and
> installed. Networking is not brought back up again until the postinst
> script from the new init-ifupdown package is called. That only happens
> after all the packages have been downloaded, unpacked and installed.
> This leaves a window where any package that needs to be downloaded after
> init-ifupdown was encountered will fail because networking is down.
> 
> This patch fixes the problem by delaying the restart of the old service
> during an upgrade until postinst. In the case of a package removal, the
> service will still be stopped in prerm.

Hello Peter,

did you read my reply to your initial patch? I don't see any obvious
changes. What's the difference between v1 and this version?

Regards,
Andreas

> 
> Signed-off-by: Peter Urbanec <openembedded-devel@urbanec.net>
> ---
>  meta/classes/update-rc.d.bbclass | 73 ++++++++++++++++++++++++----------------
>  1 file changed, 44 insertions(+), 29 deletions(-)
> 
> diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
> index bc1aa7d..fcb82fe 100644
> --- a/meta/classes/update-rc.d.bbclass
> +++ b/meta/classes/update-rc.d.bbclass
> @@ -14,45 +14,60 @@ INITSCRIPT_PARAMS ?= "defaults"
>   INIT_D_DIR = "${sysconfdir}/init.d"
>  -updatercd_preinst() {
> -if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
> -	${INIT_D_DIR}/${INITSCRIPT_NAME} stop
> +# pre/postrm scripts come from old package, pre/postinst scripts come from
> +# new package. See https://wiki.debian.org/MaintainerScripts for dpkg
> +# diagrams. opkg uses a subset, which lacks most of the error handling.
> +
> +# Old package, step 1
> +updatercd_prerm() {
> +if [ -z "$D" ]; then
> +  if [ "$1" != "upgrade" ] ; then
> +    ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
> +  fi
> +  OPT="-f"
> +else
> +  OPT="-f -r $D"
>  fi
>  if type update-rc.d >/dev/null 2>/dev/null; then
> -	if [ -n "$D" ]; then
> -		OPT="-f -r $D"
> -	else
> -		OPT="-f"
> -	fi
> -	update-rc.d $OPT ${INITSCRIPT_NAME} remove
> +  update-rc.d $OPT ${INITSCRIPT_NAME} remove
>  fi
>  }
>  -updatercd_postinst() {
> -if type update-rc.d >/dev/null 2>/dev/null; then
> -	if [ -n "$D" ]; then
> -		OPT="-r $D"
> -	else
> -		OPT="-s"
> -	fi
> -	update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
> -fi
> +# New package, step 2
> +updatercd_preinst() {
> +case "$1" in
> +  upgrade)
> +    ;;
> +  *)
> +    ;;
> +esac
>  }
>  -updatercd_prerm() {
> -if [ -z "$D" ]; then
> -	${INIT_D_DIR}/${INITSCRIPT_NAME} stop
> -fi
> +# Old package, step 3
> +updatercd_postrm() {
> +case "$1" in
> +  upgrade)
> +    ;;
> +  *)
> +    ;;
> +esac
>  }
>  -updatercd_postrm() {
> +# New package, step 4
> +# This step runs after all packages have been through steps 1-3. We need to
> +# delay service restarts during upgrade until here, otherwise we could end
> +# up in situations, like networking going down in the middle of "opkg upgrade",
> +# thus resulting in failures to fetch further packages.
> +updatercd_postinst() {
> +if [ -z "$D" ]; then
> +  # This will catch the upgrade case and result in a restart.
> +  ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
> +  OPT="-s"
> +else
> +  OPT="-r $D"
> +fi
>  if type update-rc.d >/dev/null 2>/dev/null; then
> -	if [ -n "$D" ]; then
> -		OPT="-r $D"
> -	else
> -		OPT=""
> -	fi
> -	update-rc.d $OPT ${INITSCRIPT_NAME} remove
> +  update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
>  fi
>  }
>  -- 2.1.2
> 



      reply	other threads:[~2014-10-16 18:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 11:49 [PATCH 2/2] update-rc.d.bbclass: Better handling of package upgrades Peter Urbanec
2014-10-16 18:51 ` Andreas Oberritter [this message]

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=544013CD.9010703@opendreambox.org \
    --to=obi@opendreambox.org \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=openembedded-devel@urbanec.net \
    /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.