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:
<snip>
if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
PERL_DL_NONLAZY=1
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 "$@"
else
exec /usr/share/debconf/frontend $0 "$@"
fi
fi
</snip>
No frontend is yet running, so one is started and the script gets
re-executed *under debconf*!
++ '[' '!' '' ']'
++ PERL_DL_NONLAZY=1
++ export PERL_DL_NONLAZY
++ '[' '' ']'
++ 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
++ DEBCONF_REDIR=1
++ export DEBCONF_REDIR
+ 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:
<snip>
#!/bin/sh
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
db_capb
fi
# End automatically added section
</snip>
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 :-(
Cheers,
FJP
Attachment:
signature.asc
Description: This is a digitally signed message part.