Kaydet (Commit) ce86d339 authored tarafından Andre Fischer's avatar Andre Fischer

123729: More cleanup in make_installer.pl

üst c66c37e8
......@@ -1929,7 +1929,9 @@ for (;1;last)
if ( $installer::globals::patch_user_dir )
{
installer::scriptitems::replace_userdir_variable($profileitemsinproductlanguageresolvedarrayref);
installer::scriptitems::replace_userdir_variable(
$profileitemsinproductlanguageresolvedarrayref,
$allvariableshashref);
}
installer::scriptitems::get_Destination_Directory_For_Item_From_Directorylist($profilesinproductlanguageresolvedarrayref, $dirsinproductarrayref);
......
......@@ -305,18 +305,17 @@ sub make_path_conform
sub copy_collector
{
my ( $oldcollector ) = @_;
my ($oldcollector) = @_;
my @newcollector = ();
for ( my $i = 0; $i <= $#{$oldcollector}; $i++ )
foreach my $oldhash (@$oldcollector)
{
my %newhash = ();
my $key;
foreach $key (keys %{${$oldcollector}[$i]})
while (my ($key, $value) = each %$oldhash)
{
$newhash{$key} = ${$oldcollector}[$i]->{$key};
$newhash{$key} = $value;
}
push(@newcollector, \%newhash);
......
......@@ -46,6 +46,14 @@ sub get_path_from_fullqualifiedname
}
}
=head2
Despite its name, this function seems just to return the basename of the given filename.
=cut
sub make_absolute_filename_to_relative_filename
{
my ($longfilenameref) = @_;
......
......@@ -100,31 +100,10 @@ sub replace_productname_in_file
change_length_of_string(\$unicode_productname, $replacestring);
my $found1 = $onefile =~ s/$replacestring/$unicode_productname/sg;
my $found2 = 0;
if ( $styles =~ /\bPATCH_SO_NAME_Z\b/ )
{
# searching for "z"
$onestring = "z" . chr(0);
$replacestring = "";
for ( my $i = 1; $i <= 80; $i++ ) { $replacestring .= $onestring; }
my $productname2 = $variableshashref->{'PRODUCTNAME'} . " " . $variableshashref->{'PRODUCTVERSION'};
if ( exists($onefilehash->{'FileDescriptionZ'}) ) { $productname2 = $onefilehash->{'FileDescriptionZ'}; }
my $unicode_productname2 = convert_to_unicode($productname2);
change_length_of_string_with_letter(\$unicode_productname2, $replacestring, $onestring);
$found2 = $onefile =~ s/$replacestring/$unicode_productname2/sg;
}
my $found = $onefile =~ s/$replacestring/$unicode_productname/sg;
installer::files::save_binary_file($onefile, $destpath);
my $found = $found1 + $found2;
return $found;
}
......
......@@ -29,29 +29,35 @@ use installer::logger;
use installer::pathanalyzer;
use installer::systemactions;
use strict;
########################################################################################
# Replacing all zip list variables in setup script and files with flag scpzip_replace
########################################################################################
sub replace_all_ziplistvariables_in_file
sub replace_all_ziplistvariables_in_file ($$)
{
my ( $fileref, $variableshashref ) = @_;
my ($lines, $variables) = @_;
for ( my $i = 0; $i <= $#{$fileref}; $i++ )
my $count = scalar @$lines;
for (my $lineno=0; $lineno<$count; ++$lineno)
{
my $line = ${$fileref}[$i];
if ( $line =~ /^.*\$\{\w+\}.*$/ ) # only occurence of ${abc}
my $line = $lines->[$lineno];
if ($line =~ /\$\{/) # early rejection of lines that don't need replacements
{
my $key;
foreach $key (keys %{$variableshashref})
while (my ($key,$value) = each %$variables)
{
my $value = $variableshashref->{$key};
$key = '${' . $key . '}';
$line =~ s/\Q$key\E/$value/g;
${$fileref}[$i] = $line;
my $pattern = '${' . $key . '}';
my $replacement_count = ($line =~ s/\Q$pattern\E/$value/g);
if ($key eq "PRODUCTADDON" && $replacement_count>0)
{
$installer::logger::Lang->printf(
"replaced PRODUCTADDON %d times in line %d\n",
$replacement_count,
$lineno);
}
}
$lines->[$lineno] = $line;
}
}
}
......@@ -63,7 +69,7 @@ sub replace_all_ziplistvariables_in_file
sub replace_all_ziplistvariables_in_rtffile ($$)
{
my ($lines, $variablesref) = @_;
my ($lines, $variables) = @_;
my $line_count = scalar @$lines;
for (my $i=0; $i<=$line_count; ++$i)
......
......@@ -31,6 +31,8 @@ use installer::remover;
use installer::scriptitems;
use installer::ziplist;
use strict;
#######################################################
# Set setup script name, if not defined as parameter
#######################################################
......@@ -74,9 +76,9 @@ sub set_setupscript_name
# Reading script variables from installation object of script file
#####################################################################
sub get_all_scriptvariables_from_installation_object
sub get_all_scriptvariables_from_installation_object ($$)
{
my ($scriptref) = @_;
my ($scriptref, $script_filename) = @_;
my @installobjectvariables;
......@@ -521,13 +523,9 @@ sub replace_preset_properties
my @presetproperties = ();
push(@presetproperties, "SOLARISBRANDPACKAGENAME");
push(@presetproperties, "SYSTEMINTUNIXPACKAGENAME");
# push(@presetproperties, "UNIXPACKAGENAME");
# push(@presetproperties, "WITHOUTDOTUNIXPACKAGENAME");
# push(@presetproperties, "UNIXPRODUCTNAME");
# push(@presetproperties, "WITHOUTDOTUNIXPRODUCTNAME");
foreach $property ( @presetproperties )
foreach my $property (@presetproperties)
{
my $presetproperty = "PRESET" . $property;
if (( exists($allvariables->{$presetproperty}) ) && ( $allvariables->{$presetproperty} ne "" ))
......
......@@ -28,6 +28,8 @@ use installer::globals;
use installer::worker;
use installer::windows::idtglobal;
use strict;
##############################################################
# Returning the first module of a file from the
# comma separated list of modules.
......@@ -224,9 +226,9 @@ sub create_msiassembly_table
# Returning the name for the table MsiAssemblyName
####################################################################################
sub get_msiassemblyname_name
sub get_msiassemblyname_name ($)
{
( $number ) = @_;
my ($number) = @_;
my $name = "";
......@@ -315,12 +317,9 @@ sub add_assembly_condition_into_component_table
my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt";
my $componenttable = installer::files::read_file($componenttablename);
my $changed = 0;
my $infoline = "";
for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
foreach my $onefile (@$installer::globals::msiassemblyfiles)
{
my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
my $filecomponent = get_msiassembly_component($onefile);
for ( my $j = 0; $j <= $#{$componenttable}; $j++ )
......@@ -342,13 +341,17 @@ sub add_assembly_condition_into_component_table
# $condition = "MsiNetAssemblySupport";
$condition = "DOTNET_SUFFICIENT=1";
$oneline = $component . "\t" . $componentid . "\t" . $directory . "\t" . $attributes . "\t" . $condition . "\t" . $keypath . "\n";
$oneline = join("\t",
$component,
$componentid,
$directory,
$attributes,
$condition,
$keypath) . "\n";
${$componenttable}[$j] = $oneline;
$changed = 1;
$infoline = "Changing $componenttablename :\n";
$installer::logger::Lang->print($infoline);
$infoline = $oneline;
$installer::logger::Lang->print($infoline);
$installer::logger::Lang->print("Changing %s :\n", $componenttablename);
$installer::logger::Lang->print($oneline);
last;
}
}
......@@ -359,8 +362,7 @@ sub add_assembly_condition_into_component_table
{
# Saving the file
installer::files::save_file($componenttablename ,$componenttable);
$infoline = "Saved idt file: $componenttablename\n";
$installer::logger::Lang->print($infoline);
$installer::logger::Lang->print("Saved idt file: %s\n", $componenttablename);
}
}
......
......@@ -49,6 +49,9 @@ sub get_component_guid ($)
# Returning a ComponentID, that is assigned in scp project
if ( exists($installer::globals::componentid{$componentname}) )
{
$installer::logger::Lang->printf("reusing guid %s for component %s\n",
$installer::globals::componentid{$componentname},
$componentname);
$returnvalue = "\{" . $installer::globals::componentid{$componentname} . "\}";
}
......@@ -59,51 +62,49 @@ sub get_component_guid ($)
# Returning the directory for a file component.
##############################################################
sub get_file_component_directory
sub get_file_component_directory ($$$)
{
my ($componentname, $filesref, $dirref) = @_;
my ($onefile, $component, $onedir, $hostname, $uniquedir);
my ($component, $uniquedir);
my $found = 0;
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
foreach my $onefile (@$filesref)
{
$onefile = ${$filesref}[$i];
$component = $onefile->{'componentname'};
if ( $component eq $componentname )
if ($onefile->{'componentname'} eq $componentname)
{
$found = 1;
last;
return get_file_component_directory_for_file($onefile, $dirref);
}
}
if (!($found))
{
# This component can be ignored, if it exists in a version with extension "_pff" (this was renamed in file::get_sequence_for_file() )
my $ignore_this_component = 0;
my $origcomponentname = $componentname;
my $componentname = $componentname . "_pff";
for ( my $j = 0; $j <= $#{$filesref}; $j++ )
{
$onefile = ${$filesref}[$j];
$component = $onefile->{'componentname'};
# This component can be ignored, if it exists in a version with
# extension "_pff" (this was renamed in file::get_sequence_for_file() )
my $ignore_this_component = 0;
my $origcomponentname = $componentname;
my $componentname_pff = $componentname . "_pff";
if ( $component eq $componentname )
{
$ignore_this_component = 1;
last;
}
foreach my $onefile (@$filesref)
{
if ($onefile->{'componentname'} eq $componentname_pff)
{
return "IGNORE_COMP";
}
if ( $ignore_this_component ) { return "IGNORE_COMP"; }
else { installer::exiter::exit_program("ERROR: Did not find component \"$origcomponentname\" in file collection", "get_file_component_directory"); }
}
my $localstyles = "";
installer::exiter::exit_program(
"ERROR: Did not find component \"$origcomponentname\" in file collection",
"get_file_component_directory");
}
if ( $onefile->{'Styles'} ) { $localstyles = $onefile->{'Styles'}; }
sub get_file_component_directory_for_file ($$)
{
my ($onefile, $dirref) = @_;
my $localstyles = $onefile->{'Styles'} // "";
if ( $localstyles =~ /\bFONT\b/ ) # special handling for font files
{
......@@ -127,6 +128,7 @@ sub get_file_component_directory
# This path has to be defined in the directory collection at "HostName"
my $uniquedir = undef;
if ($destination eq "") # files in the installation root
{
$uniquedir = "INSTALLLOCATION";
......@@ -135,24 +137,23 @@ sub get_file_component_directory
{
$found = 0;
for ( my $i = 0; $i <= $#{$dirref}; $i++ )
foreach my $directory (@$dirref)
{
$onedir = ${$dirref}[$i];
$hostname = $onedir->{'HostName'};
if ( $hostname eq $destination )
if ($directory->{'HostName'} eq $destination )
{
$found = 1;
$uniquedir = $directory->{'uniquename'};
last;
}
}
if (!($found))
if ( ! $found)
{
installer::exiter::exit_program("ERROR: Did not find destination $destination in directory collection", "get_file_component_directory");
installer::exiter::exit_program(
"ERROR: Did not find destination $destination in directory collection",
"get_file_component_directory");
}
$uniquedir = $onedir->{'uniquename'};
if ( $uniquedir eq $installer::globals::officeinstalldirectory )
{
......@@ -226,7 +227,8 @@ sub get_file_component_attributes
$attributes = 0; # Assembly files cannot run from source
}
if (( $onefile->{'Dir'} =~ /\bPREDEFINED_OSSHELLNEWDIR\b/ ) || ( $onefile->{'needs_user_registry_key'} ))
if ((defined $onefile->{'Dir'} && $onefile->{'Dir'} =~ /\bPREDEFINED_OSSHELLNEWDIR\b/)
|| $onefile->{'needs_user_registry_key'})
{
$attributes = 4; # Files in shellnew dir and in non advertised startmenu entries must have user registry key as KeyPath
}
......@@ -324,37 +326,47 @@ sub get_component_keypath ($$)
{
my ($componentname, $itemsref) = @_;
my $oneitem;
my $found = 0;
my $infoline = "";
for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
foreach my $oneitem (@$itemsref)
{
$oneitem = ${$itemsref}[$i];
my $component = $oneitem->{'componentname'};
if ( $component eq $componentname )
if ( ! defined $component)
{
$found = 1;
last;
installer::scriptitems::print_script_item($oneitem);
installer::logger::PrintError("item in get_component_keypath has no 'componentname'\n");
return "";
}
}
if ( $component eq $componentname )
{
my $keypath = $oneitem->{'uniquename'}; # "uniquename", not "Name"
if (!($found))
{
installer::exiter::exit_program("ERROR: Did not find component in file/registry collection, function get_component_keypath", "get_component_keypath");
}
# Special handling for components in
# PREDEFINED_OSSHELLNEWDIR. These components need as
# KeyPath a RegistryItem in HKCU
if ($oneitem->{'userregkeypath'})
{
$keypath = $oneitem->{'userregkeypath'};
}
my $keypath = $oneitem->{'uniquename'}; # "uniquename", not "Name"
# saving it in the file and registry collection
$oneitem->{'keypath'} = $keypath;
# Special handling for components in PREDEFINED_OSSHELLNEWDIR. These components
# need as KeyPath a RegistryItem in HKCU
if ( $oneitem->{'userregkeypath'} ) { $keypath = $oneitem->{'userregkeypath'}; }
return $keypath
}
# saving it in the file and registry collection
$oneitem->{'keypath'} = $keypath;
if ($oneitem->{'componentname'} eq $componentname)
{
$found = 1;
last;
}
}
return $keypath
installer::exiter::exit_program(
"ERROR: Did not find component in file/registry collection, function get_component_keypath",
"get_component_keypath");
}
###################################################################
......
......@@ -733,9 +733,11 @@ sub remove_all_items_with_special_flag
if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
if ( $styles =~ /\b$flag\b/ )
{
my $infoline = "Attention: Removing from collector: $oneitem->{'Name'} !\n";
$installer::logger::Lang->print($infoline);
if ( $flag eq "BINARYTABLE_ONLY" ) { push(@installer::globals::binarytableonlyfiles, $oneitem); }
$installer::logger::Lang->printf("Attention: Removing from collector: %s\n", $oneitem->{'Name'});
if ($flag eq "BINARYTABLE_ONLY")
{
push(@installer::globals::binarytableonlyfiles, $oneitem);
}
next;
}
push( @allitems, $oneitem );
......@@ -2377,7 +2379,6 @@ sub collect_all_files_from_includepathes
my @sourcefiles = ();
my $pathstring = "";
# installer::systemactions::read_complete_directory($includepath, $pathstring, \@sourcefiles);
installer::systemactions::read_full_directory($includepath, $pathstring, \@sourcefiles);
if ( ! ( $#sourcefiles > -1 ))
......@@ -2711,8 +2712,8 @@ sub generate_cygwin_pathes
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $line = ${$filesref}[$i]->{'sourcepath'} . "\n";
push(@pathcollector, $line);
my $filename = ${$filesref}[$i]->{'sourcepath'};
push(@pathcollector, $filename . "\n");
$counter++;
if (( $i == $#{$filesref} ) || ((( $counter % $max ) == 0 ) && ( $i > 0 )))
......@@ -2728,6 +2729,9 @@ sub generate_cygwin_pathes
installer::files::save_file($tmpfilename, \@pathcollector);
my $success = 0;
$installer::logger::Lang->printf(
"Converting %d filenames to cygwin notation\n",
$counter);
my @cyg_sourcepathlist = qx{cygpath -w -f "$tmpfilename"};
chomp @cyg_sourcepathlist;
......@@ -2737,14 +2741,19 @@ sub generate_cygwin_pathes
if ($success)
{
$infoline = "Success: Successfully converted to cygwin pathes!\n";
$installer::logger::Lang->print($infoline);
$installer::logger::Lang->printf(
"Successfully converted %d paths to cygwin notation\n",
$counter);
$installer::logger::Lang->printf(
"there where %d unique paths\n",
scalar keys %paths);
}
else
{
$infoline = "ERROR: Failed to convert to cygwin pathes!\n";
$installer::logger::Lang->print($infoline);
installer::exiter::exit_program("ERROR: Failed to convert to cygwin pathes!", "generate_cygwin_pathes");
$installer::logger::Lang->print("ERROR: Failed to convert to cygwin pathes!\n");
installer::exiter::exit_program(
"ERROR: Failed to convert to cygwin pathes!",
"generate_cygwin_pathes");
}
for ( my $j = 0; $j <= $#cyg_sourcepathlist; $j++ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment