pf-tools commit: r874 [ccaillet-guest] - in /branches/next-gen: ./ debian/ lib/PFTools/ lib/PFTools/Update/ tools/

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Sep 6 09:01:33 UTC 2010


Author: ccaillet-guest
Date: Mon Sep  6 09:01:21 2010
New Revision: 874

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=874
Log:
* new upstream release
* lib/PFTools/Conf.pm
  - correctly handle hosttype into Init_SUBST
* lib/PFTools/Update/*.pm
  - fix Installpkg_depends
  - fix dirname to avoid empty string return
  - fix some *_depends for not adding "." as a dependancy
  - fix Removedir and Removefile for correctly handle diff option
* lib/PFTools/Utils.pm
  - correctly handle pf_config_file into Init_TOOLS
  - adding hosttype parameter where calling Init_SUBST function 
  - comment the check for checking if a depend exists

Modified:
    branches/next-gen/TODO
    branches/next-gen/debian/changelog
    branches/next-gen/lib/PFTools/Conf.pm
    branches/next-gen/lib/PFTools/Update/Addfile.pm
    branches/next-gen/lib/PFTools/Update/Common.pm
    branches/next-gen/lib/PFTools/Update/Installpkg.pm
    branches/next-gen/lib/PFTools/Update/Mkdir.pm
    branches/next-gen/lib/PFTools/Update/Removedir.pm
    branches/next-gen/lib/PFTools/Update/Removefile.pm
    branches/next-gen/lib/PFTools/Utils.pm
    branches/next-gen/tools/Translate_old_config

Modified: branches/next-gen/TODO
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/TODO?rev=874&op=diff
==============================================================================
--- branches/next-gen/TODO (original)
+++ branches/next-gen/TODO Mon Sep  6 09:01:21 2010
@@ -2,10 +2,20 @@
 |/-Difficulty: Easy/Medium/Hard
 ||
 MH implementing scope for network when building zones
-UH implementing SVN commands into VCS.pm
+    - the IPs of hosts which are into a private scope network appear only into the site
+    where there are defined
+    - the IPs of hosts which are into a public scope network appear on all sites
 LH finishing IPv6 implementation and testing it for zones and DHCP handlers
 LH implementing strong authentication like X509 when accessing to repository instead
    of hostname vlaue, with CA and all functions for adding or revoking new hosts
+NH definition of group actions e.g. reloading a server like postfix or apache only once
+MH creating into the sort funtion for update-* file the actiongroup trigger which
+   check the dependances validity with the following rules :
+    - a section is able to depend of another section into the same actiongroup
+    - a section is able to depend of an actiongroup which is different of his own
+    - an actiongroup is able to depend of another actiongroup
+	- abort if a section into actiongroup A is depending of a section into actiongroup B
+    - abort if A -> B -> C -> A where -> is a dependancy link
 LH adding a keyring for handling SSH keys for servers
 LH specifying and rewriting code with devel rules like fix indent and PERL best practices
 LH adding a mechanism of zone delegation inside a zone e.g. between ROOT and EDGE sites
@@ -13,7 +23,6 @@
    on a given site (including empty range into this vlan)
 LH alias definition like CONFIG: in pf-tools.conf file for using in Get_source
 LH implementing a web interface for building pf-tools configurator
-NH definition of group actions e.g. reloading a server like postfix or apache only once
 NM permit interface with no IP in promisc mode (ex: for probing hosts)
 NH implementing monitoring as defined in hostfile-syntax with PFTools::Monitoring
 

Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=874&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Mon Sep  6 09:01:21 2010
@@ -1,3 +1,21 @@
+pf-tools (1.0-1) unstable; urgency=low
+
+  * new upstream release
+  [Christophe Caillet]
+  * lib/PFTools/Conf.pm
+    - correctly handle hosttype into Init_SUBST
+  * lib/PFTools/Update/*.pm
+    - fix Installpkg_depends
+    - fix dirname to avoid empty string return
+    - fix some *_depends for not adding "." as a dependancy
+    - fix Removedir and Removefile for correctly handle diff option
+  * lib/PFTools/Utils.pm
+    - correctly handle pf_config_file into Init_TOOLS
+    - adding hosttype parameter where calling Init_SUBST function 
+    - comment the check for checking if a depend exists
+
+ -- Christophe Caillet <quadchris at free.fr>  Mon, 06 Sep 2010 08:29:45 +0200
+
 pf-tools (0.99.99-1) unstable; urgency=low
 
   * RC2 : validation

Modified: branches/next-gen/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Conf.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Conf.pm (original)
+++ branches/next-gen/lib/PFTools/Conf.pm Mon Sep  6 09:01:21 2010
@@ -165,8 +165,8 @@
 	return $PF_CONFIG;
 }
 
-sub Init_SUBST (;$$$) {
-	my ( $host, $pf_config, $domain ) = @_ ;
+sub Init_SUBST (;$$$$) {
+	my ( $host, $hosttype, $pf_config, $domain ) = @_ ;
 	my $host_regex; my $ref_subst = {};
 
 	if ( ! defined $pf_config ) {
@@ -198,7 +198,7 @@
 	unless ($ref_subst->{'HOSTNAME'} =~ m/$host_regex/) {
 	    Abort( $CODE->{'OPEN'}, "Init_SUBST failed: invalid hostname $ref_subst->{'HOSTNAME'}" );
 	}
-	$ref_subst->{'HOSTTYPE'}	= $+{HOSTTYPE} ;
+	$ref_subst->{'HOSTTYPE'}	= $hosttype || $+{HOSTTYPE} ;
 	$ref_subst->{'HOSTDIGITS'}	= $+{HOSTDIGITS} ;
 	$ref_subst->{'HOSTCLUSTER'}	= $+{HOSTDIGITS}.$+{HOSTNODEINDEX} if ( defined $+{HOSTDIGITS} && defined $+{HOSTNODEINDEX} );
 	$ref_subst->{'HOSTNODEINDEX'}	= $+{HOSTNODEINDEX} || "" ;

Modified: branches/next-gen/lib/PFTools/Update/Addfile.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Addfile.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addfile.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Addfile.pm Mon Sep  6 09:01:21 2010
@@ -44,8 +44,9 @@
     my ( $ref_section, $dest, $options ) = @_;
 
     while ( $dest ne "/" && $dest ne "." ) {
-		$ref_section->{'depends'} .= " ".dirname ( $dest );
-		$dest = dirname ( $dest );
+		my $new_dest = dirname ( $dest );
+		$ref_section->{'depends'} .= " ".$new_dest if ( $new_dest ne "." && $new_dest ne "/" );
+		$dest = $new_dest;
     }
 }
 
@@ -108,7 +109,12 @@
 			Log("(action needed)");
 		}
 		if ( $options->{'diff'} ) {
-			print diff ( $dest, $tmp, { STYLE => "Unified" } );
+			if ( ! -e $dest ) {
+				print diff ( [], $tmp, { STYLE => "Unified" } );
+			}
+			else {
+				print diff ( $dest, $tmp, { STYLE => "Unified" } );
+			}
 		}
 		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
 		Do_before_change ( $ref_section, $options, $hash_subst ) && return 1;

Modified: branches/next-gen/lib/PFTools/Update/Common.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Common.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Common.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Common.pm Mon Sep  6 09:01:21 2010
@@ -133,6 +133,7 @@
 
     if ( $file =~ m|/| ) {
 		$file =~ s|^(.*)/[^/]+/?$|$1|;
+		$file = "." if ( $file =~ /^\s*$/ );
     }
     else {
 		$file = '.';

Modified: branches/next-gen/lib/PFTools/Update/Installpkg.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Installpkg.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Installpkg.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Installpkg.pm Mon Sep  6 09:01:21 2010
@@ -53,21 +53,21 @@
 sub Installpkg_depends ($$$) {
     my ( $ref_section, $dest, $options ) = @_;
 
-    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+	$options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
 	my $deps = Get_pkg_depends ( $options->{'pkg_type'}, $dest ) ;
 	if ( ! defined $deps ) {
 		Warn ( $CODE->{'OPEN'}, "Unable to get depends for package ".$dest ) ;
 		return 1;
 	}
 	else {
-		$ref_section->{'depends'} = $dest ;
+		$ref_section->{'depends'} = $deps ;
 	}
 }
 
 sub Installpkg_action ($$$$$) {
     my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
-    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+	$options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
 	my $installed_version;
 	my $available_version;
 	my $specified_version = 0;

Modified: branches/next-gen/lib/PFTools/Update/Mkdir.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Mkdir.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Mkdir.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Mkdir.pm Mon Sep  6 09:01:21 2010
@@ -45,8 +45,9 @@
 	my ( $ref_section, $dest, $options ) = @_;
 
 	while ( $dest ne "/" && $dest ne "." ) {
-		$ref_section->{'depends'} .= " " . dirname($dest);
-		$dest = dirname($dest);
+		my $new_dest = dirname ( $dest );
+		$ref_section->{'depends'} .= " " . $new_dest if ( $new_dest ne "/" || $new_dest ne "." );
+		$dest = $new_dest;
 	}
 }
 

Modified: branches/next-gen/lib/PFTools/Update/Removedir.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Removedir.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Removedir.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Removedir.pm Mon Sep  6 09:01:21 2010
@@ -40,7 +40,7 @@
     my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
     my $cmp = 0;
-	if ( -e $dest && !-d $dest ) {
+	if ( ! $options->{'simul'} && -e $dest && !-d $dest ) {
 		Warn( $CODE->{'OPEN'},
 			"Destination ".$dest." MUST BE a directory" );
 		return 1;

Modified: branches/next-gen/lib/PFTools/Update/Removefile.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Removefile.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Removefile.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Removefile.pm Mon Sep  6 09:01:21 2010
@@ -41,7 +41,7 @@
 	my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
 	my $cmp = 0;
-	if ( ! -f $dest ) {
+	if ( ! -f $dest && ! $options->{'simul'} ) {
 		Warn( $CODE->{'OPEN'},
 			"Destination ".$dest. " MUST BE a file" );
 		return 1;
@@ -53,7 +53,7 @@
 		}
 		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
 		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
-		if ( !$options->{'simul'} ) {
+		if ( ! $options->{'simul'} ) {
 			Do_moveold ( $dest, $options );
 		}
 	}

Modified: branches/next-gen/lib/PFTools/Utils.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Utils.pm?rev=874&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Utils.pm (original)
+++ branches/next-gen/lib/PFTools/Utils.pm Mon Sep  6 09:01:21 2010
@@ -68,29 +68,27 @@
 #########################################################################
 # Functions
 
-sub Init_TOOLS ($$$;$) {
+sub Init_TOOLS ($;$$$) {
 	my ( $hostname, $pf_config_file, $global_store_file, $reload ) = @_;
 	my ( $pf_config, $global_struct );
 
-	if ( $pf_config_file ne '' ) {
+	if ( $pf_config_file && $pf_config_file ne '' ) {
 		if ( ! -e $pf_config_file ) {
 			Abort ( $CODE->{'OPEN'},
 				"Unable to open configuration file ".$pf_config_file." : no such file or directory" );
 		}
 		$pf_config = Init_PF_CONFIG ( $pf_config_file );
 	}
+	elsif ( -e '/etc/pf-tools.conf' ) {
+		$pf_config = Init_PF_CONFIG ( '/etc/pf-tools.conf' );
+	}
 	else {
-		if ( -e '/etc/pf-tools.conf' ) {
-			$pf_config = Init_PF_CONFIG ( '/etc/pf-tools.conf' );
-		}
-		else {
-			$pf_config = Init_PF_CONFIG ();
-		}
+		$pf_config = Init_PF_CONFIG ();
 	}
 
 	$global_store_file	= $pf_config->{'path'}->{'global_struct'} if ( $global_store_file eq '' );
 	if ( ! -e $global_store_file || ( defined $reload && $reload ) ) {
-		print "Forcing reload or no storable available\n";
+# 		print "Forcing reload or no storable available\n";
 		my $source = Get_source ( 'COMMON:/'.$pf_config->{'path'}->{'start_file'}, $hostname, {}, $pf_config );
 		if ( ! -e $source ) {
 			Set_deferredlog ();
@@ -497,7 +495,8 @@
 				"Unable top resolve from configuration structure which is not defined" );
 			return undef;
 	}
-	my $subst		= Init_SUBST ( $hostname, $pf_config );
+	my $hosttype	= Get_hosttype_from_hostname ( $hostname, $global_config, $site );
+	my $subst		= Init_SUBST ( $hostname, $hosttype, $pf_config );
 	my $host_props	= Get_host_config_from_CONFIG ( $hostname, $global_config, $site );
 
 	unless ( open ( SRC, $input_file ) ) {
@@ -812,8 +811,8 @@
 		) {
 			$host_config->{$section}->{'doing'} = 1;
 			Get_depends_for_action ( $host_config->{$section}->{'action'}, $host_config->{$section}, $section, $options );
-			if ( defined( $host_config->{$section}->{'depends'} ) ) {
-				my $depends;
+			if ( defined( $host_config->{$section}->{'depends'} ) && $host_config->{$section}->{'depends'} =~ /\S+/ ) {
+				my $depends = [];
 				my @dependsraw = split( /\s+/, $host_config->{$section}->{'depends'} );
 				foreach my $depend (@dependsraw) {
 					if ( defined($depend) && $depend ne "" && defined( $host_config->{$depend} ) ) {
@@ -830,10 +829,10 @@
 							FlushLog();
 						}
 					}
-					else {
-						Abort ( $CODE->{'UNDEF_KEY'},
-							"[".$section."] depends on [".$depend."] which is not defined" );
-					}
+# 					else {
+# 						Abort ( $CODE->{'UNDEF_KEY'},
+# 							"[".$section."] depends on [".$depend."] which is not defined" );
+# 					}
 				}
 				if ( scalar @{$depends} ) {
 					Log ( "<".$section."> ".join( ' ', @{$depends} ) );
@@ -864,7 +863,8 @@
 			"Unable to checkout configuration from VCS system" );
 	}
 	Unset_deferredlog ();
-	my $hash_subst	= Init_SUBST ( $hostname, $pf_config );
+	my $hosttype	= Get_hosttype_from_hostname ( $hostname, $global_config, $site );
+	my $hash_subst	= Init_SUBST ( $hostname, $hosttype, $pf_config );
 	my $host_props	= Get_host_config_from_CONFIG ( $hostname, $global_config, $site );
 	if ( ! defined $host_props ) {
 		Abort ( $CODE->{'UNDEF_KEY'},

Modified: branches/next-gen/tools/Translate_old_config
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/tools/Translate_old_config?rev=874&op=diff
==============================================================================
--- branches/next-gen/tools/Translate_old_config (original)
+++ branches/next-gen/tools/Translate_old_config Mon Sep  6 09:01:21 2010
@@ -122,7 +122,7 @@
 			next if ( $key =~ /^__/ );
 			print OUTPUT "\t".$key."\t= ".$trans->{$section}->{$key}."\n";
 		}
-		print "\n";
+		print OUTPUT "\n";
 	}
 }
 else {




More information about the pf-tools-commits mailing list