pf-tools/pf-tools: search automaticaly %SECTIONNAME% in HOSTSITE...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri Dec 5 14:53:50 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/590a1edbb17d
changeset: 1352:590a1edbb17d
user:      melkor <melkor at sitadelle.com>
date:      Fri Dec 05 15:53:47 2014 +0100
description:
search automaticaly %SECTIONNAME% in HOSTSITE, HOST, SHORTHOSTHOSTSITE, SHORTHOSTHOST, CONFIGSITE and CONFIG if source not defined in add-file action

diffstat:

 doc/updatefile-syntax         |   6 +++---
 lib/PFTools/Conf/Syntax.pm    |   2 +-
 lib/PFTools/Update/ADDFILE.pm |  33 +++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 4 deletions(-)

diffs (71 lines):

diff -r 1d27fe0ea54c -r 590a1edbb17d doc/updatefile-syntax
--- a/doc/updatefile-syntax	Fri Dec 05 14:44:19 2014 +0100
+++ b/doc/updatefile-syntax	Fri Dec 05 15:53:47 2014 +0100
@@ -179,9 +179,9 @@
 						 - CONFIGSITE:  	    resolve to	/module/SITE/pop/CONFIG/    (if the hosttype of machine is pop-bar)
 						 - CONFIGSITE_foo:	    resolve to	/module/SITE/foo/CONFIG/
 						 - COMMON:		    resolve to	/module/COMMON/
-						 - HOST:		    resolve to	/module/bar/	(if the hosttype of machine is pop-bar)
-						 - HOSTSITE:    	    resolve to	/module/SITE/pop/pop-bar/	(if the hosttype of machine is pop-bar)
-						 - HOSTSITE_foo:	    resolve to	/module/SITE/foo/pop-bar/	(if the hosttype of machine is pop-bar)
+						 - HOST:		    resolve to	/module/CONFIG/bar/	(if the hosttype of machine is pop-bar)
+						 - HOSTSITE:    	    resolve to	/module/SITE/pop/CONFIG/pop-bar/	(if the hosttype of machine is pop-bar)
+						 - HOSTSITE_foo:	    resolve to	/module/SITE/foo/CONFIG/pop-bar/	(if the hosttype of machine is pop-bar)
 						 - MODEL:		    resolve to	/module/MODEL/
 						 - MODELSITE:   	    resolve to	/module/SITE/pop/MODEL/ (if the hosttype of machine is pop-bar)
 						 - MODELSITE_foo:	    resolve to	/module/SITE/foo/MODEL/
diff -r 1d27fe0ea54c -r 590a1edbb17d lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm	Fri Dec 05 14:44:19 2014 +0100
+++ b/lib/PFTools/Conf/Syntax.pm	Fri Dec 05 15:53:47 2014 +0100
@@ -253,7 +253,7 @@
     },
     'config' => {
         'addfile' => {
-            'MANDATORY_KEYS' => ['source'],
+            #'MANDATORY_KEYS' => ['source'],
             'depends'        => 'undefined',
             'source'         => 'undefined',
             'filter'         => 'undefined',
diff -r 1d27fe0ea54c -r 590a1edbb17d lib/PFTools/Update/ADDFILE.pm
--- a/lib/PFTools/Update/ADDFILE.pm	Fri Dec 05 14:44:19 2014 +0100
+++ b/lib/PFTools/Update/ADDFILE.pm	Fri Dec 05 15:53:47 2014 +0100
@@ -86,6 +86,39 @@
             }
         }
     }
+    elsif (!$ref_section->{'source'}) {
+        $ref_section->{'source'} = 'SHORTHOSTSITE';
+        $source = get_source( $ref_section->{'source'},
+            $options->{'host'}, $hash_subst );
+        if ( !-e $source ) {
+            $ref_section->{'source'} = 'SHORTHOST';
+            $source = get_source( $ref_section->{'source'},
+                $options->{'host'}, $hash_subst );
+        }
+        my @search_dirs = (
+            'HOSTSITE',
+            'HOST',
+            'SHORTHOSTHOSTSITE',
+            'SHORTHOSTHOST',
+            'CONFIGSITE',
+            'CONFIG',
+        );
+        SEARCH_DIR:
+        foreach my $search_dir (@search_dirs) {
+            my @search_files = (
+                qq{$search_dir:%SECTIONNAME%.%HOSTDIGITS%},
+                qq{$search_dir:%SECTIONNAME%},
+            );
+            foreach my $search_file (@search_files) {
+                $source = get_source( $search_file,
+                    $options->{'host'}, $hash_subst );
+                if (-e $source) {
+                $ref_section->{source} = $search_file;
+                    last SEARCH_DIR;
+                }
+            }
+        }
+    }        
     else {
         $source = get_source( $ref_section->{'source'},
             $options->{'host'}, $hash_subst );



More information about the pf-tools-commits mailing list