Hi,

Am Fri, Jan 17, 2025 at 03:29:39PM -0700, schrieb Soren Stoutner:
> > to test if the diversion is installed you can probably use
> > 
> > dpkg-divert --list | grep courier-mta
> 
> Thanks for the pointer.  I have added the following code:
> 
> # Delete the old diversions if they exist, which are no longer needed.
> # These commands can be removed in trixie +1.
> # See <https://github.com/svarshavchik/courier/issues/56>
> # See also <https://lists.debian.org/debian-mentors/2025/01/msg00219.html>
> if [ dpkg-divert --list | grep courier-mta ]; then
>      dpkg-divert --package courier-mta --remove --rename \
>             --divert /usr/bin/addcr.ucspi-tcp /usr/bin/addcr
>      dpkg-divert --package courier-mta --remove --rename \
>             --divert /usr/share/man/man1/addcr.ucspi-tcp.1.gz 
> /usr/share/man/man1/addcr.1.gz
> fi

The presented alternative was using a version check. I get it, it looks
a bit more complex and you need to know the version number, but the
benefit of the version check is that it is easy to proof that it runs
once in the upgrade and then never again (if you pick the right number).

By comparison, the grep-based solution is hoping that no translation, no
package name and no path name now and up to the point you remove that
code happens to contain the string you grep for.

Sure, "courier-mta" seems like a string unlikely to appear, but can you
be sure?


Random example, but if we ever end up merging /usr/sbin with /usr/bin
and the long tail turns out to be as messy as /bin with /usr/bin
this long forgotten and done with upgrade stanza becomes suddenly very
relevant again as courier-mta will once again appear in dpkg-divert.


Best regards

David Kalnischkies

P.S.: Your grep, if it triggers, also generates output on stdout.
At least silence it with -q.

Attachment: signature.asc
Description: PGP signature

Reply via email to