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