diff options
author | Sean McMurray <sean@mcmurrays.org> | 2010-10-27 16:35:38 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-10-27 16:35:38 +0100 |
commit | b0de32db530147143f1a1cc225dbb2ccf0c0b177 (patch) | |
tree | 8fae08a1c0cdb6a59f2e8110dbfbb13e8e493561 | |
parent | a5741658529c5a01dae8474a67112c7a89be8931 (diff) |
Start of built-in md5 computationfeature/fastinstall
-rw-r--r-- | solenv/bin/make_installer.pl | 8 | ||||
-rw-r--r-- | solenv/bin/modules/Digest.pm | 315 | ||||
-rw-r--r-- | solenv/bin/modules/Digest/MD5.pm | 376 | ||||
-rw-r--r-- | solenv/bin/modules/installer/control.pm | 12 | ||||
-rw-r--r-- | solenv/bin/modules/installer/languages.pm | 15 | ||||
-rw-r--r-- | solenv/bin/modules/installer/systemactions.pm | 12 |
6 files changed, 711 insertions, 27 deletions
diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl index 441f28d94..f9b5f63ac 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/Digest.pm b/solenv/bin/modules/Digest.pm new file mode 100644 index 000000000..fb5b0d796 --- /dev/null +++ b/solenv/bin/modules/Digest.pm @@ -0,0 +1,315 @@ +package Digest; + +use strict; +use vars qw($VERSION %MMAP $AUTOLOAD); + +$VERSION = "1.15"; + +%MMAP = ( + "SHA-1" => ["Digest::SHA1", ["Digest::SHA", 1], ["Digest::SHA2", 1]], + "SHA-224" => [["Digest::SHA", 224]], + "SHA-256" => [["Digest::SHA", 256], ["Digest::SHA2", 256]], + "SHA-384" => [["Digest::SHA", 384], ["Digest::SHA2", 384]], + "SHA-512" => [["Digest::SHA", 512], ["Digest::SHA2", 512]], + "HMAC-MD5" => "Digest::HMAC_MD5", + "HMAC-SHA-1" => "Digest::HMAC_SHA1", + "CRC-16" => [["Digest::CRC", type => "crc16"]], + "CRC-32" => [["Digest::CRC", type => "crc32"]], + "CRC-CCITT" => [["Digest::CRC", type => "crcccitt"]], +); + +sub new +{ + shift; # class ignored + my $algorithm = shift; + my $impl = $MMAP{$algorithm} || do { + $algorithm =~ s/\W+//; + "Digest::$algorithm"; + }; + $impl = [$impl] unless ref($impl); + my $err; + for (@$impl) { + my $class = $_; + my @args; + ($class, @args) = @$class if ref($class); + no strict 'refs'; + unless (exists ${"$class\::"}{"VERSION"}) { + eval "require $class"; + if ($@) { + $err ||= $@; + next; + } + } + return $class->new(@args, @_); + } + die $err; +} + +sub AUTOLOAD +{ + my $class = shift; + my $algorithm = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2); + $class->new($algorithm, @_); +} + +1; + +__END__ + +=head1 NAME + +Digest - Modules that calculate message digests + +=head1 SYNOPSIS + + $md5 = Digest->new("MD5"); + $sha1 = Digest->new("SHA-1"); + $sha256 = Digest->new("SHA-256"); + $sha384 = Digest->new("SHA-384"); + $sha512 = Digest->new("SHA-512"); + + $hmac = Digest->HMAC_MD5($key); + +=head1 DESCRIPTION + +The C<Digest::> modules calculate digests, also called "fingerprints" +or "hashes", of some data, called a message. The digest is (usually) +some small/fixed size string. The actual size of the digest depend of +the algorithm used. The message is simply a sequence of arbitrary +bytes or bits. + +An important property of the digest algorithms is that the digest is +I<likely> to change if the message change in some way. Another +property is that digest functions are one-way functions, that is it +should be I<hard> to find a message that correspond to some given +digest. Algorithms differ in how "likely" and how "hard", as well as +how efficient they are to compute. + +Note that the properties of the algorithms change over time, as the +algorithms are analyzed and machines grow faster. If your application +for instance depends on it being "impossible" to generate the same +digest for a different message it is wise to make it easy to plug in +stronger algorithms as the one used grow weaker. Using the interface +documented here should make it easy to change algorithms later. + +All C<Digest::> modules provide the same programming interface. A +functional interface for simple use, as well as an object oriented +interface that can handle messages of arbitrary length and which can +read files directly. + +The digest can be delivered in three formats: + +=over 8 + +=item I<binary> + +This is the most compact form, but it is not well suited for printing +or embedding in places that can't handle arbitrary data. + +=item I<hex> + +A twice as long string of lowercase hexadecimal digits. + +=item I<base64> + +A string of portable printable characters. This is the base64 encoded +representation of the digest with any trailing padding removed. The +string will be about 30% longer than the binary version. +L<MIME::Base64> tells you more about this encoding. + +=back + + +The functional interface is simply importable functions with the same +name as the algorithm. The functions take the message as argument and +return the digest. Example: + + use Digest::MD5 qw(md5); + $digest = md5($message); + +There are also versions of the functions with "_hex" or "_base64" +appended to the name, which returns the digest in the indicated form. + +=head1 OO INTERFACE + +The following methods are available for all C<Digest::> modules: + +=over 4 + +=item $ctx = Digest->XXX($arg,...) + +=item $ctx = Digest->new(XXX => $arg,...) + +=item $ctx = Digest::XXX->new($arg,...) + +The constructor returns some object that encapsulate the state of the +message-digest algorithm. You can add data to the object and finally +ask for the digest. The "XXX" should of course be replaced by the proper +name of the digest algorithm you want to use. + +The two first forms are simply syntactic sugar which automatically +load the right module on first use. The second form allow you to use +algorithm names which contains letters which are not legal perl +identifiers, e.g. "SHA-1". If no implementation for the given algorithm +can be found, then an exception is raised. + +If new() is called as an instance method (i.e. $ctx->new) it will just +reset the state the object to the state of a newly created object. No +new object is created in this case, and the return value is the +reference to the object (i.e. $ctx). + +=item $other_ctx = $ctx->clone + +The clone method creates a copy of the digest state object and returns +a reference to the copy. + +=item $ctx->reset + +This is just an alias for $ctx->new. + +=item $ctx->add( $data ) + +=item $ctx->add( $chunk1, $chunk2, ... ) + +The string value of the $data provided as argument is appended to the +message we calculate the digest for. The return value is the $ctx +object itself. + +If more arguments are provided then they are all appended to the +message, thus all these lines will have the same effect on the state +of the $ctx object: + + $ctx->add("a"); $ctx->add("b"); $ctx->add("c"); + $ctx->add("a")->add("b")->add("c"); + $ctx->add("a", "b", "c"); + $ctx->add("abc"); + +Most algorithms are only defined for strings of bytes and this method +might therefore croak if the provided arguments contain chars with +ordinal number above 255. + +=item $ctx->addfile( $io_handle ) + +The $io_handle is read until EOF and the content is appended to the +message we calculate the digest for. The return value is the $ctx +object itself. + +The addfile() method will croak() if it fails reading data for some +reason. If it croaks it is unpredictable what the state of the $ctx +object will be in. The addfile() method might have been able to read +the file partially before it failed. It is probably wise to discard +or reset the $ctx object if this occurs. + +In most cases you want to make sure that the $io_handle is in +"binmode" before you pass it as argument to the addfile() method. + +=item $ctx->add_bits( $data, $nbits ) + +=item $ctx->add_bits( $bitstring ) + +The add_bits() method is an alternative to add() that allow partial +bytes to be appended to the message. Most users should just ignore +this method as partial bytes is very unlikely to be of any practical +use. + +The two argument form of add_bits() will add the first $nbits bits +from $data. For the last potentially partial byte only the high order +C<< $nbits % 8 >> bits are used. If $nbits is greater than C<< +length($data) * 8 >>, then this method would do the same as C<< +$ctx->add($data) >>. + +The one argument form of add_bits() takes a $bitstring of "1" and "0" +chars as argument. It's a shorthand for C<< $ctx->add_bits(pack("B*", +$bitstring), length($bitstring)) >>. + +The return value is the $ctx object itself. + +This example shows two calls that should have the same effect: + + $ctx->add_bits("111100001010"); + $ctx->add_bits("\xF0\xA0", 12); + +Most digest algorithms are byte based and for these it is not possible +to add bits that are not a multiple of 8, and the add_bits() method +will croak if you try. + +=item $ctx->digest + +Return the binary digest for the message. + +Note that the C<digest> operation is effectively a destructive, +read-once operation. Once it has been performed, the $ctx object is +automatically C<reset> and can be used to calculate another digest +value. Call $ctx->clone->digest if you want to calculate the digest +without resetting the digest state. + +=item $ctx->hexdigest + +Same as $ctx->digest, but will return the digest in hexadecimal form. + +=item $ctx->b64digest + +Same as $ctx->digest, but will return the digest as a base64 encoded +string. + +=back + +=head1 Digest speed + +This table should give some indication on the relative speed of +different algorithms. It is sorted by throughput based on a benchmark +done with of some implementations of this API: + + Algorithm Size Implementation MB/s + + MD4 128 Digest::MD4 v1.3 165.0 + MD5 128 Digest::MD5 v2.33 98.8 + SHA-256 256 Digest::SHA2 v1.1.0 66.7 + SHA-1 160 Digest::SHA v4.3.1 58.9 + SHA-1 160 Digest::SHA1 v2.10 48.8 + SHA-256 256 Digest::SHA v4.3.1 41.3 + Haval-256 256 Digest::Haval256 v1.0.4 39.8 + SHA-384 384 Digest::SHA2 v1.1.0 19.6 + SHA-512 512 Digest::SHA2 v1.1.0 19.3 + SHA-384 384 Digest::SHA v4.3.1 19.2 + SHA-512 512 Digest::SHA v4.3.1 19.2 + Whirlpool 512 Digest::Whirlpool v1.0.2 13.0 + MD2 128 Digest::MD2 v2.03 9.5 + + Adler-32 32 Digest::Adler32 v0.03 1.3 + CRC-16 16 Digest::CRC v0.05 1.1 + CRC-32 32 Digest::CRC v0.05 1.1 + MD5 128 Digest::Perl::MD5 v1.5 1.0 + CRC-CCITT 16 Digest::CRC v0.05 0.8 + +These numbers was achieved Apr 2004 with ActivePerl-5.8.3 running +under Linux on a P4 2.8 GHz CPU. The last 5 entries differ by being +pure perl implementations of the algorithms, which explains why they +are so slow. + +=head1 SEE ALSO + +L<Digest::Adler32>, L<Digest::CRC>, L<Digest::Haval256>, +L<Digest::HMAC>, L<Digest::MD2>, L<Digest::MD4>, L<Digest::MD5>, +L<Digest::SHA>, L<Digest::SHA1>, L<Digest::SHA2>, L<Digest::Whirlpool> + +New digest implementations should consider subclassing from L<Digest::base>. + +L<MIME::Base64> + +http://en.wikipedia.org/wiki/Cryptographic_hash_function + +=head1 AUTHOR + +Gisle Aas <gisle@aas.no> + +The C<Digest::> interface is based on the interface originally +developed by Neil Winton for his C<MD5> module. + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + + Copyright 1998-2006 Gisle Aas. + Copyright 1995,1996 Neil Winton. + +=cut diff --git a/solenv/bin/modules/Digest/MD5.pm b/solenv/bin/modules/Digest/MD5.pm new file mode 100644 index 000000000..0188637d6 --- /dev/null +++ b/solenv/bin/modules/Digest/MD5.pm @@ -0,0 +1,376 @@ +package Digest::MD5; + +use strict; +use vars qw($VERSION @ISA @EXPORT_OK); + +$VERSION = '2.51'; + +require Exporter; +*import = \&Exporter::import; +@EXPORT_OK = qw(md5 md5_hex md5_base64); + +eval { + require Digest::base; + push(@ISA, 'Digest::base'); +}; +if ($@) { + my $err = $@; + *add_bits = sub { die $err }; +} + + +eval { + require XSLoader; + XSLoader::load('Digest::MD5', $VERSION); +}; +if ($@) { + my $olderr = $@; + eval { + # Try to load the pure perl version + require Digest::Perl::MD5; + + Digest::Perl::MD5->import(qw(md5 md5_hex md5_base64)); + push(@ISA, "Digest::Perl::MD5"); # make OO interface work + }; + if ($@) { + # restore the original error + die $olderr; + } +} +else { + *reset = \&new; +} + +1; +__END__ + +=head1 NAME + +Digest::MD5 - Perl interface to the MD5 Algorithm + +=head1 SYNOPSIS + + # Functional style + use Digest::MD5 qw(md5 md5_hex md5_base64); + + $digest = md5($data); + $digest = md5_hex($data); + $digest = md5_base64($data); + + # OO style + use Digest::MD5; + + $ctx = Digest::MD5->new; + + $ctx->add($data); + $ctx->addfile(*FILE); + + $digest = $ctx->digest; + $digest = $ctx->hexdigest; + $digest = $ctx->b64digest; + +=head1 DESCRIPTION + +The C<Digest::MD5> module allows you to use the RSA Data Security +Inc. MD5 Message Digest algorithm from within Perl programs. The +algorithm takes as input a message of arbitrary length and produces as +output a 128-bit "fingerprint" or "message digest" of the input. + +Note that the MD5 algorithm is not as strong as it used to be. It has +since 2005 been easy to generate different messages that produce the +same MD5 digest. It still seems hard to generate messages that +produce a given digest, but it is probably wise to move to stronger +algorithms for applications that depend on the digest to uniquely identify +a message. + +The C<Digest::MD5> module provide a procedural interface for simple +use, as well as an object oriented interface that can handle messages +of arbitrary length and which can read files directly. + +=head1 FUNCTIONS + +The following functions are provided by the C<Digest::MD5> module. +None of these functions are exported by default. + +=over 4 + +=item md5($data,...) + +This function will concatenate all arguments, calculate the MD5 digest +of this "message", and return it in binary form. The returned string +will be 16 bytes long. + +The result of md5("a", "b", "c") will be exactly the same as the +result of md5("abc"). + +=item md5_hex($data,...) + +Same as md5(), but will return the digest in hexadecimal form. The +length of the returned string will be 32 and it will only contain +characters from this set: '0'..'9' and 'a'..'f'. + +=item md5_base64($data,...) + +Same as md5(), but will return the digest as a base64 encoded string. +The length of the returned string will be 22 and it will only contain +characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and +'/'. + +Note that the base64 encoded string returned is not padded to be a +multiple of 4 bytes long. If you want interoperability with other +base64 encoded md5 digests you might want to append the redundant +string "==" to the result. + +=back + +=head1 METHODS + +The object oriented interface to C<Digest::MD5> is described in this +section. After a C<Digest::MD5> object has been created, you will add +data to it and finally ask for the digest in a suitable format. A +single object can be used to calculate multiple digests. + +The following methods are provided: + +=over 4 + +=item $md5 = Digest::MD5->new + +The constructor returns a new C<Digest::MD5> object which encapsulate +the state of the MD5 message-digest algorithm. + +If called as an instance method (i.e. $md5->new) it will just reset the +state the object to the state of a newly created object. No new +object is created in this case. + +=item $md5->reset + +This is just an alias for $md5->new. + +=item $md5->clone + +This a copy of the $md5 object. It is useful when you do not want to +destroy the digests state, but need an intermediate value of the +digest, e.g. when calculating digests iteratively on a continuous data +stream. Example: + + my $md5 = Digest::MD5->new; + while (<>) { + $md5->add($_); + print "Line $.: ", $md5->clone->hexdigest, "\n"; + } + +=item $md5->add($data,...) + +The $data provided as argument are appended to the message we +calculate the digest for. The return value is the $md5 object itself. + +All these lines will have the same effect on the state of the $md5 +object: + + $md5->add("a"); $md5->add("b"); $md5->add("c"); + $md5->add("a")->add("b")->add("c"); + $md5->add("a", "b", "c"); + $md5->add("abc"); + +=item $md5->addfile($io_handle) + +The $io_handle will be read until EOF and its content appended to the +message we calculate the digest for. The return value is the $md5 +object itself. + +The addfile() method will croak() if it fails reading data for some +reason. If it croaks it is unpredictable what the state of the $md5 +object will be in. The addfile() method might have been able to read +the file partially before it failed. It is probably wise to discard +or reset the $md5 object if this occurs. + +In most cases you want to make sure that the $io_handle is in +C<binmode> before you pass it as argument to the addfile() method. + +=item $md5->add_bits($data, $nbits) + +=item $md5->add_bits($bitstring) + +Since the MD5 algorithm is byte oriented you might only add bits as +multiples of 8, so you probably want to just use add() instead. The +add_bits() method is provided for compatibility with other digest +implementations. See L<Digest> for description of the arguments +that add_bits() take. + +=item $md5->digest + +Return the binary digest for the message. The returned string will be +16 bytes long. + +Note that the C<digest> operation is effectively a destructive, +read-once operation. Once it has been performed, the C<Digest::MD5> +object is automatically C<reset> and can be used to calculate another +digest value. Call $md5->clone->digest if you want to calculate the +digest without resetting the digest state. + +=item $md5->hexdigest + +Same as $md5->digest, but will return the digest in hexadecimal +form. The length of the returned string will be 32 and it will only +contain characters from this set: '0'..'9' and 'a'..'f'. + +=item $md5->b64digest + +Same as $md5->digest, but will return the digest as a base64 encoded +string. The length of the returned string will be 22 and it will only +contain characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' +and '/'. + + +The base64 encoded string returned is not padded to be a multiple of 4 +bytes long. If you want interoperability with other base64 encoded +md5 digests you might want to append the string "==" to the result. + +=back + + +=head1 EXAMPLES + +The simplest way to use this library is to import the md5_hex() +function (or one of its cousins): + + use Digest::MD5 qw(md5_hex); + print "Digest is ", md5_hex("foobarbaz"), "\n"; + +The above example would print out the message: + + Digest is 6df23dc03f9b54cc38a0fc1483df6e21 + +The same checksum can also be calculated in OO style: + + use Digest::MD5; + + $md5 = Digest::MD5->new; + $md5->add('foo', 'bar'); + $md5->add('baz'); + $digest = $md5->hexdigest; + + print "Digest is $digest\n"; + +With OO style you can break the message arbitrary. This means that we +are no longer limited to have space for the whole message in memory, i.e. +we can handle messages of any size. + +This is useful when calculating checksum for files: + + use Digest::MD5; + + my $file = shift || "/etc/passwd"; + open(FILE, $file) or die "Can't open '$file': $!"; + binmode(FILE); + + $md5 = Digest::MD5->new; + while (<FILE>) { + $md5->add($_); + } + close(FILE); + print $md5->b64digest, " $file\n"; + +Or we can use the addfile method for more efficient reading of +the file: + + use Digest::MD5; + + my $file = shift || "/etc/passwd"; + open(FILE, $file) or die "Can't open '$file': $!"; + binmode(FILE); + + print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n"; + +Perl 5.8 support Unicode characters in strings. Since the MD5 +algorithm is only defined for strings of bytes, it can not be used on +strings that contains chars with ordinal number above 255. The MD5 +functions and methods will croak if you try to feed them such input +data: + + use Digest::MD5 qw(md5_hex); + + my $str = "abc\x{300}"; + print md5_hex($str), "\n"; # croaks + # Wide character in subroutine entry + +What you can do is calculate the MD5 checksum of the UTF-8 +representation of such strings. This is achieved by filtering the +string through encode_utf8() function: + + use Digest::MD5 qw(md5_hex); + use Encode qw(encode_utf8); + + my $str = "abc\x{300}"; + print md5_hex(encode_utf8($str)), "\n"; + # 8c2d46911f3f5a326455f0ed7a8ed3b3 + +=head1 SEE ALSO + +L<Digest>, +L<Digest::MD2>, +L<Digest::SHA>, +L<Digest::HMAC> + +L<md5sum(1)> + +RFC 1321 + +http://en.wikipedia.org/wiki/MD5 + +The paper "How to Break MD5 and Other Hash Functions" by Xiaoyun Wang +and Hongbo Yu. + +=head1 COPYRIGHT + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + + Copyright 1998-2003 Gisle Aas. + Copyright 1995-1996 Neil Winton. + Copyright 1991-1992 RSA Data Security, Inc. + +The MD5 algorithm is defined in RFC 1321. This implementation is +derived from the reference C code in RFC 1321 which is covered by +the following copyright statement: + +=over 4 + +=item + +Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + +=back + +This copyright does not prohibit distribution of any version of Perl +containing this extension under the terms of the GNU or Artistic +licenses. + +=head1 AUTHORS + +The original C<MD5> interface was written by Neil Winton +(C<N.Winton@axion.bt.co.uk>). + +The C<Digest::MD5> module is written by Gisle Aas <gisle@ActiveState.com>. + +=cut diff --git a/solenv/bin/modules/installer/control.pm b/solenv/bin/modules/installer/control.pm index 5f7c2ca9d..0d9e2384a 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 84828bfea..1e9b59741 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 { + 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; + chomp $shorter; + 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 e3ef783cb..bade02c6f 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); |