On Mon, 24 Jul 2023, 11:35 David Bremner, <da...@tethera.net> wrote:

> Richard Lewis <richard.lewis.deb...@googlemail.com> writes:
> > On Sun, 23 Jul 2023, 12:34 David Bremner, <da...@tethera.net> wrote:
> >
>
> As far as the actual bug with failing to clean up, I ran
>
> % systemd-nspawn --machine bullseye /usr/lib/dh-elpa/helper/remove emacs
> dash 2.17.0
>
> and that cleans up the directory
>
>     /usr/share/emacs/site-lisp/elpa/dash-2.17.0
>
> so the bug is at some other level of the stack. I guess I will have to
> look at the log from the upgrade, but I haven't had a chance to do that
> yet.
>

I was trying to understand when (and how ) your command above was intended
to be run as part of the upgrade. I cna see that in bullseye
/usr/lib/emacsen-common/packages/remove/elpa-dash would do it if called
with 'emacs'. but this is never called:

What happens in the 'apt upgrade' is:

the old emacsen-common prerm is called ('<old prerm> upgrade
<new-version>'):

/var/lib/dpkg/info/emacsen-common.prerm upgrade 3.0.5

This calls:
/usr/lib/emacsen-common/emacs-package-remove --prerm emacsen-common

This calls:
/usr/lib/emacsen-common/packages/remove/emacsen-common

and at the end it _unlinks_:
/var/lib/emacsen-common/state/package/installed/emacsen-common

Then, apt prepares to unpack elpa-dash:

The elpa-dash prerm (from bullseye) is called as:
/var/lib/dpkg/info/elpa-dash.prerm upgrade
2.19.1+git20220608.1.0ac1ecf+dfsg-1)

but this starts with:

if [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a
-x
  /usr/lib/emacsen-common/emacs-package-remove ] ; then
/usr/lib/emacsen-common/emacs-package-remove --prerm elpa-dash

fi

... and so does nothing,
because /var/lib/emacsen-common/state/package/installed/emacsen-common is
gone.

I couldnt add debug statements to the new maintainer scripts, but: reading
https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-unpack-phase-of-installation-or-upgrade

I think we are now at step 3: '<new-preinst> upgrade <old-version>
<new-version>'

the elpa-dash preinst starts with
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" =
"abort-deconfigure" ] || [ "$1" = "abort-remove"
  ] ; then

so this does nothing.

then elpa-dash files are unpacked (step 4)
now /usr/lib/emacsen-common/packages/remove/elpa-dash contains
'usr/lib/dh-elpa/helper/remove $1 dash 2.19.1' so we can no longer remove
the old version


So the issue is that emacsen-common is unpacked before the elpa-dash package

Reply via email to