pf-tools/pf-tools: 3 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Aug 7 13:16:37 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/f67796488bde
changeset: 1302:f67796488bde
user:      shad
date:      Thu Aug 07 14:54:39 2014 +0200
description:
the removedir was implemented and documented but not declared

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/f9a2d45602b9
changeset: 1303:f9a2d45602b9
user:      shad
date:      Thu Aug 07 14:55:16 2014 +0200
description:
test for declaration of removefile and removedir

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/9034a7ecbb2d
changeset: 1304:9034a7ecbb2d
user:      shad
date:      Thu Aug 07 15:15:52 2014 +0200
description:
fix file backup, removedir and removefile

diffstat:

 doc/updatefile-syntax                                                |  2 +-
 lib/PFTools/Conf/Syntax.pm                                           |  1 +
 lib/PFTools/Update/Common.pm                                         |  2 +-
 lib/PFTools/Update/REMOVEDIR.pm                                      |  4 +++-
 lib/PFTools/Update/REMOVEFILE.pm                                     |  4 +++-
 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn |  5 +++++
 t/13.conf.t                                                          |  8 ++++++++
 7 files changed, 22 insertions(+), 4 deletions(-)

diffs (100 lines):

diff -r 6b010e649d6a -r 9034a7ecbb2d doc/updatefile-syntax
--- a/doc/updatefile-syntax	Thu Aug 07 10:43:31 2014 +0200
+++ b/doc/updatefile-syntax	Thu Aug 07 15:15:52 2014 +0200
@@ -58,7 +58,7 @@
 						is used with update-config, this(these) command(s) is(are) ignored. You can use
 						backslash char for using multiline command(s) like in bash script
 
-SYNOPSYS : removefile
+SYNOPSYS : removefile or removedir
 	* removefile	: removing a file if exists
 	* removedir		: removing a directory if exists
 
diff -r 6b010e649d6a -r 9034a7ecbb2d lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm	Thu Aug 07 10:43:31 2014 +0200
+++ b/lib/PFTools/Conf/Syntax.pm	Thu Aug 07 15:15:52 2014 +0200
@@ -277,6 +277,7 @@
             'after_change'  => 'undefined',
         },
         'removefile' => {},
+        'removedir' => {},
         'ignore'     => {},
         'mkdir'      => {
             'depends'       => 'undefined',
diff -r 6b010e649d6a -r 9034a7ecbb2d lib/PFTools/Update/Common.pm
--- a/lib/PFTools/Update/Common.pm	Thu Aug 07 10:43:31 2014 +0200
+++ b/lib/PFTools/Update/Common.pm	Thu Aug 07 15:15:52 2014 +0200
@@ -166,7 +166,7 @@
         Log(qq{(moving old to $old)}) if ( $options->{'verbose'} );
         unless ( $options->{'simul'} ) {
             Mk_dest_dir($old);
-            return move( $old, $dest );
+            return move( $dest, $old );
         }
     }
     return 1;
diff -r 6b010e649d6a -r 9034a7ecbb2d lib/PFTools/Update/REMOVEDIR.pm
--- a/lib/PFTools/Update/REMOVEDIR.pm	Thu Aug 07 10:43:31 2014 +0200
+++ b/lib/PFTools/Update/REMOVEDIR.pm	Thu Aug 07 15:15:52 2014 +0200
@@ -45,7 +45,9 @@
     my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
     # Is $options->{'simul'} necessary ?
-    if ( !-d $dest && !$options->{'simul'} ) {
+    if ( !-e $dest ) {
+        return 1;
+    } elsif ( !-d $dest && !$options->{'simul'} ) {
         carp qq{ERROR: $dest MUST BE a directory};
         return;
     }
diff -r 6b010e649d6a -r 9034a7ecbb2d lib/PFTools/Update/REMOVEFILE.pm
--- a/lib/PFTools/Update/REMOVEFILE.pm	Thu Aug 07 10:43:31 2014 +0200
+++ b/lib/PFTools/Update/REMOVEFILE.pm	Thu Aug 07 15:15:52 2014 +0200
@@ -45,7 +45,9 @@
     my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
     # Is $options->{'simul'} necessary ?
-    if ( !-f $dest && !$options->{'simul'} ) {
+    if ( !-e $dest ) {
+        return 1;
+    } elsif ( !-f $dest && !$options->{'simul'} ) {
         carp qq{ERROR: $dest MUST BE a file};
         return;
     }
diff -r 6b010e649d6a -r 9034a7ecbb2d t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn
--- a/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn	Thu Aug 07 10:43:31 2014 +0200
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn	Thu Aug 07 15:15:52 2014 +0200
@@ -72,3 +72,8 @@
         on_noaction     = umask 022; mk_pxelinuxcfg GLOBAL:private-network /distrib/tftpboot/pxelinux.cfg/template
         after_change    = umask 022; mk_pxelinuxcfg GLOBAL:private-network /distrib/tftpboot/pxelinux.cfg/template && /etc/init.d/dhcp3-server restart
 
+[/var/www/testfile]
+        action          = removefile
+
+[/var/www/testdir]
+        action          = removedir
diff -r 6b010e649d6a -r 9034a7ecbb2d t/13.conf.t
--- a/t/13.conf.t	Thu Aug 07 10:43:31 2014 +0200
+++ b/t/13.conf.t	Thu Aug 07 15:15:52 2014 +0200
@@ -1737,6 +1737,8 @@
         '/var/www/debian-custom',
         '/var/www/debian-backports',
         'dhcp',
+        '/var/www/testfile',
+        '/var/www/testdir',
     ],
     '/etc/apt/apt-ftp-debian.conf' => {
         'on_noaction' => 'true',
@@ -1791,6 +1793,12 @@
         'action'  => 'addlink',
         'depends' => '/etc/apache2/sites-available/default /distrib',
     },
+    '/var/www/testfile' => {
+        'action'  => 'removefile',
+    },
+    '/var/www/testdir' => {
+        'action'  => 'removedir',
+    },
 };
 
 is_deeply $parsed_configuration, $expected_configuration



More information about the pf-tools-commits mailing list