David, On Tuesday, January 21, 2025 10:56:31 AM MST David Kalnischkies wrote: > Am Mon, Jan 20, 2025 at 02:58:21PM -0700, schrieb Soren Stoutner: > > if [[ `dpkg-divert --list courier-mta` ]]; then > > [[ is a bashism (see checkbashisms from devscripts), so I wonder a bit > how that worked for you in testing and why lintian and co haven't > screamed at you. > > You can see the call fail e.g. in piuparts: > https://piuparts.debian.org/sid/pass/courier-mta_1.3.13-4.log > > | /var/lib/dpkg/info/courier-mta.postinst: 23: [[: not found > > (It doesn't fail the script, as using an unknown binary like > this is technically the same as writing `if false; then`)
Thanks for catching that. I always run piuparts and lintian locally when building a package. Indeed, piuparts does flag the [[, but it still exits successfully (as can be seen in the log you linked to). Lintian also flagged it, but I missed it when I scanned through all of the linitan warnings. This particular package has a large number of lintian problems, which is going to take me several years to cleanup after salvaging the package. Having so many warnings sometimes makes it difficult to notice when a recent change adds a new one. > You can write this line in (da)sh compatible way e.g. so: > | if [ -n "$(dpkg-divert --list courier-mta)" ]; then > > (Realising that [ is not syntax but an actual command name > might help in understanding why [[ is not bad syntax either) > > > One of the advantages of using this check instead of a package version > > number > > is that it can be tested on a machine by manually creating diversions and > > then running the script to see if it removes them, which is how I caught > > the problem. > > Well, given a version check is done via parameter $2 to the maintainer > script (see d-policy) I suppose testing this is equally hard… as it is > mostly about how you call it (did you call it with > bash courier-mta.postinst configure 1.3.13-4 > perhaps?) correctly and in the same way it would be called in various > situations by dpkg which is the non-trivial part that e.g. piuparts > is supposed to help you with by testing various scenarios. I ran a number of routines on my local system, creating various diversions and see the results when running the logic of this part of the script against them, which, unfortunately, was running under . . . bash. So, it liked the previous version of the script just fine. Thanks again for catching this. I would have eventually have noticed the lintian warning as I read over those frequently. But I am sure users will appreciate having this fix sooner. So, for clarity of documentation in case anyone stumbles across this thread and needs to do something similar in the future. # 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 [ -n "$(dpkg-divert --list 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 https://salsa.debian.org/debian/courier/-/blob/ 1ec1938107a9529d9febd4a4a05c8e89e347148c/debian/courier-mta.postinst#L19 -- Soren Stoutner so...@debian.org
signature.asc
Description: This is a digitally signed message part.