Changes between Version 1 and Version 2 of ConfigPackageDev


Ignore:
Timestamp:
03/08/13 13:43:19 (9 years ago)
Author:
jdreed
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ConfigPackageDev

    v1 v2  
    11See [http://debathena.mit.edu/config-package-dev/] 
     2 
     3 
     4A brief discussion of the debconf-hack feature: 
     5 
     6Primarily 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  
     10zephyr-clients  zephyr-clients/read_conf        boolean true 
     11zephyr-clients  zephyr-clients/need-servers     note     
     12zephyr-clients  zephyr-clients/servers  string  z1.mit.edu z2.mit.edu 
     13}}} 
     14 
     15This snippet is added the the postinst, postrm 
     16 
     17{{{ 
     18debconf_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 
     30debconf_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 
     57And then the postinst and postrm have: 
     58{{{ 
     59if [ -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 
     62fi 
     63}}} 
     64 
     65The preinst has: 
     66{{{ 
     67if [ ! -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 
     70zephyr-clients  zephyr-clients/read_conf        boolean true    true 
     71zephyr-clients  zephyr-clients/need-servers     note            true 
     72zephyr-clients  zephyr-clients/servers  string  z1.mit.edu z2.mit.edu   true 
     73EOF 
     74fi 
     75}}}