pf-tools commit: r824 [ccaillet-guest] - in /branches/next-gen: debian/changelog debian/control lib/PFTools/Conf.pm lib/PFTools/Update.pm lib/PFTools/Update/Installpkg.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Aug 12 21:43:25 UTC 2010


Author: ccaillet-guest
Date: Thu Aug 12 21:43:25 2010
New Revision: 824

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=824
Log:
* lib/PFTools/Update/Installpkg.pm
  - extrating apt-get functions (action and depends) from Update.pm
* debian/control
  - adding libtext-diff-perl as depends for pf-tools package

Added:
    branches/next-gen/lib/PFTools/Update/Installpkg.pm   (with props)
Modified:
    branches/next-gen/debian/changelog
    branches/next-gen/debian/control
    branches/next-gen/lib/PFTools/Conf.pm
    branches/next-gen/lib/PFTools/Update.pm

Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=824&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Thu Aug 12 21:43:25 2010
@@ -17,8 +17,12 @@
     and $DEPENDS in lib/PFTools/Update.pm
   * lib/PFTools/Update/Addfile.pm
     - extrating addfile functions (action and depends) from Update.pm
-
- -- Christophe Caillet <quadchris at free.fr>  Thu, 12 Aug 2010 23:19:31 +0200
+  * lib/PFTools/Update/Installpkg.pm
+    - extrating apt-get functions (action and depends) from Update.pm
+  * debian/control
+    - adding libtext-diff-perl as depends for pf-tools package
+
+ -- Christophe Caillet <quadchris at free.fr>  Thu, 12 Aug 2010 23:41:45 +0200
 
 pf-tools (0.99.98-1) unstable; urgency=low
 

Modified: branches/next-gen/debian/control
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/control?rev=824&op=diff
==============================================================================
--- branches/next-gen/debian/control (original)
+++ branches/next-gen/debian/control Thu Aug 12 21:43:25 2010
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, cvs, ssh, iproute, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, libtext-diff-perl, cvs, ssh, iproute, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.

Modified: branches/next-gen/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Conf.pm?rev=824&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Conf.pm (original)
+++ branches/next-gen/lib/PFTools/Conf.pm Thu Aug 12 21:43:25 2010
@@ -267,6 +267,7 @@
 	'on_noaction'		=> 'undefined',
 	'after_change'		=> 'undefined'
 };
+$DEF_SECTIONS->{'config'}->{'installpkg'} = $DEF_SECTIONS->{'config'}->{'apt-get'};
 $DEF_SECTIONS->{'config'}->{'dpkg-purge'} = $DEF_SECTIONS->{'config'}->{'apt-get'};
 $DEF_SECTIONS->{'config'}->{'filter-model'} = {
 	'MANDATORY_KEYS'	=> [ 'filter' ],

Modified: branches/next-gen/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update.pm?rev=824&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update.pm (original)
+++ branches/next-gen/lib/PFTools/Update.pm Thu Aug 12 21:43:25 2010
@@ -227,127 +227,127 @@
 	return 0;
 }
 
-$DEPENDS{'apt-get'} = sub ($$$) {
-    my ( $ref_section, $dest, $options ) = @_;
-
-    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
-    if ( aptupdate( $options->{'pkg_type'} ) ) {
-		return 1;
-	}
-	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 ;
-	}
-};
-
-$FUNCTIONS{'apt-get'} = sub ($$$$) {
-    my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
-
-    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
-	my $installed_version;
-	my $available_version;
-	my $specified_version = 0;
-	my $install = 0;
-
-	my $name_filter = $ref_section->{'name_filter'};
-	if ( $name_filter ) {
-		$hash_subst->{'SECTIONNAME'} = $dest;
-		my $newdest = deferredlogpipe ( Subst_vars ( $name_filter, $hash_subst ) );
-		unless ( defined $newdest ) {
-			Warn( $CODE->{'OPEN'}, "Unable to apply name_filter".$name_filter );
-			return 1;
-		}
-		unless ( $newdest ) {
-			Warn( $CODE->{'OPEN'}, "Empty result for name_filter".$name_filter );
-			return 1;
-		}
-		$dest = $newdest;
-	}
-	aptupdate( $options->{'pkg_type'} );
-	( $installed_version, $available_version, $specified_version ) = Get_pkg_policy ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ;
-	if ( ! defined ( $available_version ) ) {
-		Warn( $CODE->{'OPEN'}, "Package ".$dest." is unavailable" );
-		return 1;
-	}
-	if ( defined ( $ref_section->{'version'} ) && ! $specified_version ) {
-		Warn( $CODE->{'OPEN'}, "Package ".$dest." in version ".$ref_section->{'version'}." is unavailable" );
-		return 1;
-	}
-	if ( defined $installed_version ) {
-		my $compare = Cmp_pkg_version ( $options->{'pkg_type'}, $dest, $installed_version, $available_version ) ;
-		$install++ if ( defined $compare && $compare < 0 );
-	}
-
-	if ($install) {
-		if ( $options->{'verbose'} || $options->{'simul'} ) {
-			Log("(action needed)");
-		}
-		if ( $options->{'diff'} ) {
-			Log ( 
-				"(inst = ".( defined($installed_version) ? $installed_version : '?' )
-				.", avail = ".( defined($available_version) ? $available_version : '?' )
-				.")"
-			);
-		}
-		if ( defined( $ref_section->{'delay'} ) && ! $options->{'noaction'} ) {
-			$hash_subst->{'HOSTNAME'} =~ /\d+$/;
-			if ( $& ne "" ) {
-				sleep( 120 * $& );
-			}
-		}
-		if ( ! $options->{'simul'} ) {
-			my $debconf = 0;
-			my $debconf_vars = {};
-			foreach my $key ( keys %{$ref_section} ) {
-				next if ( $key !~ /^debconf/ );
-				$debconf = 1;
-				$key =~ /^debconf\.(.*)$/;
-				$debconf_vars->{$1} = $ref_section->{$key};
-			}
-			if ( $debconf ) {
-				my $DEB;
-				my $conf;
-				my $pkg;
-				my $pf_config	= Init_PF_CONFIG ();
-				my $vcs_tpl_dir	= $pf_config->{'path'}->{'checkout_dir'}.'/TEMPLATES';
-				Debconf::Db->load;
-				foreach $conf ( keys %{ $ref_section->{'debconf'} } ) {
-					($pkg) = split( m:/:, $conf );
-					if ( !$DEB->{$pkg} ) {
-						$DEB->{$pkg} = 1;
-						Debconf::Template->load( $vcs_tpl_dir."/".$pkg, $pkg );
-					}
-					Debconf::ConfModule->command_set( $conf,
-					$ref_section->{'debconf'}->{$conf} );
-					Debconf::ConfModule->command_fset( $conf, "seen", "true" );
-				}
-				Debconf::Db->save;
-			}
-		}
-		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
-		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
-		if ( defined( $ref_section->{'reply'} ) ) {
-			$install = $ref_section->{'reply'};
-			eval "\$install = sprintf (\"echo '$install' |\")";
-		}
-		else {
-			$install = '';
-		}
-		if ( !$options->{'simul'} ) {
-			if ( ! Install_pkg ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ) {
-				Warn( $CODE->{'OPEN'}, "Unable to install ".$dest ) ;
-				return 1;
-			}
-		}
-		Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
-		Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
-	}
-	return 0;
-};
+# $DEPENDS{'apt-get'} = sub ($$$) {
+#     my ( $ref_section, $dest, $options ) = @_;
+# 
+#     $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+#     if ( aptupdate( $options->{'pkg_type'} ) ) {
+# 		return 1;
+# 	}
+# 	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 ;
+# 	}
+# };
+# 
+# $FUNCTIONS{'apt-get'} = sub ($$$$) {
+#     my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
+# 
+#     $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+# 	my $installed_version;
+# 	my $available_version;
+# 	my $specified_version = 0;
+# 	my $install = 0;
+# 
+# 	my $name_filter = $ref_section->{'name_filter'};
+# 	if ( $name_filter ) {
+# 		$hash_subst->{'SECTIONNAME'} = $dest;
+# 		my $newdest = deferredlogpipe ( Subst_vars ( $name_filter, $hash_subst ) );
+# 		unless ( defined $newdest ) {
+# 			Warn( $CODE->{'OPEN'}, "Unable to apply name_filter".$name_filter );
+# 			return 1;
+# 		}
+# 		unless ( $newdest ) {
+# 			Warn( $CODE->{'OPEN'}, "Empty result for name_filter".$name_filter );
+# 			return 1;
+# 		}
+# 		$dest = $newdest;
+# 	}
+# 	aptupdate( $options->{'pkg_type'} );
+# 	( $installed_version, $available_version, $specified_version ) = Get_pkg_policy ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ;
+# 	if ( ! defined ( $available_version ) ) {
+# 		Warn( $CODE->{'OPEN'}, "Package ".$dest." is unavailable" );
+# 		return 1;
+# 	}
+# 	if ( defined ( $ref_section->{'version'} ) && ! $specified_version ) {
+# 		Warn( $CODE->{'OPEN'}, "Package ".$dest." in version ".$ref_section->{'version'}." is unavailable" );
+# 		return 1;
+# 	}
+# 	if ( defined $installed_version ) {
+# 		my $compare = Cmp_pkg_version ( $options->{'pkg_type'}, $dest, $installed_version, $available_version ) ;
+# 		$install++ if ( defined $compare && $compare < 0 );
+# 	}
+# 
+# 	if ($install) {
+# 		if ( $options->{'verbose'} || $options->{'simul'} ) {
+# 			Log("(action needed)");
+# 		}
+# 		if ( $options->{'diff'} ) {
+# 			Log ( 
+# 				"(inst = ".( defined($installed_version) ? $installed_version : '?' )
+# 				.", avail = ".( defined($available_version) ? $available_version : '?' )
+# 				.")"
+# 			);
+# 		}
+# 		if ( defined( $ref_section->{'delay'} ) && ! $options->{'noaction'} ) {
+# 			$hash_subst->{'HOSTNAME'} =~ /\d+$/;
+# 			if ( $& ne "" ) {
+# 				sleep( 120 * $& );
+# 			}
+# 		}
+# 		if ( ! $options->{'simul'} ) {
+# 			my $debconf = 0;
+# 			my $debconf_vars = {};
+# 			foreach my $key ( keys %{$ref_section} ) {
+# 				next if ( $key !~ /^debconf/ );
+# 				$debconf = 1;
+# 				$key =~ /^debconf\.(.*)$/;
+# 				$debconf_vars->{$1} = $ref_section->{$key};
+# 			}
+# 			if ( $debconf ) {
+# 				my $DEB;
+# 				my $conf;
+# 				my $pkg;
+# 				my $pf_config	= Init_PF_CONFIG ();
+# 				my $vcs_tpl_dir	= $pf_config->{'path'}->{'checkout_dir'}.'/TEMPLATES';
+# 				Debconf::Db->load;
+# 				foreach $conf ( keys %{ $ref_section->{'debconf'} } ) {
+# 					($pkg) = split( m:/:, $conf );
+# 					if ( !$DEB->{$pkg} ) {
+# 						$DEB->{$pkg} = 1;
+# 						Debconf::Template->load( $vcs_tpl_dir."/".$pkg, $pkg );
+# 					}
+# 					Debconf::ConfModule->command_set( $conf,
+# 					$ref_section->{'debconf'}->{$conf} );
+# 					Debconf::ConfModule->command_fset( $conf, "seen", "true" );
+# 				}
+# 				Debconf::Db->save;
+# 			}
+# 		}
+# 		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
+# 		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
+# 		if ( defined( $ref_section->{'reply'} ) ) {
+# 			$install = $ref_section->{'reply'};
+# 			eval "\$install = sprintf (\"echo '$install' |\")";
+# 		}
+# 		else {
+# 			$install = '';
+# 		}
+# 		if ( !$options->{'simul'} ) {
+# 			if ( ! Install_pkg ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ) {
+# 				Warn( $CODE->{'OPEN'}, "Unable to install ".$dest ) ;
+# 				return 1;
+# 			}
+# 		}
+# 		Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
+# 		Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
+# 	}
+# 	return 0;
+# };
 
 $DEPENDS{'addmount'} = sub ($$$) {
 	my ( $ref_section, $dest, $options ) = @_;
@@ -844,6 +844,9 @@
 	if ( $action eq 'addfile' ) {
 		Addfile_depends ( $ref_section, $dest, $options );
 	}
+	elsif ( $action eq "apt-get" || $action eq "" ) {
+		Installpk_depends ( $ref_section, $dest, $options );
+	}
 	elsif ( $DEPENDS{$action} ) {
 		$DEPENDS{$action}->( $ref_section, $dest, $options );
 	}
@@ -853,6 +856,15 @@
 	my ( $action, $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
 	return Addfile_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq 'addfile' );
+	if ( $action eq "apt-get" || $action eq "installpkg" ) {
+		if ( $APT_UPDATE ) {
+			if ( ! Update_pkg_repository ( $pkg_type ) ) {
+				return 1;
+			}
+			$APT_UPDATE = 0;
+		}
+		return Installpkg_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "apt-get" || $action eq "installpkg" );
+	}
 	return $FUNCTIONS{$action}->( $ref_section, $dest, $options, $hash_subst, $global_config );
 }
 

Added: 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=824&op=file
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Installpkg.pm (added)
+++ branches/next-gen/lib/PFTools/Update/Installpkg.pm Thu Aug 12 21:43:25 2010
@@ -1,0 +1,165 @@
+package PFTools::Update::Installpkg;
+##
+##  $Id$
+##
+##  Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+##
+##  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 strict;
+use warnings;
+
+use Exporter;
+
+our @ISA = ('Exporter');
+
+our @EXPORT = qw(
+	Insallpkg_depends
+	Installpkg_action
+);
+
+our @EXPORT_OK = qw();
+
+use File::Compare;
+use File::Copy;
+use Text::Diff;
+use PFTools::Logger;
+use PFTools::Conf;
+use PFTools::Update::Common;
+
+sub Insallpkg_depends ($$$) {
+    my ( $ref_section, $dest, $options ) = @_;
+
+    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+    if ( aptupdate( $options->{'pkg_type'} ) ) {
+		return 1;
+	}
+	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 ;
+	}
+}
+
+sub Installpkg_action ($$$$) {
+    my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
+
+    $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
+	my $installed_version;
+	my $available_version;
+	my $specified_version = 0;
+	my $install = 0;
+
+	my $name_filter = $ref_section->{'name_filter'};
+	if ( $name_filter ) {
+		$hash_subst->{'SECTIONNAME'} = $dest;
+		my $newdest = deferredlogpipe ( Subst_vars ( $name_filter, $hash_subst ) );
+		unless ( defined $newdest ) {
+			Warn( $CODE->{'OPEN'}, "Unable to apply name_filter".$name_filter );
+			return 1;
+		}
+		unless ( $newdest ) {
+			Warn( $CODE->{'OPEN'}, "Empty result for name_filter".$name_filter );
+			return 1;
+		}
+		$dest = $newdest;
+	}
+# 	aptupdate( $options->{'pkg_type'} );
+	( $installed_version, $available_version, $specified_version ) = Get_pkg_policy ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ;
+	if ( ! defined ( $available_version ) ) {
+		Warn( $CODE->{'OPEN'}, "Package ".$dest." is unavailable" );
+		return 1;
+	}
+	if ( defined ( $ref_section->{'version'} ) && ! $specified_version ) {
+		Warn( $CODE->{'OPEN'}, "Package ".$dest." in version ".$ref_section->{'version'}." is unavailable" );
+		return 1;
+	}
+	if ( defined $installed_version ) {
+		my $compare = Cmp_pkg_version ( $options->{'pkg_type'}, $dest, $installed_version, $available_version ) ;
+		$install++ if ( defined $compare && $compare < 0 );
+	}
+
+	if ($install) {
+		if ( $options->{'verbose'} || $options->{'simul'} ) {
+			Log("(action needed)");
+		}
+		if ( $options->{'diff'} ) {
+			Log ( 
+				"(inst = ".( defined($installed_version) ? $installed_version : '?' )
+				.", avail = ".( defined($available_version) ? $available_version : '?' )
+				.")"
+			);
+		}
+		if ( defined( $ref_section->{'delay'} ) && ! $options->{'noaction'} ) {
+			$hash_subst->{'HOSTNAME'} =~ /\d+$/;
+			if ( $& ne "" ) {
+				sleep( 120 * $& );
+			}
+		}
+		if ( ! $options->{'simul'} ) {
+			my $debconf = 0;
+			my $debconf_vars = {};
+			foreach my $key ( keys %{$ref_section} ) {
+				next if ( $key !~ /^debconf/ );
+				$debconf = 1;
+				$key =~ /^debconf\.(.*)$/;
+				$debconf_vars->{$1} = $ref_section->{$key};
+			}
+			if ( $debconf ) {
+				my $DEB;
+				my $conf;
+				my $pkg;
+				my $pf_config	= Init_PF_CONFIG ();
+				my $vcs_tpl_dir	= $pf_config->{'path'}->{'checkout_dir'}.'/TEMPLATES';
+				Debconf::Db->load;
+				foreach $conf ( keys %{ $ref_section->{'debconf'} } ) {
+					($pkg) = split( m:/:, $conf );
+					if ( !$DEB->{$pkg} ) {
+						$DEB->{$pkg} = 1;
+						Debconf::Template->load( $vcs_tpl_dir."/".$pkg, $pkg );
+					}
+					Debconf::ConfModule->command_set( $conf,
+					$ref_section->{'debconf'}->{$conf} );
+					Debconf::ConfModule->command_fset( $conf, "seen", "true" );
+				}
+				Debconf::Db->save;
+			}
+		}
+		Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
+		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
+		if ( defined( $ref_section->{'reply'} ) ) {
+			$install = $ref_section->{'reply'};
+			eval "\$install = sprintf (\"echo '$install' |\")";
+		}
+		else {
+			$install = '';
+		}
+		if ( !$options->{'simul'} ) {
+			if ( ! Install_pkg ( $options->{'pkg_type'}, $dest, $ref_section->{'version'} ) ) {
+				Warn( $CODE->{'OPEN'}, "Unable to install ".$dest ) ;
+				return 1;
+			}
+		}
+		Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
+		Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
+	}
+	return 0;
+}
+
+1;

Propchange: branches/next-gen/lib/PFTools/Update/Installpkg.pm
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu Aug 12 21:43:25 2010
@@ -1,0 +1,2 @@
+Id
+Revision




More information about the pf-tools-commits mailing list