#777162 preconfiguration doesn't work as expected

#777162#5
Date:
2015-02-05 18:40:35 UTC
From:
To:
The following has been tested on Debian Jessie on AMD64.

Preamble:
I've set up a clean system via debootstrap and want to set it up using
chroot. For configuring, I'd like to use debconf (the backend database,
not the conference of course). debconf seems to work better than
copying configuration files, since dpkg-reconfigure scripts often don't
parse them. I know, there's also "console-setup", but since "console-data"
is still supported in Jessie, I'd like to use this one (no x11 at all).

About this report:
"console-data"'s config scripts seems to have problems reading values
from the debconf-database. This might be a bug in the perl-based script
or even a bug in debconfig-tools.

What I want to do:
Setup the correct keyboard on TTY (not ssh), in my case it's "de-latin1".

===

Information to  all parts of this report:
The settings for debconf-DB have been exported after manually configuration
using "dpkg-reconfigure -plow console-data". I've used this snipped for export:
debconf-get-selections | grep ^console | grep -v $'\t'$ | awk '{$1=$1}{ print $0 }' | sort

Before each part, I'm running these commands to clean the system:
# purge packages and old configuration files
DEBIAN_FRONTEND=noninteractive apt-get --yes purge console-data kbd
DEBIAN_FRONTEND=noninteractive apt-get --yes autoremove --purge

# purge the debconf-DB (just to be shure)
echo purge | debconf-communicate console-data
echo purge | debconf-communicate console-common

# fix the debconf-DB (just to be shure)
/usr/share/debconf/fix_db.pl

Please check all the files in attachment.

===

Part 1: preconfiguration as it is expected to work => it's NOT working!

# preconfigure debconfig-database
debconf-set-selections <<\EOF
console-common console-data/keymap/family select qwertz
console-common console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/family select qwertz
console-data console-data/keymap/qwertz/german/standard/keymap select latin1
console-data console-data/keymap/qwertz/german/variant select Standard
console-data console-data/keymap/qwertz/layout select German
EOF

# install console-data
DEBCONF_DEBUG=developer DEBIAN_FRONTEND=noninteractive apt-get install --yes console-data 2>&1 | tee logfile_part01.txt

As you can see, "NONE" didn't work as expected and serveral "//" show
that some values didn't get parsed from debconf-database the correct way.

===

Part 2: a crazy "hack" => WORKS 50 %
Okay, after playing around with preconfiguration settings and reading the
debug output of part 1, I figured out these settings:

debconf-set-selections <<\EOF
console-common console-data/keymap/family select qwertz
console-common console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/family select qwertz
console-data console-data/keymap/qwertz/german/standard/keymap string latin1
console-data console-data/keymap/qwertz/german/variant string Standard
console-data console-data/keymap/qwertz/layout string German
EOF

# install console-data
DEBCONF_DEBUG=developer DEBIAN_FRONTEND=noninteractive apt-get install --yes console-data 2>&1 | tee logfile_part02.txt

Oh my, it worked... but "dpkg-reconfigure -plow console-data" doesn't
like this. It warns the user that something didn't work as expected.

===

Part 3: a nasty "workaround" => WORKS 100%
After reading DPKG-manual again, I wrote this little script:

# download DEB-files to temporary directory
mkdir /tmp/preconf
cd /tmp/preconf
apt-get --yes --install-recommends download console-data

# preconfigure DEB-files
ls *.deb | DEBCONF_DEBUG=developer DEBIAN_FRONTEND=noninteractive dpkg-preconfigure --apt --priority=low 2>&1 | tee logfile_part03_preconf.txt

# user the "expected" preconfiguration settings
debconf-set-selections <<\EOF
console-common console-data/keymap/family select qwertz
console-common console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/policy select Select keymap from arch list
console-data console-data/keymap/family select qwertz
console-data console-data/keymap/qwertz/german/standard/keymap select latin1
console-data console-data/keymap/qwertz/german/variant select Standard
console-data console-data/keymap/qwertz/layout select German
EOF

# install console-data from DEB-files
DEBCONF_DEBUG=developer DEBIAN_FRONTEND=noninteractive dpkg --install *.deb 2>&1 | tee logfile_part03.txt

# remove the temporary files
rm --force *.deb

Result: it works :D

===

Conclusion:
Seems that the package doesn't follow all the variables it should when
configuring the package. I wonder, why the "hack" (part 2) works, but
since "dpkg-reconfigure" throws out warnings, it's no good at all.

Only solution/part 3 seems to be the working, but it's a pretty
faulty work-around.

Any ideas about this?