[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debconf making package removal fail because of warnings issues by an earlier called program (in postrm)

Right. This is getting somewhat beyond my knowledge of debconf internals, 
but here is what happens.

Daniel Leidert wrote:
> You don't need more. For some reason "Make me fail." is given as
> argument to the debconf confmodule:

The full debug log and the sourced confmodule file fairly clearly show 
what happens.

This is where the execution of the script starts:

+ echo 'Make me fail.'
Make me fail.
+ '[' purge = purge ']'
+ '[' -e /usr/share/debconf/confmodule ']'
+ . /usr/share/debconf/confmodule

Here confmodule is sourced. If you look at what it does when there is
no frontend running yet, the behavior becomes clear:

if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
        export PERL_DL_NONLAZY
        # Since there is no FrontEnd, this program execs a FrontEnd.
        # It will then run a new copy of $0 that can talk to it.
        if [ "$DEBCONF_USE_CDEBCONF" ]; then
                exec /usr/lib/cdebconf/debconf $0 "$@"
                exec /usr/share/debconf/frontend $0 "$@"

No frontend is yet running, so one is started and the script gets
re-executed *under debconf*!

++ '[' '!' '' ']'
++ '[' '' ']'
++ exec /usr/share/debconf/frontend ./test purge

Which is exactly what happens here:

+ echo 'Make me fail.'

So, we get another echo to stdout and _that_ is the one that causes
the eventual error.

+ '[' purge = purge ']'
+ '[' -e /usr/share/debconf/confmodule ']'

The next line is now basically a no-op as it has already been sourced:

+ . /usr/share/debconf/confmodule
++ '[' '!' 1 ']'
++ '[' -z '' ']'
++ exec
++ '[' '' ']'
++ exec
+ db_capb
+ _db_cmd 'CAPB '
+ IFS=' '
+ printf '%s\n' 'CAPB '
+ IFS='
+ read -r _db_internal_line
+ RET='20 Unsupported command "make" (full line was "Make me fail.") 
received from confmodule.'
+ case ${_db_internal_line%%[   ]*} in
+ return 20

Don't ask me why this is done the way this is done, but AFAIK debconf has 
always worked this way. The correct version of your test script would be:

set -ex

. /usr/share/debconf/confmodule

echo "Make me fail." >&2

# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
        . /usr/share/debconf/confmodule
# End automatically added section

So, the automatic snippets work fine as long as they are the sole content 
of a maintainer script, but if not they need to be properly wrapped. And
use of stdin/stdout is not allowed _anywhere_ in the script, even if it 
happens before debconf gets sourced (which is why for D-I we always 
source confmodule at the top of scripts).

Maybe not intuitive, but that's life. And again, don't ask me why.

/me suspects this may be cause for some nice mass-filing of RC bugs :-(


Attachment: signature.asc
Description: This is a digitally signed message part.

Reply to: