File: debconf-hack.sh

package info (click to toggle)
config-package-dev 5.5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 632 kB
  • sloc: perl: 247; makefile: 66; sh: 49
file content (37 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 '
        Debconf::Db->load;
        while (<>) {
            chomp;
            ($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->value($value);
            $q->flag("seen", $seen);
            @qo{split(", ", $q->owners)} = ();
            map { $q->addowner($_) unless exists $qo{$_}; } keys %o;
            map { $q->removeowner($_) unless exists $o{$_}; } keys %qo;
        }
        Debconf::Db->save;'
}