Version 3 (modified by jdreed, 11 years ago) (diff)



A brief discussion of the debconf-hack feature:

Primarily developed for zephyr-config to workaround the bug where you choose to use Hesiod (or have DEBIAN_FRONTEND=noninteractive), it pulls in an unconfigured Hesiod, tries to restart zhm, which can't contact any zephyr servers, and exits non-zero, so the postinst fails.

$ cat debathena-zephyr-config.debconf-hack 
zephyr-clients	zephyr-clients/read_conf	boolean	true
zephyr-clients	zephyr-clients/need-servers	note	
zephyr-clients	zephyr-clients/servers	string

This snippet (from is added the the postinst, postrm, and preinst.

debconf_get () {
    perl -MDebconf::Db -MDebconf::Question -e '
        Debconf::Db->load(readonly => "true");
        for $label (@ARGV) {
            if ($q = Debconf::Question->get($label)) {
                print $q->owners."\t".$q->name."\t".$q->type."\t".$q->value."\t".$q->flag("seen")."\n";
            } else {
                print "\t$label\t\t\tfalse\n";
        }' -- "$@"

debconf_set () {
    perl -MDebconf::Db -MDebconf::Template -MDebconf::Question -e '
        while (<>) {
            ($owners, $label, $type, $value, $seen) = split("\t");
            @o{split(", ", $owners)} = ();
            unless ($t = Debconf::Template->get($label)) {
                next unless ($owners);
                $t = Debconf::Template->new($label, $owners[0], $type);
                $t->description("Dummy template");
                $t->extended_description("This is a fake template used to pre-seed the debconf database. If you are seeing this, something is probably wrong.");
            @to{split(", ", $t->owners)} = ();
            map { $t->addowner($_) unless exists $to{$_}; } keys %o;
            map { $t->removeowner($_) unless exists $o{$_}; } keys %to;
            next unless ($q = Debconf::Question->get($label));
            $q->flag("seen", $seen);
            @qo{split(", ", $q->owners)} = ();
            map { $q->addowner($_) unless exists $qo{$_}; } keys %o;
            map { $q->removeowner($_) unless exists $o{$_}; } keys %qo;

And then the postinst and postrm have:

if [ -f /var/cache/debathena-zephyr-config.debconf-save ]; then
    debconf_set </var/cache/debathena-zephyr-config.debconf-save
    rm -f /var/cache/debathena-zephyr-config.debconf-save

The preinst has:

if [ ! -f /var/cache/debathena-zephyr-config.debconf-save ]; then
    debconf_get zephyr-clients/read_conf zephyr-clients/need-servers zephyr-clients/servers >/var/cache/debathena-zephyr-config.debconf-save
    debconf_set <<EOF
zephyr-clients	zephyr-clients/read_conf	boolean	true	true
zephyr-clients	zephyr-clients/need-servers	note		true
zephyr-clients	zephyr-clients/servers	string	true