pf-tools commit: r842 [ccaillet-guest] - in /branches/next-gen/lib/PFTools: Parser.pm Update/Addfile.pm Update/Addlink.pm Update/Common.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Aug 25 07:51:30 UTC 2010


Author: ccaillet-guest
Date: Wed Aug 25 07:51:21 2010
New Revision: 842

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=842
Log:
FIX: misc fixes which validate Addfile.pm and Addlink.pm

Modified:
    branches/next-gen/lib/PFTools/Parser.pm
    branches/next-gen/lib/PFTools/Update/Addfile.pm
    branches/next-gen/lib/PFTools/Update/Addlink.pm
    branches/next-gen/lib/PFTools/Update/Common.pm

Modified: branches/next-gen/lib/PFTools/Parser.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Parser.pm?rev=842&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Parser.pm (original)
+++ branches/next-gen/lib/PFTools/Parser.pm Wed Aug 25 07:51:21 2010
@@ -78,14 +78,15 @@
 sub Subst_vars ($$) {
     my ( $str, $hash_subst ) = @_;
 
+	$str =~ s/%([^\%]+)%/$hash_subst->{$1}/gm;
 #     while ( $str =~ s/%([^%\s]*)%/$SUBST{"$1"}/ ) { }
-    foreach my $elt ( split ( '%', $str ) ) {
-        next if ( $elt eq '' );
-        if ( defined $hash_subst->{$elt} ) {
-            $str =~ s/%$elt%/$hash_subst->{$elt}/;
-        }
-    }
-    return ($str);
+#     foreach my $elt ( split ( '%', $str ) ) {
+#         next if ( $elt eq '' );
+#         if ( defined $hash_subst->{$elt} ) {
+#             $str =~ s/%$elt%/$hash_subst->{$elt}/;
+#         }
+#     }
+    return $str;
 }
 
 my $PFTOOLS_VARS = {};

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=842&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addfile.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Addfile.pm Wed Aug 25 07:51:21 2010
@@ -37,6 +37,7 @@
 use File::Copy;
 use Text::Diff;
 use PFTools::Logger;
+use PFTools::Parser;
 use PFTools::Conf;
 use PFTools::Update::Common;
 
@@ -44,8 +45,8 @@
     my ( $ref_section, $dest, $options ) = @_;
 
     while ( $dest ne "/" && $dest ne "." ) {
-		$ref_section->{'depends'} .= " " . dirname($dest);
-		$dest = dirname($dest);
+		$ref_section->{'depends'} .= " ".dirname ( $dest );
+		$dest = dirname ( $dest );
     }
 }
 
@@ -60,7 +61,7 @@
 		unlink ($source);
 		my $splitsource;
 		foreach $splitsource ( split( ' ', $ref_section->{'source'} ) ) {
-			$splitsource = Get_source( Subst_vars ( $splitsource, $hash_subst ), $options->{'host'}, $hash_subst );
+			$splitsource = Get_source ( Subst_vars ( $splitsource, $hash_subst ), $options->{'host'}, $hash_subst );
 			if ( ! -f $splitsource ) {
 				Warn( $CODE->{'OPEN'}, "Unable to open ".$splitsource );
 				return 1;
@@ -73,11 +74,15 @@
 		}
 	}
 	else {
-		$source = Get_source( Subst_vars( $ref_section->{'source'}, $hash_subst ), $hash_subst );
+		$source = Get_source( Subst_vars( $ref_section->{'source'}, $hash_subst ), $options->{'host'}, $hash_subst );
 	}
 
+	if ( ! -e $source ) {
+		Warn ( $CODE->{'OPEN'}, $source." : no such file or directory" );
+		return 1;
+	}
 	$hash_subst->{'SOURCE'}			= $source;
-	$tmp							= Get_tmp_dest($dest);
+	$tmp							= Get_tmp_dest ($dest);
 	$hash_subst->{'DESTINATION'}	= $tmp;
 	if ( defined( $ref_section->{'filter'} ) ) {
 		my $filter = Subst_vars( $ref_section->{'filter'}, $hash_subst );
@@ -109,28 +114,23 @@
 		}
 		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'} ) {
 			# Fuck dpkg conffiles
-			if ( $options->{'noaction'}
-				&& -e $dest
-				&& ! -e $dest.'.dpkg-dist'
-			) {
+			if ( $options->{'noaction'} && -e $dest && ! -e $dest.'.dpkg-dist' ) {
 				copy ( $dest, $dest.'.dpkg-dist' );
-				Do_moveold( $dest, $options );
-				if ( Mk_dest_dir($dest)
-					|| ! copy ( $tmp, $dest )
-				) {
-					Warn( $CODE->{'OPEN'},
-						"Unable to copy file " . $tmp . " to " . $dest );
-					return 1;
-				}
 			}
+			Do_moveold( $dest, $options );
+			if ( Mk_dest_dir ( $dest ) || ! copy ( $tmp, $dest ) ) {
+				Warn( $CODE->{'OPEN'},
+					"Unable to copy file ".$tmp." to ".$dest );
+				return 1;
+			}
+			Do_chownmod( $ref_section, $dest, $options );
 		}
-	}
-	Do_chownmod( $ref_section, $dest, $options );
-	if ( $diff ) {
-		Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
-		Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
+		if ( $diff ) {
+			Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
+			Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
+		}
     }
     return 0;
 };

Modified: branches/next-gen/lib/PFTools/Update/Addlink.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Addlink.pm?rev=842&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addlink.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Addlink.pm Wed Aug 25 07:51:21 2010
@@ -33,6 +33,7 @@
 
 our @EXPORT_OK = qw();
 
+use PFTools::Parser;
 use PFTools::Logger;
 use PFTools::Conf;
 use PFTools::Update::Common;
@@ -51,9 +52,11 @@
 
 	$hash_subst->{'SECTIONNAME'} = $dest;
 	my $source = Subst_vars( $ref_section->{'source'}, $hash_subst );
-	while ( $source ne "/" && $source ne "." ) {
-		$ref_section->{'depends'} .= " " . dirname($source);
-		$source = dirname($source);
+	# Need to check the source ...
+	my $dep_src = $source;
+	while ( $dep_src ne "/" && $dep_src ne "." ) {
+		$ref_section->{'depends'} .= " " . dirname ( $dep_src );
+		$dep_src = dirname ( $dep_src );
 	}
 	if ( ! -l $dest || ( -l $dest && readlink($dest) ne $source ) ) {
 		if ( $options->{'verbose'} || $options->{'simul'} ) {
@@ -64,16 +67,16 @@
 				Log( "( readlink = " . readlink($dest) . ")" );
 			}
 			else {
-				Log( "( !-l " . $dest . ")" );
+				Log( "( ! -l " . $dest . ")" );
 			}
 		}
 		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
 		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
 		if ( ! $options->{'simul'} ) {
-			Do_moveold( $dest, $options );
+			Do_moveold ( $dest, $options );
 			if ( Mk_dest_dir ( $dest ) || ln_sfn( $source, $dest ) ) {
 				Warn( $CODE->{'OPEN'},
-					"Impossible de lier " . $dest . " a " . $source );
+					"Unable to symlink ".$dest." to ".$source );
 				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=842&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Common.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Common.pm Wed Aug 25 07:51:21 2010
@@ -46,6 +46,7 @@
 use File::Compare;
 use File::Copy;
 use PFTools::Logger;
+use PFTools::Conf;
 
 use Fcntl ':mode';
 




More information about the pf-tools-commits mailing list