[Debconf-devel] Bug#560317: dpkg-reconfigure does not set DPKG_MAINTSCRIPT_PACKAGE (et al)

Raphael Hertzog hertzog at debian.org
Fri Aug 5 19:57:33 UTC 2011


Hi Joey,

On Fri, 05 Aug 2011, Joey Hess wrote:
> I keep seeing people complain that this bug is not fixed, but every
> time I look at it, I find myself unable to fix it, and with issues like
> these:

Thanks for looking into it!

> * Where are these variables documented?
>   (Appears that they're basically not, which makes it sorta hard to
>   know that they are being set, or used, as intended.)

man dpkg

ENVIRONMENT
[...]
       DPKG_MAINTSCRIPT_PACKAGE
              Defined  by  dpkg on the maintainer script environment to the package
              name being handled.

       DPKG_MAINTSCRIPT_ARCH
              Defined by dpkg on the maintainer script environment to the architec-
              ture the package got built for.

       DPKG_MAINTSCRIPT_NAME
              Defined  by  dpkg on the maintainer script environment to the name of
              the script running (preinst, postinst, prerm, postrm).

> * How is debconf supposed to set DPKG_MAINTSCRIPT_ARCH? If it has to call
>   dpkg --print-architecture every time, that just makes every run slower,
>   which would seem to be the opposite of the point of having such a
>   variable in the first place. But it cannot be that simple anyway, with
>   multiarch. What uses DPKG_MAINTSCRIPT_ARCH anyway?

Nothing uses DPKG_MAINTSCRIPT_ARCH yet, to the best of my knowledge. It has been
introduced for completeness in the multiarch world because DPKG_MAINTSCRIPT_PACKAGE
might not be enough to precisely identify the package in the case of Multi-Arch:
same packages.

The goal of this variable was definitely not to be a cache for "dpkg
--print-architecture". It should be set to the architecture of the package
(i.e. it can be "all" too).

So really the value you want is:
"dpkg -s <package-typed-by-user> | awk '/^Architecture: / { print $2 }'"
(you're already querying dpkg -s so it's fine to extract it too)

BTW, for multiarch compliance you should use "dpkg-query --control-path
<package-typed-by-user> postinst" to find out the path of the postinst script
(and similar for the config script).

I have attached 3 patches, you should consider at least the first two.
(Not tested though)

> * What should DPKG_MAINTSCRIPT_NAME be set to when the config script
>   is being run?

"config" should be fine.

> * How is it appropriate for dpkg-maintscript-helper etc to be already using
>   these variables when debconf is not yet setting them? Would it make
>   more sense for dpkg-reconfigure to not set them, and
>   dpkg-maintscript-helper etc to be a no-op when a package is being
>   reconfigured?

I'm not sure we can answer this in the same way for all dpkg-maintscript-helper
sub-commands (existing and to come). Thus I prefer the statu quo over
arbitrarily deciding that being a no-op is ok when its action might be required
by something that happened earlier in the postinst.

> * Nobody has ever addressed my concern that, if dpkg-reconfigure runs
>   dpkg --configure --pending, this will result in it confusingly doing
>   other things than configuring the specified package.

I believe this should simply be documented. I rarely run dpkg-reconfigure
on a system that's not "clean" from an installation point of view.

But if you really want to try to limit the side effects then you can compare
the status of all packages before and after having run the scripts and decide
whether or not you have to run it. You could also try to configure only the
affected packages but since triggers processing can activate other triggers,
you might have to fallback to --configure --pending anyway if it turns out
it was not enough.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Follow my Debian News ▶ http://RaphaelHertzog.com (English)
                      ▶ http://RaphaelHertzog.fr (Français)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Set-environment-variables-expected-by-maintainer-scr.patch
Type: text/x-diff
Size: 1250 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debconf-devel/attachments/20110805/b460c83b/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Do-not-hardcode-the-path-of-maintainer-scripts.patch
Type: text/x-diff
Size: 2621 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debconf-devel/attachments/20110805/b460c83b/attachment-0004.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Properly-differentiate-Multi-Arch-same-packages-when.patch
Type: text/x-diff
Size: 1472 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debconf-devel/attachments/20110805/b460c83b/attachment-0005.patch>


More information about the Debconf-devel mailing list