[Libreoffice-commits] .: solenv/bin

Norbert Thiebaud nthiebaud at kemper.freedesktop.org
Wed Aug 10 12:19:54 PDT 2011


 solenv/bin/build.pl                |  216 ++---------------
 solenv/bin/modules/SourceConfig.pm |  470 +------------------------------------
 2 files changed, 48 insertions(+), 638 deletions(-)

New commits:
commit 0ca248b0d5799bf6c4dcb7a359800579f83f43ae
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Tue Aug 9 23:54:56 2011 -0500

    remove the concept of modules_type, source_config and related things
    
    all these bells and whistles seems to be hamburg specific.
    modules_type in you build seems to always be 'mod', so no need
    to track it.
    
    the whole source_config things is not use in our build either.
    
    note: this is a rough cut... there is probably left-over to trim as
    a consequence of this.

diff --git a/solenv/bin/build.pl b/solenv/bin/build.pl
index cc53a5d..9c6bc3c 100755
--- a/solenv/bin/build.pl
+++ b/solenv/bin/build.pl
@@ -118,7 +118,6 @@
     my $child = 0;
     my %processes_hash = ();
     my %module_announced = ();
-    my $prepare = ''; # prepare for following incompatible build
     my $ignore = '';
     my $html = '';
     my @ignored_errors = ();
@@ -178,15 +177,10 @@
     my %reversed_dependencies = ();
     my %module_paths = (); # hash with absolute module paths
     my %active_modules = ();
-    my $generate_config = 0;
-    my %add_to_config = ();
-    my %remove_from_config = ();
-    my $clear_config = 0;
     my $finished_children = 0;
     my $debug = 0;
     my %module_deps_hash_pids = ();
     my @argv = @ARGV;
-    my $source_config_file;
     my $zenity_pid = 0;
     my $zenity_in = '';
     my $zenity_out = '';
@@ -214,16 +208,6 @@
 
     get_build_modes();
     my %deliver_env = ();
-    if ($prepare) {
-        get_platforms(\%platforms);
-
-        $deliver_env{'COMMON_OUTDIR'}++;
-        $deliver_env{'GUI'}++;
-        $deliver_env{'INPATH'}++;
-        $deliver_env{'OFFENV_PATH'}++;
-        $deliver_env{'OUTPATH'}++;
-        $deliver_env{'L10N_framework'}++;
-    };
     my $workspace_path = get_workspace_path();   # This also sets $initial_module
     my $build_error_log = Cwd::realpath(correct_path($workspace_path)) ."/build_error.log";
     my $source_config = SourceConfig -> new($workspace_path);
@@ -243,10 +227,6 @@
         };
     };
 
-    if ($generate_config && ($clear_config || (scalar keys %remove_from_config)||(scalar keys %add_to_config))) {
-        generate_config_file();
-        exit 0;
-    }
     get_module_and_buildlist_paths();
 
     $deliver_command .= ' -verbose' if ($html || $verbose);
@@ -344,12 +324,6 @@ sub rename_file {
     };
 };
 
-sub generate_config_file {
-    $source_config->add_active_modules([keys %add_to_config], 1) if (scalar %add_to_config);
-    $source_config->remove_activated_modules([keys %remove_from_config], 1) if (scalar %remove_from_config);
-    $source_config->remove_all_activated_modules() if ($clear_config);
-};
-
 
 sub start_interactive {
     my $pid = open(HTML_PIPE, "-|");
@@ -649,7 +623,6 @@ sub build_all {
             $active_modules{$initial_module}++;
             $modules_types{$initial_module} = 'mod';
         };
-        modules_classify(keys %global_deps_hash);
         expand_dependencies (\%global_deps_hash);
         prepare_incompatible_build(\%global_deps_hash) if ($incompatible && (!$build_from_with_branches));
         if ($build_from_with_branches) {
@@ -662,18 +635,11 @@ sub build_all {
             prepare_build_all_cont(\%global_deps_hash);
             %weights_hash = ();
         };
-        if ($generate_config) {
-            %add_to_config = %global_deps_hash;
-            generate_config_file();
-            exit 0;
-        } elsif ($incompatible) {
+        if ($incompatible) {
             my @missing_modules = ();
             foreach (sort keys %global_deps_hash) {
                 push(@missing_modules, $_) if (!defined $active_modules{$_});
             };
-            if (scalar @missing_modules) {
-                push(@warnings, "The modules: \"@missing_modules\" should be have been built, but they are not activated and have been skipped. Be aware, that can cause compatibility problems. Maybe you should verify your $source_config_file.\n");
-            };
         };
         foreach my $module (keys %dead_parents, keys %skip_modules) {
             remove_from_dependencies($module, \%global_deps_hash);
@@ -933,18 +899,13 @@ sub get_deps_hash {
     my %dead_dependencies = ();
     $module_to_build = shift;
     my $dependencies_hash = shift;
-    if ($custom_job) {
-        if ($modules_types{$module_to_build} ne 'lnk') {
-            add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job);
-            add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job);
-            add_dependent_job($dependencies_hash, $module_to_build, $custom_job);
-            add_dependent_job($dependencies_hash, $module_to_build, $post_job);
-            add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job);
-        };
-        return;
-    };
-    if ( defined $modules_types{$module_to_build} && $modules_types{$module_to_build} ne 'mod') {
+    if ($custom_job)
+    {
+        add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job);
         add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job);
+        add_dependent_job($dependencies_hash, $module_to_build, $custom_job);
+        add_dependent_job($dependencies_hash, $module_to_build, $post_job);
+        add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job);
         return;
     };
 
@@ -1016,13 +977,11 @@ sub get_deps_hash {
         };
     };
     resolve_aliases($dependencies_hash, \%path_hash);
-    if (!$prepare) {
-        add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job);
-        add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job);
-        add_dependent_job($dependencies_hash, $module_to_build, $custom_job);
-        add_dependent_job($dependencies_hash, $module_to_build, $post_job) if ($module_to_build ne $initial_module);
-        add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job);
-    };
+    add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job);
+    add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job);
+    add_dependent_job($dependencies_hash, $module_to_build, $custom_job);
+    add_dependent_job($dependencies_hash, $module_to_build, $post_job) if ($module_to_build ne $initial_module);
+    add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job);
     store_weights($dependencies_hash);
 };
 
@@ -1402,7 +1361,7 @@ sub print_error {
 
 sub usage {
     print STDERR "\nbuild\n";
-    print STDERR "Syntax:    build    [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2] [prj_name3 [...]]]|[--since|-c prj_name] [--with_branches prj_name1[:prj_name2] [--skip prj_name1[:prj_name2] [prj_name3 [...]] [prj_name3 [...]|-b]|[--prepare|-p][:platform] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes|--server [--setenvstring \"string\"] [--client_timeout MIN] [--port port1[:port2:...:portN]]] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [--mode|-m OOo[,SO[,EXT]] [--html [--html_path html_file_path] [--dontgraboutput]] [--pre_job=pre_job_sring] [--job=job_string|-j] [--post_job=post_job_sring] [--stoponerror] [--genconf [--removeall|--clear|--remove|--add [module1,module2[,...,moduleN]]]] [--exclude_branch_from prj_name1[:prj_name2] [prj_name3 [...]]] [--interactive] [--verbose]\n";
+    print STDERR "Syntax:    build    [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2] [prj_name3 [...]]]|[--since|-c prj_name] [--with_branches prj_name1[:prj_name2] [--skip prj_name1[:prj_name2] [prj_name3 [...]] [prj_name3 [...]|-b] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes|--server [--setenvstring \"string\"] [--client_timeout MIN] [--port port1[:port2:...:portN]]] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [--mode|-m OOo[,SO[,EXT]] [--html [--html_path html_file_path] [--dontgraboutput]] [--pre_job=pre_job_sring] [--job=job_string|-j] [--post_job=post_job_sring] [--stoponerror] [--exclude_branch_from prj_name1[:prj_name2] [prj_name3 [...]]] [--interactive] [--verbose]\n";
     print STDERR "Example1:    build --from sfx2\n";
     print STDERR "                     - build all projects dependent from sfx2, starting with sfx2, finishing with the current module\n";
     print STDERR "Example2:    build --all:sfx2\n";
@@ -1417,7 +1376,6 @@ sub usage {
     print STDERR "        --from       - build all projects dependent from the specified (including it) till current one\n";
     print STDERR "        --exclude_branch_from    - exclude module(s) and its branch from the build\n";
     print STDERR "        --mode OOo   - build only projects needed for OpenOffice.org\n";
-    print STDERR "        --prepare    - clear all projects for incompatible build from prj_name till current one [for platform] (cws version)\n";
     print STDERR "        --with_branches- the same as \"--from\" but with build all projects in neighbour branches\n";
     print STDERR "        --skip       - do not build certain module(s)\n";
     print STDERR "        --since      - build all projects beginning from the specified till current one (the same as \"--all:prj_name\", but skipping prj_name)\n";
@@ -1438,11 +1396,6 @@ sub usage {
     print STDERR "                       file named $ENV{INPATH}.build.html will be generated in $ENV{SOLARSRC}\n";
     print STDERR "          --html_path      - set html page path\n";
     print STDERR "          --dontgraboutput - do not grab console output when generating html page\n";
-    print STDERR "        --genconf    - generate/modify workspace configuration file\n";
-    print STDERR "          --add            - add active module(s) to configuration file\n";
-    print STDERR "          --remove         - removeactive  modules(s) from configuration file\n";
-    print STDERR "          --removeall|--clear          - remove all active modules(s) from configuration file\n";
-
     print STDERR "        --stoponerror      - stop build when error occurs (for mp builds)\n";
     print STDERR "        --interactive      - start interactive build process (process can be managed via html page)\n";
     print STDERR "        --verbose          - generates a detailed output of the build process\n";
@@ -1478,12 +1431,6 @@ sub get_options {
         $arg =~ /^-F$/        and $cmd_file = shift @ARGV             and next;
         $arg =~ /^--skip$/    and get_modules_passed(\%skip_modules)      and next;
 
-        if ($arg =~ /^--with_branches$/ || $arg =~ /^-b$/) {
-                                    $build_from_with_branches = 1;
-                                    $build_all_parents = 1;
-                                    get_modules_passed(\%incompatibles);
-                                    next;
-        };
         $arg =~ /^--all:(\S+)$/ and $build_all_parents = 1
                                 and $build_all_cont = $1            and next;
         $arg =~ /^-a:(\S+)$/ and $build_all_parents = 1
@@ -1493,14 +1440,6 @@ sub get_options {
                                     get_modules_passed(\%incompatibles);
                                     next;
         };
-        if ($arg =~ /^--exclude_branch_from$/) {
-                                    get_modules_passed(\%exclude_branches);
-                                    next;
-        };
-        $arg =~ /^--prepare$/    and $prepare = 1 and next;
-        $arg =~ /^-p$/            and $prepare = 1 and next;
-        $arg =~ /^--prepare:/    and $prepare = 1 and $only_platform = $' and next;
-        $arg =~ /^-p:/            and $prepare = 1 and $only_platform = $' and next;
         $arg =~ /^--since$/        and $build_all_parents = 1
                                 and $build_since = shift @ARGV         and next;
         $arg =~ /^-c$/        and $build_all_parents = 1
@@ -1510,19 +1449,6 @@ sub get_options {
         $arg =~ /^--help$/        and usage()                            and do_exit(0);
         $arg =~ /^-h$/        and usage()                            and do_exit(0);
         $arg =~ /^--ignore$/        and $ignore = 1                            and next;
-        $arg =~ /^--genconf$/        and $generate_config = 1                  and next;
-        if ($arg =~ /^--add$/)      {
-                                        get_list_of_modules(\%add_to_config);
-                                        next;
-        };
-        if ($arg =~ /^--remove$/)   {
-                                        get_list_of_modules(\%remove_from_config);
-                                        if (!scalar %remove_from_config) {
-                                            print_error('No module list supplied!!');
-                                        };
-                                        next;
-        };
-        ($arg =~ /^--clear$/ || $arg =~ /^--removeall$/)  and $clear_config = 1 and next;
         $arg =~ /^--html$/        and $html = 1                            and next;
         $arg =~ /^--dontgraboutput$/        and $dont_grab_output = 1      and next;
         $arg =~ /^--html_path$/ and $html_path = shift @ARGV  and next;
@@ -1563,9 +1489,6 @@ sub get_options {
     $custom_job = 'deliver' if $deliver;
     $post_job = 'deliver' if (!$custom_job);
     $incompatible = scalar keys %incompatibles;
-    if ($prepare) {
-        print_error("--prepare is for use with --from switch only!\n") if (!$incompatible);
-    };
     if ($processes_to_run) {
         if ($ignore && !$html) {
             print_error("Cannot ignore errors in multiprocessing build");
@@ -1588,16 +1511,6 @@ sub get_options {
         print_error("--client_timeout switch is for server mode only!!") if ($client_timeout);
     };
 
-    if (!$generate_config) {
-        my $error_message = ' switch(es) should be used only with "--genconf"';
-        print_error('"--removeall" ("--clear")' . $error_message) if ($clear_config);
-        if ((scalar %add_to_config) || (scalar %remove_from_config)) {
-            print_error('"--add" or/and "--remove"' . $error_message);
-        };
-    } elsif ((!scalar %add_to_config) && !$clear_config && (!scalar %remove_from_config) && !$build_all_parents){
-        print_error('Please supply necessary switch for "--genconf" (--add|--remove|--removeall). --add can be used with --from and such');
-    };
-
     if ($only_platform) {
         $only_common = 'common';
         $only_common .= '.pro' if ($only_platform =~ /\.pro$/);
@@ -1617,7 +1530,6 @@ sub get_options {
 
 sub get_module_and_buildlist_paths {
     if ($build_all_parents || $checkparents) {
-        $source_config_file = $source_config->get_config_file_path();
         $active_modules{$_}++ foreach ($source_config->get_active_modules());
         my %active_modules_copy = %active_modules;
         foreach my $module ($source_config->get_all_modules()) {
@@ -2080,22 +1992,13 @@ sub announce_module {
 sub print_announce {
     my $prj = shift;
     return if (defined $module_announced{$prj});
-    my $prj_type = '';
-    $prj_type = $modules_types{$prj} if (defined $modules_types{$prj});
     my $text;
-    if ($prj_type eq 'lnk') {
-        if (!defined $active_modules{$prj}) {
-            $text = "Skipping module $prj\n";
-        } else {
-            $text = "Skipping link to $prj\n";
-        };
-        $build_is_finished{$prj}++;
-    } elsif ($prj_type eq 'img') {
-        $text = "Skipping incomplete $prj\n";
-        $build_is_finished{$prj}++;
-    } elsif ($custom_job) {
+    if ($custom_job)
+    {
         $text = "Running custom job \"$custom_job\" in module $prj\n";
-    } else {
+    }
+    else
+    {
         $text = "Building module $prj\n";
     };
     my $announce_string = $new_line;
@@ -2167,48 +2070,6 @@ sub are_all_dependent {
 
 
 #
-# Procedure defines if the local directory is a
-# complete module, an image or a link
-# return values: lnk link
-#                img incomplete (image)
-#                mod complete (module)
-#
-sub modules_classify {
-    my @modules = @_;
-    foreach my $module (sort @modules) {
-        if (!defined $module_paths{$module}) {
-            $modules_types{$module} = 'img';
-            next;
-        };
-        if (( $module_paths{$module} =~ /\.lnk$/) || ($module_paths{$module} =~ /\.link$/)
-                || (!defined $active_modules{$module})) {
-            $modules_types{$module} = 'lnk';
-            next;
-        };
-        $modules_types{$module} = 'mod';
-    };
-};
-
-#
-# Procedure clears up module for incompatible build
-#
-sub ensure_clear_module {
-    my $module = shift;
-    if ($modules_types{$module} eq 'mod') {
-         clear_module($module);
-         return;
-    };
-    if ($modules_types{$module} eq 'lnk' && (File::Basename::basename($module_paths{$module}) ne $module)) {
-        if(rename($module_paths{$module}, File::Basename::dirname($module_paths{$module}) ."/$module")) {
-            $module_paths{$module} = File::Basename::dirname($module_paths{$module}) ."/$module";
-            clear_module($module);
-        } else {
-            print_error("Cannot rename link to $module. Please rename it manually");
-        };
-    };
-};
-
-#
 # Procedure removes output tree from the module (without common trees)
 #
 sub clear_module {
@@ -2340,26 +2201,21 @@ sub prepare_incompatible_build {
         delete $$deps_hash{$build_all_cont};
     };
     @modules_built = keys %$deps_hash;
-    %add_to_config = %$deps_hash;
-    if ($prepare) {
-        if (!(defined $ENV{UPDATER})) {
-            $source_config->add_active_modules([keys %add_to_config], 0);
-        }
-        clear_delivered();
-    }
+
     my $old_output_tree = '';
-    foreach $prj (sort keys %$deps_hash) {
-        if ($prepare) {
-            ensure_clear_module($prj);
-        } else {
-            next if ($show);
-            if ($modules_types{$prj} ne 'mod') {
-                push(@missing_modules, $prj);
-            } elsif (-d $module_paths{$prj}. '/'. $ENV{INPATH}) {
-                $old_output_tree++;
-            };
+    foreach $prj (sort keys %$deps_hash)
+    {
+        next if ($show);
+        if ($modules_types{$prj} ne 'mod')
+        {
+            push(@missing_modules, $prj);
+        }
+        elsif (-d $module_paths{$prj}. '/'. $ENV{INPATH})
+        {
+            $old_output_tree++;
         };
     };
+
     if (scalar @missing_modules) {
         my $warning_string = 'Following modules are inconsistent/missing: ' . "@missing_modules";
         push(@warnings, $warning_string);
@@ -2371,19 +2227,13 @@ sub prepare_incompatible_build {
     if ($old_output_tree) {
         push(@warnings, 'Some module(s) contain old output tree(s)!');
     };
-    if (!$generate_config && scalar @warnings) {
+    if (scalar @warnings)
+    {
         print "WARNING(S):\n";
         print STDERR "$_\n" foreach (@warnings);
-        print "\nATTENTION: If you are performing an incompatible build, please break the build with Ctrl+C and prepare the workspace with \"--prepare\" switch!\n\n" if (!$prepare);
+        print "\nATTENTION: If you are performing an incompatible build, please break the build with Ctrl+C and prepare the workspace with \"--prepare\" switch!\n\n";
         sleep(5);
     };
-    if ($prepare) {
-    print "\nPreparation finished";
-        if (scalar @warnings) {
-            print " with WARNINGS!!\n\n";
-        } else {print " successfully\n\n";}
-    }
-    do_exit(0) if ($prepare);
 };
 
 #
diff --git a/solenv/bin/modules/SourceConfig.pm b/solenv/bin/modules/SourceConfig.pm
index b416bbb..c70f127 100644
--- a/solenv/bin/modules/SourceConfig.pm
+++ b/solenv/bin/modules/SourceConfig.pm
@@ -38,7 +38,6 @@ package SourceConfig;
 
 use strict;
 
-use constant SOURCE_CONFIG_FILE_NAME => 'source_config';
 use constant SOURCE_CONFIG_VERSION => 3;
 
 use Carp;
@@ -59,24 +58,14 @@ sub new {
     my $source_root = shift;
     my $self = {};
     $self->{USER_SOURCE_ROOT} = undef;
-    $self->{SOURCE_CONFIG_FILE} = undef;
     if (defined $source_root) {
         $source_root = Cwd::realpath($source_root);
         $source_root =~ s/\\|\/$//;
-        if (-f $source_root) {
-            # We have path to source_config
-            if (File::Basename::basename($source_root) eq 'source_config') {
-                # We have path to source_config
-                $self->{SOURCE_CONFIG_FILE} = $source_root;
-                $source_root = File::Basename::dirname($source_root);
-            } else {
-                croak("$source_root is not a source_config file");
-            };
-        } else {
-            $self->{USER_SOURCE_ROOT} = $source_root;
-            $source_root .= '/..';
-        }
-    } else {
+        $self->{USER_SOURCE_ROOT} = $source_root;
+        $source_root .= '/..';
+    }
+    else
+    {
         $source_root = $ENV{SRC_ROOT};
     };
     if ( defined $ENV{USE_GBUILD} and "$ENV{USE_GBUILD}" ne "" )
@@ -95,7 +84,6 @@ sub new {
     $self->{ACTIVATED_REPOSITORIES} = {};
     $self->{MODULE_PATHS} = {};
     $self->{MODULE_BUILD_LIST_PATHS} = {};
-    $self->{ACTIVATED_MODULES} = {};
     $self->{MODULE_REPOSITORY} = {};
     $self->{REAL_MODULES} = {};
     $self->{NEW_MODULES} = [];
@@ -106,16 +94,16 @@ sub new {
     $self->{GBUILD} = 0;
     $self->{REPORT_MESSAGES} = [];
     $self->{CONFIG_FILE_CONTENT} = [];
-    if (defined $self->{USER_SOURCE_ROOT}) {
-        ${$self->{REPOSITORIES}}{File::Basename::basename($self->{USER_SOURCE_ROOT})} = $self->{USER_SOURCE_ROOT};
-    };
-    $self->{SOURCE_CONFIG_FILE} = get_config_file($self->{SOURCE_ROOT}) if (!defined $self->{SOURCE_CONFIG_FILE});
-    $self->{SOURCE_CONFIG_DEFAULT} = $self->{SOURCE_ROOT} .'/'.SOURCE_CONFIG_FILE_NAME;
-    if (defined $self->{USER_SOURCE_ROOT}) {
+    if (defined $self->{USER_SOURCE_ROOT})
+    {
         ${$self->{REPOSITORIES}}{File::Basename::basename($self->{USER_SOURCE_ROOT})} = $self->{USER_SOURCE_ROOT};
+    }
+    else
+    {
+        get_fallback_repository($self);
     };
-    read_config_file($self);
-       get_module_paths($self);
+
+    get_module_paths($self);
     bless($self, $class);
     return $self;
 }
@@ -132,29 +120,6 @@ sub get_repositories
     return sort keys %{$self->{REPOSITORIES}};
 }
 
-sub add_repository
-{
-    my $self        = shift;
-    my $new_rep_path = shift;
-    $new_rep_path = Cwd::realpath($new_rep_path);
-    my $new_rep_name = File::Basename::basename($new_rep_path);
-    if (defined ${$self->{REPOSITORIES}}{$new_rep_name}) {
-        croak("Repository $new_rep_name is already defined!!");
-    };
-    ${$self->{REPOSITORIES}}{$new_rep_name} = $new_rep_path;
-    $self -> get_repository_module_paths($new_rep_name);
-}
-
-sub get_config_file_default_path {
-    my $self        = shift;
-    return $self->{SOURCE_CONFIG_DEFAULT};
-}
-
-sub get_config_file_path {
-    my $self = shift;
-    return $self->{SOURCE_CONFIG_FILE};
-}
-
 sub get_module_repository {
     my $self = shift;
     my $module = shift;
@@ -172,7 +137,7 @@ sub get_module_path {
     if (defined ${$self->{MODULE_PATHS}}{$module}) {
         return ${$self->{MODULE_PATHS}}{$module};
     } else {
-        Carp::cluck("No path for module $module in active repositories!!\n") if ($debug);
+        Carp::cluck("No path for module $module in active repositories!!\n");
         return undef;
     };
 }
@@ -209,19 +174,13 @@ sub get_all_modules
 sub get_active_modules
 {
     my $self        = shift;
-    if (scalar keys %{$self->{ACTIVATED_MODULES}}) {
-        return sort keys %{$self->{ACTIVATED_MODULES}};
-    }
-       return sort keys %{$self->{REAL_MODULES}};
+    return sort keys %{$self->{REAL_MODULES}};
 }
 
 sub is_active
 {
     my $self        = shift;
     my $module      = shift;
-    if (scalar keys %{$self->{ACTIVATED_MODULES}}) {
-        return exists ($self->{ACTIVATED_MODULES}{$module});
-    }
     return exists ($self->{REAL_MODULES}{$module});
 }
 
@@ -259,21 +218,9 @@ sub get_module_paths {
     foreach my $repository (keys %{$self->{REPOSITORIES}}) {
         get_repository_module_paths($self, $repository);
     };
-    my @false_actives = ();
-    foreach (keys %{$self->{ACTIVATED_MODULES}}) {
-        push(@false_actives, $_) if (!defined  ${$self->{MODULE_PATHS}}{$_});
-    };
-    croak("Error!! Activated module(s): @false_actives\nnot found in the active repositories!! Please check your " . $self->{SOURCE_CONFIG_FILE} . "\n") if (scalar @false_actives);
     croak("No modules found!") if (!scalar keys %{$self->{MODULE_PATHS}});
 };
 
-sub get_config_file {
-    my $source_root = shift;
-    my $possible_path = $source_root . '/' . SOURCE_CONFIG_FILE_NAME;
-    return $possible_path if (-f $possible_path);
-    return '';
-};
-
 #
 # Fallback - fallback repository is based on RepositoryHelper educated guess
 #
@@ -283,394 +230,7 @@ sub get_fallback_repository {
     ${$self->{REPOSITORIES}}{File::Basename::basename($repository_root)} = $repository_root;
 };
 
-sub read_config_file {
-    my $self = shift;
-    if (!$self->{SOURCE_CONFIG_FILE}) {
-        if (!defined $self->{USER_SOURCE_ROOT}) {
-            get_fallback_repository($self);
-        };
-        return;
-    };
-    my $repository_section = 0;
-    my $module_section = 0;
-    my $line = 0;
-    my @file_content = ();
-
-    if (open(SOURCE_CONFIG_FILE, $self->{SOURCE_CONFIG_FILE})) {
-        foreach (<SOURCE_CONFIG_FILE>) {
-            push (@{$self->{CONFIG_FILE_CONTENT}}, $_);
-            $line++;
-            chomp;
-            next if (!/^\S+/);
-            next if (/^\s*#+/);
-            s/\r\n//;
-            if (/^\[repositories\]\s*(\s+#)*/) {
-                $module_section = 0;
-                $repository_section = 1;
-                next;
-            };
-            if (/^\[modules\]\s*(\s+#)*/) {
-                $module_section = 1;
-                $repository_section = 0;
-                next;
-            };
-            next if (!$repository_section && !$module_section);
-            if (/\s*(\S+)=active\s*(\s+#)*/) {
-                if ($repository_section) {
-                    my $repository_source_path = $self->{SOURCE_ROOT} . "/$1";
-                    ${$self->{REPOSITORIES}}{$1} = $repository_source_path;
-                    ${$self->{ACTIVATED_REPOSITORIES}}{$1}++;
-                    next;
-                }
-                if ($module_section) {
-                    ${$self->{ACTIVATED_MODULES}}{$1}++;
-                    next;
-                };
-            };
-            croak("Line $line in " . $self->{SOURCE_CONFIG_FILE} . ' violates format. Please make your checks!');
-        };
-        close SOURCE_CONFIG_FILE;
-        if (!scalar keys %{$self->{REPOSITORIES}}) {
-            get_fallback_repository($self);
-        };
-    } else {
-        croak('Cannot open ' . $self->{SOURCE_CONFIG_FILE} . ' for reading');
-    };
-};
-
-sub remove_all_activated_repositories {
-    my $self = shift;
-    $self->remove_activated_repositories([keys %{$self->{ACTIVATED_REPOSITORIES}}]);
-};
-
-sub remove_activated_repositories {
-    my $self = shift;
-    my $new_repositories_ref = shift;
-    push(@{$self->{WARNINGS}}, "\nWARNING: Empty repository list passed for removing from source_config\n") if (!scalar @$new_repositories_ref);
-    $self->{VERBOSE} = shift;
-    $self->{REMOVE_REPOSITORIES} = {};
-    foreach (@$new_repositories_ref) {
-        if (!defined ${$self->{ACTIVATED_REPOSITORIES}}{$_}) {
-            push (@{$self->{WARNINGS}}, "\nWARNING: repository $_ is not activated in ". $self->get_config_file_default_path()."\n");
-        } else {
-            ${$self->{REMOVE_REPOSITORIES}}{$_}++;
-            delete ${$self->{ACTIVATED_REPOSITORIES}}{$_};
-        };
-    };
-    generate_config_file($self);
-};
-
-sub remove_all_activated_modules {
-    my $self = shift;
-    $self->remove_activated_modules([keys %{$self->{ACTIVATED_MODULES}}]);
-};
-
-sub remove_activated_modules {
-    my $self = shift;
-    my $new_modules_ref = shift;
-    push(@{$self->{WARNINGS}}, "\nWARNING: Empty module list passed for removing from source_config\n") if (!scalar @$new_modules_ref);
-    $self->{VERBOSE} = shift;
-    $self->{REMOVE_MODULES} = {};
-    foreach (@$new_modules_ref) {
-        if (!defined ${$self->{ACTIVATED_MODULES}}{$_}) {
-            push (@{$self->{WARNINGS}}, "\nWARNING: module $_ is not activated in ". $self->get_config_file_default_path()."\n");
-        } else {
-            ${$self->{REMOVE_MODULES}}{$_}++;
-            delete ${$self->{ACTIVATED_MODULES}}{$_};
-        };
-    };
-    generate_config_file($self);
-};
-
-sub add_active_repositories {
-    my $self = shift;
-    $self->{NEW_REPOSITORIES} = shift;
-    croak('Empty repository list passed for addition to source_config') if (!scalar @{$self->{NEW_REPOSITORIES}});
-    $self->{VERBOSE} = shift;
-    foreach (@{$self->{NEW_REPOSITORIES}}) {
-        $self->add_repository($_);
-    };
-    generate_config_file($self);
-};
-
-sub add_active_modules {
-    my $self = shift;
-    my $module_list_ref = shift;
-    my $ignored_modules_string = '';
-    my @real_modules = ();
-    foreach my $module (sort @$module_list_ref) {
-        if ($self->get_module_path($module)) {
-            push(@real_modules, $module);
-        } else {
-            $ignored_modules_string .= " $module";
-        };
-    };
-    push (@{$self->{WARNINGS}}, "\nWARNING: following modules are not found in active repositories, and have not been added to the " . $self->get_config_file_default_path() . ":$ignored_modules_string\n") if ($ignored_modules_string);
-    $self->{NEW_MODULES} = \@real_modules;
-    croak('Empty module list passed for addition to source_config') if (!scalar @{$self->{NEW_MODULES}});
-    $self->{VERBOSE} = shift;
-    generate_config_file($self);
-};
-
-sub add_content {
-    my $self = shift;
-    my $content = shift;
-    my $entries_to_add = shift;
-    return if (!scalar @$entries_to_add);
-    my $message;
-    my $message_part1;
-    my $warning_message;
-    my $activated_entries;
-
-    if ($entries_to_add == $self->{NEW_MODULES}) {
-        $self->{NEW_MODULES} = [];
-        $message_part1 = "Module(s):\n";
-        $activated_entries = $self->{ACTIVATED_MODULES};
-    } elsif ($entries_to_add == $self->{NEW_REPOSITORIES}) {
-        $self->{NEW_REPOSITORIES} = [];
-        $message_part1 = "Repositories:\n";
-        $activated_entries = $self->{ACTIVATED_REPOSITORIES};
-    };
-    foreach my $entry (@$entries_to_add) {
-        if (defined $$activated_entries{$entry}) {
-            $warning_message .= "$entry "
-        } else {
-            push(@$content, "$entry=active\n");
-            ${$activated_entries}{$entry}++;
-            $message .= "$entry "
-        };
-    };
-
-    push(@{$self->{REPORT_MESSAGES}}, "\n$message_part1 $message\nhave been added to the ". $self->get_config_file_default_path()."\n") if ($message);
-    push (@{$self->{WARNINGS}}, "\nWARNING: $message_part1 $warning_message\nare already added to the ". $self->get_config_file_default_path()."\n") if ($warning_message);
-};
-
-sub generate_config_file {
-    my $self = shift;
-    my @config_content_new = ();
-    my ($module_section, $repository_section);
-    my %removed_modules = ();
-    my %removed_repositories = ();
-    foreach (@{$self->{CONFIG_FILE_CONTENT}}) {
-        if (/^\[repositories\]\s*(\s+#)*/) {
-            if ($module_section) {
-                $self->add_content(\@config_content_new, $self->{NEW_MODULES});
-            };
-            $module_section = 0;
-            $repository_section = 1;
-        };
-        if (/^\[modules\]\s*(\s+#)*/) {
-            if ($repository_section) {
-                $self->add_content(\@config_content_new, $self->{NEW_REPOSITORIES});
-            };
-            $module_section = 1;
-            $repository_section = 0;
-        };
-        if ($module_section && /\s*(\S+)=active\s*(\s+#)*/) {
-            if (defined ${$self->{REMOVE_MODULES}}{$1}) {
-                $removed_modules{$1}++;
-                next;
-            };
-        }
-        if ($repository_section && /\s*(\S+)=active\s*(\s+#)*/) {
-            if (defined ${$self->{REMOVE_REPOSITORIES}}{$1}) {
-                $removed_repositories{$1}++;
-                next;
-            };
-        }
-        push(@config_content_new, $_);
-    };
-    if (scalar @{$self->{NEW_MODULES}}) {
-        push(@config_content_new, "[modules]\n") if (!$module_section);
-        $self->add_content(\@config_content_new, $self->{NEW_MODULES});
-    };
-    if (scalar @{$self->{NEW_REPOSITORIES}}) {
-        push(@config_content_new, "[repositories]\n") if (!$repository_section);
-        $self->add_content(\@config_content_new, $self->{NEW_REPOSITORIES});
-    };
-    if (scalar keys %removed_modules) {
-        my @deleted_modules = keys %removed_modules;
-        push(@{$self->{REPORT_MESSAGES}}, "\nModules: @deleted_modules\nhave been removed from the ". $self->get_config_file_default_path()."\n");
-
-    };
-    if (scalar keys %removed_repositories) {
-        my @deleted_repositories = keys %removed_repositories;
-        push(@{$self->{REPORT_MESSAGES}}, "\nRepositories: @deleted_repositories\nhave been removed from the ". $self->get_config_file_default_path()."\n");
-
-    };
-
-    # Writing file, printing warnings and reports
-
-    #check if we need to write a new file
-    my $write_needed = 0;
-    if ((scalar @{$self->{CONFIG_FILE_CONTENT}}) != (scalar @config_content_new)) {
-        $write_needed++;
-    } else {
-        foreach my $i (0 .. $#{$self->{CONFIG_FILE_CONTENT}}) {
-            if (${$self->{CONFIG_FILE_CONTENT}}[$i] ne $config_content_new[$i]) {
-                $write_needed++;
-                last;
-            };
-        };
-    };
-    if ($write_needed) {
-        my $temp_config_file = File::Temp::tmpnam($ENV{TMP});
-        die("Cannot open $temp_config_file") if (!open(NEW_CONFIG, ">$temp_config_file"));
-        print NEW_CONFIG $_ foreach (@config_content_new);
-        close NEW_CONFIG;
-        rename($temp_config_file, $self->get_config_file_default_path()) or  system("mv", $temp_config_file, $self->get_config_file_default_path());
-        if (-e $temp_config_file) {
-            system("rm -rf $temp_config_file") if (!unlink $temp_config_file);
-        };
-        $self->{CONFIG_FILE_CONTENT} = \@config_content_new;
-    };
-    if ($self->{VERBOSE}) {
-        print $_ foreach (@{$self->{WARNINGS}});
-        $self->{VERBOSE} = 0;
-    };
-    $self->{WARNINGS} = [];
-    print $_ foreach (@{$self->{REPORT_MESSAGES}});
-    $self->{REPORT_MESSAGES} = [];
-};
-
 ##### finish #####
 
 1; # needed by use or require
 
-__END__
-
-=head1 NAME
-
-SourceConfig - Perl extension for parsing general info databases
-
-=head1 SYNOPSIS
-
-    # example that will read source_config file and return the active repositories
-
-    use SourceConfig;
-
-    # Create a new instance of the parser:
-    $a = SourceConfig->new();
-
-    # Get repositories for the actual workspace:
-    $a->get_repositories();
-
-    # Add a repository new_repository for the actual workspace (via full path):
-    $a->add_repository(/DEV300/new_repository);
-
-=head1 DESCRIPTION
-
-SourceConfig is a perl extension to load and parse General Info Databses.
-It uses a simple object oriented interface to retrieve the information stored
-in the database.
-
-Methods:
-
-SourceConfig::new()
-
-Creates a new instance of SourceConfig. Can be initialized by: path to the default repository, path to the source_config, default - empty, the source_config will be taken from the environment
-
-
-SourceConfig::get_version()
-
-Returns version number of the module. Can't fail.
-
-
-SourceConfig::get_repositories()
-
-Returns sorted list of active repositories for the actual workspace
-
-
-SourceConfig::add_repository(REPOSITORY_PATH)
-
-Adds a repository to the list of active repositories
-
-
-SourceConfig::get_active_modules()
-
-Returns a sorted list of active modules
-
-SourceConfig::get_all_modules()
-
-Returns sorted list of all modules in active repositories.
-
-SourceConfig::get_module_path($module)
-
-Returns absolute module path
-
-SourceConfig::get_module_build_list($module)
-
-Returns absolute module build list path
-
-SourceConfig::get_module_repository($module)
-
-Returns the module's repository
-
-SourceConfig::get_config_file_path()
-
-Returns absolute module to the source configuration file
-
-SourceConfig::get_config_file_default_path()
-
-Returns default path for source configuration file
-
-SourceConfig::is_active()
-
-Returns 1 (TRUE) if a module is active
-Returns 0 (FALSE) if a module is not active
-
-SourceConfig::add_active_modules($module_array_ref)
-
-Adds modules from the @$module_array_ref as active to the source_config file
-
-SourceConfig::add_active_repositories($repository_array_ref)
-
-Adds repositories from the @$repository_array_ref as active to the source_config file
-
-SourceConfig::remove_activated_modules($module_array_ref)
-
-Removes modules from the @$module_array_ref from the source_config file
-
-SourceConfig::remove_all_activated_modules()
-
-Removes all activated modules from the source_config file
-
-SourceConfig::remove_activated_repositories($repository_array_ref)
-
-Removes repositories from the @$repository_array_ref from the source_config file
-
-SourceConfig::remove_all_activated_repositories()
-
-Removes all activated repositories from the source_config file
-
-
-=head2 EXPORT
-
-SourceConfig::new()
-SourceConfig::get_version()
-SourceConfig::get_repositories()
-SourceConfig::add_repository()
-SourceConfig::get_active_modules()
-SourceConfig::get_all_modules()
-SourceConfig::get_module_path($module)
-SourceConfig::get_module_build_list($module)
-SourceConfig::get_module_repository($module)
-SourceConfig::get_config_file_path()
-SourceConfig::get_config_file_default_path()
-SourceConfig::is_active($module)
-SourceConfig::add_active_modules($module_array_ref)
-SourceConfig::add_active_repositories($repository_array_ref)
-SourceConfig::remove_activated_modules($module_array_ref)
-SourceConfig::remove_all_activated_modules()
-SourceConfig::remove_activated_repositories($repository_array_ref)
-SourceConfig::remove_all_activated_repositories()
-
-=head1 AUTHOR
-
-Vladimir Glazunov, vg at openoffice.org
-
-=head1 SEE ALSO
-
-perl(1).
-
-=cut


More information about the Libreoffice-commits mailing list