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