diff options
author | Eike Rathke <erack@apache.org> | 2011-09-10 14:23:26 +0000 |
---|---|---|
committer | Eike Rathke <erack@apache.org> | 2011-09-10 14:23:26 +0000 |
commit | 2053c34c87236293d56276f420f9fbcba6454d7b (patch) | |
tree | ee3e618c51956baf8745d64127fbaa8e2854a93d /solenv | |
parent | 1e81ed0235744af93196cc9f5485e8a14e4ec6e0 (diff) |
native373: #164472# improvements for msi database
# User Ingo Schmidt <is@openoffice.org>
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/make_installer.pl | 2 | ||||
-rw-r--r-- | solenv/bin/modules/installer/globals.pm | 1 | ||||
-rw-r--r-- | solenv/bin/modules/installer/windows/directory.pm | 137 | ||||
-rw-r--r-- | solenv/bin/modules/installer/windows/file.pm | 21 | ||||
-rw-r--r-- | solenv/bin/modules/installer/windows/msiglobal.pm | 18 | ||||
-rw-r--r-- | solenv/bin/modules/installer/windows/registry.pm | 17 |
6 files changed, 119 insertions, 77 deletions
diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl index c85aaffcde07..73c4e87771ad 100644 --- a/solenv/bin/make_installer.pl +++ b/solenv/bin/make_installer.pl @@ -2028,7 +2028,7 @@ for ( my $n = 0; $n <= $#installer::globals::languageproducts; $n++ ) installer::windows::idtglobal::prepare_language_idt_directory($languageidtdir, $newidtdir, $onelanguage, $filesinproductlanguageresolvedarrayref, \@iconfilecollector, $binarytablefiles, $allvariableshashref); - if ( ! $installer::globals::languagepack ) + if (( ! $installer::globals::languagepack ) && ( ! $allvariableshashref->{'NOLANGUAGESELECTIONPRODUCT'} )) { # For multilingual installation sets, the dialog for the language selection can now be prepared, with # a checkbox for each available language. This has to happen before the following translation. diff --git a/solenv/bin/modules/installer/globals.pm b/solenv/bin/modules/installer/globals.pm index 066e13dcf6d4..22ee98f60358 100644 --- a/solenv/bin/modules/installer/globals.pm +++ b/solenv/bin/modules/installer/globals.pm @@ -385,7 +385,6 @@ BEGIN %allcomponents = (); %allcomponents_in_this_database = (); %allshortcomponents = (); - %alluniquedirectorynames = (); %allregistrycomponents_ = (); %allregistrycomponents_in_this_database_ = (); %allshortregistrycomponents = (); diff --git a/solenv/bin/modules/installer/windows/directory.pm b/solenv/bin/modules/installer/windows/directory.pm index f7b13747e3bf..11cf289e6833 100644 --- a/solenv/bin/modules/installer/windows/directory.pm +++ b/solenv/bin/modules/installer/windows/directory.pm @@ -32,6 +32,7 @@ use installer::files; use installer::globals; use installer::pathanalyzer; use installer::windows::idtglobal; +use installer::windows::msiglobal; ############################################################## # Collecting all directory trees in global hash @@ -83,11 +84,12 @@ sub overwrite_programfilesfolder sub make_short_dir_version { - my ($longstring, $length, $displayname) = @_; + my ($longstring) = @_; my $shortstring = ""; - my $infoline = ""; - my $savestring = $longstring; + my $cutlength = 60; + my $length = 5; # So the directory can still be recognized + my $longstring_save = $longstring; # Splitting the string at each "underline" and allowing only $length characters per directory name. # Checking also uniqueness and length. @@ -119,12 +121,17 @@ sub make_short_dir_version $shortstring =~ s/^\s*\_//; - if ( length($shortstring) > 72 ) - { - my $shortlength = length($shortstring); - $infoline = "WARNING: Failed to create unique directory name with less than 72 characters: \"$displayname\" ($shortstring ($shortlength)).\n"; - push(@installer::globals::logfileinfo, $infoline); - } + # Setting unique ID to each directory + # No counter allowed, process must be absolute reproducable due to patch creation process. + + # chomp(my $id = `echo $longstring_save | md5sum | sed -e "s/ .*//g"`); # Very, very slow + # my $subid = substr($id, 0, 9); # taking only the first 9 digits + + my $subid = installer::windows::msiglobal::calculate_id($longstring_save, 9); # taking only the first 9 digits + + if ( length($shortstring) > $cutlength ) { $shortstring = substr($shortstring, 0, $cutlength); } + + $shortstring = $shortstring . "_" . $subid; return $shortstring; } @@ -139,28 +146,29 @@ sub create_unique_directorynames $installer::globals::officeinstalldirectoryset = 0; - my %conversionhash = (); + my %completedirhashstep1 = (); + my %shortdirhash = (); + my %shortdirhashreverse = (); my $infoline = ""; my $errorcount = 0; for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) { my $onedir = ${$directoryref}[$i]; - my $hostname = $onedir->{'HostName'}; + my $uniquename = $onedir->{'HostName'}; - my $uniquename = $hostname; my $styles = ""; if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } - # get_path_from_fullqualifiedname(\$uniqueparentname); - # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs $uniquename =~ s/^\s*//g; # removing beginning white spaces $uniquename =~ s/\s*$//g; # removing ending white spaces $uniquename =~ s/\s//g; # removing white spaces $uniquename =~ s/\_//g; # removing existing underlines $uniquename =~ s/\.//g; # removing dots in directoryname - $uniquename =~ s/\Q$installer::globals::separator\E/\_/g; # replacing slash and backslash with underline $uniquename =~ s/OpenOffice/OO/g; + + $uniquename =~ s/\Q$installer::globals::separator\E/\_/g; # replacing slash and backslash with underline + $uniquename =~ s/_registry/_rgy/g; $uniquename =~ s/_registration/_rgn/g; $uniquename =~ s/_extension/_ext/g; @@ -168,60 +176,94 @@ sub create_unique_directorynames $uniquename =~ s/_table/_tbl/g; $uniquename =~ s/_chart/_crt/g; - my $startlength = 5; + # The names after this small changes must still be unique! + if ( exists($completedirhashstep1{$uniquename}) ) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 1): \"$uniquename\".", "create_unique_directorynames"); } + $completedirhashstep1{$uniquename} = 1; - if ( ! $allvariables->{'NOSHORTDIRECTORYNAMES'} ) - { - # This process does not work for SDK, because of its long and similar pathes - $uniquename = make_short_dir_version($uniquename, $startlength, $hostname); # taking care of underlines! - } + # Starting to make unique name for the parent and its directory + my $originaluniquename = $uniquename; - if ( exists($installer::globals::alluniquedirectorynames{$uniquename}) ) - { - # This is an error, that must stop the packaging process - $errorcount++; - - $infoline = "$errorcount: Already existing unique directory: $uniquename\n"; - push( @installer::globals::logfileinfo, $infoline); - $infoline = "$errorcount: First full directory: $conversionhash{$uniquename}\n"; - push( @installer::globals::logfileinfo, $infoline); - $infoline = "$errorcount: Current full directory: $hostname\n"; - push( @installer::globals::logfileinfo, $infoline); - } + $uniquename = make_short_dir_version($uniquename); + + # Checking if the same directory already exists, but has another short version. + if (( exists($shortdirhash{$originaluniquename}) ) && ( $shortdirhash{$originaluniquename} ne $uniquename )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 2A): \"$uniquename\".", "create_unique_directorynames"); } - $conversionhash{$uniquename} = $hostname; + # Also checking vice versa + # Checking if the same short directory already exists, but has another long version. + if (( exists($shortdirhashreverse{$uniquename}) ) && ( $shortdirhashreverse{$uniquename} ne $originaluniquename )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 2B): \"$uniquename\".", "create_unique_directorynames"); } - $installer::globals::alluniquedirectorynames{$uniquename} = 1; + # Creating assignment from long to short directory names + $shortdirhash{$originaluniquename} = $uniquename; + $shortdirhashreverse{$uniquename} = $originaluniquename; - # Important: The unique parent is generated from the string $uniquename. Therefore counters - # like adding "_1" is not allowed to achive uniqueness, because this depends from other directories - # and does not deliver always the same result. + # Important: The unique parent is generated from the string $originaluniquename (with the use of underlines). - my $uniqueparentname = $uniquename; + my $uniqueparentname = $originaluniquename; + my $keepparent = 1; if ( $uniqueparentname =~ /^\s*(.*)\_(.*?)\s*$/ ) # the underline is now the separator { $uniqueparentname = $1; + $keepparent = 0; } else { $uniqueparentname = $installer::globals::programfilesfolder; + $keepparent = 1; } - if ( $styles =~ /\bPROGRAMFILESFOLDER\b/ ) { $uniqueparentname = $installer::globals::programfilesfolder; } - if ( $styles =~ /\bCOMMONFILESFOLDER\b/ ) { $uniqueparentname = $installer::globals::commonfilesfolder; } - if ( $styles =~ /\bCOMMONAPPDATAFOLDER\b/ ) { $uniqueparentname = $installer::globals::commonappdatafolder; } - if ( $styles =~ /\bLOCALAPPDATAFOLDER\b/ ) { $uniqueparentname = $installer::globals::localappdatafolder; } + if ( $styles =~ /\bPROGRAMFILESFOLDER\b/ ) + { + $uniqueparentname = $installer::globals::programfilesfolder; + $keepparent = 1; + } + if ( $styles =~ /\bCOMMONFILESFOLDER\b/ ) + { + $uniqueparentname = $installer::globals::commonfilesfolder; + $keepparent = 1; + } + if ( $styles =~ /\bCOMMONAPPDATAFOLDER\b/ ) + { + $uniqueparentname = $installer::globals::commonappdatafolder; + $keepparent = 1; + } + if ( $styles =~ /\bLOCALAPPDATAFOLDER\b/ ) + { + $uniqueparentname = $installer::globals::localappdatafolder; + $keepparent = 1; + } if ( $styles =~ /\bSHAREPOINTPATH\b/ ) { $uniqueparentname = "SHAREPOINTPATH"; $installer::globals::usesharepointpath = 1; + $keepparent = 1; } + # also setting short directory name for the parent + + my $originaluniqueparentname = $uniqueparentname; + + if ( ! $keepparent ) + { + $uniqueparentname = make_short_dir_version($uniqueparentname); + } + + # Again checking if the same directory already exists, but has another short version. + if (( exists($shortdirhash{$originaluniqueparentname}) ) && ( $shortdirhash{$originaluniqueparentname} ne $uniqueparentname )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 3A): \"$uniqueparentname\".", "create_unique_directorynames"); } + + # Also checking vice versa + # Checking if the same short directory already exists, but has another long version. + if (( exists($shortdirhashreverse{$uniqueparentname}) ) && ( $shortdirhashreverse{$uniqueparentname} ne $originaluniqueparentname )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 3B): \"$uniqueparentname\".", "create_unique_directorynames"); } + + $shortdirhash{$originaluniqueparentname} = $uniqueparentname; + $shortdirhashreverse{$uniqueparentname} = $originaluniqueparentname; + + # Hyphen not allowed in database $uniquename =~ s/\-/\_/g; # making "-" to "_" $uniqueparentname =~ s/\-/\_/g; # making "-" to "_" + # And finally setting the values for the directories $onedir->{'uniquename'} = $uniquename; $onedir->{'uniqueparentname'} = $uniqueparentname; @@ -242,11 +284,6 @@ sub create_unique_directorynames $installer::globals::vendordirectoryset = 1; } } - - if ( $errorcount > 0 ) - { - installer::exiter::exit_program("ERROR: Failed to create unique directory names.", "create_unique_directorynames"); - } } ##################################################### @@ -530,6 +567,8 @@ sub create_directory_table # Before ":" : [sourcedir]:[destdir] (not programmed yet) # After ":" : 8+3 and not 8+3 the destination directory name + installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table start"); + my @directorytable = (); my $infoline; @@ -552,6 +591,8 @@ sub create_directory_table $infoline = "Created idt file: $directorytablename\n"; push(@installer::globals::logfileinfo, $infoline); + installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table end"); + } 1; diff --git a/solenv/bin/modules/installer/windows/file.pm b/solenv/bin/modules/installer/windows/file.pm index 3ac72ecf6ac3..fb485e16533b 100644 --- a/solenv/bin/modules/installer/windows/file.pm +++ b/solenv/bin/modules/installer/windows/file.pm @@ -37,6 +37,7 @@ use installer::pathanalyzer; use installer::worker; use installer::windows::font; use installer::windows::idtglobal; +use installer::windows::msiglobal; use installer::windows::language; ########################################################################## @@ -179,25 +180,18 @@ sub assign_sequencenumbers_to_files # -> no resetting of # %installer::globals::allshortcomponents # after a package was created. +# Using no counter because of reproducibility. ######################################################### sub generate_new_short_componentname { my ($componentname) = @_; - my $shortcomponentname = ""; - my $counter = 1; - my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters - $startversion = $startversion . "_"; - - $shortcomponentname = $startversion . $counter; + my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits + my $shortcomponentname = $startversion . "_" . $subid; - while ( exists($installer::globals::allshortcomponents{$shortcomponentname}) ) - { - $counter++; - $shortcomponentname = $startversion . $counter; - } + if ( exists($installer::globals::allshortcomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_componentname"); } $installer::globals::allshortcomponents{$shortcomponentname} = 1; @@ -282,11 +276,8 @@ sub get_file_component_name } else { - if ( length($componentname) > 60 ) + if ( length($componentname) > 70 ) { - # Using md5sum needs much time - # chomp(my $shorter = `echo $componentname | md5sum | sed -e "s/ .*//g"`); - # $componentname = "comp_$shorter"; $componentname = generate_new_short_componentname($componentname); # This has to be unique for the complete product, not only one package } diff --git a/solenv/bin/modules/installer/windows/msiglobal.pm b/solenv/bin/modules/installer/windows/msiglobal.pm index dbb6e051aa29..f4b6a9604fd0 100644 --- a/solenv/bin/modules/installer/windows/msiglobal.pm +++ b/solenv/bin/modules/installer/windows/msiglobal.pm @@ -1527,6 +1527,24 @@ sub calculate_guid } ################################################################# +# Calculating a ID with a string using md5 (very fast). +################################################################# + +sub calculate_id +{ + my ( $string, $length ) = @_; + + my $id = ""; + + my $md5 = Digest::MD5->new; + $md5->add($string); + my $digest = lc($md5->hexdigest); + $id = substr($digest, 0, $length); + + return $id; +} + +################################################################# # Filling the component hash with the values of the # component file. ################################################################# diff --git a/solenv/bin/modules/installer/windows/registry.pm b/solenv/bin/modules/installer/windows/registry.pm index 18981d661372..8f76f01dc2ed 100644 --- a/solenv/bin/modules/installer/windows/registry.pm +++ b/solenv/bin/modules/installer/windows/registry.pm @@ -30,6 +30,7 @@ package installer::windows::registry; use installer::files; use installer::globals; use installer::worker; +use installer::windows::msiglobal; use installer::windows::idtglobal; ##################################################### @@ -116,7 +117,7 @@ sub get_registry_component_name } else { - if ( length($componentname) > 60 ) + if ( length($componentname) > 70 ) { $componentname = generate_new_short_registrycomponentname($componentname); # This has to be unique for the complete product, not only one package } @@ -145,19 +146,11 @@ sub generate_new_short_registrycomponentname { my ($componentname) = @_; - my $shortcomponentname = ""; - my $counter = 1; - my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters - $startversion = $startversion . "_"; - - $shortcomponentname = $startversion . $counter; + my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits + my $shortcomponentname = $startversion . "_" . $subid; - while ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) - { - $counter++; - $shortcomponentname = $startversion . $counter; - } + if ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_registrycomponentname"); } $installer::globals::allshortregistrycomponents{$shortcomponentname} = 1; |