[...] > > As stated earlier, I'm trying to find a solution within FAI, and I already got > quite far. I'll let you know as soon as it seems to be fixed! >
Well, it's quite a while since I said that, but finally I also found the time to test my patches and for me they worked without any problems. The results are: - any changes to the debconf-database, that had been configured in one of the files in the debconf/ directory, are enforce - even, if, e.g., /etc/default/package contains some other values. It is the packages responsibility to update this file. - dpkg-reconfigure is only called for packages, whose configs were modified - this saves quite a lot of time (especially regenerating locales is a time-consuming task) The attached patch applies to version 2.8.4. Regards, Michael
diff -ruN official_FAI/scripts/fai-debconf MT_FAI/scripts/fai-debconf --- official_FAI/scripts/fai-debconf 2005-05-17 13:55:30.000000000 +0200 +++ MT_FAI/scripts/fai-debconf 2005-09-30 16:51:55.000000000 +0200 @@ -60,12 +60,18 @@ reconfigure_packages() { local packages p + if [ -x /usr/bin/diff -a -r $LOGDIR/debconf.old ] ; then + $ROOTCMD debconf-get-selections > $LOGDIR/debconf.new + diff --changed-group-format="%>" --unchanged-line-format="" \ + $LOGDIR/debconf.old $LOGDIR/debconf.new > $LOGDIR/debconf.data + fi packages=$(awk '{print $1}' $LOGDIR/debconf.data | sort | uniq) for p in $packages; do # test if package is installed if [ -f $target/var/lib/dpkg/info/$p.list ]; then echo "Reconfiguring package $p" - DEBCONF_FRONTEND=noninteractive $ROOTCMD dpkg-reconfigure $p + $ROOTCMD /usr/bin/fai-debconf-pipe $p & + DEBCONF_PIPE=/var/run/fai/debconf.pipe DEBIAN_FRONTEND=passthrough $ROOTCMD dpkg-reconfigure $p else : # for debugging only @@ -89,11 +95,13 @@ # main program reconf=1 # call dpkg-reconfigure by default -while getopts "hvs" opt ; do +forcereconf=0 # don't call dpkg-reconfigure for unchanged packages +while getopts "hvsf" opt ; do case "$opt" in h) usage 0 ;; s) reconf=0 ;; v) verbose=1 ;; + f) forcereconf=1 ;; esac done shift $(($OPTIND - 1)) @@ -105,5 +113,6 @@ exit 9 fi +[ $forcereconf -eq 0 ] && $ROOTCMD debconf-get-selections > $LOGDIR/debconf.old call_conf # add data to debconf database [ $reconf -eq 1 ] && reconfigure_packages diff -ruN official_FAI/scripts/fai-debconf-pipe MT_FAI/scripts/fai-debconf-pipe --- official_FAI/scripts/fai-debconf-pipe 1970-01-01 01:00:00.000000000 +0100 +++ MT_FAI/scripts/fai-debconf-pipe 2005-09-30 16:42:50.000000000 +0200 @@ -0,0 +1,83 @@ +#!/usr/bin/perl -w + +use strict; +use IO::Socket; + +my $debug = $ENV{"debug"}; + +my $PIPEFILE="/var/run/fai/debconf.pipe"; + +die "No package name given!\n" unless $ARGV[0]; +my $packagename = shift @ARGV; + +my %answers; + +select STDERR; + +open(DH, $ENV{"LOGDIR"}."/debconf.data") or die "Cannot open ".$ENV{"LOGDIR"}."/debconf.data\n" ; + +print "Reading from <". $ENV{"LOGDIR"}."/debconf.data ... " if $debug; + +while(<DH>) { + print "read: $_"; + chomp; + next unless /^([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]*(.*)$/; + print "extracted: PN: $1, Q: $2, T: $3, A: $4\n" if $debug; + next unless ( $1 eq $packagename ); + $answers{ "$2" } = "$4"; + + print "Got answer for $2: " . $answers{ "$2" } . "\n" if $debug; +} +close DH; + +print "done.\n" if $debug; + +my $thepipe = IO::Socket::UNIX->new( + Type => SOCK_STREAM, + Local => $PIPEFILE, Listen => 1 ) || die "Cannot create socket!\n"; + + +my $client = $thepipe->accept(); +while(<$client>) { + chomp; + print "Read: $_\n" if $debug; + if( /^CAPB backup$/ ) { + print $client "0 backup\n"; + print "Sent: 0 backup\n" if $debug; + } + elsif( /^STOP$/ ) { + print $client "0 OK\n"; + print "Sent: 0 OK\n" if $debug; + last; + } + elsif( /^GET ([^[:space:]]*)$/ ) { + if( defined $answers{ "$1" } ) { + print $client "0 " . $answers{ "$1" } . "\n"; + print "Sent: 0 " . $answers{ "$1" }. "\n" if $debug; + } + else { + print $client "0 \n"; + print "Sent: 0 \n" if $debug; + } + } + elsif( /^SET ([^[:space:]]*)[[:space:]]+(.*)$/ ) { + if( defined $answers{ "$1" } ) { + print $client "0 OK\n"; + print "Sent: 0 OK (known answer)\n" if $debug; + } + else { + $answers{ "$1" } = "$2"; + print $client "0 OK \n"; + print "Sent: 0 OK (unknown answer)\n" if $debug; + } + } + else { + #elsif( /^(TITLE|SETTITLE|INPUT|CLEAR|GO|BEGINBLOCK|ENDBLOCK|DATA|GO|CAPB|PURGE).*$/ ) { + print $client "0 OK\n"; + print "Sent: 0 OK\n" if $debug; + #} + #warn "No match found for $_\n"; + } +} + +unlink "$PIPEFILE";
signature.asc
Description: Digital signature