pf-tools/pf-tools: 6 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Tue Sep 21 07:12:24 UTC 2010


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/04d43bf36905
changeset: 798:04d43bf36905
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Mon Sep 20 18:41:37 2010 +0200
description:
Style

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/8518a796578e
changeset: 799:8518a796578e
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Mon Sep 20 18:42:48 2010 +0200
description:
Useless scripts: now we use debian-installer or standard installation process

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/ce9a0fc937cd
changeset: 800:ce9a0fc937cd
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Mon Sep 20 18:54:02 2010 +0200
description:
Coding style or filters/filter_distrib

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/611afcf5c22e
changeset: 801:611afcf5c22e
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Mon Sep 20 19:06:37 2010 +0200
description:
Remove useless entry in $DEF_SECTIONS

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/021b8d42bffb
changeset: 802:021b8d42bffb
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Tue Sep 21 09:08:49 2010 +0200
description:
Coding style and using croak and carp instead of Abort and Warn

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/291abd3f33a1
changeset: 803:291abd3f33a1
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Tue Sep 21 09:09:28 2010 +0200
description:
Merging

diffstat:

7 files changed, 3 insertions(+), 1152 deletions(-)
filters/filter_distrib      |    2 
installers/install          |  545 ---------------------------------------
installers/install.dist-2.6 |  598 -------------------------------------------
lib/PFTools/Conf/Host.pm    |    5 
lib/PFTools/Conf/Syntax.pm  |    2 
lib/PFTools/Net.pm          |    1 
t/13.conf.t                 |    2 

diffs (3391 lines):

diff -r 6d007d250b23 -r 291abd3f33a1 filters/filter_distrib
--- a/filters/filter_distrib	Mon Sep 20 17:08:34 2010 +0200
+++ b/filters/filter_distrib	Tue Sep 21 09:09:28 2010 +0200
@@ -1,6 +1,4 @@
 #!/usr/bin/perl
-##
-##  $Id$
 ##
 ##  Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
 ##
@@ -24,6 +22,7 @@
 
 use English qw( -no_match_vars );    # Avoids regex performance penalty
 use Getopt::Long qw( :config ignore_case_always bundling );
+use IO::File;
 use Sys::Hostname;
 
 use PFTools::Logger;
@@ -32,27 +31,35 @@
 
 #################################
 # VARS
-my $HELP              = 0;
-my $HOSTNAME          = hostname;
-my $SITE              = '';
-my $GLOBAL_STORE_FILE = '';
-my $PF_CONFIG_FILE    = '';
+
+my @options_specs = (
+    'help',
+    'host|h=s',
+    'site|s=s',
+    'config|c=s',
+    'store=s',
+    'input|i=s',
+    'output|o=s',
+);
+
+my $options = {
+    'help'      => 0,
+    'host'      => hostname,
+    'output'    => '-',
+};
+
 my $PF_CONFIG         = {};
-my $INPUT_FILE        = '';
-my $OUTPUT_FILE       = '';
 my $GLOBAL_STRUCT     = {};
 
 my $program = $0;
 $program =~ s%.*/%%;    # cheap basename
 
-my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ );
 
 ###################################
 # Funtions
 
 sub Do_help {
     print STDERR << "# ENDHELP";
-    $program - version $version
 
 Usage:	$program [options]
 	--help		: print help and exit
@@ -69,65 +76,62 @@
 ##################################
 ### MAIN
 
-GetOptions(
-    'help'       => \$HELP,
-    'host|h=s'   => \$HOSTNAME,
-    'site|s=s'   => \$SITE,
-    'config|c=s' => \$PF_CONFIG_FILE,
-    'store=s'    => \$GLOBAL_STORE_FILE,
-    'input|i=s'  => \$INPUT_FILE,
-    'output|o=s' => \$OUTPUT_FILE
-) or die "Didn't grok options (see --help).\n";
+GetOptions( $options, @options_specs )
+    or die "Didn't grok options (see --help).\n";
 
-if ($HELP) {
+if ($options->{'help'}) {
     Do_help();
     exit 0;
 }
 
-( $PF_CONFIG, $GLOBAL_STRUCT )
-    = Init_TOOLS( $HOSTNAME, $PF_CONFIG_FILE, $GLOBAL_STORE_FILE );
+( $PF_CONFIG, $GLOBAL_STRUCT ) = Init_TOOLS(
+    $options->{'host'},
+    $options->{'config'},
+    $options->{'store'}
+);
 
-if ( $SITE eq '' ) {
-    if ( !defined $PF_CONFIG->{'location'}->{'site'} ) {
-        my $site_list = Get_site_from_hostname( $HOSTNAME, $GLOBAL_STRUCT );
-        if ( !defined $site_list ) {
+unless( $options->{'site'} ) {
+    unless( $PF_CONFIG->{'location'}->{'site'} ) {
+        my $site_list = Get_site_from_hostname(
+            $options->{'host'}, $GLOBAL_STRUCT
+        );
+        unless( $site_list ) {
             Abort( $CODE->{'UNDEF_KEY'},
-                      "Unable to retrieve site for hostname "
-                    . $HOSTNAME
-                    . " : hostname not defined" );
+                "Unknown hostname $options->{'host'}" );
         }
-        elsif ( scalar @{$site_list} > 1 ) {
+        if ( scalar @{$site_list} > 1 ) {
             Abort( $CODE->{'DUPLICATE_VALUE'},
-                      "Unable to retrieve site for hostname "
-                    . $HOSTNAME
-                    . " : hostname appeared in multiple sites : "
-                    . join( ",", @{$site_list} ) . ".\n"
-                    . "Please relaunch this command with the right site" );
+                "Multiple sites for hostname $options->{'host'}" );
         }
-        else {
-            ($SITE) = @{$site_list};
-        }
+        ($options->{'site'}) = @{$site_list};
     }
-    else {
-        $SITE = $PF_CONFIG->{'location'}->{'site'};
-    }
+    $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
 }
 
-if ( $INPUT_FILE eq '' || $OUTPUT_FILE eq '' ) {
+if ( $options->{'input'} eq '' || $options->{'output'} eq '' ) {
     Abort( $CODE->{'UNDEF_KEY'},
         "Source and/or destination file is(are) not defined on CLI" );
 }
 
-my $filtered_src
-    = Search_and_replace( $HOSTNAME, $SITE, $INPUT_FILE, 'distrib',
-    $PF_CONFIG, "", $GLOBAL_STRUCT );
+my $filtered_src = Search_and_replace(
+    $options->{'host'}, $options->{'site'},
+    $options->{'input'}, 'distrib',
+    $PF_CONFIG, "", $GLOBAL_STRUCT
+);
 
-unless ( open( OUTPUT, ">" . $OUTPUT_FILE ) ) {
+my $output_fh = IO::File->new ( ">" . $options->{'output'} );
+unless( $output_fh ) {
     Abort( $CODE->{'OPEN'},
-        "Unable to open destination file " . $OUTPUT_FILE . " : $OS_ERROR" );
+        "Unable to open destination $options->{'output'} : $OS_ERROR" );
 }
 
-print OUTPUT join( "", @{$filtered_src} );
-close(OUTPUT);
+$output_fh->print( join( "", @{$filtered_src} ) )
+    or Abort( $CODE->{'OPEN'},
+        "Unable to write on destination $options->{'output'} : $OS_ERROR" );
+
+$output_fh->close()
+    or Abort( $CODE->{'OPEN'},
+        "Unable to close destination $options->{'output'} : $OS_ERROR" );
 
 exit 0;
+
diff -r 6d007d250b23 -r 291abd3f33a1 installers/install
--- a/installers/install	Mon Sep 20 17:08:34 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1091 +0,0 @@
-#!/usr/bin/perl
-
-##  Copyright (C) 2005 Olivier MOLTENI <olivier at molteni.net>
-##
-##  This program is free software; you can redistribute it and/or
-##  modify it under the terms of the GNU General Public License
-##  as published by the Free Software Foundation; either version 2
-##  of the License, or (at your option) any later version.
-##
-##  This program is distributed in the hope that it will be useful,
-##  but WITHOUT ANY WARRANTY; without even the implied warranty of
-##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-##  GNU General Public License for more details.
-##
-##  You should have received a copy of the GNU General Public License
-##  along with this program; if not, write to the Free Software
-##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
-
-
-use warnings;
-
-#---------------------------------------------------------------#
-#								#
-#	install.pl v0.1						#
-#								#
-#	Script de deploiement de master Linux			#
-#								#
-#---------------------------------------------------------------#
-
-#
-# AVERTISSEMENT : Ce script ne doit JAMAIS etre execute sur un system
-#                 fonctionnel. Il est reserve au deploiement.
-#==========================================================================
-
-chomp( $init = readlink("/proc/1/exe") );
-if ( $init eq "/sbin/init" ) {
-    print "     ************************************************\n";
-    print "     *                                              *\n";
-    print "     *     MALHEUREUX !!!!                          *\n";
-    print "     *     Faut JAMAIS lancer ce machin sur un      *\n";
-    print "     *     system qui fonctionne !!!                *\n";
-    print "     *                                              *\n";
-    print "     ************************************************\n";
-    exit;
-}
-
-# constantes
-#===================================
-
-$QUIETDEBOOTSTRAP  = 1;
-$QUIETUPDATECONFIG = 1;
-
-$DEPLOY = "deploy";
-
-$TIMEOUT = 10;
-
-$DEFAULT_REINSTALL = 0;
-
-$NUMMODEHD    = 0;
-$MODEHD       = "hd";
-$NUMMODEMIXED = 1;
-$MODEMIXED    = "mixed";
-$NUMMODETMPFS = 2;
-$MODETMPFS    = "tmpfs";
- at MODES        = ( $MODEHD, $MODEMIXED, $MODETMPFS );
-$DEFAULT_MODE = 0;
-
-$FSTYPE = "ext2";
-
-$BEGIN           = '0';
-$FOLLOW          = '';
-$LINUX_NATIVE    = '83';
-$LINUX_SWAP      = '82';
-$BOOTABLE        = '*';
-$NOOPTION        = '-';
-$HDBOOT          = '1';
-$HDROOT          = '2';
-$HDSWAP          = '3';
-$MIXEDVAR        = '1';
-$MIXEDSWAP       = '2';
-$TMPFSMAX        = '512m';
-$SLASH           = "/mnt";
-$SLASH_BOOT      = "$SLASH/boot";
-$PIVOT           = "/initrd";
-$DISTRIB         = "/distrib";
-$DISTRIB_DIR     = "$DISTRIB/debian/dists";
-$INSTALLERCONFIG = "$DISTRIB/installerconfig";
-$RESOLV_CONF     = "/etc/resolv.conf";
-
-$NFSFILER = $ENV{NFSFILER};
-
-$CVS      = $NFSFILER . ":/vol/voldata/cvs";
-$CVSGUEST = "/var/lib/cvsguest";
-$CVSROOT  = "/var/lib/cvs/repository";
-
-#Si une branche CVS a été passée en paramètre, je la récupère.
-open CMDLINE, "</proc/cmdline" or warn "Can't open /proc/cmdline\n";
-<CMDLINE> =~ /branchecvs=(\S+)/;
-close CMDLINE;
-$CVS_BRANCHE = $1 if $1;
-
-#
-#	Debut du script d'installation
-#============================================
-$| = 1;
-
-#$SIG{CHLD} = \&REAPER;
-
-use POSIX ":math_h";
-use POSIX ":sys_wait_h";
-
-sub REAPER {
-    my $child;
-
-    while ( ( $child = waitpid( -1, WNOHANG ) ) > 0 ) {
-
-        #$Kid_Status{$child} = $?;
-    }
-    $SIG{CHLD} = \&REAPER;
-}
-
- at rotatecursortemplate = ( '-', '\\', '|', '/' );
-$rotatecursorcount    = 0;
-
-sub RotateCursor {
-    print STDERR $rotatecursortemplate[$rotatecursorcount], "\r";
-    $rotatecursorcount =
-      ( $rotatecursorcount + 1 ) % ( $#rotatecursortemplate + 1 );
-}
-
-sub main {
-    my @DISQUES;
-    my $NumMode;
-    my $Mode;
-    my $Reinstall;
-    my $Disque;
-
-    # Etape I: Recolte des informations
-    # Toutes les interractions avec l'utilisateur
-    # doivent etre limites au debut du process d'install.
-
-    @DISQUES = Scan_disques();
-    if ( $#DISQUES >= 0 ) {
-        $NumMode = Get_installed(@DISQUES);
-        if ( $NumMode < 0 || $MODES[$NumMode] eq $MODETMPFS ) {
-            $reinstall = Get_reinstall( 1, $NumMode );
-        }
-        else {
-            $reinstall = Get_reinstall( $DEFAULT_REINSTALL, $NumMode );
-        }
-    }
-    else {
-        $reinstall = 1;
-        $NumMode   = $NUMMODETMPFS;
-    }
-
-    if ( $reinstall || $MODES[$NumMode] eq $MODEMIXED ) {
-
-        if ($reinstall) {
-            $Mode = Get_mode($NumMode);
-        }
-        else {
-            $Mode = $MODES[$NumMode];
-        }
-
-        if ( $Mode eq $MODEHD || $Mode eq $MODEMIXED ) {
-            if ($reinstall) {
-                $Disque = Get_disque(@DISQUES);
-            }
-            else {
-                $Disque = $DISQUES[0];
-            }
-        }
-        else {
-            $Disque = "tmpfs";
-        }
-
-        $Distrib = Get_distrib( ( Get_name() )[1] );
-
-        # Etape II: Configuration automatique
-        # A partir d'ici aucune question ne sera posee.
-
-        if ($reinstall) {
-            Make_disque( $Mode, $Disque );
-        }
-        Mount_install( $Mode, $Disque );
-
-        if ( !$reinstall ) {
-            system(
-"mv $SLASH/var/log $SLASH/var/.log.orig; mv $SLASH/var/spool $SLASH/var/.spool.orig"
-            );
-        }
-
-        Init_config( $Mode, $Disque );
-        Base_install($Distrib);
-
-        if ( !$reinstall ) {
-            system(
-"rm -Rf $SLASH/var/log; mv $SLASH/var/.log.orig $SLASH/var/log; rm -Rf $SLASH/var/spool; mv $SLASH/var/.spool.orig $SLASH/var/spool"
-            );
-        }
-
-        if ( defined($Distrib) && $Distrib ne "" ) {
-            system(
-"echo deb file:/distrib/debian $Distrib plateforme > $SLASH/etc/apt/sources.list"
-            );
-        }
-        else {
-            print STDERR "No distrib?! Falling back to default\n";
-            system("cp $INSTALLERCONFIG/sources.list $SLASH/etc/apt/");
-        }
-
-    }
-    else {
-        $Mode   = $MODES[$NumMode];
-        $Disque = $DISQUES[0];
-        Mount_install( $Mode, $Disque );
-    }
-
-    Update_config($Distrib);
-
-    Restart();
-
-}
-
-#
-#	STRING Get_distrib (VOID)
-#	Affiche un menu de selection des distrib disponibles.
-#==============================================================
-sub Get_distrib {
-    my ($name) = @_;
-    my $type = $name;
-    $type =~ s/[0-9]*$//;
-    my $distrib;
-    my @DISTRIBS;
-    my $NAME;
-    my $TYPE;
-    my $CURRENT;
-
-    # Liste des distrib diponibles
-    opendir( DISTRIB_DIR, $DISTRIB_DIR ) || warn "Cannot open $DISTRIB_DIR";
-    @DISTRIBSDIR = sort readdir(DISTRIB_DIR);
-    closedir(DISTRIB_DIR);
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq $name && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            $NAME = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-            $NAME =~ s:^.*/([^/]*)$:$1:;
-            push @DISTRIBS, $NAME . " (" . $DISTRIBDIR . ")";
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq $type && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            $TYPE = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-            $TYPE =~ s:^.*/([^/]*)$:$1:;
-            push @DISTRIBS, $TYPE . " (" . $DISTRIBDIR . ")";
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq "current"
-            && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            $CURRENT = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-            $CURRENT =~ s:/+$::;
-            $CURRENT =~ s:^.*/([^/]+)$:$1:;
-            push @DISTRIBS, $CURRENT . " (" . $DISTRIBDIR . ")";
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR ne "current"
-            && ( !defined $CURRENT || $DISTRIBDIR ne $CURRENT )
-            && ( !defined $TYPE    || $DISTRIBDIR ne $TYPE )
-            && ( !defined $NAME    || $DISTRIBDIR ne $NAME )
-            && !-l "$DISTRIB_DIR/$DISTRIBDIR"
-            && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            push @DISTRIBS, $DISTRIBDIR;
-        }
-    }
-
-    # Choix d'une distrib
-    if ( $#DISTRIBS > 0 ) {
-        $distrib =
-          $DISTRIBS[ Menu( "Selectionnez une distrib.", 0, 1, @DISTRIBS ) ];
-    }
-    else {
-        $distrib = $DISTRIBS[0];
-    }
-
-    if ( !defined $distrib ) {
-        print STDERR "Pas de distrib...\n";
-        system("sh");
-    }
-
-    $distrib =~ s/^([^ ]+).*$/$1/;
-
-    return ($distrib);
-}
-
-#
-#	VOID Restart (VOID) ;
-#	Redemarer le PC apres install.
-#================================================================
-sub Restart {
-    do {
-        Cls();
-        print "\tInstallation terminee ...\n\n";
-        print "\tRetirez les disquettes et cdroms de tous les lecteurs\n";
-        print "\tAppuyez sur ENTREE pour redemarer le system.\n";
-        print "\tTappez SH pour acceder a un shell.\n";
-        chomp( $_ = <> );
-
-        if (/^SH$/) {
-            system("bash");
-        }
-    } while ( !/^$/ );
-
-    system "umount -ar";
-    system "reboot -fni";
-}
-
-#
-#	VOID Make_disque (STRING $Mode, $Disque)
-#	Partitione et formate le disque system
-#	Le schema applique est le suivant:
-#	swap	partition 3	2 * memsize
-#	/boot	partition 1	10M
-#	/	partition 2	le restant du disque
-#==========================================================
-sub Make_disque {
-    my ( $Mode, $Disque ) = @_;
-
-    my $D;
-    my $Cylindres;
-    my $Tetes;
-    my $Secteurs;
-    my $Memoire;
-    my $Swap;
-    my $Boot;
-    my $Root;
-    my $Var;
-
-    if ( $Mode eq $MODETMPFS ) {
-        return;
-    }
-
-    # Geometrie du disque
-    ( $D, $Cylindres, $D, $Tetes, $D, $Secteurs ) =
-      split ( /\s+/, `sfdisk -f -g $Disque` );
-
-    if ( $Cylindres == 0 || $Tetes == 0 || $Secteurs == 0 ) {
-        print STDERR "Oops! sfdisk renvoie des valeurs nulles!!!\n";
-        return;
-    }
-
-    # Calcul de la taille du swap (1 * taille memoire)
-    ( $D, $D, $D, $D, $D, $D, $D, $D, $Memoire ) = split ( /\s+/, `free -om` );
-    $Swap = ceil( ( $Memoire * 1 * 2048 ) / ( $Tetes * $Secteurs ) );
-
-    # Calcul de la taille du bootfs (10M environ)
-    $Boot = ceil( ( 10 * 2048 ) / ( $Tetes * $Secteurs ) );
-
-    # Calcul de la taile du rootfs (le reste du disque)
-    $Root = $Cylindres - ( $Boot + $Swap );
-    $Var  = $Cylindres - $Swap;
-
-    if ( $Mode eq $MODEHD ) {
-
-        # Creation des partitions sur le disque
-        open( SFDISK, "| sfdisk -f $Disque" );
-        print SFDISK "$BEGIN,$Boot,$LINUX_NATIVE,$NOOPTION\n";
-        print SFDISK "$FOLLOW,$Root,$LINUX_NATIVE,$BOOTABLE\n";
-        print SFDISK "$FOLLOW,$Swap,$LINUX_SWAP,$NOOPTION\n";
-        close(SFDISK);
-
-        # Creation des filesystems
-        system "mkfs.$FSTYPE $Disque$HDBOOT || sh";
-        system "mkfs.$FSTYPE $Disque$HDROOT || sh";
-        system "mkswap $Disque$HDSWAP || sh";
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-
-        # Creation des partitions sur le disque
-        open( SFDISK, "| sfdisk -f $Disque" );
-        print SFDISK "$BEGIN,$Var,$LINUX_NATIVE,$NOOPTION\n";
-        print SFDISK "$FOLLOW,$Swap,$LINUX_SWAP,$NOOPTION\n";
-        close(SFDISK);
-
-        # Creation des filesystems
-        system "mkfs.$FSTYPE $Disque$MIXEDVAR || sh";
-        system "mkswap $Disque$MIXEDSWAP || sh";
-    }
-}
-
-sub Mount_install {
-    my ( $Mode, $Disque ) = @_;
-
-    # Montage des filesystems
-    system "sync";
-
-    if ( $Mode eq $MODEHD ) {
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$HDROOT";
-        system "mount $Disque$HDROOT $SLASH || sh";
-        system "mkdir -p $SLASH_BOOT";
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$HDBOOT";
-        system "mount $Disque$HDBOOT $SLASH_BOOT || sh";
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-
-        system "mount -t tmpfs -o size=$TMPFSMAX none $SLASH || sh";
-        system "mkdir -p $SLASH/var";
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$MIXEDVAR";
-        system "mount $Disque$MIXEDVAR $SLASH/var || sh";
-    }
-    elsif ( $Mode eq $MODETMPFS ) {
-        system "mount -t tmpfs -o size=$TMPFSMAX none $SLASH || sh";
-    }
-}
-
-#
-#	VOID Base_install (STRING $Disque, STRING $Distrib)
-#	Monte les filesystems et copie la base
-#========================================================
-sub Base_install {
-    my ($Distrib) = @_;
-    my $script;
-    my $output = '';
-
-    # Copie de la base Debian
-    print "\nInstallation de la base"
-      . ( $QUIETDEBOOTSTRAP ? " (quiet mode)" : "" ) . "...\n";
-
-    $script = "/distrib/debian/dists/" . $Distrib . "/debootstrap";
-    if ( !-e $script ) {
-        $script = "/usr/lib/debootstrap/scripts/sid";
-    }
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        system("echo 0 >/proc/sys/kernel/grsecurity/chroot_caps");
-        system("echo 0 >/proc/sys/kernel/grsecurity/chroot_deny_chmod");
-        system("echo 0 >/proc/sys/kernel/grsecurity/chroot_deny_mknod");
-        system("echo 0 >/proc/sys/kernel/grsecurity/chroot_deny_mount");
-    }
-
-    system("mkdir -m 755 -p $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/passwd $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/group $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/shadow $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/gshadow $SLASH/etc/");
-
-    if ( !open(
-            DEBOOTSTRAP,
-"cd $SLASH; debootstrap --arch i386 --components=plateforme,main --exclude=pcmcia-cs,man-db $Distrib . file:/distrib/debian $script 2>&1 |"
-        ) )
-    {
-        print STDERR "open: $!\n";
-        system("sh");
-    }
-    while (<DEBOOTSTRAP>) {
-        if ($QUIETDEBOOTSTRAP) {
-            $output .= $_;
-            RotateCursor();
-        }
-        else {
-            print STDERR $_;
-        }
-    }
-    if ( !close(DEBOOTSTRAP) ) {
-
-        #print STDERR "\$! = $!\n";
-        #print STDERR "\$? = $?\n";
-        #if ( !$! && $? ) {
-        if ($QUIETDEBOOTSTRAP) {
-            print STDERR $output;
-        }
-
-        system("sh");
-
-        #}
-    }
-    $output = '';
-
-    print STDERR "\n";
-
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/passwd $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/group $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/shadow $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/gshadow $SLASH/etc/");
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        system("echo 1 >/proc/sys/kernel/grsecurity/chroot_caps");
-        system("echo 1 >/proc/sys/kernel/grsecurity/chroot_deny_chmod");
-        system("echo 1 >/proc/sys/kernel/grsecurity/chroot_deny_mknod");
-        system("echo 1 >/proc/sys/kernel/grsecurity/chroot_deny_mount");
-    }
-    print "Done\n\n";
-}
-
-#
-#	VOID Init_config (STRING $Disque) 
-#	Initialise une config de base a partir de templates
-#	Fichiers traites:
-#		/root
-#		/etc/ioctl.save
-#		/etc/hostname
-#		/etc/hosts
-#		/etc/lilo.conf
-#		/etc/fstab
-#		/etc/inittab
-#		/etc/securetty
-#		/var/lib/cvsguest/.ssh/id_rsa
-#===============================================================
-sub Init_config {
-    my ( $Mode, $Disque ) = @_;
-
-    system("mkdir $SLASH/root");
-    chmod 0700, "$SLASH/root";
-
-    system("mkdir $SLASH/etc");
-    unlink "$SLASH/etc/ioctl.save";
-
-    # Resolv.conf
-    if ( -r $RESOLV_CONF ) {
-        system("cp $RESOLV_CONF $SLASH$RESOLV_CONF");
-    }
-
-    # /etc/hostname
-    my ( $ip, $name, $domain ) = Get_name();
-
-    my $longname;
-    if ( defined $domain && $domain ne "" ) {
-        $longname = $name . '.' . $domain;
-    }
-    else {
-        $longname = $name . '.private';
-    }
-
-    if ( !-r "$SLASH/etc/hostname" ) {    # no dhcp
-        if ( open( HOSTNAME, "> $SLASH/etc/hostname" ) ) {
-            print HOSTNAME "$name\n";
-            close(HOSTNAME);
-        }
-    }
-
-    #if ( !-r "$SLASH/etc/mailname" ) {    # no dhcp
-    #    if ( open( MAILNAME, "> $SLASH/etc/mailname" ) ) {
-    #        print MAILNAME "$longname\n";
-    #        close(MAILNAME);
-    #    }
-    #}
-
-    # /etc/hosts
-    if ( !-r "$SLASH/etc/hosts" ) {
-        system(
-"(echo \"127.0.0.1	localhost\"; echo \"$ip	$longname $name\") > $SLASH/etc/hosts"
-        );
-    }
-    else {
-        system(
-"cp -a $SLASH/etc/hosts $SLASH/etc/hosts.old; (echo \"$ip	$longname $name\"; grep -v -e \"\[^a-z0-9-\]$name\[^a-z0-9-\]\" ) < $SLASH/etc/hosts.old > $SLASH/etc/hosts"
-        );
-    }
-
-    # /etc/lilo.conf
-
-    if ( $Mode eq $MODEHD ) {
-
-	open PROCCMDLINE, '</proc/cmdline'
-	    or die "open: /proc/cmdline: $!\n";
-	my $proc_cmdline = <PROCCMDLINE>;
-	close PROCCMDLINE;
-	my $lilo_append = '';
-	if ($proc_cmdline =~ m/\b(console=\S+)/) {
-	    $lilo_append = $1;
-	}
-
-        open( LILO, "> $SLASH/etc/lilo.conf" );
-        print LILO <<"# END lilo.conf" ;
-# BEGIN lilo.conf
-#----------------------------------------------------------------------
-boot=$Disque
-root=$Disque$HDROOT
-install=/boot/boot.b
-map=/boot/map
-serial=0,115200n8
-compact
-prompt
-timeout=40
-default=Linux
-
-image=/boot/vmlinuz
-	label=Linux
-	read-only
-	append="$lilo_append"
-
-image=/boot/vmlinuz.old
-	label=old
-	read-only
-	optional
-	append="$lilo_append"
-# END lilo.conf
-
-        #----------------------------------------------------------------------
-        close(LILO);
-
-        #system("lilo -r $SLASH");
-    }
-
-    # /etc/fstab
-    open( FSTAB, "> $SLASH/etc/fstab" );
-
-    if ( $Mode eq $MODEHD ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-$Disque$HDROOT		/	$FSTYPE	defaults,errors=remount-ro	0 1
-$Disque$HDBOOT		/boot	$FSTYPE	defaults,errors=remount-ro,nodev,nosuid			0 2
-$Disque$HDSWAP		none	swap	sw				0 0
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-none			/	tmpfs	defaults,errors=remount-ro	0 1
-$Disque$MIXEDVAR	/var	$FSTYPE	defaults,errors=remount-ro,nodev,nosuid	0 1
-$Disque$MIXEDSWAP	none	swap	sw				0 0
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-    elsif ( $Mode eq $MODETMPFS ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-none			/	tmpfs	defaults,errors=remount-ro	0 1
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-
-    close(FSTAB);
-
-    # inittab (ajout console serial)
-    open( INITTAB, ">>$SLASH/etc/inittab" );
-    print INITTAB
-      "\n# serial console\nS0:2345:respawn:/sbin/getty 115200 ttyS0 vt102\n";
-    close(INITTAB);
-
-    open( SECURETTY, ">>$SLASH/etc/securetty" );
-    print SECURETTY "\nttyS0\ntts/0\n";
-    close(SECURETTY);
-
-    # APT sources.list
-    #system("cp $INSTALLERCONFIG/sources.list $SLASH/etc/apt/");
-
-    # DEBCONF
-    #system("cp $INSTALLERCONFIG/config.dat $SLASH/var/cache/debconf/");
-    #system("cp $INSTALLERCONFIG/apt.conf $SLASH/etc/apt/apt.conf");
-
-    # CVS security settings
-    system("mkdir -p -m 0700 $SLASH$CVSGUEST/.ssh >/dev/null 2>&1");
-    system("chmod 700 $SLASH$CVSGUEST");
-    system("cp $INSTALLERCONFIG/id_rsa $SLASH$CVSGUEST/.ssh");
-    system("chmod 400 $SLASH$CVSGUEST/.ssh/id_rsa");
-}
-
-#
-#	VOID Cls (VOID) ;
-#	Effacer l'ecran.
-#	Comme aucun TERM n'est defini on utilise une methode certe primitive mais efficasse !
-#===================================================================================================
-sub Cls {
-
-    #print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
-};
-
-sub Timeout {
-    my $timeout;
-    my $rin;
-    my $win;
-    my $ein;
-    my $rout;
-    my $wout;
-    my $eout;
-    my $nfound;
-    my $timeleft;
-
-    $timeout = $TIMEOUT;
-
-    $rin = $win = $ein = '';
-    vec( $rin, fileno(STDIN),  1 ) = 1;
-    vec( $ein, fileno(STDIN),  1 ) = 1;
-    vec( $ein, fileno(STDOUT), 1 ) = 1;
-
-    $| = 1;
-    ( $nfound, $timeleft ) =
-      select( $rout = $rin, $wout = $win, $eout = $ein, $timeout );
-
-    return ($nfound);
-};
-
-#
-#       INT Menu (STRING $text, INT $default,  LIST @list)
-#       Menu de choix dans une liste.
-#	$default est le choix par defaut
-#       l'indice de l'element choisi est retourne.
-#=========================================================
-
-sub Menu {
-    my ( $text, $default, $timeout, @list ) = @_;
-
-    my $rep;
-
-    do {
-
-        my $d;
-        my $c = 0;
-
-        Cls();
-
-        print "\t$text\n\n";
-        foreach $d (@list) {
-            print "\t\t[$c] $d\n";
-            $c++;
-        }
-        print "\n\tVotre choix (";
-
-        if ($timeout) {
-            print "timeout = $TIMEOUT, ";
-        }
-        print "defaut = [$default] $list[$default]): ";
-
-        $ok = 1;
-        if ($timeout) {
-            $ok = Timeout();
-        }
-
-        if ($ok) {
-            chomp( $rep = <STDIN> );
-        }
-        else {
-            print "\n";
-        }
-
-        if ( !defined $rep || $rep =~ /^$/ ) {
-            $rep = $default;
-        }
-
-    } until ( ( $rep !~ /\D/ ) && ( defined( $list[$rep] ) ) );
-
-    return $rep;
-}
-
-#
-#       LIST Scan_disques (VOID)
-#       Return la liste des disques dispo
-#============================================================
-sub Scan_disques {
-    my @DISQUES;
-
-    undef @DISQUES;
-
-    open( SFDISK, "sfdisk -f -s | sort -u |" );
-    while (<SFDISK>) {
-        if ( m:^/: && /:/ ) {
-            push @DISQUES, $`;
-        }
-    }
-    close(SFDISK);
-
-    if ( $#DISQUES < 0 ) {
-        open( PARTITIONS, "</proc/partitions" );
-        while (<PARTITIONS>) {
-            if (m:^\s*\d+\s+\d+\s+(\d+)\s+(\w+)\s+$:) {
-                my $blocks = $1;
-                my $disque = $2;
-                if ( $disque !~ /\d$/ && $disque !~ /fake/ ) {
-                    $disque =~ s/^ubd/hd/;
-                    chomp( my $blocks2 =
-                        `sfdisk -f -s /dev/$disque 2>/dev/null` );
-                    if ( $blocks2 =~ /^\d+$/ && $blocks == $blocks2 ) {
-                        push @DISQUES, "/dev/$disque";
-                    }
-                    else {
-                        print STDERR "Gni? $disque: $blocks, $blocks2\n";
-                    }
-                }
-            }
-        }
-        close(PARTITIONS);
-    }
-
-    return (@DISQUES);
-}
-
-#
-#       INT Get_Installed (@DISQUES)
-#       Return le mode deja installe
-#============================================================
-sub Get_installed {
-    my @DISQUES = @_;
-    my $default = -1;
-    my @PARTID;
-
-    if ( $#DISQUES == -1 ) {
-        $default = $NUMMODETMPFS;
-    }
-    else {
-        open( SFDISK, "sfdisk -f -l " . $DISQUES[0] . " 2>>/dev/null |" );
-        while (<SFDISK>) {
-
-            if (
-m:^[^\s]+[\s]+\*?[\s]+[^\s]+[\s]+[^\s]+[\s]+[^\s]+[\s]+[^\s]+[\s]+([^\s]+)[\s]+[^\s]+.*$:
-              )
-            {
-                push @PARTID, $1;
-            }
-        }
-        close(SFDISK);
-
-        if ( $#PARTID < 0 ) {
-            $default = -1;
-        }
-        elsif ( $PARTID[0] == $LINUX_NATIVE
-            && $PARTID[1] == $LINUX_NATIVE
-            && $PARTID[2] == $LINUX_SWAP
-            && $PARTID[3] == 0 )
-        {
-            $default = $NUMMODEHD;
-        }
-        elsif ( $PARTID[0] == $LINUX_NATIVE
-            && $PARTID[1] == $LINUX_SWAP
-            && $PARTID[2] == 0
-            && $PARTID[3] == 0 )
-        {
-            $default = $NUMMODEMIXED;
-        }
-        elsif ( $PARTID[0] == 0
-            && $PARTID[1] == 0
-            && $PARTID[2] == 0
-            && $PARTID[3] == 0 )
-        {
-            $default = -1;    # tmpfs or 1st install?
-        }
-    }
-
-    return $default;
-}
-
-sub Get_reinstall {
-    my ( $default, $mode ) = @_;
-    my $defaulttext;
-    my $reinstall;
-
-    if ( $mode >= 0 ) {
-        $defaulttext = "reinstaller ($MODES[$mode])";
-    }
-    else {
-        $defaulttext = "installer ($MODES[$DEFAULT_MODE])";
-    }
-
-    my @REINSTALL = ( "utiliser existant", $defaulttext );
-
-    $reinstall = Menu( "Installation ?", $default, 1, @REINSTALL );
-
-    return ($reinstall);
-}
-
-sub Get_mode {
-    my ($default) = @_;
-
-    if ( $default < 0 ) {
-        $default = $DEFAULT_MODE;
-    }
-
-    $mode = Menu( "Quel est le mode d'installation ?", $default, 1, @MODES );
-
-    return $MODES[$mode];
-}
-
-#
-#	STRING Get_disque (@DISQUES) 
-#	Return le nom du disque d'installation
-#============================================================
-sub Get_disque {
-    my @DISQUES = @_;
-    my $disque  = 0;
-
-    if ( $#DISQUES > 0 ) {
-        $disque =
-          Menu( "Sur quel disque installer le systeme ?", 0, 1, @DISQUES );
-    }
-
-    return $DISQUES[$disque];
-}
-
-#
-#	(STING ip, STRING name) = Get_name (VOID)
-#	Retourne le nom de serveur correspondant
-#	a l'ip optenue par DHCP.
-#=====================================================
-sub Get_name {
-
-    my $ip;
-    my $name;
-    my $domain;
-
-    open( IP, "LANG=C LC_ALL=C ifconfig |" );
-    while (<IP>) {
-        if (/inet addr:([0-9.]+)/) {
-            $ip = $1;
-            last;
-        }
-    }
-    close(IP);
-
-    $name = $ENV{INSTALLNAME};
-
-    if ( -r "/etc/resolv.conf" ) {
-        chomp( $domain =
-`grep '^search ' /etc/resolv.conf | awk '{print \$2}' | awk -F, '{print \$1}'`
-        );
-    }
-    elsif ( -r "$SLASH/etc/resolv.conf" ) {
-        chomp( $domain =
-`grep '^search ' $SLASH/etc/resolv.conf | awk '{print \$2}' | awk -F, '{print \$1}'`
-        );
-    }
-
-    return ( $ip, $name, $domain );
-}
-
-#
-#	VOID Update_config (VOID)
-#	Initialise les fichiers de conf centralises avec CVS
-#================================================================
-sub Update_config {
-    my ($Distrib) = @_;
-
-    chdir "$SLASH";
-
-    system("mount --bind /proc $SLASH/proc");
-    system("mkdir -p $SLASH$DISTRIB; mount --bind $DISTRIB $SLASH$DISTRIB");
-
-    system("pivot_root . ./$PIVOT");
-
-    chdir "/";
-
-    system("hostname -F /etc/hostname");
-
-    system("cat /proc/mounts > /etc/mtab");
-
-    close(STDIN);
-    open( STDIN, "<dev/console" );
-    close(STDOUT);
-    open( STDOUT, ">dev/console" );
-    close(STDERR);
-    open( STDERR, ">dev/console" );
-
-    # putain de perl, a proprer, opendir /proc/self/fd
-    if ( opendir( SELFFDS, "/proc/self/fd" ) ) {
-        foreach $fd ( sort readdir(SELFFDS) ) {
-            $file = readlink( "/proc/self/fd/" . $fd );
-            if ( defined $file && $file =~ m|^$PIVOT| ) {
-                print "Fd ", $fd, " -> ", $file, " ferme\n";
-                open( BURP, "<&=" . $fd );
-                close(BURP);
-            }
-        }
-        closedir(SELFFDS);
-    }
-
-    system("umount -l $PIVOT/proc $PIVOT/sys");
-
-    system("swapon -a");
-
-    system("mount -t devpts devpts /dev/pts");
-
-    system("mv /dev/tty /dev/tty.bqp; ln -s /dev/console /dev/tty");
-    system(
-"mv /sbin/start-stop-daemon /sbin/start-stop-daemon.bqp; cp -a /bin/true /sbin/start-stop-daemon"
-    );
-
-    $ENV{DEBIAN_FRONTEND} = "noninteractive";
-    $ENV{DEBIAN_PRIORITY} = "critical";
-
-    system("echo '[update]'; apt-get -y --force-yes update -y");
-    system("echo '[pf-tools]'; apt-get -y --force-yes install pf-tools");
-
-    #system("echo '[debconf]'; apt-get -y --force-yes install debconf");
-    #system("echo '[psmisc]'; apt-get -y --force-yes install psmisc");
-
-    chomp( $name = ( Get_name() )[1] );
-    if ( $name =~ m/^$DEPLOY/ ) {
-        system("mkdir -p $CVSROOT; mount -o nolock,tcp $CVS $CVSROOT");
-    }
-
-    system("umount -l $PIVOT$DISTRIB");
-
-    print STDERR "\n";
-
-    system( "update-config"
-        . ( $QUIETUPDATECONFIG ? " -q"                         : "" )
-        . ( $CVS_BRANCHE       ? " --branche-cvs $CVS_BRANCHE" : "" )
-        . " :NO-ACTION:" );
-    my $signal_num = $? & 127;
-    if ( $signal_num != 0 && $signal_num != 127 ) {
-        print "Ooops, update-config exited with signal"
-          . $signal_num
-          . ", reexec";
-        system( "update-config"
-            . ( $QUIETUPDATECONFIG ? " -q"                         : "" )
-            . ( $CVS_BRANCHE       ? " --branche-cvs $CVS_BRANCHE" : "" )
-            . " :NO-ACTION:" );
-    }
-
-    print "\n";
-    if ( opendir( PROC, "/proc" ) ) {
-        foreach $dir ( sort readdir(PROC) ) {
-            if ( $dir =~ /^\d+$/ && $dir ne "1" ) {
-                $exe = readlink( "/proc/" . $dir . "/exe" );
-                if ( defined $exe && $exe ne "" ) {
-                    print "Retardataire ", $exe, " tue\n";
-                    kill( 9, $dir );
-                }
-            }
-        }
-        closedir(PROC);
-    }
-
-    print "\nSync...";
-    system("sync");
-    print "done\n";
-
-    print "\nShell de la derniere chance (TMOUT=15)\n";
-    system("TMOUT=15 sh");
-
-    system("cat /proc/mounts | grep -v -e '[ 	]/[ 	]' > /etc/mtab");
-
-    system("rm -f /var/run/*.pid");
-
-    system("sync; swapoff -a");
-
-    system("rm -f /dead.letter");
-    system(
-"rm -f /sbin/start-stop-daemon; mv /sbin/start-stop-daemon.bqp /sbin/start-stop-daemon"
-    );
-    system("rm -f /dev/tty; mv /dev/tty.bqp /dev/tty");
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        system("echo 1 >/proc/sys/kernel/grsecurity/grsec_lock");
-    }
-
-    # GRUIK
-    if ( -e "/proc/mconsole" && -d "/lib/tls" ) {
-
-        # uml + tls = segfault
-# http://marc.theaimsgroup.com/?l=user-mode-linux-user&m=110212807330138&w=2
-        system("mv /lib/tls /lib/tls-disabled; touch /lib/tls");
-    }
-
-    system(
-"umount -t nfs -a -l; umount -l $PIVOT $CVSROOT $DISTRIB /boot /var /dev/pts /proc /sys; mount -n -o remount,ro /"
-    );
-
-    exec "/sbin/init" || warn "exec a foire!";
-}
-
-&main;
-
diff -r 6d007d250b23 -r 291abd3f33a1 installers/install.dist-2.6
--- a/installers/install.dist-2.6	Mon Sep 20 17:08:34 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1196 +0,0 @@
-#!/usr/bin/perl
-#
-#   $Id$
-#   $Name$
-#
-
-##  Copyright (C) 2005 Olivier MOLTENI <olivier at molteni.net>
-##
-##  This program is free software; you can redistribute it and/or
-##  modify it under the terms of the GNU General Public License
-##  as published by the Free Software Foundation; either version 2
-##  of the License, or (at your option) any later version.
-##
-##  This program is distributed in the hope that it will be useful,
-##  but WITHOUT ANY WARRANTY; without even the implied warranty of
-##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-##  GNU General Public License for more details.
-##
-##  You should have received a copy of the GNU General Public License
-##  along with this program; if not, write to the Free Software
-##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
-
-#open STDERR, ">&STDOUT" or die "Can't dup STDOUT: $!";
-
-use warnings;
-
-#---------------------------------------------------------------#
-#								#
-#	install.pl v0.1						#
-#								#
-#	Script de deploiement de master Linux			#
-#								#
-#---------------------------------------------------------------#
-
-#
-# AVERTISSEMENT : Ce script ne doit JAMAIS etre execute sur un system
-#                 fonctionnel. Il est reserve au deploiement.
-#==========================================================================
-
-chomp( $init = readlink("/proc/1/exe") );
-if ( $init eq "/sbin/init" ) {
-    print "     ************************************************\n";
-    print "     *                                              *\n";
-    print "     *     MALHEUREUX !!!!                          *\n";
-    print "     *     Faut JAMAIS lancer ce machin sur un      *\n";
-    print "     *     system qui fonctionne !!!                *\n";
-    print "     *                                              *\n";
-    print "     ************************************************\n";
-    exit;
-}
-
-# constantes
-#===================================
-
-$QUIETDEBOOTSTRAP  = 1;
-$QUIETUPDATECONFIG = 1;
-
-$DEPLOY = "deploy";
-
-$TIMEOUT = 10;
-
-$DEFAULT_REINSTALL = 0;
-
-$NUMMODEHD    = 0;
-$MODEHD       = "hd (/ au max)";
-$NUMMODERAID  = 1;
-$MODERAIDSIZE = 12;
-$MODERAID     = "raid manuel (/ de " . $MODERAIDSIZE . "Go max)";
-$NUMMODEMIXED = 2;
-$MODEMIXED    = "mixed";
-$NUMMODETMPFS = 3;
-$MODETMPFS    = "tmpfs";
- at MODES        = ( $MODEHD, $MODERAID, $MODEMIXED, $MODETMPFS );
-$DEFAULT_MODE = $NUMMODEHD;
-
-$FSTYPE = "ext2";
-
-$BEGIN           = '0';
-$FOLLOW          = '';
-$LINUX_NATIVE    = '83';
-$LINUX_SWAP      = '82';
-$LINUX_RAID      = 'FD';
-$BOOTABLE        = '*';
-$NOOPTION        = '-';
-$HDBOOT          = '1';
-$HDROOT          = '2';
-$HDSWAP          = '3';
-$MIXEDVAR        = '1';
-$MIXEDSWAP       = '2';
-$TMPFSMAX        = '512m';
-$SLASH           = "/mnt";
-$SLASH_BOOT      = "$SLASH/boot";
-$PIVOT           = "/initrd";
-$DISTRIB         = "/distrib";
-$DISTRIB_DIR     = "$DISTRIB/debian/dists";
-$INSTALLERCONFIG = "$DISTRIB/installerconfig";
-$RESOLV_CONF     = "/etc/resolv.conf";
-
-$NFSFILER = $ENV{NFSFILER};
-
-$CVS      = $NFSFILER . ":/vol/voldata/cvs";
-$CVSGUEST = "/var/lib/cvsguest";
-$CVSROOT  = "/var/lib/cvs/repository";
-
-#Si une branche CVS a été passée en paramètre, je la récupère.
-open CMDLINE, "</proc/cmdline" or warn "Can't open /proc/cmdline\n";
-<CMDLINE> =~ /branchecvs=(\S+)/;
-close CMDLINE;
-$CVS_BRANCHE = $1 if $1;
-
-#
-#	Debut du script d'installation
-#============================================
-$| = 1;
-
-#$SIG{CHLD} = \&REAPER;
-
-use POSIX ":math_h";
-use POSIX ":sys_wait_h";
-
-sub REAPER {
-    my $child;
-
-    while ( ( $child = waitpid( -1, WNOHANG ) ) > 0 ) {
-
-        #$Kid_Status{$child} = $?;
-    }
-    $SIG{CHLD} = \&REAPER;
-}
-
- at rotatecursortemplate = ( '-', '\\', '|', '/' );
-$rotatecursorcount    = 0;
-
-sub RotateCursor {
-    print STDERR $rotatecursortemplate[$rotatecursorcount], "\r";
-    $rotatecursorcount =
-      ( $rotatecursorcount + 1 ) % ( $#rotatecursortemplate + 1 );
-}
-
-sub main {
-    my @DISQUES;
-    my $NumMode;
-    my $Mode;
-    my $Reinstall;
-    my $Disque;
-
-    # Etape I: Recolte des informations
-    # Toutes les interractions avec l'utilisateur
-    # doivent etre limites au debut du process d'install.
-
-    @DISQUES = Scan_disques();
-    if ( $#DISQUES >= 0 ) {
-        $NumMode = Get_installed(@DISQUES);
-        if ( $NumMode < 0 || $MODES[$NumMode] eq $MODETMPFS ) {
-            $reinstall = Get_reinstall( 1, $NumMode );
-        }
-        else {
-            $reinstall = Get_reinstall( $DEFAULT_REINSTALL, $NumMode );
-        }
-    }
-    else {
-        $reinstall = 1;
-        $NumMode   = $NUMMODETMPFS;
-    }
-
-    if ( $reinstall || $MODES[$NumMode] eq $MODEMIXED ) {
-
-        if ($reinstall) {
-            $Mode = Get_mode($NumMode);
-        }
-        else {
-            $Mode = $MODES[$NumMode];
-        }
-
-        if ( $Mode eq $MODEHD || $Mode eq $MODEMIXED ) {
-            if ($reinstall) {
-                $Disque = Get_disque(@DISQUES);
-            }
-            else {
-                $Disque = $DISQUES[0];
-            }
-        }
-	elsif ( $Mode eq $MODERAID ) {
-	    $Disque = $DISQUES[0];
-	}
-        else {
-            $Disque = "tmpfs";
-        }
-
-        $Distrib = Get_distrib( ( Get_name() )[1] );
-
-        # Etape II: Configuration automatique
-        # A partir d'ici aucune question ne sera posee.
-
-        if ($reinstall) {
-            Make_disque( $Mode, $Disque );
-        }
-        Mount_install( $Mode, $Disque );
-
-        if ( !$reinstall ) {
-            system(
-"mv $SLASH/var/log $SLASH/var/.log.orig; mv $SLASH/var/spool $SLASH/var/.spool.orig"
-            );
-        }
-
-        Init_config( $Mode, $Disque );
-	# Si on veut pouvoir atteindre une machine extérieure pendant l'install
-	# par exemple pour une source http
-	# system("route add default gw 10.128.2.10");
-        Base_install($Distrib);
-
-        if ( !$reinstall ) {
-            system(
-"rm -Rf $SLASH/var/log; mv $SLASH/var/.log.orig $SLASH/var/log; rm -Rf $SLASH/var/spool; mv $SLASH/var/.spool.orig $SLASH/var/spool"
-            );
-        }
-
-	# Installation sources apt
-        if ( defined($Distrib) && $Distrib ne "" ) {
-	    # Anciennes distribs
-            #system( "echo deb file:/distrib/debian $Distrib plateforme > $SLASH/etc/apt/sources.list" );
-	    # Nouvelle distrib
-	    if (open(SOURCESLIST, ">$SLASH/etc/apt/sources.list")) {
-		print SOURCESLIST <<"EOT";
-deb file:///distrib/debian                 $Distrib	plateforme custom
-deb file:///distrib/debian-snapshot/debian testing	main contrib non-free
-EOT
-# deb http://172.16.71.53/debian-tom testing  main contrib non-free
-		close SOURCESLIST;
-	    }
-	    else {
-		# FIXME erreur fatale
-		warn "Can't open $SLASH/etc/apt/sources.list: $!\n";
-	    }
-        }
-        else {
-            print STDERR "No distrib?! Falling back to default\n";
-            system("cp $INSTALLERCONFIG/sources.list $SLASH/etc/apt/");
-        }
-
-	# Installation preferences apt
-	if (open(PREFS, ">$SLASH/etc/apt/preferences")) {
-	    print PREFS <<"EOT";
-Package: *
-Pin: release a=$Distrib
-Pin-Priority: 900
-
-EOT
-	    close PREFS;
-	}
-	else {
-	    warn "Can't open $SLASH/etc/apt/preferences: $!\n";
-	}
-    }
-    else {
-        $Mode   = $MODES[$NumMode];
-        $Disque = $DISQUES[0];
-        Mount_install( $Mode, $Disque );
-	# Si on veut pouvoir atteindre une machine extérieure pendant l'install
-	# par exemple pour une source http
-	# system("route add default gw 10.128.2.10");
-    }
-
-    Update_config($Distrib);
-
-    Restart();
-
-}
-
-#
-#	STRING Get_distrib (VOID)
-#	Affiche un menu de selection des distrib disponibles.
-#==============================================================
-sub Get_distrib {
-    my ($name) = @_;
-    my $type = $name;
-    $type =~ s/[0-9]*$//;
-    my $distrib;
-    my @DISTRIBS;
-    my $NAME;
-    my $TYPE;
-    my $CURRENT;
-
-    # Liste des distrib diponibles
-    opendir( DISTRIB_DIR, $DISTRIB_DIR ) || warn "Cannot open $DISTRIB_DIR";
-    @DISTRIBSDIR = sort readdir(DISTRIB_DIR);
-    closedir(DISTRIB_DIR);
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq $name && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            if ( -l $DISTRIB_DIR . "/" . $DISTRIBDIR ) {
-                $NAME = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-                $NAME =~ s:/+$::;
-                $NAME =~ s:^.*/([^/]+)$:$1:;
-                push @DISTRIBS, $NAME . " (" . $DISTRIBDIR . ")";
-            }
-            else {
-                $NAME = $name;
-                push @DISTRIBS, $DISTRIBDIR;
-            }
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq $type && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            if ( -l $DISTRIB_DIR . "/" . $DISTRIBDIR ) {
-                $TYPE = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-                $TYPE =~ s:/+$::;
-                $TYPE =~ s:^.*/([^/]+)$:$1:;
-                push @DISTRIBS, $TYPE . " (" . $DISTRIBDIR . ")";
-            }
-            else {
-                $TYPE = $type;
-                push @DISTRIBS, $DISTRIBDIR;
-            }
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR eq "current"
-            && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            if ( -l $DISTRIB_DIR . "/" . $DISTRIBDIR ) {
-                $CURRENT = readlink $DISTRIB_DIR . "/" . $DISTRIBDIR;
-                $CURRENT =~ s:/+$::;
-                $CURRENT =~ s:^.*/([^/]+)$:$1:;
-                push @DISTRIBS, $CURRENT . " (" . $DISTRIBDIR . ")";
-            }
-            else {
-                $CURRENT = "current";
-                push @DISTRIBS, $DISTRIBDIR;
-            }
-        }
-    }
-
-    foreach $DISTRIBDIR (@DISTRIBSDIR) {
-        if ( $DISTRIBDIR ne "current"
-            && ( !defined $CURRENT || $DISTRIBDIR ne $CURRENT )
-            && ( !defined $TYPE    || $DISTRIBDIR ne $TYPE )
-            && ( !defined $NAME    || $DISTRIBDIR ne $NAME )
-            && !-l "$DISTRIB_DIR/$DISTRIBDIR"
-            && -d "$DISTRIB_DIR/$DISTRIBDIR/plateforme" )
-        {
-            push @DISTRIBS, $DISTRIBDIR;
-        }
-    }
-
-    # Choix d'une distrib
-    if ( $#DISTRIBS > 0 ) {
-        $distrib =
-          $DISTRIBS[ Menu( "Selectionnez une distrib.", 0, 1, @DISTRIBS ) ];
-    }
-    else {
-        $distrib = $DISTRIBS[0];
-    }
-
-    if ( !defined $distrib ) {
-        print STDERR "Pas de distrib...\n";
-        system("sh");
-    }
-
-    $distrib =~ s/^([^ ]+).*$/$1/;
-
-    return ($distrib);
-}
-
-#
-#	VOID Restart (VOID) ;
-#	Redemarer le PC apres install.
-#================================================================
-sub Restart {
-    do {
-        Cls();
-        print "\tInstallation terminee ...\n\n";
-        print "\tRetirez les disquettes et cdroms de tous les lecteurs\n";
-        print "\tAppuyez sur ENTREE pour redemarer le system.\n";
-        print "\tTappez SH pour acceder a un shell.\n";
-        chomp( $_ = <> );
-
-        if (/^SH$/) {
-            system("bash");
-        }
-    } while ( !/^$/ );
-
-    system "umount -ar";
-    system "reboot -fni";
-}
-
-#
-#	VOID Make_disque (STRING $Mode, $Disque)
-#	Partitione et formate le disque system
-#	Le schema applique est le suivant:
-#	swap	partition 3	2 * memsize
-#	/boot	partition 1	10M
-#	/	partition 2	le restant du disque
-#==========================================================
-sub Make_disque {
-    my ( $Mode, $Disque ) = @_;
-
-    my $D;
-    my $Cylindres;
-    my $Tetes;
-    my $Secteurs;
-    my $Memoire;
-    my $Swap;
-    my $Boot;
-    my $Root;
-    my $Var;
-
-    if ( $Mode eq $MODETMPFS ) {
-        return;
-    }
-
-    # Geometrie du disque
-    ( $D, $Cylindres, $D, $Tetes, $D, $Secteurs ) =
-      split ( /\s+/, `sfdisk -f -g $Disque` );
-
-    if ( $Cylindres == 0 || $Tetes == 0 || $Secteurs == 0 ) {
-        print STDERR "Oops! sfdisk renvoie des valeurs nulles!!!\n";
-        return;
-    }
-
-    # Calcul de la taille du swap (1 * taille memoire)
-    ( $D, $D, $D, $D, $D, $D, $D, $D, $Memoire ) = split ( /\s+/, `free -om` );
-    $Swap = ceil( ( $Memoire * 1 * 2048 ) / ( $Tetes * $Secteurs ) );
-
-    # Calcul de la taille du bootfs (10M environ)
-    $Boot = ceil( ( 10 * 2048 ) / ( $Tetes * $Secteurs ) );
-
-    # Calcul de la taile du rootfs (le reste du disque)
-    if ( $Mode eq $MODERAID ) {
-	$Root = ceil( ( $MODERAIDSIZE * 1024 * 2048 ) / ( $Tetes * $Secteurs ) );
-	if ( $Root >= $Cylindres - ( $Boot + $Swap ) ) {
-	    print STDERR "Oops! Pas assez de place pour le raid!!!\n";
-	    $Root = $Cylindres - ( $Boot + $Swap );
-	}
-    }
-    else {
-	$Root = $Cylindres - ( $Boot + $Swap );
-    }
-    $Var  = $Cylindres - $Swap;
-
-    if ( $Mode eq $MODEHD || $Mode eq $MODERAID ) {
-
-        # Creation des partitions sur le disque
-        open( SFDISK, "| sfdisk -f $Disque" );
-        print SFDISK "$BEGIN,$Boot,$LINUX_NATIVE,$NOOPTION\n";
-        print SFDISK "$FOLLOW,$Root,$LINUX_NATIVE,$BOOTABLE\n";
-        print SFDISK "$FOLLOW,$Swap,$LINUX_SWAP,$NOOPTION\n";
-	if ( $Mode eq $MODERAID ) {
-	    print SFDISK "$FOLLOW,,$LINUX_RAID,$NOOPTION\n";
-	}
-        close(SFDISK);
-
-        # Creation des filesystems
-        system "mkfs.$FSTYPE $Disque$HDBOOT || sh";
-        system "mkfs.$FSTYPE $Disque$HDROOT || sh";
-        system "mkswap $Disque$HDSWAP || sh";
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-
-        # Creation des partitions sur le disque
-        open( SFDISK, "| sfdisk -f $Disque" );
-        print SFDISK "$BEGIN,$Var,$LINUX_NATIVE,$NOOPTION\n";
-        print SFDISK "$FOLLOW,$Swap,$LINUX_SWAP,$NOOPTION\n";
-        close(SFDISK);
-
-        # Creation des filesystems
-        system "mkfs.$FSTYPE $Disque$MIXEDVAR || sh";
-        system "mkswap $Disque$MIXEDSWAP || sh";
-    }
-}
-
-sub Mount_install {
-    my ( $Mode, $Disque ) = @_;
-
-    # Montage des filesystems
-    system "sync";
-
-    if ( $Mode eq $MODEHD || $Mode eq $MODERAID ) {
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$HDROOT";
-        system "mount $Disque$HDROOT $SLASH || sh";
-        system "mkdir -p $SLASH_BOOT";
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$HDBOOT";
-        system "mount $Disque$HDBOOT $SLASH_BOOT || sh";
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-
-        system "mount -t tmpfs -o size=$TMPFSMAX none $SLASH || sh";
-        system "mkdir -p $SLASH/var";
-
-        system "fsck.$FSTYPE -C 0 -v -y $Disque$MIXEDVAR";
-        system "mount $Disque$MIXEDVAR $SLASH/var || sh";
-    }
-    elsif ( $Mode eq $MODETMPFS ) {
-        system "mount -t tmpfs -o size=$TMPFSMAX none $SLASH || sh";
-    }
-}
-
-#
-#	VOID Base_install (STRING $Disque, STRING $Distrib)
-#	Monte les filesystems et copie la base
-#========================================================
-sub Base_install {
-    my ($Distrib) = @_;
-    my $script;
-    my $output = '';
-
-    # Copie de la base Debian
-    print "\nInstallation de la base"
-      . ( $QUIETDEBOOTSTRAP ? " (quiet mode)" : "" ) . "...\n";
-
-    $script = "/distrib/debian/dists/" . $Distrib . "/debootstrap";
-    if ( !-e $script ) {
-        $script = "/usr/lib/debootstrap/scripts/sid";
-    }
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        foreach my $chroot_file (
-            'chroot_caps',       'chroot_deny_chmod',
-            'chroot_deny_mknod', 'chroot_deny_mount'
-          )
-        {
-            if ( -e "/proc/sys/kernel/grsecurity/" . $chroot_file ) {
-                system( "echo 0 >/proc/sys/kernel/grsecurity/" . $chroot_file );
-            }
-        }
-    }
-
-    system("mkdir -m 755 -p $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/passwd $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/group $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/shadow $SLASH/etc/");
-    system("cp -a $INSTALLERCONFIG/gshadow $SLASH/etc/");
-
-    # Ancien debootstrap
-    #my $debootstrap_cmd = "cd $SLASH; debootstrap --arch i386 --components=plateforme,main --exclude=pcmcia-cs,man-db $Distrib . file:/distrib/debian $script 2>&1 |";
-    # Nouveau debootstrap
-    #my $debootstrap_cmd = "debootstrap --verbose --keep-debootstrap-dir --arch i386 --components=main --exclude=pcmcia-cs,man-db testing $SLASH http://172.16.71.53/debian-tom $script 2>&1 |";
-    my $debootstrap_cmd = "debootstrap --keep-debootstrap-dir --arch i386 --components=main --exclude=pcmcia-cs,man-db testing $SLASH file:///distrib/debian-snapshot/debian $script 2>&1 |";
-
-    if ( !open(DEBOOTSTRAP, $debootstrap_cmd)) {
-        print STDERR "open: $!\n";
-        system("sh");
-    }
-    while (<DEBOOTSTRAP>) {
-        if ($QUIETDEBOOTSTRAP) {
-            $output .= $_;
-            RotateCursor();
-        }
-        else {
-            print STDERR $_;
-        }
-    }
-    if ( !close(DEBOOTSTRAP) ) {
-
-        #print STDERR "\$! = $!\n";
-        #print STDERR "\$? = $?\n";
-        #if ( !$! && $? ) {
-        if ($QUIETDEBOOTSTRAP) {
-            print STDERR $output;
-        }
-
-	warn "debootstrap failed.\n";
-        system("sh");
-
-        #}
-    }
-    $output = '';
-
-    print STDERR "\n";
-
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/passwd $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/group $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/shadow $SLASH/etc/");
-    system("cp -b -S .sitadelle -a $INSTALLERCONFIG/gshadow $SLASH/etc/");
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        foreach my $chroot_file (
-            'chroot_caps',       'chroot_deny_chmod',
-            'chroot_deny_mknod', 'chroot_deny_mount'
-          )
-        {
-            if ( -e "/proc/sys/kernel/grsecurity/" . $chroot_file ) {
-                system( "echo 1 >/proc/sys/kernel/grsecurity/" . $chroot_file );
-            }
-        }
-    }
-    print "Done\n\n";
-}
-
-#
-#	VOID Init_config (STRING $Disque) 
-#	Initialise une config de base a partir de templates
-#	Fichiers traites:
-#		/root
-#		/etc/ioctl.save
-#		/etc/hostname
-#		/etc/hosts
-#		/etc/lilo.conf
-#		/etc/fstab
-#		/etc/inittab
-#		/etc/securetty
-#		/var/lib/cvsguest/.ssh/id_rsa
-#===============================================================
-sub Init_config {
-    my ( $Mode, $Disque ) = @_;
-
-    system("mkdir $SLASH/root");
-    chmod 0700, "$SLASH/root";
-
-    system("mkdir $SLASH/etc");
-    unlink "$SLASH/etc/ioctl.save";
-
-    # Resolv.conf
-    if ( -r $RESOLV_CONF ) {
-        system("cp $RESOLV_CONF $SLASH$RESOLV_CONF");
-    }
-
-    # /etc/hostname
-    my ( $ip, $name, $domain ) = Get_name();
-
-    my $longname;
-    if ( defined $domain && $domain ne "" ) {
-        $longname = $name . '.' . $domain;
-    }
-    else {
-        $longname = $name . '.private';
-    }
-
-    if ( !-r "$SLASH/etc/hostname" ) {    # no dhcp
-        if ( open( HOSTNAME, "> $SLASH/etc/hostname" ) ) {
-            print HOSTNAME "$name\n";
-            close(HOSTNAME);
-        }
-    }
-
-    #if ( !-r "$SLASH/etc/mailname" ) {    # no dhcp
-    #    if ( open( MAILNAME, "> $SLASH/etc/mailname" ) ) {
-    #        print MAILNAME "$longname\n";
-    #        close(MAILNAME);
-    #    }
-    #}
-
-    # /etc/hosts
-    if ( !-r "$SLASH/etc/hosts" ) {
-        system(
-"(echo \"127.0.0.1	localhost\"; echo \"$ip	$longname $name\") > $SLASH/etc/hosts"
-        );
-    }
-    else {
-        system(
-"cp -a $SLASH/etc/hosts $SLASH/etc/hosts.old; (echo \"$ip	$longname $name\"; grep -v -e \"\[^a-z0-9-\]$name\[^a-z0-9-\]\" ) < $SLASH/etc/hosts.old > $SLASH/etc/hosts"
-        );
-    }
-
-    # /etc/lilo.conf
-
-    if ( $Mode eq $MODEHD || $Mode eq $MODERAID ) {
-
-	open PROCCMDLINE, '</proc/cmdline'
-	    or die "open: /proc/cmdline: $!\n";
-	my $proc_cmdline = <PROCCMDLINE>;
-	close PROCCMDLINE;
-	my $lilo_append = '';
-	if ($proc_cmdline =~ m/\b(console=\S+)/) {
-	    $lilo_append = $1;
-	}
-
-        open( LILO, "> $SLASH/etc/lilo.conf" );
-        print LILO <<"# END lilo.conf" ;
-# BEGIN lilo.conf
-#----------------------------------------------------------------------
-boot=$Disque
-root=$Disque$HDROOT
-install=/boot/boot.b
-map=/boot/map
-serial=0,115200n8
-compact
-prompt
-timeout=40
-default=Linux
-
-image=/boot/vmlinuz
-	label=Linux
-	read-only
-	append="$lilo_append"
-
-image=/boot/vmlinuz.old
-	label=old
-	read-only
-	optional
-	append="$lilo_append"
-# END lilo.conf
-
-        #----------------------------------------------------------------------
-        close(LILO);
-
-        #system("lilo -r $SLASH");
-    }
-
-    # /etc/fstab
-    open( FSTAB, "> $SLASH/etc/fstab" );
-
-    if ( $Mode eq $MODEHD || $Mode eq $MODERAID ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-$Disque$HDROOT		/	$FSTYPE	defaults,errors=remount-ro	0 1
-$Disque$HDBOOT		/boot	$FSTYPE	defaults,errors=remount-ro,nodev,nosuid			0 2
-$Disque$HDSWAP		none	swap	sw				0 0
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-    elsif ( $Mode eq $MODEMIXED ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-none			/	tmpfs	defaults,errors=remount-ro	0 1
-$Disque$MIXEDVAR	/var	$FSTYPE	defaults,errors=remount-ro,nodev,nosuid	0 1
-$Disque$MIXEDSWAP	none	swap	sw				0 0
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-    elsif ( $Mode eq $MODETMPFS ) {
-        print FSTAB <<"# END fstab" ;
-# BEGIN fstab
-#------------------------------------------------------------------
-# /etc/fstab: static file system information.
-#
-# <file system> <mount point> <type> <options> <dump>  <pass>
-none			/	tmpfs	defaults,errors=remount-ro	0 1
-# END fstab
-
-        #------------------------------------------------------------------
-    }
-
-    close(FSTAB);
-
-    # inittab (ajout console serial)
-    open( INITTAB, ">>$SLASH/etc/inittab" );
-    print INITTAB
-      "\n# serial console\nS0:2345:respawn:/sbin/getty 115200 ttyS0 vt102\n";
-    close(INITTAB);
-
-    open( SECURETTY, ">>$SLASH/etc/securetty" );
-    print SECURETTY "\nttyS0\ntts/0\n";
-    close(SECURETTY);
-
-    # APT sources.list
-    #system("cp $INSTALLERCONFIG/sources.list $SLASH/etc/apt/");
-
-    # DEBCONF
-    #system("cp $INSTALLERCONFIG/config.dat $SLASH/var/cache/debconf/");
-    #system("cp $INSTALLERCONFIG/apt.conf $SLASH/etc/apt/apt.conf");
-
-    # CVS security settings
-    system("mkdir -p -m 0700 $SLASH$CVSGUEST/.ssh >/dev/null 2>&1");
-    system("chmod 700 $SLASH$CVSGUEST");
-    system("cp $INSTALLERCONFIG/id_rsa $SLASH$CVSGUEST/.ssh");
-    system("chmod 400 $SLASH$CVSGUEST/.ssh/id_rsa");
-}
-
-#
-#	VOID Cls (VOID) ;
-#	Effacer l'ecran.
-#	Comme aucun TERM n'est defini on utilise une methode certe primitive mais efficasse !
-#===================================================================================================
-sub Cls {
-
-    #print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
-};
-
-sub Timeout {
-    my $timeout;
-    my $rin;
-    my $win;
-    my $ein;
-    my $rout;
-    my $wout;
-    my $eout;
-    my $nfound;
-    my $timeleft;
-
-    $timeout = $TIMEOUT;
-
-    $rin = $win = $ein = '';
-    vec( $rin, fileno(STDIN),  1 ) = 1;
-    vec( $ein, fileno(STDIN),  1 ) = 1;
-    vec( $ein, fileno(STDOUT), 1 ) = 1;
-
-    $| = 1;
-    ( $nfound, $timeleft ) =
-      select( $rout = $rin, $wout = $win, $eout = $ein, $timeout );
-
-    return ($nfound);
-};
-
-#
-#       INT Menu (STRING $text, INT $default,  LIST @list)
-#       Menu de choix dans une liste.
-#	$default est le choix par defaut
-#       l'indice de l'element choisi est retourne.
-#=========================================================
-
-sub Menu {
-    my ( $text, $default, $timeout, @list ) = @_;
-
-    my $rep;
-
-    do {
-
-        my $d;
-        my $c = 0;
-
-        Cls();
-
-        print "\t$text\n\n";
-        foreach $d (@list) {
-            print "\t\t[$c] $d\n";
-            $c++;
-        }
-        print "\n\tVotre choix (";
-
-        if ($timeout) {
-            print "timeout = $TIMEOUT, ";
-        }
-        print "defaut = [$default] $list[$default]): ";
-
-        $ok = 1;
-        if ($timeout) {
-            $ok = Timeout();
-        }
-
-        if ($ok) {
-            chomp( $rep = <STDIN> );
-        }
-        else {
-            print "\n";
-        }
-
-        if ( !defined $rep || $rep =~ /^$/ ) {
-            $rep = $default;
-        }
-
-    } until ( ( $rep !~ /\D/ ) && ( defined( $list[$rep] ) ) );
-
-    return $rep;
-}
-
-#
-#       LIST Scan_disques (VOID)
-#       Return la liste des disques dispo
-#============================================================
-sub Scan_disques {
-    my @DISQUES;
-
-    undef @DISQUES;
-
-    open( SFDISK, "sfdisk -f -s | sort -u |" );
-    while (<SFDISK>) {
-        if ( m:^/: && /:/ ) {
-            push @DISQUES, $`;
-        }
-    }
-    close(SFDISK);
-
-    if ( $#DISQUES < 0 ) {
-        open( PARTITIONS, "</proc/partitions" );
-        while (<PARTITIONS>) {
-            if (m:^\s*\d+\s+\d+\s+(\d+)\s+(\w+)\s+$:) {
-                my $blocks = $1;
-                my $disque = $2;
-                if ( $disque !~ /\d$/ && $disque !~ /fake/ ) {
-                    $disque =~ s/^ubd/hd/;
-                    chomp( my $blocks2 =
-                        `sfdisk -f -s /dev/$disque 2>/dev/null` );
-                    if ( $blocks2 =~ /^\d+$/ && $blocks == $blocks2 ) {
-                        push @DISQUES, "/dev/$disque";
-                    }
-                    else {
-                        print STDERR "Gni? $disque: $blocks, $blocks2\n";
-                    }
-                }
-            }
-        }
-        close(PARTITIONS);
-    }
-
-    return (@DISQUES);
-}
-
-#
-#       INT Get_Installed (@DISQUES)
-#       Return le mode deja installe
-#============================================================
-sub Get_installed {
-    my @DISQUES = @_;
-    my $default = -1;
-    my @PARTID;
-
-    if ( $#DISQUES == -1 ) {
-        $default = $NUMMODETMPFS;
-    }
-    else {
-        open( SFDISK, "sfdisk -f -l " . $DISQUES[0] . " 2>>/dev/null |" );
-        while (<SFDISK>) {
-
-            if (
-m:^[^\s]+[\s]+\*?[\s]+[^\s]+[\s]+[^\s]+[\s]+[^\s]+[\s]+[^\s]+[\s]+([^\s]+)[\s]+[^\s]+.*$:
-              )
-            {
-                push @PARTID, $1;
-            }
-        }
-        close(SFDISK);
-
-        if ( $#PARTID < 0 ) {
-            $default = -1;
-        }
-        elsif ( $PARTID[0] == $LINUX_NATIVE
-            && $PARTID[1] == $LINUX_NATIVE
-            && $PARTID[2] == $LINUX_SWAP
-            && $PARTID[3] == 0 )
-        {
-            $default = $NUMMODEHD;
-        }
-        elsif ( $PARTID[0] == $LINUX_NATIVE
-	    && $PARTID[1] == $LINUX_NATIVE
-	    && $PARTID[2] == $LINUX_SWAP
-	    && $PARTID[3] != 0 )
-	{
-	    $default = $NUMMODERAID;
-	}
-	elsif ( $PARTID[0] == $LINUX_NATIVE
-            && $PARTID[1] == $LINUX_SWAP
-            && $PARTID[2] == 0
-            && $PARTID[3] == 0 )
-        {
-            $default = $NUMMODEMIXED;
-        }
-        elsif ( $PARTID[0] == 0
-            && $PARTID[1] == 0
-            && $PARTID[2] == 0
-            && $PARTID[3] == 0 )
-        {
-            $default = -1;    # tmpfs or 1st install?
-        }
-    }
-
-    return $default;
-}
-
-sub Get_reinstall {
-    my ( $default, $mode ) = @_;
-    my $defaulttext;
-    my $reinstall;
-
-    if ( $mode >= 0 ) {
-        $defaulttext = "reinstaller ($MODES[$mode])";
-    }
-    else {
-        $defaulttext = "installer ($MODES[$DEFAULT_MODE])";
-    }
-
-    my @REINSTALL = ( "utiliser existant", $defaulttext );
-
-    $reinstall = Menu( "Installation ?", $default, 1, @REINSTALL );
-
-    return ($reinstall);
-}
-
-sub Get_mode {
-    my ($default) = @_;
-
-    if ( $default < 0 ) {
-        $default = $DEFAULT_MODE;
-    }
-
-    $mode = Menu( "Quel est le mode d'installation ?", $default, 1, @MODES );
-
-    return $MODES[$mode];
-}
-
-#
-#	STRING Get_disque (@DISQUES) 
-#	Return le nom du disque d'installation
-#============================================================
-sub Get_disque {
-    my @DISQUES = @_;
-    my $disque  = 0;
-
-    if ( $#DISQUES > 0 ) {
-        $disque =
-          Menu( "Sur quel disque installer le systeme ?", 0, 1, @DISQUES );
-    }
-
-    return $DISQUES[$disque];
-}
-
-#
-#	(STING ip, STRING name) = Get_name (VOID)
-#	Retourne le nom de serveur correspondant
-#	a l'ip optenue par DHCP.
-#=====================================================
-sub Get_name {
-
-    my $ip;
-    my $name;
-    my $domain;
-
-    open( IP, "LANG=C LC_ALL=C ifconfig |" );
-    while (<IP>) {
-        if (/inet addr:([0-9.]+)/) {
-            $ip = $1;
-            last;
-        }
-    }
-    close(IP);
-
-    $name = $ENV{INSTALLNAME};
-
-    # Si le $name est vide, on regarde si l'IP n'est pas reversee...
-    # Breed Change
-    if ( !defined $name ) {
-        $name = `echo \`host $ip | awk '{ print \$5; }'\``;
-        $name =~ s/^([^\.]*)\.vlan-systeme\.private\.$/$1/;
-        chomp($name);
-    }
-
-    if ( -r "/etc/resolv.conf" ) {
-        chomp( $domain =
-`grep '^search ' /etc/resolv.conf | awk '{print \$2}' | awk -F, '{print \$1}'`
-        );
-    }
-    elsif ( -r "$SLASH/etc/resolv.conf" ) {
-        chomp( $domain =
-`grep '^search ' $SLASH/etc/resolv.conf | awk '{print \$2}' | awk -F, '{print \$1}'`
-        );
-    }
-
-    return ( $ip, $name, $domain );
-}
-
-#
-#	VOID Update_config (VOID)
-#	Initialise les fichiers de conf centralises avec CVS
-#================================================================
-sub Update_config {
-    my ($Distrib) = @_;
-
-    chdir "$SLASH";
-
-    system("mount --bind /proc $SLASH/proc");
-    system("mkdir -p $SLASH$DISTRIB; mount --bind $DISTRIB $SLASH$DISTRIB");
-
-    system("pivot_root . ./$PIVOT");
-
-    chdir "/";
-
-    system("hostname -F /etc/hostname");
-
-    system("cat /proc/mounts > /etc/mtab");
-
-    close(STDIN);
-    open( STDIN, "<dev/console" );
-    close(STDOUT);
-    open( STDOUT, ">dev/console" );
-    close(STDERR);
-    open( STDERR, ">dev/console" );
-
-    # putain de perl, a proprer, opendir /proc/self/fd
-    if ( opendir( SELFFDS, "/proc/self/fd" ) ) {
-        foreach $fd ( sort readdir(SELFFDS) ) {
-            $file = readlink( "/proc/self/fd/" . $fd );
-            if ( defined $file && $file =~ m|^$PIVOT| ) {
-                print "Fd ", $fd, " -> ", $file, " ferme\n";
-                open( BURP, "<&=" . $fd );
-                close(BURP);
-            }
-        }
-        closedir(SELFFDS);
-    }
-
-    system("umount -l $PIVOT/proc $PIVOT/sys");
-
-    system("swapon -a");
-
-    system("mount -t devpts devpts /dev/pts");
-
-    system("mv /dev/tty /dev/tty.bqp; ln -s /dev/console /dev/tty");
-    system(
-"mv /sbin/start-stop-daemon /sbin/start-stop-daemon.bqp; cp -a /bin/true /sbin/start-stop-daemon"
-    );
-
-    $ENV{DEBIAN_FRONTEND} = "noninteractive";
-    $ENV{DEBIAN_PRIORITY} = "critical";
-
-    system("echo '[update]'; apt-get -y --force-yes update -y");
-    #system("echo '[upgrade]'; apt-get -y --force-yes upgrade -y");
-    system("echo '[pf-tools]'; apt-get -y --force-yes install pf-tools");
-
-    #system("echo '[debconf]'; apt-get -y --force-yes install debconf");
-    #system("echo '[psmisc]'; apt-get -y --force-yes install psmisc");
-
-    chomp( $name = ( Get_name() )[1] );
-    if ( $name =~ m/^$DEPLOY/ ) {
-        system("mkdir -p $CVSROOT; mount -o nolock,tcp $CVS $CVSROOT");
-    }
-
-    system("umount -l $PIVOT$DISTRIB");
-
-    print STDERR "\n";
-
-    system( "update-config"
-        . ( $QUIETUPDATECONFIG ? " -q"                         : "" )
-        . ( $CVS_BRANCHE       ? " --branche-cvs $CVS_BRANCHE" : "" )
-        . " --noaction" );
-    my $signal_num = $? & 127;
-    if ( $signal_num != 0 && $signal_num != 127 ) {
-        print "Ooops, update-config exited with signal"
-          . $signal_num
-          . ", reexec";
-        system( "update-config"
-            . ( $QUIETUPDATECONFIG ? " -q"                         : "" )
-            . ( $CVS_BRANCHE       ? " --branche-cvs $CVS_BRANCHE" : "" )
-            . " --noaction" );
-    }
-
-    print "\n";
-    if ( opendir( PROC, "/proc" ) ) {
-        foreach $dir ( sort readdir(PROC) ) {
-            if ( $dir =~ /^\d+$/ && $dir ne "1" ) {
-                $exe = readlink( "/proc/" . $dir . "/exe" );
-                if ( defined $exe && $exe ne "" ) {
-                    print "Retardataire ", $exe, " tue\n";
-                    kill( 9, $dir );
-                }
-            }
-        }
-        closedir(PROC);
-    }
-
-    print "\nSync...";
-    system("sync");
-    print "done\n";
-
-    print "\nShell de la derniere chance (TMOUT=15)\n";
-    system("TMOUT=15 sh");
-
-    system("cat /proc/mounts | grep -v -e '[ 	]/[ 	]' > /etc/mtab");
-
-    system("rm -f /var/run/*.pid");
-
-    system("sync; swapoff -a");
-
-    system("rm -f /dead.letter");
-    system(
-"rm -f /sbin/start-stop-daemon; mv /sbin/start-stop-daemon.bqp /sbin/start-stop-daemon"
-    );
-    system("rm -f /dev/tty; mv /dev/tty.bqp /dev/tty");
-
-    if ( -d "/proc/sys/kernel/grsecurity" ) {
-        system("echo 1 >/proc/sys/kernel/grsecurity/grsec_lock");
-    }
-
-    # GRUIK
-    if ( -e "/proc/mconsole" && -d "/lib/tls" ) {
-
-        # uml + tls = segfault
-# http://marc.theaimsgroup.com/?l=user-mode-linux-user&m=110212807330138&w=2
-        system("mv /lib/tls /lib/tls-disabled; touch /lib/tls");
-    }
-
-    system(
-"umount -t nfs -a -l; umount -l $PIVOT $CVSROOT $DISTRIB /boot /var /dev/pts /proc /sys; mount -n -o remount,ro /"
-    );
-
-    exec "/sbin/init" || warn "exec a foire!";
-}
-
-&main;
-
diff -r 6d007d250b23 -r 291abd3f33a1 lib/PFTools/Conf.pm
--- a/lib/PFTools/Conf.pm	Mon Sep 20 17:08:34 2010 +0200
+++ b/lib/PFTools/Conf.pm	Tue Sep 21 09:09:28 2010 +0200
@@ -64,7 +64,7 @@
 
 =head1 INTERFACE
 
-This modules defines the following variables and functions:
+This module defines the following variables and functions:
 
 =head2 $PF_CONFIG
 
@@ -288,8 +288,9 @@
     }
 
     my $vcs_work_dir = $pf_config->{'path'}->{'checkout_dir'}
-        || q{};    # FIXME croak?
-    my $module = $pf_config->{'vcs'}->{'module'} || q{};    # FIXME croak?
+        or croak q{ERROR: Undefined configuration parameter: path.checkout_dir};
+    my $module = $pf_config->{'vcs'}->{'module'}
+        or croak q{ERROR: Undefined configuration parameter: vcs.module};
 
     my $result = $source;
 
@@ -317,6 +318,276 @@
     return $result;
 }
 
+sub Load_conf {
+    my ( $file, $hash_subst, $context, $pf_config ) = @_;
+
+    return unless $file and $hash_subst and $context and $pf_config;
+
+    if ( $context !~ m/^$ALLOWED_PARSING_CONTEXT$/ ) {
+        Abort(
+            $CODE->{'INVALID_CONTEXT'},
+            "Context $context for file $file doesn't match $ALLOWED_PARSING_CONTEXT"
+        );
+    }
+
+    my $parsed = Parser_ini($file);
+
+    if ( $context =~ /^(model|host)$/ ) {
+        if ( defined $parsed->{'hostgroup'}->{'model'} ) {
+            $parsed->{'hostgroup'}->{'__model'} = Load_conf(
+                Get_source(
+                    $parsed->{'hostgroup'}->{'model'},
+                    "", $hash_subst, $pf_config
+                ),
+                $hash_subst,
+                'model',
+                $pf_config
+            );
+        }
+    }
+    else {
+        my $select = ( $context eq 'config' ) ? 'action' : 'type';
+        foreach my $section ( keys %{$parsed} ) {
+            next if ( $section =~ /^__/ );
+            if ( !defined $parsed->{$section}->{$select} ) {
+                Abort(
+                    $CODE->{'UNDEF_KEY'},
+                    "Key $select on section $section from file $file MUST BE defined"
+                );
+            }
+            my $sect_type = $parsed->{$section}->{$select};
+            if ( $sect_type eq 'include' ) {
+
+                # We need to dive into deep ...
+                $parsed->{$section}->{'__content'}
+                    = Load_conf(
+                    Get_source( $section, "", $hash_subst, $pf_config ),
+                    $hash_subst, $context, $pf_config
+                    );
+            }
+        }
+    }
+
+    # Merging if needed
+    $parsed = __Merge_conf_includes( $parsed, $hash_subst, $context );
+
+    # Basic checks
+    foreach my $section ( keys %{$parsed} ) {
+        next if $section =~ /^__/;
+        my $sect_type;
+        if ( $context =~ /^(host|model)$/ ) {
+            $section =~ /^([^:]+)(::(.+))?$/;
+            $sect_type = $1;
+
+            # $iface_name = $3;
+        }
+        else {
+            my $select = ( $context eq 'config' ) ? 'action' : 'type';
+            if ( !defined $parsed->{$section}->{$select} ) {
+                Abort(
+                    $CODE->{'UNDEF_KEY'},
+                    "Key  $select on section $section from file $file MUST BE defined"
+                );
+            }
+            $sect_type = $parsed->{$section}->{$select};
+        }
+        my ( $code, $msg )
+            = Chk_section_struct(
+            $section, $sect_type, $parsed->{$section},
+            $context
+            );
+        if ( $code > 1 ) {
+            Warn(
+                $code,
+                "Errors occur during parsing model from file $file"
+            );
+            Abort( $code, $msg );
+        }
+    }
+
+    return $parsed;
+}
+
+sub Init_GLOBAL_NETCONFIG {
+    my ( $start_file, $hash_subst, $pf_config ) = @_;
+
+    return unless $start_file and $hash_subst;
+
+    if ( !defined $pf_config ) {
+        $pf_config = $PF_CONFIG;
+    }
+
+    my $GLOBAL = { 'SITE' => { 'BY_NAME' => {}, } };
+    foreach my $ip_type ( 'ipv4', 'ipv6' ) {
+        next if !$pf_config->{'features'}->{$ip_type};
+        my $zone_key = ( $ip_type eq 'ipv6' ) ? 'ZONE6' : 'ZONE';
+        my $dhcp_key = ( $ip_type eq 'ipv6' ) ? 'DHCP6' : 'DHCP';
+        $GLOBAL->{$zone_key} = {
+            'BY_NAME' => {},
+            'BY_SITE' => {}
+        };
+        $GLOBAL->{$dhcp_key} = { 'BY_SITE' => {} };
+    }
+
+    my $net_parsed
+        = Load_conf( $start_file, $hash_subst, 'network', $pf_config );
+    my @sortnetkeys = sort { __Sort_net_section( $net_parsed, $a, $b ) }
+        @{ $net_parsed->{'__sections_order'} };
+    foreach my $section (@sortnetkeys) {
+        if ( $net_parsed->{$section}->{'type'} eq 'zone' ) {
+            Add_zone(
+                $start_file, $section, $net_parsed->{$section},
+                $GLOBAL, $pf_config
+            );
+        }
+        elsif ( $net_parsed->{$section}->{'type'} eq 'site' ) {
+            Add_site(
+                $start_file, $section, $net_parsed->{$section},
+                $GLOBAL, $pf_config
+            );
+        }
+        elsif ( $net_parsed->{$section}->{'type'} eq 'network' ) {
+            Add_network(
+                $start_file, $section, $net_parsed->{$section},
+                $GLOBAL, $pf_config
+            );
+        }
+        elsif ( $net_parsed->{$section}->{'type'} eq 'server' ) {
+            my $convert = Build_host_from_server(
+                $section,
+                $net_parsed->{$section}
+            );
+            Add_host(
+                $start_file, 'server', $convert,
+                $GLOBAL, $pf_config
+            );
+        }
+        elsif ( $net_parsed->{$section}->{'type'} eq 'service' ) {
+            my $site_list = Get_site_list( $net_parsed->{$section}, $GLOBAL );
+            foreach my $site ( @{$site_list} ) {
+                my $service_part
+                    = $GLOBAL->{'SITE'}->{'BY_NAME'}->{$site}->{'SERVICE'}
+                    ->{'BY_NAME'};
+                foreach my $host ( @{ $net_parsed->{$section}->{'@host'} } ) {
+                    my $hostfile
+                        = Get_source( $host, "", $hash_subst, $pf_config );
+                    my $host_parsed
+                        = Load_conf(
+                        $hostfile, $hash_subst, 'host',
+                        $pf_config
+                        );
+                    Add_host(
+                        $hostfile, 'host', $host_parsed,
+                        $GLOBAL, $pf_config
+                    );
+                    push @{ $service_part->{$section} }, $host;
+                }
+            }
+        }
+    }
+
+    return $GLOBAL;
+}
+
+=head2 Flush2disk_GLOBAL( $global_config, $pf_config, $flush_file )
+
+Stores $global_config on disk in $flush_file (defaults to
+$pf_config->{'path'}->{'global_struct'}).
+
+Returns a true value on success.
+
+=cut
+
+sub Flush2disk_GLOBAL {
+    my ( $global_config, $pf_config, $flush_file ) = @_;
+
+    return unless $global_config and $pf_config;
+
+    $flush_file ||= $pf_config->{'path'}->{'global_struct'};
+
+    my $ret = eval { store( $global_config, $flush_file ); };
+    if ($EVAL_ERROR) {
+        croak "ERROR: $EVAL_ERROR";
+    }
+    if ( !$ret ) {
+        croak "ERROR: unable to flush global structure to $flush_file";
+    }
+
+    return 1;
+}
+
+=head2 Retrieve_GLOBAL($path_global_file)
+
+Retrieves from $path_global_file and returns the stored $global_config.
+
+=cut
+
+sub Retrieve_GLOBAL {
+    my ($path_global_file) = @_;
+
+    return unless $path_global_file;
+
+    my $ret = eval { retrieve($path_global_file); };
+    if ($EVAL_ERROR) {
+        croak "ERROR: $EVAL_ERROR";
+    }
+    if ( !$ret ) {
+        croak
+            "ERROR: unable to retrieve global structure from $path_global_file";
+    }
+
+    return $ret;
+}
+
+sub Get_config_for_hostname_on_site {
+    my ( $hostname, $site, $hash_subst, $global_config, $pf_config ) = @_;
+
+    # Common configuration file e.g. update-common
+    my $global_host_conf = Load_conf(
+        Get_source(
+            'COMMON:/' . $pf_config->{'path'}->{'common_config'},
+            $hostname, $hash_subst, $pf_config
+        ),
+        $hash_subst,
+        'config',
+        $pf_config
+    );
+    my $hosttype
+        = Get_hosttype_from_hostname( $hostname, $global_config, $site );
+    if ( !defined $hosttype ) {
+        Abort(
+            $CODE->{'UNDEF_KEY'},
+            "Unable to get hosttype from hostname $hostname for getting hosttype configuration file"
+        );
+    }
+
+    # Hosttype configuration file e.g. update-<hosttype>
+    my $hosttype_conf_file
+        = __Get_config_path( $hosttype, $pf_config, $site );
+
+    # Hostname configuration file e.g. update-<hostname>
+    my $hostname_conf_file
+        = __Get_config_path( $hostname, $pf_config, $site );
+
+    foreach my $file ( $hosttype_conf_file, $hostname_conf_file ) {
+        next if !defined $file;
+        my $config = Load_conf( $file, $hash_subst, 'config', $pf_config );
+        foreach my $section ( @{ $config->{'__sections_order'} } ) {
+            push @{ $global_host_conf->{'__sections_order'} }, $section
+                if !defined $global_host_conf->{$section};
+            $global_host_conf->{$section} = $config->{$section};
+        }
+    }
+
+    return $global_host_conf;
+}
+
+=head1 INTERNAL INTERFACE
+
+This module defines the following internal (not exported) variables and functions:
+
+=cut
+
 =head2 __Get_config_path( $host_value, $pf_config, $site ) -- NOT EXPORTED
 
 Given a host value (host name or host type) and a site, returns the path to the
@@ -341,7 +612,7 @@
 
     my @sources = (
         "CONFSITE_${site}:/update-${host_value}",
-        "CONFIG:/update-${host_value}",
+        "CONF:/update-${host_value}",
     );
 
     foreach my $source (@sources) {
@@ -448,96 +719,6 @@
     return $global_parsed;
 }
 
-sub Load_conf {
-    my ( $file, $hash_subst, $context, $pf_config ) = @_;
-
-    return unless $file and $hash_subst and $context and $pf_config;
-
-    if ( $context !~ m/^$ALLOWED_PARSING_CONTEXT$/ ) {
-        Abort(
-            $CODE->{'INVALID_CONTEXT'},
-            "Context $context for file $file doesn't match $ALLOWED_PARSING_CONTEXT"
-        );
-    }
-
-    my $parsed = Parser_ini($file);
-
-    if ( $context =~ /^(model|host)$/ ) {
-        if ( defined $parsed->{'hostgroup'}->{'model'} ) {
-            $parsed->{'hostgroup'}->{'__model'} = Load_conf(
-                Get_source(
-                    $parsed->{'hostgroup'}->{'model'},
-                    "", $hash_subst, $pf_config
-                ),
-                $hash_subst,
-                'model',
-                $pf_config
-            );
-        }
-    }
-    else {
-        my $select = ( $context eq 'config' ) ? 'action' : 'type';
-        foreach my $section ( keys %{$parsed} ) {
-            next if ( $section =~ /^__/ );
-            if ( !defined $parsed->{$section}->{$select} ) {
-                Abort(
-                    $CODE->{'UNDEF_KEY'},
-                    "Key $select on section $section from file $file MUST BE defined"
-                );
-            }
-            my $sect_type = $parsed->{$section}->{$select};
-            if ( $sect_type eq 'include' ) {
-
-                # We need to dive into deep ...
-                $parsed->{$section}->{'__content'}
-                    = Load_conf(
-                    Get_source( $section, "", $hash_subst, $pf_config ),
-                    $hash_subst, $context, $pf_config
-                    );
-            }
-        }
-    }
-
-    # Merging if needed
-    $parsed = __Merge_conf_includes( $parsed, $hash_subst, $context );
-
-    # Basic checks
-    foreach my $section ( keys %{$parsed} ) {
-        next if $section =~ /^__/;
-        my $sect_type;
-        if ( $context =~ /^(host|model)$/ ) {
-            $section =~ /^([^:]+)(::(.+))?$/;
-            $sect_type = $1;
-
-            # $iface_name = $3;
-        }
-        else {
-            my $select = ( $context eq 'config' ) ? 'action' : 'type';
-            if ( !defined $parsed->{$section}->{$select} ) {
-                Abort(
-                    $CODE->{'UNDEF_KEY'},
-                    "Key  $select on section $section from file $file MUST BE defined"
-                );
-            }
-            $sect_type = $parsed->{$section}->{$select};
-        }
-        my ( $code, $msg )
-            = Chk_section_struct(
-            $section, $sect_type, $parsed->{$section},
-            $context
-            );
-        if ( $code > 1 ) {
-            Warn(
-                $code,
-                "Errors occur during parsing model from file $file"
-            );
-            Abort( $code, $msg );
-        }
-    }
-
-    return $parsed;
-}
-
 =head2 __Sort_net_section( $net, $a, $b )
 
 This function is used to sort the network configuration sections by section
@@ -565,167 +746,5 @@
     return $net_prio_for{$a_type} <=> $net_prio_for{$b_type};
 }
 
-sub Init_GLOBAL_NETCONFIG {
-    my ( $start_file, $hash_subst, $pf_config ) = @_;
-
-    return unless $start_file and $hash_subst;
-
-    if ( !defined $pf_config ) {
-        $pf_config = $PF_CONFIG;
-    }
-
-    my $GLOBAL = { 'SITE' => { 'BY_NAME' => {}, } };
-    foreach my $ip_type ( 'ipv4', 'ipv6' ) {
-        next if !$pf_config->{'features'}->{$ip_type};
-        my $zone_key = ( $ip_type eq 'ipv6' ) ? 'ZONE6' : 'ZONE';
-        my $dhcp_key = ( $ip_type eq 'ipv6' ) ? 'DHCP6' : 'DHCP';
-        $GLOBAL->{$zone_key} = {
-            'BY_NAME' => {},
-            'BY_SITE' => {}
-        };
-        $GLOBAL->{$dhcp_key} = { 'BY_SITE' => {} };
-    }
-
-    my $net_parsed
-        = Load_conf( $start_file, $hash_subst, 'network', $pf_config );
-    my @sortnetkeys = sort { __Sort_net_section( $net_parsed, $a, $b ) }
-        @{ $net_parsed->{'__sections_order'} };
-    foreach my $section (@sortnetkeys) {
-        if ( $net_parsed->{$section}->{'type'} eq 'zone' ) {
-            Add_zone(
-                $start_file, $section, $net_parsed->{$section},
-                $GLOBAL, $pf_config
-            );
-        }
-        elsif ( $net_parsed->{$section}->{'type'} eq 'site' ) {
-            Add_site(
-                $start_file, $section, $net_parsed->{$section},
-                $GLOBAL, $pf_config
-            );
-        }
-        elsif ( $net_parsed->{$section}->{'type'} eq 'network' ) {
-            Add_network(
-                $start_file, $section, $net_parsed->{$section},
-                $GLOBAL, $pf_config
-            );
-        }
-        elsif ( $net_parsed->{$section}->{'type'} eq 'server' ) {
-            my $convert = Build_host_from_server(
-                $section,
-                $net_parsed->{$section}
-            );
-            Add_host(
-                $start_file, 'server', $convert,
-                $GLOBAL, $pf_config
-            );
-        }
-        elsif ( $net_parsed->{$section}->{'type'} eq 'service' ) {
-            my $site_list = Get_site_list( $net_parsed->{$section}, $GLOBAL );
-            foreach my $site ( @{$site_list} ) {
-                my $service_part
-                    = $GLOBAL->{'SITE'}->{'BY_NAME'}->{$site}->{'SERVICE'}
-                    ->{'BY_NAME'};
-                foreach my $host ( @{ $net_parsed->{$section}->{'@host'} } ) {
-                    my $hostfile
-                        = Get_source( $host, "", $hash_subst, $pf_config );
-                    my $host_parsed
-                        = Load_conf(
-                        $hostfile, $hash_subst, 'host',
-                        $pf_config
-                        );
-                    Add_host(
-                        $hostfile, 'host', $host_parsed,
-                        $GLOBAL, $pf_config
-                    );
-                    push @{ $service_part->{$section} }, $host;
-                }
-            }
-        }
-    }
-
-    return $GLOBAL;
-}
-
-# store $global_config in $flush_file
-# $flush_file defaults to $pf_config->{'path'}->{'global_struct'}
-sub Flush2disk_GLOBAL {
-    my ( $global_config, $pf_config, $flush_file ) = @_;
-
-    return unless $global_config and $pf_config;
-
-    $flush_file ||= $pf_config->{'path'}->{'global_struct'};
-
-    my $ret = eval { store( $global_config, $flush_file ); };
-    if ($EVAL_ERROR) {
-        croak "ERROR: $EVAL_ERROR";
-    }
-    if ( !$ret ) {
-        croak "ERROR: unable to flush global structure to $flush_file";
-    }
-
-    return 1;
-}
-
-# retrieve and return $global_config from $path_global_file
-sub Retrieve_GLOBAL {
-    my ($path_global_file) = @_;
-
-    return unless $path_global_file;
-
-    my $ret = eval { retrieve($path_global_file); };
-    if ($EVAL_ERROR) {
-        croak "ERROR: $EVAL_ERROR";
-    }
-    if ( !$ret ) {
-        croak
-            "ERROR: unable to retrieve global structure from $path_global_file";
-    }
-
-    return $ret;
-}
-
-sub Get_config_for_hostname_on_site {
-    my ( $hostname, $site, $hash_subst, $global_config, $pf_config ) = @_;
-
-    # Common configuration file e.g. update-common
-    my $global_host_conf = Load_conf(
-        Get_source(
-            'COMMON:/' . $pf_config->{'path'}->{'common_config'},
-            $hostname, $hash_subst, $pf_config
-        ),
-        $hash_subst,
-        'config',
-        $pf_config
-    );
-    my $hosttype
-        = Get_hosttype_from_hostname( $hostname, $global_config, $site );
-    if ( !defined $hosttype ) {
-        Abort(
-            $CODE->{'UNDEF_KEY'},
-            "Unable to get hosttype from hostname $hostname for getting hosttype configuration file"
-        );
-    }
-
-    # Hosttype configuration file e.g. update-<hosttype>
-    my $hosttype_conf_file
-        = __Get_config_path( $hosttype, $pf_config, $site );
-
-    # Hostname configuration file e.g. update-<hostname>
-    my $hostname_conf_file
-        = __Get_config_path( $hostname, $pf_config, $site );
-
-    foreach my $file ( $hosttype_conf_file, $hostname_conf_file ) {
-        next if !defined $file;
-        my $config = Load_conf( $file, $hash_subst, 'config', $pf_config );
-        foreach my $section ( @{ $config->{'__sections_order'} } ) {
-            push @{ $global_host_conf->{'__sections_order'} }, $section
-                if !defined $global_host_conf->{$section};
-            $global_host_conf->{$section} = $config->{$section};
-        }
-    }
-
-    return $global_host_conf;
-}
-
 1;    # Magic true value required at end of module
 
diff -r 6d007d250b23 -r 291abd3f33a1 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Mon Sep 20 17:08:34 2010 +0200
+++ b/lib/PFTools/Conf/Host.pm	Tue Sep 21 09:09:28 2010 +0200
@@ -164,11 +164,12 @@
     my ( $hostname_model, $hostnum, $hostnode, $site_prefix, $ref_host ) = @_;
     my ( $hostname, $index );
 
-    $hostname = $hostname_model;
-    $index
-        = __Get_hostnumber_from_model( $hostname_model, $hostnum, $hostnode );
-    $hostname =~ s/(%*)(_*)$/$index/;
-    $hostname = $site_prefix . $hostname
+    $hostname   = $hostname_model;
+    $index      = __Get_hostnumber_from_model(
+        $hostname_model, $hostnum, $hostnode 
+    );
+    $hostname   =~ s/(%*)(_*)$/$index/;
+    $hostname   = $site_prefix . $hostname
         if ( $ref_host->{'prefix'} && $ref_host->{'prefix'} eq 'true' );
     return $hostname;
 }
@@ -224,8 +225,7 @@
                 . $ipstart );
     }
     if ($hostnum) {
-        my $add
-            = ($hostnode)
+        my $add = ($hostnode)
             ? ( $hostnum * $nodes ) + $hostnode
             : $hostnum;
         $ip = $ip + $add;
@@ -257,27 +257,21 @@
         = @_;
 
     my $prefix = $vlan_block->prefix();
-    my $realip
-        = __Get_ip_from_hostindex( $vlan_block, $ipstart, $hostnum, $hostnode,
-        $nodes );
+    my $realip = __Get_ip_from_hostindex(
+        $vlan_block, $ipstart, $hostnum,
+        $hostnode, $nodes
+    );
     my $host_addr_site = $ref_site->{'HOST'}->{'BY_ADDR'};
-    if ( defined $host_addr_site->{ $realip->addr() } ) {
+    if ( defined $host_addr_site->{ $realip->cidr() } ) {
         Abort( $CODE->{'DUPLICATE_VALUE'},
-                  "IP "
-                . $realip->addr()
-                . " is already in use by host "
-                . $host_addr_site->{ $realip->cidr() }
-                . " on site "
-                . $site );
+            "IP $realip->addr() is already in use by host "
+            . $host_addr_site->{ $realip->cidr() } . " on site $site"
+        );
     }
     if ( !$vlan_block->contains($realip) ) {
         Abort( $CODE->{'INVALID_VALUE'},
-                  "IP of type " 
-                . $ip_type
-                . " is out of "
-                . $vlan_block->cidr()
-                . " on site "
-                . $site );
+            "IP of type $ip_type is out of $vlan_block->cidr() on site $site"
+        );
     }
     return $realip;
 }
@@ -506,18 +500,13 @@
     foreach my $ip_type ( 'ipv4', 'ipv6' ) {
         next if ( !$pf_config->{'features'}->{$ip_type} );
         my $suffix = ( $ip_type eq 'ipv6' ) ? '6' : '';
-        my $netblock = Get_netblock_from_vlan( $ip_type,
-            $network_site->{'BY_NAME'}->{$vlan} );
-        if ( !defined $netblock ) {
+        my $netblock = Get_netblock_from_vlan(
+            $ip_type, $network_site->{'BY_NAME'}->{$vlan} );
+        unless( $netblock ) {
             Abort( $CODE->{'INVALID_VALUE'},
-                      "Unable to retrieve network block of type " 
-                    . $ip_type
-                    . " for vlan "
-                    . $vlan
-                    . " on site "
-                    . $site
-                    . " for host "
-                    . $hostname );
+                "Unable to retrieve network block of type " 
+                . $ip_type . " for vlan " . $vlan
+                . " on site " . $site . " for host " . $hostname );
         }
         my $realip;
         if ( $ref_host->{$iface_section}->{ $ip_type . '.' . $host_number } )
diff -r 6d007d250b23 -r 291abd3f33a1 lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm	Mon Sep 20 17:08:34 2010 +0200
+++ b/lib/PFTools/Conf/Syntax.pm	Tue Sep 21 09:09:28 2010 +0200
@@ -1,6 +1,4 @@
 package PFTools::Conf::Syntax;
-##
-##  $Id$
 ##
 ##  Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
 ##
@@ -186,24 +184,22 @@
             'MANDATORY_KEYS' => [ 'network', 'site' ],
             'comment'        => 'undefined',
             'tag'            => '\d{1,4}',
-            'network'        => '([\d]{1,3}\.){3}[\d]{1,3}(\/\d+)?',
+            'network'        => '([\d]{1,3}\.){3}[\d]{1,3}\/\d+',
             'network6'       => 'undefined',
-            'netmask'        => '(/\d{2}|([\d]{1,3}\.){3}[\d]{1,3})',
-            'netmask6'       => 'undefined',
             'scope'          => '(private|public)',
             'site'           => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
             'gateway'        => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
             'gateway6'       => 'undefined'
         },
         'server' => {
-            'MANDATORY_KEYS' => [ 'site', 'number', ],
-            'comment'        => 'undefined',
-            'site'           => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
-            'number'         => '\d+',
-            'ipv4'      => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
-            'ipv6'      => 'undefined',
-            'alias'     => '[a-z][a-z0-9\-]+[a-z0-9]',
-            'shortname' => '[a-z][a-z0-9\-]+[a-z0-9]'
+            'MANDATORY_KEYS'    => [ 'site', 'number', ],
+            'comment'           => 'undefined',
+            'site'              => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
+            'number'            => '\d+',
+            'ipv4'              => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
+            'ipv6'              => 'undefined',
+            'alias'             => '[a-z][a-z0-9\-]+[a-z0-9]',
+            'shortname'         => '[a-z][a-z0-9\-]+[a-z0-9]'
         },
         'service' => {
             'MANDATORY_KEYS' => [ 'site', '@host' ],
diff -r 6d007d250b23 -r 291abd3f33a1 lib/PFTools/Net.pm
--- a/lib/PFTools/Net.pm	Mon Sep 20 17:08:34 2010 +0200
+++ b/lib/PFTools/Net.pm	Tue Sep 21 09:09:28 2010 +0200
@@ -25,13 +25,14 @@
 use strict;
 use warnings;
 
+use Carp;
 use English qw( -no_match_vars );    # Avoids regex performance penalty
 use Exporter;
 use Net::DNS;
 use NetAddr::IP;
 
 use PFTools::Logger;
-use PFTools::Structqueries;
+#use PFTools::Structqueries;
 
 our @ISA = ('Exporter');
 
@@ -41,11 +42,6 @@
 );
 
 our @EXPORT_OK = qw();
-
-#########################################################################
-### Rewrite with new syntax
-### Enhancement : creating DNS entries when adding network or hosts
-### Enhancement : creating DHCP entries when adding hosts
 
 #########################################################################
 #
@@ -64,32 +60,19 @@
     my ( $type, $net_hash ) = @_;
 
     my $suffix = ( $type eq 'ipv6' ) ? '6' : '';
-    my @net_def;
-    my $msg;
-    if ( $net_hash->{ 'network' . $suffix } =~ /\/\d+$/ ) {
-        @net_def = ( $net_hash->{ 'network' . $suffix } );
-        $msg
-            = "Invalid network "
-            . $net_hash->{ 'network' . $suffix } . " "
-            . $type
-            . " defintion";
+    my $net_def = ( $net_hash->{ 'network' . $suffix } );
+    my $block;
+    if ( $net_hash->{ 'network' . $suffix } !~ m{\/[\d]+} ) {
+        unless ( $net_hash->{ 'netmask' } ) {
+            croak q{ERROR: Unable to retrieve netmask};
+        }
+        $block = new NetAddr::IP( $net_def, $net_hash->{ 'netmask' } );    
     }
     else {
-        @net_def = (
-            $net_hash->{ 'network' . $suffix },
-            $net_hash->{ 'netmask' . $suffix }
-        );
-        $msg
-            = "Invalid network "
-            . $net_hash->{ 'network' . $suffix }
-            . " and/or netmask "
-            . $net_hash->{ 'netmask' . $suffix } . " "
-            . $type
-            . " defintion";
+        $block = new NetAddr::IP( $net_def );
     }
-    my $block = new NetAddr::IP(@net_def);
-    if ( !defined $block ) {
-        Abort( $CODE->{'UNDEF_KEY'}, $msg );
+    unless( $block ) {
+        croak qq{ERROR: Invalid netblock definition $net_def};
     }
     return $block;
 }
@@ -101,15 +84,13 @@
     my $res   = Net::DNS::Resolver->new;
     my $query = $res->search($hostname);
 
-    if ($query) {
-        foreach my $rr ( $query->answer ) {
-            next unless $rr->type eq "A";
-            push( @{$resolved}, $rr->address );
-        }
+    unless( $query ) {
+        carp qq{ERROR: Query failed: $res->errorstring};
+        return;
     }
-    else {
-        Warn( $CODE->{'BIND_QUERY'}, "Query failed: " . $res->errorstring );
-        return undef;
+    foreach my $rr ( $query->answer ) {
+        next unless $rr->type eq "A";
+        push( @{$resolved}, $rr->address );
     }
     return $resolved;
 }
diff -r 6d007d250b23 -r 291abd3f33a1 t/12.storable.t
--- a/t/12.storable.t	Mon Sep 20 17:08:34 2010 +0200
+++ b/t/12.storable.t	Tue Sep 21 09:09:28 2010 +0200
@@ -51,6 +51,7 @@
 $result = Flush2disk_GLOBAL($global_config, $pf_config, $store2);
 ok $result && -s $store2
     => 'Stores something in explicit path';
+unlink $store2;
 
 $result = Flush2disk_GLOBAL($global_config, {}, $store2);
 ok $result && -s $store2
@@ -75,8 +76,10 @@
 $result = Retrieve_GLOBAL($store1);
 is_deeply $result, $global_config
     => 'Store1 retrieval';
+unlink $store1;
 
 $result = Retrieve_GLOBAL($store2);
 is_deeply $result, $global_config
     => 'Store2 retrieval';
+unlink $store2;
 
diff -r 6d007d250b23 -r 291abd3f33a1 t/13.conf.t
--- a/t/13.conf.t	Mon Sep 20 17:08:34 2010 +0200
+++ b/t/13.conf.t	Tue Sep 21 09:09:28 2010 +0200
@@ -4,6 +4,10 @@
 use warnings;
 
 use English qw( -no_match_vars );    # Avoids regex performance penalty
+use File::Copy;
+use File::Path qw( make_path remove_tree );
+use Hash::Merge::Simple qw( clone_merge merge );
+use IO::File;
 use Test::Exception;
 use Test::More qw( no_plan );
 
@@ -89,7 +93,6 @@
 ok ref $parsed_configuration eq 'HASH' && keys %{$parsed_configuration}
     => 'Returns a non-empty hashref';
 
-use Hash::Merge::Simple qw( merge );
 my $expected_configuration = merge( $default_pf_config, $test_configuration );
 is_deeply $parsed_configuration, $expected_configuration
     => 'Correctly merges with the default configuration'
@@ -182,12 +185,27 @@
     => 'Returns empty string if $text is empty';
 
 throws_ok { Get_source( q{foo bar baz}, undef, q{non-hashref $hash_subst} ) }
-    qr{ \A ERROR: [ ] Invalid [ ] non-href [ ] [\$] hash_subst }xms
+qr{ \A ERROR: [ ] Invalid [ ] non-href [ ] [\$] hash_subst }xms
     => q{Dies on non-hashref $hash_subst};
 
-throws_ok { Get_source( q{foo bar baz}, undef, undef, q{non-hashref $pf_config} ) }
-    qr{ \A ERROR: [ ] Invalid [ ] non-href [ ] [\$] pf_config }xms
+throws_ok {
+    Get_source( q{foo bar baz}, undef, undef, q{non-hashref $pf_config} );
+}
+qr{ \A ERROR: [ ] Invalid [ ] non-href [ ] [\$] pf_config }xms
     => q{Dies on non-hashref $pf_config};
+
+throws_ok {
+    Get_source( q{foo bar baz}, undef, undef, { missing => 'checkout_dir' } );
+}
+qr{ \A ERROR: [ ] Undefined [ ] configuration [ ] parameter: [ ] path.checkout_dir}xms
+    => q{Dies on invalid $pf_config (no path.checkout_dir)};
+
+throws_ok {
+    Get_source( q{foo bar baz}, undef, undef,
+        { path => { checkout_dir => '/tmp/co_dir' } } );
+}
+qr{ \A ERROR: [ ] Undefined [ ] configuration [ ] parameter: [ ] vcs.module}xms
+    => q{Dies on invalid $pf_config (no vcs.module)};
 
 is Get_source( q{MODSITE_FOOBAR:/my/path/to/file} ),
     q{/var/lib/cvsguest/config/SITE/FOOBAR/MODEL/my/path/to/file}
@@ -264,8 +282,44 @@
     qr{ \A ERROR: }xms
     => q{Dies if non-href $pf_config};
 
-ok !defined PFTools::Conf::__Get_config_path( 'unknown-host', {}, 'unknown-site' )
+my $pf_config_overrides = {
+    path => {
+        status_dir => '/tmp/pftools-conf-test/status_dir',
+        checkout_dir => '/tmp/pftools-conf-test/checkout_dir',
+    },
+    location => {
+        site => 'test-site',
+    },
+};
+my $pf_config = clone_merge( $default_pf_config, $pf_config_overrides );
+ok !defined PFTools::Conf::__Get_config_path( 'unknown-host', $pf_config, 'unknown-site' )
     => q{Returns undef if no matching file found};
 
-diag( 'FIXME: add the two good cases!' );
+make_path( qw(
+    /tmp/pftools-conf-test/checkout_dir/config/SITE/test-site/CONFIG
+    /tmp/pftools-conf-test/checkout_dir/config/CONFIG
+) );
+my $site_config_file = q{/tmp/pftools-conf-test/checkout_dir/config/SITE/test-site/CONFIG/update-mytest};
+$fh = IO::File->new( $site_config_file, '>' )
+    or die "open $site_config_file: $OS_ERROR";
+$fh->print( <<'EOT' )
+[mytest%%]
+fake = value
+foo = bar
+EOT
+    or die "print $site_config_file: $OS_ERROR";
+$fh->close
+    or die "close $site_config_file: $OS_ERROR";
 
+is PFTools::Conf::__Get_config_path( 'mytest', $pf_config, 'test-site' ),
+    $site_config_file
+    => q{Returns the site specific file if it exists};
+
+my $global_config_file = q{/tmp/pftools-conf-test/checkout_dir/config/CONFIG/update-mytest};
+move( $site_config_file, $global_config_file );
+is PFTools::Conf::__Get_config_path( 'mytest', $pf_config, 'test-site' ),
+    $global_config_file
+    => q{Returns the global file if no site-specific file found};
+unlink $global_config_file;
+remove_tree( qw( /tmp/pftools-conf-test/ ) );
+



More information about the pf-tools-commits mailing list