On Saturday, January 18, 2025 8:41:18 AM MST David Kalnischkies wrote: > 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?
courier-mta is the package doing the diverting. If there is ever some other package pretending to be courier-mta entering a divert line, or some other divert line using a path name that includes courier-mta, I would definitely like to know about it. > 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. Wouldn’t output on stdout be a good thing, especially if there is ever some chance this could run when it shouldn’t. -- Soren Stoutner so...@debian.org
signature.asc
Description: This is a digitally signed message part.