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