[Fai-commit] r3050 - in people/michael/bugfixes/307266: . man scripts

fai-repository at svn.debian.org fai-repository at svn.debian.org
Fri Nov 11 15:56:01 UTC 2005


Author: michael-guest
Date: 2005-11-11 15:56:01 +0000 (Fri, 11 Nov 2005)
New Revision: 3050

Modified:
   people/michael/bugfixes/307266/Makefile
   people/michael/bugfixes/307266/man/fai-debconf.1
   people/michael/bugfixes/307266/scripts/fai-debconf
   people/michael/bugfixes/307266/scripts/fai-debconf-pipe
Log:
patch as already posted to Debian BTS; for details please refer to 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=307266


Modified: people/michael/bugfixes/307266/Makefile
===================================================================
--- people/michael/bugfixes/307266/Makefile	2005-11-11 15:53:11 UTC (rev 3049)
+++ people/michael/bugfixes/307266/Makefile	2005-11-11 15:56:01 UTC (rev 3050)
@@ -9,7 +9,7 @@
 SCRIPTS =  setup_harddisks faireboot dhclient-perl dhclient-script
 USRSBIN_SCRIPTS = make-fai-nfsroot make-fai-bootfloppy fai-setup fcopy ftar install_packages fai-chboot faimond fai-cd fai
 SBIN= fai-start-stop-daemon
-USRBIN_SCRIPTS = fai-class fai-do-scripts fai-mirror fai-debconf
+USRBIN_SCRIPTS = fai-class fai-do-scripts fai-mirror fai-debconf fai-debconf-pipe
 CONFDIR= $(SHAREDIR)/etc
 CONFFILES= apt.conf dhclient.conf fai_modules_off
 ADEXAMPLE=$(DOCDIR)/examples/advanced

Modified: people/michael/bugfixes/307266/man/fai-debconf.1
===================================================================
--- people/michael/bugfixes/307266/man/fai-debconf.1	2005-11-11 15:53:11 UTC (rev 3049)
+++ people/michael/bugfixes/307266/man/fai-debconf.1	2005-11-11 15:56:01 UTC (rev 3050)
@@ -1,5 +1,5 @@
 .\"                                      Hey, EMACS: -*- nroff -*-
-.TH fai-debconf 1 "10 march 2005" "FAI 2.7"
+.TH fai-debconf 1 "19 may 2005" "FAI 2.8"
 .\" Please adjust this date whenever revising the manpage.
 .\"
 .\" Some roff macros, for reference:
@@ -36,6 +36,10 @@
 .TP
 .B \-v
 Create verbose output.
+.TP
+.B \-f
+Run dpkg-reconfigure for all packages FAI has information for, not only for
+those we modified the entries in the database.
 .SH SEE ALSO
 .BR debconf-get-selections (1),
 .BR debconf-set-selections (1),

Modified: people/michael/bugfixes/307266/scripts/fai-debconf
===================================================================
--- people/michael/bugfixes/307266/scripts/fai-debconf	2005-11-11 15:53:11 UTC (rev 3049)
+++ people/michael/bugfixes/307266/scripts/fai-debconf	2005-11-11 15:56:01 UTC (rev 3050)
@@ -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

Modified: people/michael/bugfixes/307266/scripts/fai-debconf-pipe
===================================================================
--- people/michael/bugfixes/307266/scripts/fai-debconf-pipe	2005-11-11 15:53:11 UTC (rev 3049)
+++ people/michael/bugfixes/307266/scripts/fai-debconf-pipe	2005-11-11 15:56:01 UTC (rev 3050)
@@ -1,2 +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";




More information about the Fai-commit mailing list