1*9780544fSAndrew Rist#************************************************************** 2*9780544fSAndrew Rist# 3*9780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*9780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 5*9780544fSAndrew Rist# distributed with this work for additional information 6*9780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*9780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 8*9780544fSAndrew Rist# "License"); you may not use this file except in compliance 9*9780544fSAndrew Rist# with the License. You may obtain a copy of the License at 10*9780544fSAndrew Rist# 11*9780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*9780544fSAndrew Rist# 13*9780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 14*9780544fSAndrew Rist# software distributed under the License is distributed on an 15*9780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9780544fSAndrew Rist# KIND, either express or implied. See the License for the 17*9780544fSAndrew Rist# specific language governing permissions and limitations 18*9780544fSAndrew Rist# under the License. 19*9780544fSAndrew Rist# 20*9780544fSAndrew Rist#************************************************************** 21*9780544fSAndrew Rist 22*9780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::windows::assembly; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::files; 27cdf0e10cSrcweiruse installer::globals; 28cdf0e10cSrcweiruse installer::worker; 29cdf0e10cSrcweiruse installer::windows::idtglobal; 30cdf0e10cSrcweir 31cdf0e10cSrcweir############################################################## 32cdf0e10cSrcweir# Returning the first module of a file from the 33cdf0e10cSrcweir# comma separated list of modules. 34cdf0e10cSrcweir############################################################## 35cdf0e10cSrcweir 36cdf0e10cSrcweirsub get_msiassembly_feature 37cdf0e10cSrcweir{ 38cdf0e10cSrcweir my ( $onefile ) = @_; 39cdf0e10cSrcweir 40cdf0e10cSrcweir my $module = ""; 41cdf0e10cSrcweir 42cdf0e10cSrcweir if ( $onefile->{'modules'} ) { $module = $onefile->{'modules'}; } 43cdf0e10cSrcweir 44cdf0e10cSrcweir # If modules contains a list of modules, only taking the first one. 45cdf0e10cSrcweir 46cdf0e10cSrcweir if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; } 47cdf0e10cSrcweir 48cdf0e10cSrcweir # Attention: Maximum feature length is 38! 49cdf0e10cSrcweir installer::windows::idtglobal::shorten_feature_gid(\$module); 50cdf0e10cSrcweir 51cdf0e10cSrcweir return $module; 52cdf0e10cSrcweir} 53cdf0e10cSrcweir 54cdf0e10cSrcweir############################################################## 55cdf0e10cSrcweir# Returning the component of a file. 56cdf0e10cSrcweir############################################################## 57cdf0e10cSrcweir 58cdf0e10cSrcweirsub get_msiassembly_component 59cdf0e10cSrcweir{ 60cdf0e10cSrcweir my ( $onefile ) = @_; 61cdf0e10cSrcweir 62cdf0e10cSrcweir my $component = ""; 63cdf0e10cSrcweir 64cdf0e10cSrcweir $component = $onefile->{'componentname'}; 65cdf0e10cSrcweir 66cdf0e10cSrcweir return $component; 67cdf0e10cSrcweir} 68cdf0e10cSrcweir 69cdf0e10cSrcweir############################################################## 70cdf0e10cSrcweir# Returning the file name as manifest file 71cdf0e10cSrcweir############################################################## 72cdf0e10cSrcweir 73cdf0e10cSrcweirsub get_msiassembly_filemanifest 74cdf0e10cSrcweir{ 75cdf0e10cSrcweir my ( $onefile ) = @_; 76cdf0e10cSrcweir 77cdf0e10cSrcweir my $filemanifest = ""; 78cdf0e10cSrcweir 79cdf0e10cSrcweir $filemanifest = $onefile->{'uniquename'}; 80cdf0e10cSrcweir # $filemanifest = $onefile->{'Name'}; 81cdf0e10cSrcweir 82cdf0e10cSrcweir return $filemanifest; 83cdf0e10cSrcweir} 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir############################################################## 87cdf0e10cSrcweir# Returning the file application 88cdf0e10cSrcweir############################################################## 89cdf0e10cSrcweir 90cdf0e10cSrcweirsub get_msiassembly_fileapplication 91cdf0e10cSrcweir{ 92cdf0e10cSrcweir my ( $onefile ) = @_; 93cdf0e10cSrcweir 94cdf0e10cSrcweir my $fileapplication = ""; 95cdf0e10cSrcweir 96cdf0e10cSrcweir return $fileapplication; 97cdf0e10cSrcweir} 98cdf0e10cSrcweir 99cdf0e10cSrcweir############################################################## 100cdf0e10cSrcweir# Returning the file attributes 101cdf0e10cSrcweir############################################################## 102cdf0e10cSrcweir 103cdf0e10cSrcweirsub get_msiassembly_attributes 104cdf0e10cSrcweir{ 105cdf0e10cSrcweir my ( $onefile ) = @_; 106cdf0e10cSrcweir 107cdf0e10cSrcweir my $fileattributes = ""; 108cdf0e10cSrcweir 109cdf0e10cSrcweir if ( $onefile->{'Attributes'} ne "" ) { $fileattributes = $onefile->{'Attributes'}; } 110cdf0e10cSrcweir 111cdf0e10cSrcweir return $fileattributes; 112cdf0e10cSrcweir} 113cdf0e10cSrcweir 114cdf0e10cSrcweir############################################################## 115cdf0e10cSrcweir# Returning the file object for the msiassembly table. 116cdf0e10cSrcweir############################################################## 117cdf0e10cSrcweir 118cdf0e10cSrcweirsub get_msiassembly_file 119cdf0e10cSrcweir{ 120cdf0e10cSrcweir my ( $filesref, $filename ) = @_; 121cdf0e10cSrcweir 122cdf0e10cSrcweir my $foundfile = 0; 123cdf0e10cSrcweir my $onefile; 124cdf0e10cSrcweir 125cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir $onefile = ${$filesref}[$i]; 128cdf0e10cSrcweir my $name = $onefile->{'Name'}; 129cdf0e10cSrcweir 130cdf0e10cSrcweir if ( $name eq $filename ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir $foundfile = 1; 133cdf0e10cSrcweir last; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir # It does not need to exist. For example products that do not contain the libraries. 138cdf0e10cSrcweir # if (! $foundfile ) { installer::exiter::exit_program("ERROR: No unique file name found for $filename !", "get_selfreg_file"); } 139cdf0e10cSrcweir 140cdf0e10cSrcweir if (! $foundfile ) { $onefile = ""; } 141cdf0e10cSrcweir 142cdf0e10cSrcweir return $onefile; 143cdf0e10cSrcweir} 144cdf0e10cSrcweir 145cdf0e10cSrcweir############################################################## 146cdf0e10cSrcweir# Returning the file object for the msiassembly table. 147cdf0e10cSrcweir############################################################## 148cdf0e10cSrcweir 149cdf0e10cSrcweirsub get_msiassembly_file_by_gid 150cdf0e10cSrcweir{ 151cdf0e10cSrcweir my ( $filesref, $gid ) = @_; 152cdf0e10cSrcweir 153cdf0e10cSrcweir my $foundfile = 0; 154cdf0e10cSrcweir my $onefile; 155cdf0e10cSrcweir 156cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir $onefile = ${$filesref}[$i]; 159cdf0e10cSrcweir my $filegid = $onefile->{'gid'}; 160cdf0e10cSrcweir 161cdf0e10cSrcweir if ( $filegid eq $gid ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir $foundfile = 1; 164cdf0e10cSrcweir last; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir # It does not need to exist. For example products that do not contain the libraries. 169cdf0e10cSrcweir # if (! $foundfile ) { installer::exiter::exit_program("ERROR: No unique file name found for $filename !", "get_selfreg_file"); } 170cdf0e10cSrcweir 171cdf0e10cSrcweir if (! $foundfile ) { $onefile = ""; } 172cdf0e10cSrcweir 173cdf0e10cSrcweir return $onefile; 174cdf0e10cSrcweir} 175cdf0e10cSrcweir 176cdf0e10cSrcweir#################################################################################### 177cdf0e10cSrcweir# Creating the file MsiAssembly.idt dynamically 178cdf0e10cSrcweir# Content: 179cdf0e10cSrcweir# Component_ Feature_ File_Manifest File_Application Attributes 180cdf0e10cSrcweir# s72 s38 S72 S72 I2 181cdf0e10cSrcweir# MsiAssembly Component_ 182cdf0e10cSrcweir#################################################################################### 183cdf0e10cSrcweir 184cdf0e10cSrcweirsub create_msiassembly_table 185cdf0e10cSrcweir{ 186cdf0e10cSrcweir my ($filesref, $basedir) = @_; 187cdf0e10cSrcweir 188cdf0e10cSrcweir $installer::globals::msiassemblyfiles = installer::worker::collect_all_items_with_special_flag($filesref, "ASSEMBLY"); 189cdf0e10cSrcweir 190cdf0e10cSrcweir my @msiassemblytable = (); 191cdf0e10cSrcweir 192cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@msiassemblytable, "msiassembly"); 193cdf0e10cSrcweir 194cdf0e10cSrcweir # Registering all libraries listed in $installer::globals::msiassemblyfiles 195cdf0e10cSrcweir 196cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir my $onefile = ${$installer::globals::msiassemblyfiles}[$i]; 199cdf0e10cSrcweir 200cdf0e10cSrcweir my %msiassembly = (); 201cdf0e10cSrcweir 202cdf0e10cSrcweir $msiassembly{'Component_'} = get_msiassembly_component($onefile); 203cdf0e10cSrcweir $msiassembly{'Feature_'} = get_msiassembly_feature($onefile); 204cdf0e10cSrcweir $msiassembly{'File_Manifest'} = get_msiassembly_filemanifest($onefile); 205cdf0e10cSrcweir $msiassembly{'File_Application'} = get_msiassembly_fileapplication($onefile); 206cdf0e10cSrcweir $msiassembly{'Attributes'} = get_msiassembly_attributes($onefile); 207cdf0e10cSrcweir 208cdf0e10cSrcweir my $oneline = $msiassembly{'Component_'} . "\t" . $msiassembly{'Feature_'} . "\t" . 209cdf0e10cSrcweir $msiassembly{'File_Manifest'} . "\t" . $msiassembly{'File_Application'} . "\t" . 210cdf0e10cSrcweir $msiassembly{'Attributes'} . "\n"; 211cdf0e10cSrcweir 212cdf0e10cSrcweir push(@msiassemblytable, $oneline); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir # Saving the file 216cdf0e10cSrcweir 217cdf0e10cSrcweir my $msiassemblytablename = $basedir . $installer::globals::separator . "MsiAssem.idt"; 218cdf0e10cSrcweir installer::files::save_file($msiassemblytablename ,\@msiassemblytable); 219cdf0e10cSrcweir my $infoline = "Created idt file: $msiassemblytablename\n"; 220cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 221cdf0e10cSrcweir} 222cdf0e10cSrcweir 223cdf0e10cSrcweir#################################################################################### 224cdf0e10cSrcweir# Returning the name for the table MsiAssemblyName 225cdf0e10cSrcweir#################################################################################### 226cdf0e10cSrcweir 227cdf0e10cSrcweirsub get_msiassemblyname_name 228cdf0e10cSrcweir{ 229cdf0e10cSrcweir ( $number ) = @_; 230cdf0e10cSrcweir 231cdf0e10cSrcweir my $name = ""; 232cdf0e10cSrcweir 233cdf0e10cSrcweir if ( $number == 1 ) { $name = "name"; } 234cdf0e10cSrcweir elsif ( $number == 2 ) { $name = "publicKeyToken"; } 235cdf0e10cSrcweir elsif ( $number == 3 ) { $name = "version"; } 236cdf0e10cSrcweir elsif ( $number == 4 ) { $name = "culture"; } 237cdf0e10cSrcweir 238cdf0e10cSrcweir return $name; 239cdf0e10cSrcweir} 240cdf0e10cSrcweir 241cdf0e10cSrcweir#################################################################################### 242cdf0e10cSrcweir# Creating the file MsiAssemblyName.idt dynamically 243cdf0e10cSrcweir# Content: 244cdf0e10cSrcweir# Component_ Name Value 245cdf0e10cSrcweir# s72 s255 s255 246cdf0e10cSrcweir# MsiAssemblyName Component_ Name 247cdf0e10cSrcweir#################################################################################### 248cdf0e10cSrcweir 249cdf0e10cSrcweirsub create_msiassemblyname_table 250cdf0e10cSrcweir{ 251cdf0e10cSrcweir my ($filesref, $basedir) = @_; 252cdf0e10cSrcweir 253cdf0e10cSrcweir my @msiassemblynametable = (); 254cdf0e10cSrcweir 255cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@msiassemblynametable, "msiassemblyname"); 256cdf0e10cSrcweir 257cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir my $onefile = ${$installer::globals::msiassemblyfiles}[$i]; 260cdf0e10cSrcweir 261cdf0e10cSrcweir my $component = get_msiassembly_component($onefile); 262cdf0e10cSrcweir my $oneline = ""; 263cdf0e10cSrcweir 264cdf0e10cSrcweir # Order: (Assembly)name, publicKeyToken, version, culture. 265cdf0e10cSrcweir 266cdf0e10cSrcweir if ( $onefile->{'Assemblyname'} ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir $oneline = $component . "\t" . "name" . "\t" . $onefile->{'Assemblyname'} . "\n"; 269cdf0e10cSrcweir push(@msiassemblynametable, $oneline); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir if ( $onefile->{'PublicKeyToken'} ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir $oneline = $component . "\t" . "publicKeyToken" . "\t" . $onefile->{'PublicKeyToken'} . "\n"; 275cdf0e10cSrcweir push(@msiassemblynametable, $oneline); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir if ( $onefile->{'Version'} ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir $oneline = $component . "\t" . "version" . "\t" . $onefile->{'Version'} . "\n"; 281cdf0e10cSrcweir push(@msiassemblynametable, $oneline); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir if ( $onefile->{'Culture'} ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir $oneline = $component . "\t" . "culture" . "\t" . $onefile->{'Culture'} . "\n"; 287cdf0e10cSrcweir push(@msiassemblynametable, $oneline); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir if ( $onefile->{'ProcessorArchitecture'} ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir $oneline = $component . "\t" . "processorArchitecture" . "\t" . $onefile->{'ProcessorArchitecture'} . "\n"; 293cdf0e10cSrcweir push(@msiassemblynametable, $oneline); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir # Saving the file 298cdf0e10cSrcweir 299cdf0e10cSrcweir my $msiassemblynametablename = $basedir . $installer::globals::separator . "MsiAsseN.idt"; 300cdf0e10cSrcweir installer::files::save_file($msiassemblynametablename ,\@msiassemblynametable); 301cdf0e10cSrcweir my $infoline = "Created idt file: $msiassemblynametablename\n"; 302cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 303cdf0e10cSrcweir 304cdf0e10cSrcweir} 305cdf0e10cSrcweir 306cdf0e10cSrcweir#################################################################################### 307cdf0e10cSrcweir# setting an installation condition for the assembly libraries saved in 308cdf0e10cSrcweir# @installer::globals::msiassemblynamecontent 309cdf0e10cSrcweir#################################################################################### 310cdf0e10cSrcweir 311cdf0e10cSrcweirsub add_assembly_condition_into_component_table 312cdf0e10cSrcweir{ 313cdf0e10cSrcweir my ($filesref, $basedir) = @_; 314cdf0e10cSrcweir 315cdf0e10cSrcweir my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt"; 316cdf0e10cSrcweir my $componenttable = installer::files::read_file($componenttablename); 317cdf0e10cSrcweir my $changed = 0; 318cdf0e10cSrcweir my $infoline = ""; 319cdf0e10cSrcweir 320cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir my $onefile = ${$installer::globals::msiassemblyfiles}[$i]; 323cdf0e10cSrcweir 324cdf0e10cSrcweir my $filecomponent = get_msiassembly_component($onefile); 325cdf0e10cSrcweir 326cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$componenttable}; $j++ ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir my $oneline = ${$componenttable}[$j]; 329cdf0e10cSrcweir 330cdf0e10cSrcweir if ( $oneline =~ /(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)/ ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir my $component = $1; 333cdf0e10cSrcweir my $componentid = $2; 334cdf0e10cSrcweir my $directory = $3; 335cdf0e10cSrcweir my $attributes = $4; 336cdf0e10cSrcweir my $condition = $5; 337cdf0e10cSrcweir my $keypath = $6; 338cdf0e10cSrcweir 339cdf0e10cSrcweir if ( $component eq $filecomponent ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir # setting the condition 342cdf0e10cSrcweir 343cdf0e10cSrcweir # $condition = "MsiNetAssemblySupport"; 344cdf0e10cSrcweir $condition = "DOTNET_SUFFICIENT=1"; 345cdf0e10cSrcweir $oneline = $component . "\t" . $componentid . "\t" . $directory . "\t" . $attributes . "\t" . $condition . "\t" . $keypath . "\n"; 346cdf0e10cSrcweir ${$componenttable}[$j] = $oneline; 347cdf0e10cSrcweir $changed = 1; 348cdf0e10cSrcweir $infoline = "Changing $componenttablename :\n"; 349cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 350cdf0e10cSrcweir $infoline = $oneline; 351cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 352cdf0e10cSrcweir last; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir if ( $changed ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir # Saving the file 361cdf0e10cSrcweir installer::files::save_file($componenttablename ,$componenttable); 362cdf0e10cSrcweir $infoline = "Saved idt file: $componenttablename\n"; 363cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir} 366cdf0e10cSrcweir 367cdf0e10cSrcweir1;