pf-tools commit: r852 [ccaillet-guest] - in /branches/next-gen: debian/changelog lib/PFTools/Conf.pm lib/PFTools/Update.pm lib/PFTools/Update/Addmount.pm lib/PFTools/Utils.pm
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Aug 27 09:23:12 UTC 2010
Author: ccaillet-guest
Date: Fri Aug 27 09:23:09 2010
New Revision: 852
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=852
Log:
- optims : sorting sections according to the types in Init_GLOBAL_NETCONFIG
- renaming __Trie_prio and Trie_dependances
Modified:
branches/next-gen/debian/changelog
branches/next-gen/lib/PFTools/Conf.pm
branches/next-gen/lib/PFTools/Update.pm
branches/next-gen/lib/PFTools/Update/Addmount.pm
branches/next-gen/lib/PFTools/Utils.pm
Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=852&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Fri Aug 27 09:23:09 2010
@@ -17,6 +17,7 @@
* lib/PFTools/Conf.pm
- small fixes on Get_source for order and substitution regex
- rollback for CONFIG: alias with the 0.33-stable substitution value
+ - optims : sorting sections according to the types in Init_GLOBAL_NETCONFIG
* lib/PFTools/Utils.pm
- fix on Ini_TOOLS : if storable file doesn't exist we need to parse
- cosmetic for building zone in __Mk_zoneheader and Mk_zone_for_site
@@ -26,6 +27,7 @@
- aborting when a depend is explicited but not defined
- parameter for order sections list is now passed with an array ref instead
of an array
+ - renaming __Trie_prio and Trie_dependances
* lib/PFTools/Update/Common.pm
- extracting common functions from Update.pm which are used by $FUNCTION
and $DEPENDS in lib/PFTools/Update.pm
@@ -58,7 +60,7 @@
* TODO
- adding more TODOs :)
- -- Christophe Caillet <quadchris at free.fr> Fri, 27 Aug 2010 10:27:11 +0200
+ -- Christophe Caillet <quadchris at free.fr> Fri, 27 Aug 2010 11:21:09 +0200
pf-tools (0.99.98-1) unstable; urgency=low
Modified: branches/next-gen/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Conf.pm?rev=852&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Conf.pm (original)
+++ branches/next-gen/lib/PFTools/Conf.pm Fri Aug 27 09:23:09 2010
@@ -702,6 +702,24 @@
}
### Like old Init_lib_net
+sub __Sort_net_prio ($$) {
+ my ( $type, $section ) = @_;
+
+ my $prio = 0;
+
+ foreach my $prio_type ( 'zone', 'site', 'network', 'server', 'service' ) {
+ return $prio if ( $type eq $prio_type );
+ $prio++;
+ }
+ return $prio;
+}
+
+sub __Sort_net_section ($$$) {
+ my ( $net_parsed, $a, $b ) = @_;
+
+ return __Sort_net_prio ( $net_parsed->{$a}->{'type'}, $a ) <=> __Sort_net_prio ( $net_parsed->{$b}->{'type'}, $b )
+}
+
sub Init_GLOBAL_NETCONFIG ($$;$) {
my ( $start_file, $hash_subst, $pf_config ) = @_;
@@ -728,28 +746,21 @@
}
my $net_parsed = Load_conf ( $start_file, $hash_subst, 'network', $pf_config );
- foreach my $section ( @{$net_parsed->{'__sections_order'}} ) {
+ my @sortnetkeys = sort { __Sort_net_section ( $net_parsed, $a, $b ) } @{$net_parsed->{'__sections_order'}};
+ foreach my $section ( @sortnetkeys ) {
if ( $net_parsed->{$section}->{'type'} eq 'zone' ) {
Add_zone ( $start_file, $section, $net_parsed->{$section}, $GLOBAL, $pf_config );
}
- }
- foreach my $section ( @{$net_parsed->{'__sections_order'}} ) {
- if ( $net_parsed->{$section}->{'type'} eq 'site' ) {
+ elsif ( $net_parsed->{$section}->{'type'} eq 'site' ) {
Add_site ( $start_file, $section, $net_parsed->{$section}, $GLOBAL, $pf_config );
}
- }
- foreach my $section ( @{$net_parsed->{'__sections_order'}} ) {
- if ( $net_parsed->{$section}->{'type'} eq 'network' ) {
+ elsif ( $net_parsed->{$section}->{'type'} eq 'network' ) {
Add_network ( $start_file, $section, $net_parsed->{$section}, $GLOBAL, $pf_config );
}
- }
- foreach my $section ( @{$net_parsed->{'__sections_order'}} ) {
- if ( $net_parsed->{$section}->{'type'} eq 'server' ) {
+ elsif ( $net_parsed->{$section}->{'type'} eq 'server' ) {
Add_server ( $start_file, $section, $net_parsed->{$section}, $GLOBAL, $pf_config );
}
- }
- foreach my $section ( @{$net_parsed->{'__sections_order'}} ) {
- if ( $net_parsed->{$section}->{'type'} eq 'service' ) {
+ elsif ( $net_parsed->{$section}->{'type'} eq 'service' ) {
my $site_list = Get_site_list ( $net_parsed->{$section}, $GLOBAL );
foreach my $site ( @{$site_list} ) {
my $service_part = $GLOBAL->{'SITE'}->{'BY_NAME'}->{$site}->{'SERVICE'}->{'BY_NAME'};
Modified: branches/next-gen/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update.pm?rev=852&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update.pm (original)
+++ branches/next-gen/lib/PFTools/Update.pm Fri Aug 27 09:23:09 2010
@@ -33,7 +33,7 @@
our @EXPORT = qw(
Get_depends_for_action
Exec_action
- Trie_dependances
+ Sort_config_sections
);
our @EXPORT_OK = qw();
@@ -104,11 +104,10 @@
return Removedir_action ( $ref_section, $dest, $options, $hash_subst, $global_config ) if ( $action eq "removedir" );
}
-sub __Trie_prio {
- my ( $host_config, $section ) = @_;
+sub __Sort_depends_prio ($$) {
+ my ( $action, $section ) = @_;
my $prio = 0;
- my $action = $host_config->{$section}->{'action'};
# First : authentication parts
return $prio if ( $section eq "/etc/passwd" );
@@ -152,11 +151,11 @@
return $prio;
}
-sub Trie_dependances {
+sub Sort_config_sections ($$$) {
my ( $host_config, $a, $b ) = @_;
- my $prioa = __Trie_prio ( $host_config, $a );
- my $priob = __Trie_prio( $host_config, $b );
+ my $prioa = __Sort_depends_prio ( $host_config->{$a}->{'action'}, $a );
+ my $priob = __Sort_depends_prio ( $host_config->{$b}->{'action'}, $b );
if ( $prioa != $priob ) {
return $prioa <=> $priob;
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=852&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update/Addmount.pm (original)
+++ branches/next-gen/lib/PFTools/Update/Addmount.pm Fri Aug 27 09:23:09 2010
@@ -213,7 +213,6 @@
my $addproc = 0;
if ( ! defined $current_proc->{$dest} ) {
- print "$dest entry is not defined into current_proc\n";
$addproc = 1;
}
else {
Modified: branches/next-gen/lib/PFTools/Utils.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Utils.pm?rev=852&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Utils.pm (original)
+++ branches/next-gen/lib/PFTools/Utils.pm Fri Aug 27 09:23:09 2010
@@ -879,7 +879,7 @@
}
my $sortedkeys;
- @{$sortedkeys} = sort { Trie_dependances( $host_config, $a, $b ) } @{$host_config->{'__sections_order'}};
+ @{$sortedkeys} = sort { Sort_config_sections ( $host_config, $a, $b ) } @{$host_config->{'__sections_order'}};
$| = 1;
$errorcount = __Do_updateloop ( $host_config, $options, $hash_subst, $global_config, $sortedkeys );
More information about the pf-tools-commits
mailing list