diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-03-02 13:59:26 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-03-02 14:06:05 +0100 |
commit | ff28e99c5bffc95b06908f30469caa276efa2b38 (patch) | |
tree | f6830f7bb69b04961b402ad9d3f651c01983f8ed /solenv | |
parent | 89a4c0e15b4933f36fd0b2c39d83871bffb3405a (diff) |
solenv: remove obsolete OOo SourceConfig cruft
Change-Id: Id45dde81bb699e8c6614b70a815588b884d9a313
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/bin/modules/SourceConfig.pm | 187 | ||||
-rw-r--r-- | solenv/bin/modules/SourceConfigHelper.pm | 408 |
2 files changed, 0 insertions, 595 deletions
diff --git a/solenv/bin/modules/SourceConfig.pm b/solenv/bin/modules/SourceConfig.pm deleted file mode 100755 index 9fad7b00a0fc..000000000000 --- a/solenv/bin/modules/SourceConfig.pm +++ /dev/null @@ -1,187 +0,0 @@ -# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -#************************************************************************* -# -# SourceConfig - Perl extension for parsing general info databases -# -# usage: see below -# -#************************************************************************* - -package SourceConfig; - -use strict; - -use Carp; -use Cwd; -use RepositoryHelper; -use File::Basename; -use File::Temp qw(tmpnam); - -my $debug = 0; - -##### profiling ##### - -##### ctor ##### - -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $source_root = shift; - my @additional_repositories = @_; - - my $self = {}; - $self->{USER_SOURCE_ROOT} = undef; - if (defined $source_root) { - $source_root = Cwd::realpath($source_root); - $source_root =~ s/\\|\/$//; - $self->{USER_SOURCE_ROOT} = $source_root; - $source_root .= '/..'; - } - else - { - $source_root = $ENV{SRC_ROOT}; - }; - $source_root = Cwd::realpath($source_root); - $self->{SOURCE_ROOT} = $source_root; - $self->{DEBUG} = 0; - $self->{VERBOSE} = 0; - $self->{REPOSITORIES} = {}; - $self->{MODULE_PATHS} = {}; - $self->{MODULE_REPOSITORY} = {}; - $self->{REAL_MODULES} = {}; - if (defined $self->{USER_SOURCE_ROOT}) - { - ${$self->{REPOSITORIES}}{File::Basename::basename($self->{USER_SOURCE_ROOT})} = $self->{USER_SOURCE_ROOT}; - } - else - { - get_fallback_repository($self); - }; - foreach my $additional_repository (@additional_repositories) - { - ${$self->{REPOSITORIES}}{File::Basename::basename($additional_repository)} = $additional_repository; - } - - get_module_paths($self); - bless($self, $class); - return $self; -} - -##### methods ##### - -sub get_repositories -{ - my $self = shift; - return sort keys %{$self->{REPOSITORIES}}; -} - -sub get_module_repository { - my $self = shift; - my $module = shift; - if (defined ${$self->{MODULE_REPOSITORY}}{$module}) { - return ${$self->{MODULE_REPOSITORY}}{$module}; - } else { - Carp::cluck("No such module $module in active repositories!!\n"); - return undef; - }; -} - -sub get_module_path { - my $self = shift; - my $module = shift; - if (defined ${$self->{MODULE_PATHS}}{$module}) { - return ${$self->{MODULE_PATHS}}{$module}; - } else { - Carp::cluck("No path for module $module in active repositories!!\n"); - return undef; - }; -} - -sub get_all_modules -{ - my $self = shift; - my $module = shift; - return sort keys %{$self->{MODULE_PATHS}}; -}; - -sub get_active_modules -{ - my $self = shift; - return sort keys %{$self->{REAL_MODULES}}; -} - -sub is_active -{ - my $self = shift; - my $module = shift; - return exists ($self->{REAL_MODULES}{$module}); -} - -##### private methods ##### - -sub get_repository_module_paths { - my $self = shift; - my $repository = shift; - my $repository_path = ${$self->{REPOSITORIES}}{$repository}; - if (opendir DIRHANDLE, $repository_path) { - foreach my $module (readdir(DIRHANDLE)) { - next if (($module =~ /^\.+/) || (!-d "$repository_path/$module")); - my $module_entry = $module; - if (($module !~ s/\.lnk$//) && ($module !~ s/\.link$//)) { - $self->{REAL_MODULES}{$module}++; - } - my $possible_path = "$repository_path/$module_entry"; - if (-d $possible_path) { - if (defined ${$self->{MODULE_PATHS}}{$module}) { - close DIRHANDLE; - croak("Ambiguous paths for module $module: $possible_path and " . ${$self->{MODULE_PATHS}}{$module}); - }; - ${$self->{MODULE_PATHS}}{$module} = $possible_path; - ${$self->{MODULE_REPOSITORY}}{$module} = $repository; - } - }; - close DIRHANDLE; - } else { - croak("Cannot read $repository_path repository content"); - }; -}; - -sub get_module_paths { - my $self = shift; - foreach my $repository (keys %{$self->{REPOSITORIES}}) { - get_repository_module_paths($self, $repository); - }; - croak("No modules found!") if (!scalar keys %{$self->{MODULE_PATHS}}); -}; - -# -# Fallback - fallback repository is based on RepositoryHelper educated guess -# -sub get_fallback_repository { - my $self = shift; - my $repository_root = RepositoryHelper->new()->get_repository_root(); - ${$self->{REPOSITORIES}}{File::Basename::basename($repository_root)} = $repository_root; -}; - -##### finish ##### - -1; # needed by use or require - diff --git a/solenv/bin/modules/SourceConfigHelper.pm b/solenv/bin/modules/SourceConfigHelper.pm deleted file mode 100644 index 0d6fddf970d7..000000000000 --- a/solenv/bin/modules/SourceConfigHelper.pm +++ /dev/null @@ -1,408 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -#************************************************************************* -# -# SourceConfigHelper - Perl extension for parsing general info databases -# -# usage: see below -# -#************************************************************************* - -package SourceConfigHelper; - -use strict; - -use RepositoryHelper; -use SourceConfig; -use Cwd qw (cwd); -use Carp; - -my $debug = 0; -my @source_config_list; # array of sourceconfig objects - -#----------------------------------------------------------------------- -# Constants -#----------------------------------------------------------------------- - -use constant SOURCE_CONFIG_NONE => 0; -use constant SOURCE_CONFIG_CURRENT_FIRST => 1; -use constant SOURCE_CONFIG_ENVIRONMENT_FIRST => 2; -use constant SOURCE_CONFIG_CURRENT_ONLY => 3; -use constant SOURCE_CONFIG_ENVIRONMENT_ONLY => 4; - -use constant SOURCE_CONFIG_DEFAULT => SOURCE_CONFIG_CURRENT_FIRST; - -##### profiling ##### - -##### ctor ##### - -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $init_action = shift; - my $self = {}; - my $SourceConfigCurrent; - my $SourceConfigEnvironment; - - $init_action = SOURCE_CONFIG_DEFAULT if (!defined ($init_action)); - if (!eval ($init_action) or ($init_action < SOURCE_CONFIG_NONE) or ($init_action > SOURCE_CONFIG_ENVIRONMENT_ONLY)) { - croak("wrong initial parameter: $init_action\n"); - } - - if ($init_action != SOURCE_CONFIG_NONE) { - my $repositoryHash_ref = {}; - if ($init_action != SOURCE_CONFIG_ENVIRONMENT_ONLY) { - my $initial_directory = cwd(); - my $result = is_repository($initial_directory, $repositoryHash_ref); - if ($result) { - $SourceConfigCurrent = SourceConfig->new($repositoryHash_ref->{REPOSITORY_ROOT}); - } - } - if ($init_action != SOURCE_CONFIG_CURRENT_ONLY) { - my $source_config = $ENV{SOURCE_ROOT_DIR} . '/' . SourceConfig::SOURCE_CONFIG_FILE_NAME; - if (-f $source_config) { - $SourceConfigEnvironment = SourceConfig->new($source_config); - } - } - - # fill array - - if (($init_action == SOURCE_CONFIG_CURRENT_FIRST) or ($init_action == SOURCE_CONFIG_CURRENT_ONLY)) { - if (defined ($SourceConfigCurrent)) { - push (@source_config_list, $SourceConfigCurrent); - } - if ($init_action == SOURCE_CONFIG_CURRENT_FIRST) { - if (defined ($SourceConfigEnvironment)) { - push (@source_config_list, $SourceConfigEnvironment); - } - } - } - elsif (($init_action == SOURCE_CONFIG_ENVIRONMENT_FIRST) or ($init_action == SOURCE_CONFIG_ENVIRONMENT_ONLY)) { - if (defined ($SourceConfigEnvironment)) { - push (@source_config_list, $SourceConfigEnvironment); - } - if ($init_action == SOURCE_CONFIG_ENVIRONMENT_FIRST) { - if (defined ($SourceConfigCurrent)) { - push (@source_config_list, $SourceConfigCurrent); - } - } - } - } - - $self->{SOURCE_CONFIG_LIST} = \@source_config_list; - - bless($self, $class); - return $self; -} - -##### methods ##### - -############################################################################################ - -sub add_SourceConfig { - my $self = shift; - my $source_config = shift; - push (@{$self->{SOURCE_CONFIG_LIST}}, $source_config); -} - -############################################################################################ - -sub get_SourceConfigList { - my $self = shift; - return @{$self->{SOURCE_CONFIG_LIST}}; -} - -############################################################################################ - -sub has_SourceConfig { - my $self = shift; - my $result = 0; - my $count = @{$self->{SOURCE_CONFIG_LIST}}; - $result = 1 if ($count > 0); - return $result; -} - -############################################################################################ - -sub get_module_path { - my $self = shift; - my $module = shift; - my $function = \&SourceConfig::get_module_path; - my $result; - $result = $self->get_StringResult ($function, $module); - return $result; -} - -############################################################################################ - -sub get_active_modules { - my $self = shift; - my $parameter; # empty - my $function = \&SourceConfig::get_active_modules; - my $array_ref; - $array_ref = $self->get_ArrayResult ($function, $parameter); - return @$array_ref; -} - -############################################################################################ - -sub get_repositories { - my $self = shift; - my $parameter; # empty - my $function = \&SourceConfig::get_repositories; - my $array_ref; - $array_ref = $self->get_ArrayResult ($function, $parameter); - return @$array_ref; -} - -############################################################################################ - -sub get_module_repository { - my $self = shift; - my $module = shift; - my $function = \&SourceConfig::get_module_repository; - my $result; - $result = $self->get_StringResult ($function, $module); - return $result; -} - -############################################################################################ - -sub is_active { - my $self = shift; - my $module = shift; - my $function = \&SourceConfig::is_active; - my $result_ref; - my $is_active = 0; - $result_ref = $self->get_ResultOfList ($function, $module); - my $count = @$result_ref; - if ($count>0) { - foreach my $active (@$result_ref) { - if ($active) { - $is_active = $active; - } - } - } - return $is_active; -} - -##### private methods ##### - -############################################################################################ -# -# is_repository () : check if the directory is a valid repository -# -# input: - directory -# - hash reference, where the output will be stored -# -# output: 0 = FALSE, the directory is no valid repository -# 1 = TRUE, the repository root can be found in $repositoryHash_ref->{REPOSITORY_ROOT} -# -############################################################################################ - -sub is_repository { - my $directory = shift; - my $repositoryHash_ref = shift; - $repositoryHash_ref->{INITIAL_DIRECTORY} = $directory; - $repositoryHash_ref->{REPOSITORY_ROOT} = undef; - my $result = RepositoryHelper::search_via_build_lst($repositoryHash_ref); - return $result; -} - -############################################################################################ -# -# get_ResultOfList(): give back an array reference from all SourceConfig Objects results -# -# input: - function : reference to the called function of each SourceConfig Object -# - parameter : parameter for the called function -# -# output: result : array of all results -# -############################################################################################ - -sub get_ResultOfList { - my $self = shift; - my $function = shift; - my $parameter = shift; - my @result; - foreach my $source_config (@{$self->{SOURCE_CONFIG_LIST}}) { - push (@result, &$function ($source_config, $parameter)); - } - return \@result; -} - -############################################################################################ -# -# get_StringResult(): give back the first defined result from all SourceConfig Objects -# -# input: - function : reference to the called function of each SourceConfig Object -# - parameter : parameter for the called function -# -# output: result : scalar variable (string), undef if no result -# -############################################################################################ - -sub get_StringResult { - my $self = shift; - my $function = shift; - my $parameter = shift; - my $result_ref; - $result_ref = $self->get_ResultOfList ($function, $parameter); - my $count = @$result_ref; - if ($count>0) { - my $value; - my $i = 0; - while (($i < $count) and !defined ($value)) { # search the first defined result - $value = $$result_ref[$i]; - $i++; - } - return $value; - } - return undef; -} - -############################################################################################ -# -# get_StringResult(): give back a sorted and uniqe array reference of the results -# from all SourceConfig Objects -# -# input: - function : reference to the called function of each SourceConfig Object -# - parameter : parameter for the called function -# -# output: result : sorted and uniqe array reference -# -############################################################################################ - -sub get_ArrayResult { - my $self = shift; - my $function = shift; - my $parameter = shift; - my $result_ref; - my @modules; - $result_ref = $self->get_ResultOfList ($function, $parameter); - my $count = @$result_ref; - if ($count>0) { - my %moduleHash; - foreach my $module (@$result_ref) { - $moduleHash{$module}++; - } - @modules = sort keys %moduleHash; - } - return \@modules; -} - - ##### finish ##### - -1; # needed by use or require - -__END__ - -=head1 NAME - -SourceConfigHelper - Perl extension for handling with SourceConfigObjetcs - -=head1 SYNOPSIS - - # example that will read source_config file and return the active repositories - - use SourceConfigHelper; - - # Create a new instance: - $a = SourceConfigHelper->new(); - - # Get repositories for the actual workspace: - $a->get_repositories(); - -=head1 DESCRIPTION - -SourceConfigHelper is a perl extension to handle more than one objects of SourceConfig -to set up a search order for modules. - -Methods: - -SourceConfigHelper::new() - -Creates a new instance of SourceConfigHelper. Can be initialized by: default - empty or with a constant of search order. default: the source_config will be taken first from the current repository and second from the environment -Possible parameters are: -SourceConfigHelper::SOURCE_CONFIG_NONE - no SourceConfig Object will be created -SourceConfigHelper::SOURCE_CONFIG_CURRENT_FIRST - use the current repository first -SourceConfigHelper::SOURCE_CONFIG_ENVIRONMENT_FIRST - use the repository of the environment first -SourceConfigHelper::SOURCE_CONFIG_CURRENT_ONLY - use only the current repository -SourceConfigHelper::SOURCE_CONFIG_ENVIRONMENT_ONLY - use only the repository of the environment - -SourceConfigHelper::get_repositories() - -Returns sorted list of active repositories for the actual workspace - -SourceConfigHelper::get_active_modules() - -Returns a sorted list of active modules - -SourceConfigHelper::get_all_modules() - -Returns sorted list of all modules in active repositories. - -SourceConfigHelper::get_module_path($module) - -Returns absolute module path. If the module is not active or don't exists, "undef" will be returned. - -SourceConfigHelper::get_module_repository($module) - -Returns the module's repository. If the module is not active or don't exists, "undef" will be returned. - -SourceConfigHelper::is_active() - -Returns 1 (TRUE) if a module is active -Returns 0 (FALSE) if a module is not active - -SourceConfigHelper::add_SourceConfig($SourceConfigObject) - -Add the SourceConfigObject to the end of the list - -SourceConfigHelper::get_SourceConfigList() - -Return an array of SourceConfigObjects - -SourceConfigHelper::has_SourceConfig() - -Returns 1 (TRUE) if one or more SourceConfig Objects is in the list -Returns 0 (FALSE) if no SourceConfig Object is in the list (can happen if there is no valid repository) - -=head2 EXPORT - -SourceConfigHelper::new() -SourceConfigHelper::get_repositories() -SourceConfigHelper::get_active_modules() -SourceConfigHelper::get_all_modules() -SourceConfigHelper::get_module_path($module) -SourceConfigHelper::get_module_repository($module) -SourceConfigHelper::is_active($module) -SourceConfigHelper::add_SourceConfig($SourceConfigObject) -SourceConfigHelper::get_SourceConfigList() -SourceConfigHelper::has_SourceConfig() - -=head1 AUTHOR - -Kurt Zenker, kz@openoffice.org - -=head1 SEE ALSO - -perl(1). - -=cut |