pf-tools commit: r830 [ccaillet-guest] - in /branches/next-gen: debian/changelog lib/PFTools/Update.pm lib/PFTools/Update/Addlink.pm lib/PFTools/Update/Addmount.pm lib/PFTools/Update/Createfile.pm lib/PFTools/Update/Mkdir.pm
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Mon Aug 23 05:22:35 UTC 2010
Author: ccaillet-guest
Date: Mon Aug 23 05:22:33 2010
New Revision: 830
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=830
Log:
* lib/PFTools/Update/Creatfile.pm
- extrating apt-get functions (action and depends) from Update.pm
* lib/PFTools/Update/Addlink.pm
- extrating apt-get functions (action and depends) from Update.pm
Added:
branches/next-gen/lib/PFTools/Update/Addlink.pm (with props)
branches/next-gen/lib/PFTools/Update/Createfile.pm (with props)
Modified:
branches/next-gen/debian/changelog
branches/next-gen/lib/PFTools/Update.pm
branches/next-gen/lib/PFTools/Update/Addmount.pm
branches/next-gen/lib/PFTools/Update/Mkdir.pm
Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=830&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Mon Aug 23 05:22:33 2010
@@ -25,10 +25,14 @@
- extrating apt-get functions (action and depends) from Update.pm
* lib/PFTools/Update/Addmount.pm
- extrating apt-get functions (action and depends) from Update.pm
+ * lib/PFTools/Update/Creatfile.pm
+ - extrating apt-get functions (action and depends) from Update.pm
+ * lib/PFTools/Update/Addlink.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> Wed, 18 Aug 2010 16:39:59 +0200
+ -- Christophe Caillet <tof at sitadelle.com> Mon, 23 Aug 2010 07:21:30 +0200
pf-tools (0.99.98-1) unstable; urgency=low
Modified: branches/next-gen/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update.pm?rev=830&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update.pm (original)
+++ branches/next-gen/lib/PFTools/Update.pm Mon Aug 23 05:22:33 2010
@@ -46,6 +46,8 @@
use PFTools::Update::Purgepkg;
use PFTools::Update::Mkdir;
use PFTools::Update::Addmount;
+use PFTools::Update::Createfile;
+use PFTools::Update::Addlink;
use PFTools::Logger;
use PFTools::Parser;
use PFTools::Net;
@@ -82,139 +84,6 @@
my %DEPENDS;
my %FUNCTIONS;
-$FUNCTIONS{'ignore'} = sub ($$$$$) {
- my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
-
- return 0;
-};
-
-$DEPENDS{'addlink'} = sub ($$$) {
- my ( $ref_section, $dest, $options ) = @_;
-
- while ( $dest ne "/" && $dest ne "." ) {
- $ref_section->{'depends'} .= " " . dirname($dest);
- $dest = dirname($dest);
- }
-};
-
-$FUNCTIONS{'addlink'} = sub ($$$$$) {
- my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
-
- $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);
- }
- if ( ! -l $dest || ( -l $dest && readlink($dest) ne $source ) ) {
- if ( $options->{'verbose'} || $options->{'simul'} ) {
- Log("(action needed)");
- }
- if ( $options->{'diff'} ) {
- if ( -l $dest ) {
- Log( "( readlink = " . readlink($dest) . ")" );
- }
- else {
- 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 );
- if ( Mk_dest_dir ( $dest ) || ln_sfn( $source, $dest ) ) {
- Warn( $CODE->{'OPEN'},
- "Impossible de lier " . $dest . " a " . $source );
- 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{'createfile'} = sub ($$$) {
- my ( $ref_section, $dest, $options ) = @_;
-
- while ( $dest ne "/" && $dest ne "." ) {
- $ref_section->{'depends'} .= " " . dirname($dest);
- $dest = dirname($dest);
- }
-};
-
-$FUNCTIONS{'createfile'} = sub ($$$$$) {
- my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
-
- my $cmp = 0;
- $hash_subst->{'SECTIONNAME'} = $dest;
- if ( ! defined $ref_section->{'source'} ) {
- if ( ! -f $dest ) {
- $cmp = 1;
- if ( $options->{'verbose'} || $options->{'simul'} ) {
- Log("(action needed)");
- }
- Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
- Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
- if ( ! $options->{'simul'} ) {
- if ( deferredlogsystem ( "/usr/bin/touch '" . $dest . "'" ) ) {
- Warn( $CODE->{'OPEN'}, "Unable to create empty file ".$dest );
- return 1;
- }
- }
- }
- }
- else {
- my $source = Get_source( Subst_vars( $ref_section->{'source'}, $hash_subst ) );
- $hash_subst->{'SOURCE'} = $source;
- my $tmp = Get_tmp_dest ( $dest );
- $hash_subst->{'DESTINATION'} = $tmp;
- if ( ! -f $source ) {
- Warn( $CODE->{'OPEN'}, "Unable to open source ".$source );
- return 1;
- }
- if ( defined( $ref_section->{'filter'} ) ) {
- my $filter = Subst_vars ( $ref_section->{'filter'}, $hash_subst );
- if ( deferredlogsystem ( $filter ) ) {
- Warn( $CODE->{'OPEN'}, "Unable to apply filter ".$filter );
- return 1;
- }
- }
- else {
- if ( ! copy ( $source, $tmp ) ) {
- Warn( $CODE->{'OPEN'},
- "Unable to copy ".$source." to ".$tmp );
- return 1;
- }
- }
- if ( ! -f $tmp ) {
- Warn( $CODE->{'OPEN'}, "Unable top open file ".$tmp );
- return 1;
- }
- if ( !-f $dest ) {
- $cmp = 1;
- if ( $options->{'verbose'} || $options->{'simul'} ) {
- Log("(action needed)");
- }
- Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
- Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
- if ( !$options->{'simul'} ) {
- if ( ! copy ( $source, $dest ) ) {
- Warn( $CODE->{'OPEN'},
- "Unable to create file ".$dest." from source ".$source );
- return 1;
- }
- }
- }
- }
- Do_chownmod ( $ref_section, $dest, $options );
- if ( $cmp ) {
- Do_after_change( $ref_section, $options, $hash_subst ) && return 1;
- Do_on_noaction( $ref_section, $options, $hash_subst ) && return 1;
- }
- return 0;
-};
-
$FUNCTIONS{'removefile'} = sub ($$$$$) {
my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
@@ -269,43 +138,13 @@
return 0;
};
-# sub Mk_dest_dir ($) {
-# my ( $dir ) = @_;
-#
-# $dir =~ s://:/:g; # supprimer // sinon ca marche moins bien
-# $dir =~ s:/[^/]+/*$::;
-# my $dir2 = $dir;
-# while ( $dir2 ne "" && !-e $dir2 ) {
-# $dir2 =~ s:/[^/]+/*$::;
-# }
-# if ( $dir2 ne "" && -e $dir2 && !-d $dir2 ) {
-# unlink($dir2);
-# }
-# $dir && return system( "/bin/mkdir -p '" . $dir . "' >/dev/null 2>&1" );
-# }
-#
-# sub Get_tmp_dest ($) {
-# my ( $dest ) = @_;
-#
-# my $pf_config = Init_PF_CONFIG ();
-# my $tmp = $pf_config->{'path'}->{'checkout_dir'} . "/tmp/" . $dest;
-# Mk_dest_dir ( $tmp );
-# if ( -d $tmp ) {
-# rmdir( $tmp );
-# }
-# elsif ( -e $tmp ) {
-# unlink ( $tmp );
-# }
-# return $tmp;
-# }
-
sub Get_depends_for_action ($$$$) {
my ( $action, $ref_section, $dest, $options ) = @_;
- if ( $action eq 'addfile' ) {
+ if ( $action eq "addfile" ) {
Addfile_depends ( $ref_section, $dest, $options );
}
- elsif ( $action eq "apt-get" || $action eq "" ) {
+ elsif ( $action eq "apt-get" || $action eq "installpkg" ) {
Installpk_depends ( $ref_section, $dest, $options );
}
elsif ( $action eq "mkdir" ) {
@@ -314,6 +153,12 @@
elsif ( $action eq "addmount" ) {
Addmount_depends ( $ref_section, $dest, $options );
}
+ elsif ( $action eq "createfile" ) {
+ Createfile_depends ( $ref_section, $dest, $options );
+ }
+ elsif ( $action eq "addlink" ) {
+ Addlink_depends ( $ref_section, $dest, $options );
+ }
elsif ( $DEPENDS{$action} ) {
$DEPENDS{$action}->( $ref_section, $dest, $options );
}
@@ -322,7 +167,8 @@
sub Exec_action ($$$$$$) {
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' );
+ return 0 if ( $action eq "ignore" );
+ 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 ( $options->{'pkg_type'} ) ) {
@@ -335,6 +181,8 @@
return Purgepkg_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "dpkg-purge" || $action eq "purgepkg" );
return Mkdir_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "mkdir" );
return Addmount_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "addmount" );
+ return Createfile_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "createfile" );
+ return Addlink_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "addlink" );
return $FUNCTIONS{$action}->( $ref_section, $dest, $options, $hash_subst, $global_config );
}
Added: 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=830&op=file
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addlink.pm (added)
+++ branches/next-gen/lib/PFTools/Update/Addlink.pm Mon Aug 23 05:22:33 2010
@@ -1,0 +1,86 @@
+package PFTools::Update::Addlink;
+##
+## $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(
+ Addlink_depends
+ Addlink_action
+);
+
+our @EXPORT_OK = qw();
+
+use PFTools::Logger;
+use PFTools::Conf;
+use PFTools::Update::Common;
+
+sub Addlink_depends ($$$) {
+ my ( $ref_section, $dest, $options ) = @_;
+
+ while ( $dest ne "/" && $dest ne "." ) {
+ $ref_section->{'depends'} .= " " . dirname($dest);
+ $dest = dirname($dest);
+ }
+}
+
+sub Addlink_action ($$$$$) {
+ my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
+
+ $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);
+ }
+ if ( ! -l $dest || ( -l $dest && readlink($dest) ne $source ) ) {
+ if ( $options->{'verbose'} || $options->{'simul'} ) {
+ Log("(action needed)");
+ }
+ if ( $options->{'diff'} ) {
+ if ( -l $dest ) {
+ Log( "( readlink = " . readlink($dest) . ")" );
+ }
+ else {
+ 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 );
+ if ( Mk_dest_dir ( $dest ) || ln_sfn( $source, $dest ) ) {
+ Warn( $CODE->{'OPEN'},
+ "Impossible de lier " . $dest . " a " . $source );
+ 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/Addlink.pm
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Aug 23 05:22:33 2010
@@ -1,0 +1,2 @@
+Id
+Revision
Modified: branches/next-gen/lib/PFTools/Update/Addmount.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Addmount.pm?rev=830&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addmount.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Addmount.pm Mon Aug 23 05:22:33 2010
@@ -209,7 +209,7 @@
Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
if ( ! -d $dest && $dest ne 'none' ) {
- Mkdir_action ( $ref_section, $dest, $options, $hash_subst );
+ Mkdir_action ( $ref_section, $dest, $options, $hash_subst, $global_config );
}
if ( $addfstab ) {
my $tmp = Get_tmp_dest ("/etc/fstab");
Added: branches/next-gen/lib/PFTools/Update/Createfile.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update/Createfile.pm?rev=830&op=file
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Createfile.pm (added)
+++ branches/next-gen/lib/PFTools/Update/Createfile.pm Mon Aug 23 05:22:33 2010
@@ -1,0 +1,124 @@
+package PFTools::Update::Createfile;
+##
+## $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(
+ Createfile_depends
+ Createfile_action
+);
+
+our @EXPORT_OK = qw();
+
+use File::Compare;
+use File::Copy;
+use PFTools::Logger;
+use PFTools::Conf;
+use PFTools::Update::Common;
+
+
+sub Createfile_depends ($$$) {
+ my ( $ref_section, $dest, $options ) = @_;
+
+ while ( $dest ne "/" && $dest ne "." ) {
+ $ref_section->{'depends'} .= " " . dirname($dest);
+ $dest = dirname($dest);
+ }
+}
+
+sub Createfile_action ($$$$$) {
+ my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
+
+ my $cmp = 0;
+ $hash_subst->{'SECTIONNAME'} = $dest;
+ if ( ! defined $ref_section->{'source'} ) {
+ if ( ! -f $dest ) {
+ $cmp = 1;
+ if ( $options->{'verbose'} || $options->{'simul'} ) {
+ Log("(action needed)");
+ }
+ Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
+ Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
+ if ( ! $options->{'simul'} ) {
+ if ( deferredlogsystem ( "/usr/bin/touch '" . $dest . "'" ) ) {
+ Warn( $CODE->{'OPEN'}, "Unable to create empty file ".$dest );
+ return 1;
+ }
+ }
+ }
+ }
+ else {
+ my $source = Get_source( Subst_vars( $ref_section->{'source'}, $hash_subst ), $hash_subst->{'HOSTNAME'}, $hash_subst );
+ $hash_subst->{'SOURCE'} = $source;
+ my $tmp = Get_tmp_dest ( $dest );
+ $hash_subst->{'DESTINATION'} = $tmp;
+ if ( ! -f $source ) {
+ Warn( $CODE->{'OPEN'}, "Unable to open source ".$source );
+ return 1;
+ }
+ if ( defined( $ref_section->{'filter'} ) ) {
+ my $filter = Subst_vars ( $ref_section->{'filter'}, $hash_subst );
+ if ( deferredlogsystem ( $filter ) ) {
+ Warn( $CODE->{'OPEN'}, "Unable to apply filter ".$filter );
+ return 1;
+ }
+ }
+ else {
+ if ( ! copy ( $source, $tmp ) ) {
+ Warn( $CODE->{'OPEN'},
+ "Unable to copy ".$source." to ".$tmp );
+ return 1;
+ }
+ }
+ if ( ! -f $tmp ) {
+ Warn( $CODE->{'OPEN'}, "Unable top open file ".$tmp );
+ return 1;
+ }
+ if ( !-f $dest ) {
+ $cmp = 1;
+ if ( $options->{'verbose'} || $options->{'simul'} ) {
+ Log("(action needed)");
+ }
+ Do_on_config( $ref_section, $options, $hash_subst ) && return 1;
+ Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
+ if ( !$options->{'simul'} ) {
+ if ( ! copy ( $source, $dest ) ) {
+ Warn( $CODE->{'OPEN'},
+ "Unable to create file ".$dest." from source ".$source );
+ return 1;
+ }
+ }
+ }
+ }
+ Do_chownmod ( $ref_section, $dest, $options );
+ if ( $cmp ) {
+ 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/Createfile.pm
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Aug 23 05:22:33 2010
@@ -1,0 +1,2 @@
+Id
+Revision
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=830&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Mkdir.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Mkdir.pm Mon Aug 23 05:22:33 2010
@@ -1,4 +1,4 @@
-package PFTools::Update::Addfile;
+package PFTools::Update::Mkdir;
##
## $Id$
##
More information about the pf-tools-commits
mailing list