Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


Replaced similar code in other loactions to point to here.
Used Digest::MD5 instead of spawning a separate os process.

This patch is public domain.

---
 solenv/bin/make_installer.pl                  |    8 +-------
 solenv/bin/modules/installer/control.pm       |   12 ++----------
 solenv/bin/modules/installer/languages.pm     |   15 +++++++++++++++
 solenv/bin/modules/installer/systemactions.pm |   12 ++----------
 4 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl
index 9c6c771..6d0cfee 100644
--- a/solenv/bin/make_installer.pl
+++ b/solenv/bin/make_installer.pl
@@ -660,13 +660,7 @@ for ( my $n = 0; $n <= $#installer::globals::languageproducts; $n++ )
 
     my $loglanguagestring = $$languagestringref;
     my $loglanguagestring_orig = $loglanguagestring;
-    if (length($loglanguagestring) > $installer::globals::max_lang_length)
-    {
-        my $number_of_languages = 
installer::systemactions::get_number_of_langs($loglanguagestring);
-        chomp(my $shorter = `echo $loglanguagestring | md5sum | sed -e "s/ .*//g"`);
-        my $id = substr($shorter, 0, 8); # taking only the first 8 digits
-        $loglanguagestring = "lang_" . $number_of_languages . "_id_" . $id;                        
    
-    }
+    $loglanguagestring = installer::languages::shorten_language_string($loglanguagestring);
 
     $installer::globals::logfilename = "log_" . $installer::globals::build;
     if ( $logminor ne "" ) { $installer::globals::logfilename .= "_" . $logminor; }
diff --git a/solenv/bin/modules/installer/control.pm b/solenv/bin/modules/installer/control.pm
index 5f7c2ca..0d9e238 100644
--- a/solenv/bin/modules/installer/control.pm
+++ b/solenv/bin/modules/installer/control.pm
@@ -32,6 +32,7 @@ use installer::converter;
 use installer::exiter;
 use installer::files;
 use installer::globals;
+use installer::languages;
 use installer::pathanalyzer;
 use installer::scriptitems;
 use installer::systemactions;
@@ -409,16 +410,7 @@ sub determine_ship_directory
 
     my $shipdrive = $ENV{'SHIPDRIVE'};
 
-    my $languagestring = $$languagesref;
-
-    if (length($languagestring) > $installer::globals::max_lang_length )
-    {
-        my $number_of_languages = installer::systemactions::get_number_of_langs($languagestring);
-        chomp(my $shorter = `echo $languagestring | md5sum | sed -e "s/ .*//g"`);
-        # $languagestring = $shorter;
-        my $id = substr($shorter, 0, 8); # taking only the first 8 digits
-        $languagestring = "lang_" . $number_of_languages . "_id_" . $id;                           
    
-    }
+    my $languagestring = installer::languages::shorten_language_string($$languagesref);
 
     my $productstring = $installer::globals::product;
     my $productsubdir = "";
diff --git a/solenv/bin/modules/installer/languages.pm b/solenv/bin/modules/installer/languages.pm
index 84828bf..29f3b78 100644
--- a/solenv/bin/modules/installer/languages.pm
+++ b/solenv/bin/modules/installer/languages.pm
@@ -27,6 +27,7 @@
 
 package installer::languages;
 
+use Digest::MD5;
 use installer::converter;
 use installer::existence;
 use installer::exiter;
@@ -376,4 +377,18 @@ sub get_java_language
     return $javalanguage;
 }
 
+sub shorten_language_string {
+    chomp;
+    my $languagestring = shift;
+    if (length($languagestring) > $installer::globals::max_lang_length )
+    {
+        my $number_of_languages = installer::systemactions::get_number_of_langs($languagestring);
+        my $shorter = Digest::MD5->new($languagestring);
+        $shorter =~s/ .*//g;
+        my $id = substr($shorter, 0, 8); # taking only the first 8 digits
+        $languagestring = "lang_" . $number_of_languages . "_id_" . $id;
+    }
+    return $languagestring;
+}
+
 1;
diff --git a/solenv/bin/modules/installer/systemactions.pm 
b/solenv/bin/modules/installer/systemactions.pm
index e3ef783..0c39477 100644
--- a/solenv/bin/modules/installer/systemactions.pm
+++ b/solenv/bin/modules/installer/systemactions.pm
@@ -32,6 +32,7 @@ use File::Copy;
 use installer::converter;
 use installer::exiter;
 use installer::globals;
+use installer::languages;
 use installer::pathanalyzer;
 use installer::remover;
 
@@ -397,16 +398,7 @@ sub create_directories
 
         if (!($locallanguagesref eq "" ))      # this will be a path like "01_49", for Profiles 
and ConfigurationFiles, idt-Files
         {
-            my $languagestring = $$languagesref;
-
-            if (length($languagestring) > $installer::globals::max_lang_length )
-            {
-                my $number_of_languages = get_number_of_langs($languagestring);
-                chomp(my $shorter = `echo $languagestring | md5sum | sed -e "s/ .*//g"`);
-                # $languagestring = $shorter;
-                my $id = substr($shorter, 0, 8); # taking only the first 8 digits
-                $languagestring = "lang_" . $number_of_languages . "_id_" . $id;                   
            
-            }
+            my $languagestring = installer:languages::shorten_language_string($$languagesref);
 
             $path = $path . $languagestring  . $installer::globals::separator;
             create_directory($path);
-- 
1.6.2.5


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.