| 2 | |
| 3 | |
| 4 | A brief discussion of the debconf-hack feature: |
| 5 | |
| 6 | 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. |
| 7 | |
| 8 | {{{ |
| 9 | $ cat debathena-zephyr-config.debconf-hack |
| 10 | zephyr-clients zephyr-clients/read_conf boolean true |
| 11 | zephyr-clients zephyr-clients/need-servers note |
| 12 | zephyr-clients zephyr-clients/servers string z1.mit.edu z2.mit.edu |
| 13 | }}} |
| 14 | |
| 15 | This snippet is added the the postinst, postrm |
| 16 | |
| 17 | {{{ |
| 18 | debconf_get () { |
| 19 | perl -MDebconf::Db -MDebconf::Question -e ' |
| 20 | Debconf::Db->load(readonly => "true"); |
| 21 | for $label (@ARGV) { |
| 22 | if ($q = Debconf::Question->get($label)) { |
| 23 | print $q->owners."\t".$q->name."\t".$q->type."\t".$q->value."\t".$q->flag("seen")."\n"; |
| 24 | } else { |
| 25 | print "\t$label\t\t\tfalse\n"; |
| 26 | } |
| 27 | }' -- "$@" |
| 28 | } |
| 29 | |
| 30 | debconf_set () { |
| 31 | perl -MDebconf::Db -MDebconf::Template -MDebconf::Question -e ' |
| 32 | Debconf::Db->load; |
| 33 | while (<>) { |
| 34 | chomp; |
| 35 | ($owners, $label, $type, $value, $seen) = split("\t"); |
| 36 | @o{split(", ", $owners)} = (); |
| 37 | unless ($t = Debconf::Template->get($label)) { |
| 38 | next unless ($owners); |
| 39 | $t = Debconf::Template->new($label, $owners[0], $type); |
| 40 | $t->description("Dummy template"); |
| 41 | $t->extended_description("This is a fake template used to pre-seed the debconf database. If you are seeing this, something is probably wrong."); |
| 42 | } |
| 43 | @to{split(", ", $t->owners)} = (); |
| 44 | map { $t->addowner($_) unless exists $to{$_}; } keys %o; |
| 45 | map { $t->removeowner($_) unless exists $o{$_}; } keys %to; |
| 46 | next unless ($q = Debconf::Question->get($label)); |
| 47 | $q->value($value); |
| 48 | $q->flag("seen", $seen); |
| 49 | @qo{split(", ", $q->owners)} = (); |
| 50 | map { $q->addowner($_) unless exists $qo{$_}; } keys %o; |
| 51 | map { $q->removeowner($_) unless exists $o{$_}; } keys %qo; |
| 52 | } |
| 53 | Debconf::Db->save;' |
| 54 | } |
| 55 | }}} |
| 56 | |
| 57 | And then the postinst and postrm have: |
| 58 | {{{ |
| 59 | if [ -f /var/cache/debathena-zephyr-config.debconf-save ]; then |
| 60 | debconf_set </var/cache/debathena-zephyr-config.debconf-save |
| 61 | rm -f /var/cache/debathena-zephyr-config.debconf-save |
| 62 | fi |
| 63 | }}} |
| 64 | |
| 65 | The preinst has: |
| 66 | {{{ |
| 67 | if [ ! -f /var/cache/debathena-zephyr-config.debconf-save ]; then |
| 68 | debconf_get zephyr-clients/read_conf zephyr-clients/need-servers zephyr-clients/servers >/var/cache/debathena-zephyr-config.debconf-save |
| 69 | debconf_set <<EOF |
| 70 | zephyr-clients zephyr-clients/read_conf boolean true true |
| 71 | zephyr-clients zephyr-clients/need-servers note true |
| 72 | zephyr-clients zephyr-clients/servers string z1.mit.edu z2.mit.edu true |
| 73 | EOF |
| 74 | fi |
| 75 | }}} |