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::download; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse File::Spec; 31*cdf0e10cSrcweiruse installer::exiter; 32*cdf0e10cSrcweiruse installer::files; 33*cdf0e10cSrcweiruse installer::globals; 34*cdf0e10cSrcweiruse installer::logger; 35*cdf0e10cSrcweiruse installer::pathanalyzer; 36*cdf0e10cSrcweiruse installer::remover; 37*cdf0e10cSrcweiruse installer::systemactions; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweirBEGIN { # This is needed so that cygwin's perl evaluates ACLs 40*cdf0e10cSrcweir # (needed for correctly evaluating the -x test.) 41*cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { 42*cdf0e10cSrcweir require filetest; import filetest "access"; 43*cdf0e10cSrcweir } 44*cdf0e10cSrcweir} 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir################################################################## 47*cdf0e10cSrcweir# Including the lowercase product name into the script template 48*cdf0e10cSrcweir################################################################## 49*cdf0e10cSrcweir 50*cdf0e10cSrcweirsub put_productname_into_script 51*cdf0e10cSrcweir{ 52*cdf0e10cSrcweir my ($scriptfile, $variableshashref) = @_; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir my $productname = $variableshashref->{'PRODUCTNAME'}; 55*cdf0e10cSrcweir $productname = lc($productname); 56*cdf0e10cSrcweir $productname =~ s/\.//g; # openoffice.org -> openofficeorg 57*cdf0e10cSrcweir $productname =~ s/\s*//g; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir my $infoline = "Adding productname $productname into download shell script\n"; 60*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir} 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir######################################################### 69*cdf0e10cSrcweir# Including the linenumber into the script template 70*cdf0e10cSrcweir######################################################### 71*cdf0e10cSrcweir 72*cdf0e10cSrcweirsub put_linenumber_into_script 73*cdf0e10cSrcweir{ 74*cdf0e10cSrcweir my ( $scriptfile ) = @_; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir my $linenumber = $#{$scriptfile} + 2; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir my $infoline = "Adding linenumber $linenumber into download shell script\n"; 79*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/LINENUMBERPLACEHOLDER/$linenumber/; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir} 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir######################################################### 88*cdf0e10cSrcweir# Determining the name of the new scriptfile 89*cdf0e10cSrcweir######################################################### 90*cdf0e10cSrcweir 91*cdf0e10cSrcweirsub determine_scriptfile_name 92*cdf0e10cSrcweir{ 93*cdf0e10cSrcweir my ( $filename ) = @_; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir $installer::globals::downloadfileextension = ".sh"; 96*cdf0e10cSrcweir $filename = $filename . $installer::globals::downloadfileextension; 97*cdf0e10cSrcweir $installer::globals::downloadfilename = $filename; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir my $infoline = "Setting download shell script file name to $filename\n"; 100*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir return $filename; 103*cdf0e10cSrcweir} 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir######################################################### 106*cdf0e10cSrcweir# Saving the script file in the installation directory 107*cdf0e10cSrcweir######################################################### 108*cdf0e10cSrcweir 109*cdf0e10cSrcweirsub save_script_file 110*cdf0e10cSrcweir{ 111*cdf0e10cSrcweir my ($directory, $newscriptfilename, $scriptfile) = @_; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir $newscriptfilename = $directory . $installer::globals::separator . $newscriptfilename; 114*cdf0e10cSrcweir installer::files::save_file($newscriptfilename, $scriptfile); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir my $infoline = "Saving script file $newscriptfilename\n"; 117*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if ( ! $installer::globals::iswindowsbuild ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1"; 122*cdf0e10cSrcweir system($localcall); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir return $newscriptfilename; 126*cdf0e10cSrcweir} 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir######################################################### 129*cdf0e10cSrcweir# Including checksum and size into script file 130*cdf0e10cSrcweir######################################################### 131*cdf0e10cSrcweir 132*cdf0e10cSrcweirsub put_checksum_and_size_into_script 133*cdf0e10cSrcweir{ 134*cdf0e10cSrcweir my ($scriptfile, $sumout) = @_; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir my $checksum = ""; 137*cdf0e10cSrcweir my $size = ""; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir if ( $sumout =~ /^\s*(\d+)\s+(\d+)\s*$/ ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir $checksum = $1; 142*cdf0e10cSrcweir $size = $2; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir else 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Incorrect return value from /usr/bin/sum: $sumout", "put_checksum_and_size_into_script"); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir my $infoline = "Adding checksum $checksum and size $size into download shell script\n"; 150*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/CHECKSUMPLACEHOLDER/$checksum/; 155*cdf0e10cSrcweir ${$scriptfile}[$i] =~ s/DISCSPACEPLACEHOLDER/$size/; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir} 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir######################################################### 161*cdf0e10cSrcweir# Calling md5sum 162*cdf0e10cSrcweir######################################################### 163*cdf0e10cSrcweir 164*cdf0e10cSrcweirsub call_md5sum 165*cdf0e10cSrcweir{ 166*cdf0e10cSrcweir my ($filename) = @_; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir $md5sumfile = "/usr/bin/md5sum"; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir if ( ! -f $md5sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/md5sum", "call_md5sum"); } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir my $systemcall = "$md5sumfile $filename |"; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir my $md5sumoutput = ""; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir open (SUM, "$systemcall"); 177*cdf0e10cSrcweir $md5sumoutput = <SUM>; 178*cdf0e10cSrcweir close (SUM); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir my $returnvalue = $?; # $? contains the return value of the systemcall 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 183*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if ($returnvalue) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 188*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir else 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 193*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir return $md5sumoutput; 197*cdf0e10cSrcweir} 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir######################################################### 200*cdf0e10cSrcweir# Calling md5sum 201*cdf0e10cSrcweir######################################################### 202*cdf0e10cSrcweir 203*cdf0e10cSrcweirsub get_md5sum 204*cdf0e10cSrcweir{ 205*cdf0e10cSrcweir ($md5sumoutput) = @_; 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir my $md5sum; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir if ( $md5sumoutput =~ /^\s*(\w+?)\s+/ ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir $md5sum = $1; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir else 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Incorrect return value from /usr/bin/md5sum: $md5sumoutput", "get_md5sum"); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir my $infoline = "Setting md5sum: $md5sum\n"; 219*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir return $md5sum; 222*cdf0e10cSrcweir} 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir######################################################### 225*cdf0e10cSrcweir# Determining checksum and size of tar file 226*cdf0e10cSrcweir######################################################### 227*cdf0e10cSrcweir 228*cdf0e10cSrcweirsub call_sum 229*cdf0e10cSrcweir{ 230*cdf0e10cSrcweir my ($filename, $getuidlibrary) = @_; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir my $systemcall = "/usr/bin/sum $filename |"; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir my $sumoutput = ""; 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir open (SUM, "$systemcall"); 237*cdf0e10cSrcweir $sumoutput = <SUM>; 238*cdf0e10cSrcweir close (SUM); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir my $returnvalue = $?; # $? contains the return value of the systemcall 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 243*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir if ($returnvalue) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 248*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 253*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir $sumoutput =~ s/\s+$filename\s$//; 257*cdf0e10cSrcweir return $sumoutput; 258*cdf0e10cSrcweir} 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir######################################################### 261*cdf0e10cSrcweir# Searching for the getuid.so in the solver 262*cdf0e10cSrcweir######################################################### 263*cdf0e10cSrcweir 264*cdf0e10cSrcweirsub get_path_for_library 265*cdf0e10cSrcweir{ 266*cdf0e10cSrcweir my ($includepatharrayref) = @_; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir my $getuidlibraryname = "getuid.so"; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir my $getuidlibraryref = ""; 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir else 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$getuidlibraryname, $includepatharrayref, 0); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_path_for_library"); } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir return $$getuidlibraryref; 284*cdf0e10cSrcweir} 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir######################################################### 287*cdf0e10cSrcweir# Include the tar file into the script 288*cdf0e10cSrcweir######################################################### 289*cdf0e10cSrcweir 290*cdf0e10cSrcweirsub include_tar_into_script 291*cdf0e10cSrcweir{ 292*cdf0e10cSrcweir my ($scriptfile, $temporary_tarfile) = @_; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir my $systemcall = "cat $temporary_tarfile >> $scriptfile && rm $temporary_tarfile"; 295*cdf0e10cSrcweir my $returnvalue = system($systemcall); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 298*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if ($returnvalue) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 303*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir else 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 308*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir return $returnvalue; 311*cdf0e10cSrcweir} 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir######################################################### 314*cdf0e10cSrcweir# Create a tar file from the binary package 315*cdf0e10cSrcweir######################################################### 316*cdf0e10cSrcweir 317*cdf0e10cSrcweirsub tar_package 318*cdf0e10cSrcweir{ 319*cdf0e10cSrcweir my ( $installdir, $tarfilename, $getuidlibrary) = @_; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir my $ldpreloadstring = ""; 322*cdf0e10cSrcweir if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > $tarfilename"; 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir my $returnvalue = system($systemcall); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 329*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if ($returnvalue) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 334*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 339*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir my $localcall = "chmod 775 $tarfilename \>\/dev\/null 2\>\&1"; 343*cdf0e10cSrcweir $returnvalue = system($localcall); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir return ( -s $tarfilename ); 346*cdf0e10cSrcweir} 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir######################################################### 349*cdf0e10cSrcweir# Creating a tar.gz file 350*cdf0e10cSrcweir######################################################### 351*cdf0e10cSrcweir 352*cdf0e10cSrcweirsub create_tar_gz_file_from_package 353*cdf0e10cSrcweir{ 354*cdf0e10cSrcweir my ($installdir, $getuidlibrary) = @_; 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir my $infoline = ""; 357*cdf0e10cSrcweir my $alldirs = installer::systemactions::get_all_directories($installdir); 358*cdf0e10cSrcweir my $onedir = ${$alldirs}[0]; 359*cdf0e10cSrcweir $installdir = $onedir; 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir my $allfiles = installer::systemactions::get_all_files_from_one_directory($installdir); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allfiles}; $i++ ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir my $onefile = ${$allfiles}[$i]; 366*cdf0e10cSrcweir my $systemcall = "cd $installdir; rm $onefile"; 367*cdf0e10cSrcweir my $returnvalue = system($systemcall); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 370*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir if ($returnvalue) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 375*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir else 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 380*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir $alldirs = installer::systemactions::get_all_directories($installdir); 385*cdf0e10cSrcweir $packagename = ${$alldirs}[0]; # only taking the first Solaris package 386*cdf0e10cSrcweir if ( $packagename eq "" ) { installer::exiter::exit_program("ERROR: Could not find package in directory $installdir!", "determine_packagename"); } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packagename); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir $installer::globals::downloadfileextension = ".tar.gz"; 391*cdf0e10cSrcweir my $targzname = $packagename . $installer::globals::downloadfileextension; 392*cdf0e10cSrcweir $installer::globals::downloadfilename = $targzname; 393*cdf0e10cSrcweir my $ldpreloadstring = ""; 394*cdf0e10cSrcweir if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir $systemcall = "cd $installdir; $ldpreloadstring tar -cf - $packagename | gzip > $targzname"; 397*cdf0e10cSrcweir print "... $systemcall ...\n"; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir my $returnvalue = system($systemcall); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 402*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir if ($returnvalue) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 407*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir else 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 412*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir} 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir######################################################### 417*cdf0e10cSrcweir# Setting type of installation 418*cdf0e10cSrcweir######################################################### 419*cdf0e10cSrcweir 420*cdf0e10cSrcweirsub get_installation_type 421*cdf0e10cSrcweir{ 422*cdf0e10cSrcweir my $type = ""; 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ( $installer::globals::languagepack ) { $type = "langpack"; } 425*cdf0e10cSrcweir else { $type = "install"; } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir return $type; 428*cdf0e10cSrcweir} 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir######################################################### 431*cdf0e10cSrcweir# Setting installation languages 432*cdf0e10cSrcweir######################################################### 433*cdf0e10cSrcweir 434*cdf0e10cSrcweirsub get_downloadname_language 435*cdf0e10cSrcweir{ 436*cdf0e10cSrcweir my ($languagestringref) = @_; 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir my $languages = $$languagestringref; 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir if ( $installer::globals::added_english ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir $languages =~ s/en-US_//; 443*cdf0e10cSrcweir $languages =~ s/_en-US//; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir # en-US is default language and can be removed therefore 447*cdf0e10cSrcweir # for one-language installation sets 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir # if ( $languages =~ /^\s*en-US\s*$/ ) 450*cdf0e10cSrcweir # { 451*cdf0e10cSrcweir # $languages = ""; 452*cdf0e10cSrcweir # } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir if ( length ($languages) > $installer::globals::max_lang_length ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir $languages = 'multi'; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir return $languages; 460*cdf0e10cSrcweir} 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir######################################################### 463*cdf0e10cSrcweir# Setting download name 464*cdf0e10cSrcweir######################################################### 465*cdf0e10cSrcweir 466*cdf0e10cSrcweirsub get_downloadname_productname 467*cdf0e10cSrcweir{ 468*cdf0e10cSrcweir my ($allvariables) = @_; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir my $start = "OOo"; 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTNAME'} eq "OpenOffice.org" ) { $start = "OOo"; } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTNAME'} eq "OOo-dev" ) { $start = "OOo-Dev"; } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir if (( $allvariables->{'PRODUCTNAME'} eq "OpenOffice.org" ) && ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" )) { $start = "OOo-SDK"; } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir if (( $allvariables->{'PRODUCTNAME'} eq "OOo-dev" ) && ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" )) { $start = "OOo-Dev-SDK"; } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTNAME'} eq "URE" ) { $start = "OOo-URE"; } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTNAME'} eq "BrOffice.org" ) { $start = "BrOo"; } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTNAME'} eq "BrOo-dev" ) { $start = "BrOo-Dev"; } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir if (( $allvariables->{'PRODUCTNAME'} eq "BrOffice.org" ) && ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" )) { $start = "BrOo-SDK"; } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if (( $allvariables->{'PRODUCTNAME'} eq "BrOo-dev" ) && ( $allvariables->{'POSTVERSIONEXTENSION'} eq "SDK" )) { $start = "BrOo-Dev-SDK"; } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir return $start; 491*cdf0e10cSrcweir} 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir######################################################### 494*cdf0e10cSrcweir# Setting download version 495*cdf0e10cSrcweir######################################################### 496*cdf0e10cSrcweir 497*cdf0e10cSrcweirsub get_download_version 498*cdf0e10cSrcweir{ 499*cdf0e10cSrcweir my ($allvariables) = @_; 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir my $version = ""; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir my $devproduct = 0; 504*cdf0e10cSrcweir if (( $allvariables->{'DEVELOPMENTPRODUCT'} ) && ( $allvariables->{'DEVELOPMENTPRODUCT'} == 1 )) { $devproduct = 1; } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir my $cwsproduct = 0; 507*cdf0e10cSrcweir # the environment variable CWS_WORK_STAMP is set only in CWS 508*cdf0e10cSrcweir if ( $ENV{'CWS_WORK_STAMP'} ) { $cwsproduct = 1; } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if (( $cwsproduct ) || ( $devproduct )) # use "DEV300m75" 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir my $source = uc($installer::globals::build); # DEV300 513*cdf0e10cSrcweir my $localminor = ""; 514*cdf0e10cSrcweir if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; } 515*cdf0e10cSrcweir else { $localminor = $installer::globals::lastminor; } 516*cdf0e10cSrcweir $version = $source . $localminor; 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir else # use 3.2.0rc1 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir $version = $allvariables->{'PRODUCTVERSION'}; 521*cdf0e10cSrcweir if (( $allvariables->{'ABOUTBOXPRODUCTVERSION'} ) && ( $allvariables->{'ABOUTBOXPRODUCTVERSION'} ne "" )) { $version = $allvariables->{'ABOUTBOXPRODUCTVERSION'}; } 522*cdf0e10cSrcweir if (( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) && ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ne "" )) { $version = $version . $allvariables->{'SHORT_PRODUCTEXTENSION'}; } 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir return $version; 526*cdf0e10cSrcweir} 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir############################################################### 529*cdf0e10cSrcweir# Set date string, format: yymmdd 530*cdf0e10cSrcweir############################################################### 531*cdf0e10cSrcweir 532*cdf0e10cSrcweirsub set_date_string 533*cdf0e10cSrcweir{ 534*cdf0e10cSrcweir my ($allvariables) = @_; 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir my $datestring = ""; 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir my $devproduct = 0; 539*cdf0e10cSrcweir if (( $allvariables->{'DEVELOPMENTPRODUCT'} ) && ( $allvariables->{'DEVELOPMENTPRODUCT'} == 1 )) { $devproduct = 1; } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir my $cwsproduct = 0; 542*cdf0e10cSrcweir # the environment variable CWS_WORK_STAMP is set only in CWS 543*cdf0e10cSrcweir if ( $ENV{'CWS_WORK_STAMP'} ) { $cwsproduct = 1; } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir my $releasebuild = 1; 546*cdf0e10cSrcweir if (( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) && ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ne "" )) { $releasebuild = 0; } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir if (( ! $devproduct ) && ( ! $cwsproduct ) && ( ! $releasebuild )) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir my @timearray = localtime(time); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir my $day = $timearray[3]; 553*cdf0e10cSrcweir my $month = $timearray[4] + 1; 554*cdf0e10cSrcweir my $year = $timearray[5] + 1900; 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir if ( $month < 10 ) { $month = "0" . $month; } 557*cdf0e10cSrcweir if ( $day < 10 ) { $day = "0" . $day; } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir $datestring = $year . $month . $day; 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir return $datestring; 563*cdf0e10cSrcweir} 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir################################################################# 566*cdf0e10cSrcweir# Setting the platform name for download 567*cdf0e10cSrcweir################################################################# 568*cdf0e10cSrcweir 569*cdf0e10cSrcweirsub get_download_platformname 570*cdf0e10cSrcweir{ 571*cdf0e10cSrcweir my $platformname = ""; 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir if ( $installer::globals::islinuxbuild ) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir $platformname = "Linux"; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir elsif ( $installer::globals::issolarisbuild ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir $platformname = "Solaris"; 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir elsif ( $installer::globals::iswindowsbuild ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir $platformname = "Win"; 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir elsif ( $installer::globals::isfreebsdbuild ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir $platformname = "FreeBSD"; 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir elsif ( $installer::globals::ismacbuild ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir $platformname = "MacOS"; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir else 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir # $platformname = $installer::globals::packageformat; 596*cdf0e10cSrcweir $platformname = $installer::globals::compiler; 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir return $platformname; 600*cdf0e10cSrcweir} 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir######################################################### 603*cdf0e10cSrcweir# Setting the architecture for the download name 604*cdf0e10cSrcweir######################################################### 605*cdf0e10cSrcweir 606*cdf0e10cSrcweirsub get_download_architecture 607*cdf0e10cSrcweir{ 608*cdf0e10cSrcweir my $arch = ""; 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir if ( $installer::globals::compiler =~ /unxlngi/ ) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir $arch = "x86"; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /unxlngppc/ ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir $arch = "PPC"; 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /unxlngx/ ) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir $arch = "x86-64"; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir elsif ( $installer::globals::issolarissparcbuild ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir $arch = "Sparc"; 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir elsif ( $installer::globals::issolarisx86build ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir $arch = "x86"; 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir elsif ( $installer::globals::iswindowsbuild ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir $arch = "x86"; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /^unxmacxi/ ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir $arch = "x86"; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /^unxmacxp/ ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir $arch = "PPC"; 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir return $arch; 644*cdf0e10cSrcweir} 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir######################################################### 647*cdf0e10cSrcweir# Setting the installation type for the download name 648*cdf0e10cSrcweir######################################################### 649*cdf0e10cSrcweir 650*cdf0e10cSrcweirsub get_install_type 651*cdf0e10cSrcweir{ 652*cdf0e10cSrcweir my ($allvariables) = @_; 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir my $type = ""; 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir if ( $installer::globals::languagepack ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir $type = "langpack"; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir $type = $type . "-rpm"; 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir if ( $installer::globals::islinuxdebbuild ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir $type = $type . "-deb"; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir if ( $installer::globals::packageformat eq "archive" ) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir $type = $type . "-arc"; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir else 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir $type = "install"; 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir if ( $installer::globals::islinuxrpmbuild ) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir $type = $type . "-rpm"; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir if ( $installer::globals::islinuxdebbuild ) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir $type = $type . "-deb"; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir if ( $installer::globals::packageformat eq "archive" ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir $type = $type . "-arc"; 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir if (( $allvariables->{'WITHJREPRODUCT'} ) && ( $allvariables->{'WITHJREPRODUCT'} == 1 )) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir $type = $type . "-wJRE"; 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir return $type; 702*cdf0e10cSrcweir} 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir######################################################### 705*cdf0e10cSrcweir# Setting installation addons 706*cdf0e10cSrcweir######################################################### 707*cdf0e10cSrcweir 708*cdf0e10cSrcweirsub get_downloadname_addon 709*cdf0e10cSrcweir{ 710*cdf0e10cSrcweir my $addon = ""; 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir if ( $installer::globals::islinuxdebbuild ) { $addon = $addon . "_deb"; } 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir if ( $installer::globals::product =~ /_wJRE\s*$/ ) { $addon = "_wJRE"; } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir return $addon; 717*cdf0e10cSrcweir} 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir######################################################### 720*cdf0e10cSrcweir# Looking for versionstring in version.info 721*cdf0e10cSrcweir# This has to be the only content of this file. 722*cdf0e10cSrcweir######################################################### 723*cdf0e10cSrcweir 724*cdf0e10cSrcweirsub get_versionstring 725*cdf0e10cSrcweir{ 726*cdf0e10cSrcweir my ( $versionfile ) = @_; 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir my $versionstring = ""; 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$versionfile}; $i++ ) 731*cdf0e10cSrcweir { 732*cdf0e10cSrcweir my $oneline = ${$versionfile}[$i]; 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir if ( $oneline =~ /^\s*\#/ ) { next; } # comment line 735*cdf0e10cSrcweir if ( $oneline =~ /^\s*\"\s*(.*?)\s*\"\s*$/ ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir $versionstring = $1; 738*cdf0e10cSrcweir last; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir return $versionstring; 743*cdf0e10cSrcweir} 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir######################################################### 746*cdf0e10cSrcweir# Returning the current product version 747*cdf0e10cSrcweir# This has to be defined in file "version.info" 748*cdf0e10cSrcweir# in directory $installer::globals::ooouploaddir 749*cdf0e10cSrcweir######################################################### 750*cdf0e10cSrcweir 751*cdf0e10cSrcweirsub get_current_version 752*cdf0e10cSrcweir{ 753*cdf0e10cSrcweir my $infoline = ""; 754*cdf0e10cSrcweir my $versionstring = ""; 755*cdf0e10cSrcweir my $filename = "version.info"; 756*cdf0e10cSrcweir # $filename = $installer::globals::ooouploaddir . $installer::globals::separator . $filename; 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir if ( -f $filename ) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir $infoline = "File $filename exists. Trying to find current version.\n"; 761*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 762*cdf0e10cSrcweir my $versionfile = installer::files::read_file($filename); 763*cdf0e10cSrcweir $versionstring = get_versionstring($versionfile); 764*cdf0e10cSrcweir $infoline = "Setting version string: $versionstring\n"; 765*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir else 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir $infoline = "File $filename does not exist. No version setting in download file name.\n"; 770*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir $installer::globals::oooversionstring = $versionstring; 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir return $versionstring; 776*cdf0e10cSrcweir} 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir############################################################################################### 779*cdf0e10cSrcweir# Setting the download file name 780*cdf0e10cSrcweir# Syntax: 781*cdf0e10cSrcweir# (PRODUCTNAME)_(VERSION)_(TIMESTAMP)_(OS)_(ARCH)_(INSTALLTYPE)_(LANGUAGE).(FILEEXTENSION) 782*cdf0e10cSrcweir# Rules: 783*cdf0e10cSrcweir# Timestamp only for Beta and Release Candidate 784*cdf0e10cSrcweir############################################################################################### 785*cdf0e10cSrcweir 786*cdf0e10cSrcweirsub set_download_filename 787*cdf0e10cSrcweir{ 788*cdf0e10cSrcweir my ($languagestringref, $allvariables) = @_; 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir my $start = get_downloadname_productname($allvariables); 791*cdf0e10cSrcweir my $versionstring = get_download_version($allvariables); 792*cdf0e10cSrcweir my $date = set_date_string($allvariables); 793*cdf0e10cSrcweir my $platform = get_download_platformname(); 794*cdf0e10cSrcweir my $architecture = get_download_architecture(); 795*cdf0e10cSrcweir my $type = get_install_type($allvariables); 796*cdf0e10cSrcweir my $language = get_downloadname_language($languagestringref); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir # Setting the extension happens automatically 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir my $filename = $start . "_" . $versionstring . "_" . $date . "_" . $platform . "_" . $architecture . "_" . $type . "_" . $language; 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir $filename =~ s/\_\_/\_/g; # necessary, if $versionstring or $platform or $language are empty 803*cdf0e10cSrcweir $filename =~ s/\_\s*$//; # necessary, if $language and $addon are empty 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir $installer::globals::ooodownloadfilename = $filename; 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir return $filename; 808*cdf0e10cSrcweir} 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir######################################################### 811*cdf0e10cSrcweir# Creating a tar.gz file 812*cdf0e10cSrcweir######################################################### 813*cdf0e10cSrcweir 814*cdf0e10cSrcweirsub create_tar_gz_file_from_directory 815*cdf0e10cSrcweir{ 816*cdf0e10cSrcweir my ($installdir, $getuidlibrary, $downloaddir, $downloadfilename) = @_; 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir my $infoline = ""; 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir my $packdir = $installdir; 821*cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packdir); 822*cdf0e10cSrcweir my $changedir = $installdir; 823*cdf0e10cSrcweir installer::pathanalyzer::get_path_from_fullqualifiedname(\$changedir); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir my $ldpreloadstring = ""; 826*cdf0e10cSrcweir if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir $installer::globals::downloadfileextension = ".tar.gz"; 829*cdf0e10cSrcweir $installer::globals::downloadfilename = $downloadfilename . $installer::globals::downloadfileextension; 830*cdf0e10cSrcweir my $targzname = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename; 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir $systemcall = "cd $changedir; $ldpreloadstring tar -cf - $packdir | gzip > $targzname"; 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir my $returnvalue = system($systemcall); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 837*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir if ($returnvalue) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 842*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir else 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 847*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir return $targzname; 851*cdf0e10cSrcweir} 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir######################################################### 854*cdf0e10cSrcweir# Setting the variables in the download name 855*cdf0e10cSrcweir######################################################### 856*cdf0e10cSrcweir 857*cdf0e10cSrcweirsub resolve_variables_in_downloadname 858*cdf0e10cSrcweir{ 859*cdf0e10cSrcweir my ($allvariables, $downloadname, $languagestringref) = @_; 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir # Typical name: soa-{productversion}-{extension}-bin-{os}-{languages} 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir my $productversion = ""; 864*cdf0e10cSrcweir if ( $allvariables->{'PRODUCTVERSION'} ) { $productversion = $allvariables->{'PRODUCTVERSION'}; } 865*cdf0e10cSrcweir $downloadname =~ s/\{productversion\}/$productversion/; 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir my $ppackageversion = ""; 868*cdf0e10cSrcweir if ( $allvariables->{'PACKAGEVERSION'} ) { $packageversion = $allvariables->{'PACKAGEVERSION'}; } 869*cdf0e10cSrcweir $downloadname =~ s/\{packageversion\}/$packageversion/; 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir my $extension = ""; 872*cdf0e10cSrcweir if ( $allvariables->{'SHORT_PRODUCTEXTENSION'} ) { $extension = $allvariables->{'SHORT_PRODUCTEXTENSION'}; } 873*cdf0e10cSrcweir $extension = lc($extension); 874*cdf0e10cSrcweir $downloadname =~ s/\{extension\}/$extension/; 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir my $os = ""; 877*cdf0e10cSrcweir if ( $installer::globals::iswindowsbuild ) { $os = "windows"; } 878*cdf0e10cSrcweir elsif ( $installer::globals::issolarissparcbuild ) { $os = "solsparc"; } 879*cdf0e10cSrcweir elsif ( $installer::globals::issolarisx86build ) { $os = "solia"; } 880*cdf0e10cSrcweir elsif ( $installer::globals::islinuxbuild ) { $os = "linux"; } 881*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /unxmacxi/ ) { $os = "macosxi"; } 882*cdf0e10cSrcweir elsif ( $installer::globals::compiler =~ /unxmacxp/ ) { $os = "macosxp"; } 883*cdf0e10cSrcweir else { $os = ""; } 884*cdf0e10cSrcweir $downloadname =~ s/\{os\}/$os/; 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir my $languages = $$languagestringref; 887*cdf0e10cSrcweir $downloadname =~ s/\{languages\}/$languages/; 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir $downloadname =~ s/\-\-\-/\-/g; 890*cdf0e10cSrcweir $downloadname =~ s/\-\-/\-/g; 891*cdf0e10cSrcweir $downloadname =~ s/\-\s*$//; 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir return $downloadname; 894*cdf0e10cSrcweir} 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir################################################################## 897*cdf0e10cSrcweir# Windows: Replacing one placeholder with the specified value 898*cdf0e10cSrcweir################################################################## 899*cdf0e10cSrcweir 900*cdf0e10cSrcweirsub replace_one_variable 901*cdf0e10cSrcweir{ 902*cdf0e10cSrcweir my ($templatefile, $placeholder, $value) = @_; 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir my $infoline = "Replacing $placeholder by $value in nsi file\n"; 905*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$templatefile}; $i++ ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir ${$templatefile}[$i] =~ s/$placeholder/$value/g; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir} 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir######################################################################################## 915*cdf0e10cSrcweir# Converting a string to a unicode string 916*cdf0e10cSrcweir######################################################################################## 917*cdf0e10cSrcweir 918*cdf0e10cSrcweirsub convert_to_unicode 919*cdf0e10cSrcweir{ 920*cdf0e10cSrcweir my ($string) = @_; 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir my $unicodestring = ""; 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir my $stringlength = length($string); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir for ( my $i = 0; $i < $stringlength; $i++ ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir $unicodestring = $unicodestring . substr($string, $i, 1); 929*cdf0e10cSrcweir $unicodestring = $unicodestring . chr(0); 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir return $unicodestring; 933*cdf0e10cSrcweir} 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir################################################################## 936*cdf0e10cSrcweir# Windows: Setting nsis version is necessary because of small 937*cdf0e10cSrcweir# changes in nsis from version 2.0.4 to 2.3.1 938*cdf0e10cSrcweir################################################################## 939*cdf0e10cSrcweir 940*cdf0e10cSrcweirsub set_nsis_version 941*cdf0e10cSrcweir{ 942*cdf0e10cSrcweir my ($nshfile) = @_; 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir my $searchstring = "\$\{LangFileString\}"; # occurs only in nsis 2.3.1 or similar 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$nshfile}; $i++ ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ ) 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir # this is nsis 2.3.1 or similar 951*cdf0e10cSrcweir $installer::globals::nsis231 = 1; 952*cdf0e10cSrcweir $installer::globals::unicodensis = 0; 953*cdf0e10cSrcweir last; 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir # checking unicode version 958*cdf0e10cSrcweir $searchstring = convert_to_unicode($searchstring); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$nshfile}; $i++ ) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ ) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir # this is nsis 2.3.1 or similar 965*cdf0e10cSrcweir $installer::globals::nsis231 = 1; 966*cdf0e10cSrcweir $installer::globals::unicodensis = 1; 967*cdf0e10cSrcweir last; 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir if ( ! $installer::globals::nsis231 ) { $installer::globals::nsis204 = 1; } 972*cdf0e10cSrcweir} 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir################################################################## 975*cdf0e10cSrcweir# Windows: Including the product name into nsi template 976*cdf0e10cSrcweir################################################################## 977*cdf0e10cSrcweir 978*cdf0e10cSrcweirsub put_windows_productname_into_template 979*cdf0e10cSrcweir{ 980*cdf0e10cSrcweir my ($templatefile, $variableshashref) = @_; 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir my $productname = $variableshashref->{'PRODUCTNAME'}; 983*cdf0e10cSrcweir $productname =~ s/\.//g; # OpenOffice.org -> OpenOfficeorg 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir replace_one_variable($templatefile, "PRODUCTNAMEPLACEHOLDER", $productname); 986*cdf0e10cSrcweir} 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir################################################################## 989*cdf0e10cSrcweir# Windows: Including the path to the banner.bmp into nsi template 990*cdf0e10cSrcweir################################################################## 991*cdf0e10cSrcweir 992*cdf0e10cSrcweirsub put_banner_bmp_into_template 993*cdf0e10cSrcweir{ 994*cdf0e10cSrcweir my ($templatefile, $includepatharrayref, $allvariables) = @_; 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir # my $filename = "downloadbanner.bmp"; 997*cdf0e10cSrcweir if ( ! $allvariables->{'DOWNLOADBANNER'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBANNER not defined in product definition!", "put_banner_bmp_into_template"); } 998*cdf0e10cSrcweir my $filename = $allvariables->{'DOWNLOADBANNER'}; 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir my $completefilenameref = ""; 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 1005*cdf0e10cSrcweir } 1006*cdf0e10cSrcweir else 1007*cdf0e10cSrcweir { 1008*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_banner_bmp_into_template"); } 1012*cdf0e10cSrcweir 1013*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir replace_one_variable($templatefile, "BANNERBMPPLACEHOLDER", $$completefilenameref); 1016*cdf0e10cSrcweir} 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir################################################################## 1019*cdf0e10cSrcweir# Windows: Including the path to the welcome.bmp into nsi template 1020*cdf0e10cSrcweir################################################################## 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweirsub put_welcome_bmp_into_template 1023*cdf0e10cSrcweir{ 1024*cdf0e10cSrcweir my ($templatefile, $includepatharrayref, $allvariables) = @_; 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir # my $filename = "downloadbitmap.bmp"; 1027*cdf0e10cSrcweir if ( ! $allvariables->{'DOWNLOADBITMAP'} ) { installer::exiter::exit_program("ERROR: DOWNLOADBITMAP not defined in product definition!", "put_welcome_bmp_into_template"); } 1028*cdf0e10cSrcweir my $filename = $allvariables->{'DOWNLOADBITMAP'}; 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir my $completefilenameref = ""; 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 1033*cdf0e10cSrcweir { 1034*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir else 1037*cdf0e10cSrcweir { 1038*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_welcome_bmp_into_template"); } 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir replace_one_variable($templatefile, "WELCOMEBMPPLACEHOLDER", $$completefilenameref); 1046*cdf0e10cSrcweir} 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir################################################################## 1049*cdf0e10cSrcweir# Windows: Including the path to the setup.ico into nsi template 1050*cdf0e10cSrcweir################################################################## 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweirsub put_setup_ico_into_template 1053*cdf0e10cSrcweir{ 1054*cdf0e10cSrcweir my ($templatefile, $includepatharrayref, $allvariables) = @_; 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir # my $filename = "downloadsetup.ico"; 1057*cdf0e10cSrcweir if ( ! $allvariables->{'DOWNLOADSETUPICO'} ) { installer::exiter::exit_program("ERROR: DOWNLOADSETUPICO not defined in product definition!", "put_setup_ico_into_template"); } 1058*cdf0e10cSrcweir my $filename = $allvariables->{'DOWNLOADSETUPICO'}; 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir my $completefilenameref = ""; 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 1063*cdf0e10cSrcweir { 1064*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 0); 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir else 1067*cdf0e10cSrcweir { 1068*cdf0e10cSrcweir $completefilenameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$filename, $includepatharrayref, 0); 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir if ($$completefilenameref eq "") { installer::exiter::exit_program("ERROR: Could not find download file $filename!", "put_setup_ico_into_template"); } 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $$completefilenameref =~ s/\//\\/g; } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir replace_one_variable($templatefile, "SETUPICOPLACEHOLDER", $$completefilenameref); 1076*cdf0e10cSrcweir} 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir################################################################## 1079*cdf0e10cSrcweir# Windows: Including the publisher into nsi template 1080*cdf0e10cSrcweir################################################################## 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweirsub put_publisher_into_template 1083*cdf0e10cSrcweir{ 1084*cdf0e10cSrcweir my ($templatefile) = @_; 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir my $publisher = "Sun Microsystems, Inc."; 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir replace_one_variable($templatefile, "PUBLISHERPLACEHOLDER", $publisher); 1089*cdf0e10cSrcweir} 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir################################################################## 1092*cdf0e10cSrcweir# Windows: Including the web site into nsi template 1093*cdf0e10cSrcweir################################################################## 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweirsub put_website_into_template 1096*cdf0e10cSrcweir{ 1097*cdf0e10cSrcweir my ($templatefile) = @_; 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir my $website = "http\:\/\/www\.sun\.com\/staroffice"; 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir replace_one_variable($templatefile, "WEBSITEPLACEHOLDER", $website); 1102*cdf0e10cSrcweir} 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir################################################################## 1105*cdf0e10cSrcweir# Windows: Including the Java file name into nsi template 1106*cdf0e10cSrcweir################################################################## 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweirsub put_javafilename_into_template 1109*cdf0e10cSrcweir{ 1110*cdf0e10cSrcweir my ($templatefile, $variableshashref) = @_; 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir my $javaversion = ""; 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir if ( $variableshashref->{'WINDOWSJAVAFILENAME'} ) { $javaversion = $variableshashref->{'WINDOWSJAVAFILENAME'}; } 1115*cdf0e10cSrcweir 1116*cdf0e10cSrcweir replace_one_variable($templatefile, "WINDOWSJAVAFILENAMEPLACEHOLDER", $javaversion); 1117*cdf0e10cSrcweir} 1118*cdf0e10cSrcweir 1119*cdf0e10cSrcweir################################################################## 1120*cdf0e10cSrcweir# Windows: Including the product version into nsi template 1121*cdf0e10cSrcweir################################################################## 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweirsub put_windows_productversion_into_template 1124*cdf0e10cSrcweir{ 1125*cdf0e10cSrcweir my ($templatefile, $variableshashref) = @_; 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir my $productversion = $variableshashref->{'PRODUCTVERSION'}; 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir replace_one_variable($templatefile, "PRODUCTVERSIONPLACEHOLDER", $productversion); 1130*cdf0e10cSrcweir} 1131*cdf0e10cSrcweir 1132*cdf0e10cSrcweir################################################################## 1133*cdf0e10cSrcweir# Windows: Including the product version into nsi template 1134*cdf0e10cSrcweir################################################################## 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweirsub put_windows_productpath_into_template 1137*cdf0e10cSrcweir{ 1138*cdf0e10cSrcweir my ($templatefile, $variableshashref, $languagestringref, $localnsisdir) = @_; 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'}; 1141*cdf0e10cSrcweir 1142*cdf0e10cSrcweir my $locallangs = $$languagestringref; 1143*cdf0e10cSrcweir $locallangs =~ s/_/ /g; 1144*cdf0e10cSrcweir if (length($locallangs) > $installer::globals::max_lang_length) { $locallangs = "multi lingual"; } 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir if ( ! $installer::globals::languagepack ) { $productpath = $productpath . " (" . $locallangs . ")"; } 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir # if (( $installer::globals::languagepack ) && ( $installer::globals::unicodensis )) { $productpath = convert_textstring_to_utf16($productpath, $localnsisdir, "stringhelper.txt"); } 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir replace_one_variable($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath); 1151*cdf0e10cSrcweir} 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir################################################################## 1154*cdf0e10cSrcweir# Windows: Including download file name into nsi template 1155*cdf0e10cSrcweir################################################################## 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweirsub put_outputfilename_into_template 1158*cdf0e10cSrcweir{ 1159*cdf0e10cSrcweir my ($templatefile, $downloadname) = @_; 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir $installer::globals::downloadfileextension = ".exe"; 1162*cdf0e10cSrcweir $downloadname = $downloadname . $installer::globals::downloadfileextension; 1163*cdf0e10cSrcweir $installer::globals::downloadfilename = $downloadname; 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir replace_one_variable($templatefile, "DOWNLOADNAMEPLACEHOLDER", $downloadname); 1166*cdf0e10cSrcweir} 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir################################################################## 1169*cdf0e10cSrcweir# Windows: Generating the file list in nsi file format 1170*cdf0e10cSrcweir################################################################## 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweirsub get_file_list 1173*cdf0e10cSrcweir{ 1174*cdf0e10cSrcweir my ( $basedir ) = @_; 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir my @filelist = (); 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir my $alldirs = installer::systemactions::get_all_directories($basedir); 1179*cdf0e10cSrcweir unshift(@{$alldirs}, $basedir); # $basedir is the first directory in $alldirs 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$alldirs}; $i++ ) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir my $onedir = ${$alldirs}[$i]; 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir # Syntax: 1186*cdf0e10cSrcweir # SetOutPath "$INSTDIR" 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir my $relativedir = $onedir; 1189*cdf0e10cSrcweir $relativedir =~ s/\Q$basedir\E//; 1190*cdf0e10cSrcweir 1191*cdf0e10cSrcweir my $oneline = " " . "SetOutPath" . " " . "\"\$INSTDIR" . $relativedir . "\"" . "\n"; 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { 1194*cdf0e10cSrcweir $oneline =~ s/\//\\/g; 1195*cdf0e10cSrcweir } 1196*cdf0e10cSrcweir push(@filelist, $oneline); 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir # Collecting all files in the specific directory 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir my $files = installer::systemactions::get_all_files_from_one_directory($onedir); 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$files}; $j++ ) 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir my $onefile = ${$files}[$j]; 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir my $fileline = " " . "File" . " " . "\"" . $onefile . "\"" . "\n"; 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { 1209*cdf0e10cSrcweir $fileline =~ s/\//\\/g; 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir push(@filelist, $fileline); 1212*cdf0e10cSrcweir } 1213*cdf0e10cSrcweir } 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir return \@filelist; 1216*cdf0e10cSrcweir} 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir################################################################## 1219*cdf0e10cSrcweir# Windows: Including list of all files into nsi template 1220*cdf0e10cSrcweir################################################################## 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweirsub put_filelist_into_template 1223*cdf0e10cSrcweir{ 1224*cdf0e10cSrcweir my ($templatefile, $installationdir) = @_; 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir my $filelist = get_file_list($installationdir); 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir my $filestring = ""; 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filelist}; $i++ ) 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir $filestring = $filestring . ${$filelist}[$i]; 1233*cdf0e10cSrcweir } 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir $filestring =~ s/\s*$//; 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir replace_one_variable($templatefile, "ALLFILESPLACEHOLDER", $filestring); 1238*cdf0e10cSrcweir} 1239*cdf0e10cSrcweir 1240*cdf0e10cSrcweir################################################################## 1241*cdf0e10cSrcweir# Windows: NSIS uses specific language names 1242*cdf0e10cSrcweir################################################################## 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweirsub nsis_language_converter 1245*cdf0e10cSrcweir{ 1246*cdf0e10cSrcweir my ($language) = @_; 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir my $nsislanguage = ""; 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir # Assign language used by NSIS. 1251*cdf0e10cSrcweir # The files "$nsislanguage.nsh" and "$nsislanguage.nlf" 1252*cdf0e10cSrcweir # are needed in the NSIS environment. 1253*cdf0e10cSrcweir # Directory: <NSIS-Dir>/Contrib/Language files 1254*cdf0e10cSrcweir if ( $language eq "en-US" ) { $nsislanguage = "English"; } 1255*cdf0e10cSrcweir elsif ( $language eq "sq" ) { $nsislanguage = "Albanian"; } 1256*cdf0e10cSrcweir elsif ( $language eq "ar" ) { $nsislanguage = "Arabic"; } 1257*cdf0e10cSrcweir elsif ( $language eq "bg" ) { $nsislanguage = "Bulgarian"; } 1258*cdf0e10cSrcweir elsif ( $language eq "ca" ) { $nsislanguage = "Catalan"; } 1259*cdf0e10cSrcweir elsif ( $language eq "hr" ) { $nsislanguage = "Croatian"; } 1260*cdf0e10cSrcweir elsif ( $language eq "cs" ) { $nsislanguage = "Czech"; } 1261*cdf0e10cSrcweir elsif ( $language eq "da" ) { $nsislanguage = "Danish"; } 1262*cdf0e10cSrcweir elsif ( $language eq "nl" ) { $nsislanguage = "Dutch"; } 1263*cdf0e10cSrcweir elsif ( $language eq "de" ) { $nsislanguage = "German"; } 1264*cdf0e10cSrcweir elsif ( $language eq "de-LU" ) { $nsislanguage = "Luxembourgish"; } 1265*cdf0e10cSrcweir elsif ( $language eq "et" ) { $nsislanguage = "Estonian"; } 1266*cdf0e10cSrcweir elsif ( $language eq "fa" ) { $nsislanguage = "Farsi"; } 1267*cdf0e10cSrcweir elsif ( $language eq "el" ) { $nsislanguage = "Greek"; } 1268*cdf0e10cSrcweir elsif ( $language eq "fi" ) { $nsislanguage = "Finnish"; } 1269*cdf0e10cSrcweir elsif ( $language eq "fr" ) { $nsislanguage = "French"; } 1270*cdf0e10cSrcweir elsif ( $language eq "hu" ) { $nsislanguage = "Hungarian"; } 1271*cdf0e10cSrcweir elsif ( $language eq "he" ) { $nsislanguage = "Hebrew"; } 1272*cdf0e10cSrcweir elsif ( $language eq "is" ) { $nsislanguage = "Icelandic"; } 1273*cdf0e10cSrcweir elsif ( $language eq "id" ) { $nsislanguage = "Indonesian"; } 1274*cdf0e10cSrcweir elsif ( $language eq "it" ) { $nsislanguage = "Italian"; } 1275*cdf0e10cSrcweir elsif ( $language eq "lv" ) { $nsislanguage = "Latvian"; } 1276*cdf0e10cSrcweir elsif ( $language eq "lt" ) { $nsislanguage = "Lithuanian"; } 1277*cdf0e10cSrcweir elsif ( $language eq "mk" ) { $nsislanguage = "Macedonian"; } 1278*cdf0e10cSrcweir elsif ( $language eq "mn" ) { $nsislanguage = "Mongolian"; } 1279*cdf0e10cSrcweir elsif ( $language eq "no" ) { $nsislanguage = "Norwegian"; } 1280*cdf0e10cSrcweir elsif ( $language eq "no-NO" ) { $nsislanguage = "Norwegian"; } 1281*cdf0e10cSrcweir elsif ( $language eq "es" ) { $nsislanguage = "Spanish"; } 1282*cdf0e10cSrcweir elsif ( $language eq "sl" ) { $nsislanguage = "Slovenian"; } 1283*cdf0e10cSrcweir elsif ( $language eq "sv" ) { $nsislanguage = "Swedish"; } 1284*cdf0e10cSrcweir elsif ( $language eq "sk" ) { $nsislanguage = "Slovak"; } 1285*cdf0e10cSrcweir elsif ( $language eq "pl" ) { $nsislanguage = "Polish"; } 1286*cdf0e10cSrcweir elsif ( $language eq "pt-BR" ) { $nsislanguage = "PortugueseBR"; } 1287*cdf0e10cSrcweir elsif ( $language eq "pt" ) { $nsislanguage = "Portuguese"; } 1288*cdf0e10cSrcweir elsif ( $language eq "ro" ) { $nsislanguage = "Romanian"; } 1289*cdf0e10cSrcweir elsif ( $language eq "ru" ) { $nsislanguage = "Russian"; } 1290*cdf0e10cSrcweir elsif ( $language eq "sh" ) { $nsislanguage = "SerbianLatin"; } 1291*cdf0e10cSrcweir elsif ( $language eq "sr" ) { $nsislanguage = "Serbian"; } 1292*cdf0e10cSrcweir elsif ( $language eq "sr-SP" ) { $nsislanguage = "Serbian"; } 1293*cdf0e10cSrcweir elsif ( $language eq "uk" ) { $nsislanguage = "Ukrainian"; } 1294*cdf0e10cSrcweir elsif ( $language eq "tr" ) { $nsislanguage = "Turkish"; } 1295*cdf0e10cSrcweir elsif ( $language eq "ja" ) { $nsislanguage = "Japanese"; } 1296*cdf0e10cSrcweir elsif ( $language eq "ko" ) { $nsislanguage = "Korean"; } 1297*cdf0e10cSrcweir elsif ( $language eq "th" ) { $nsislanguage = "Thai"; } 1298*cdf0e10cSrcweir elsif ( $language eq "vi" ) { $nsislanguage = "Vietnamese"; } 1299*cdf0e10cSrcweir elsif ( $language eq "zh-CN" ) { $nsislanguage = "SimpChinese"; } 1300*cdf0e10cSrcweir elsif ( $language eq "zh-TW" ) { $nsislanguage = "TradChinese"; } 1301*cdf0e10cSrcweir else { 1302*cdf0e10cSrcweir my $infoline = "NSIS language_converter : Could not find nsis language for $language!\n"; 1303*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1304*cdf0e10cSrcweir $nsislanguage = "English"; 1305*cdf0e10cSrcweir # installer::exiter::exit_program("ERROR: Could not find nsis language for $language!", "nsis_language_converter"); 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir return $nsislanguage; 1309*cdf0e10cSrcweir} 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir################################################################## 1312*cdf0e10cSrcweir# Windows: Including list of all languages into nsi template 1313*cdf0e10cSrcweir################################################################## 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweirsub put_language_list_into_template 1316*cdf0e10cSrcweir{ 1317*cdf0e10cSrcweir my ($templatefile, $languagesarrayref) = @_; 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir my $alllangstring = ""; 1320*cdf0e10cSrcweir my %nsislangs; 1321*cdf0e10cSrcweir 1322*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 1323*cdf0e10cSrcweir { 1324*cdf0e10cSrcweir my $onelanguage = ${$languagesarrayref}[$i]; 1325*cdf0e10cSrcweir my $nsislanguage = nsis_language_converter($onelanguage); 1326*cdf0e10cSrcweir $nsislangs{$nsislanguage}++; 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir foreach my $nsislanguage ( keys(%nsislangs) ) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir # Syntax: !insertmacro MUI_LANGUAGE "English" 1332*cdf0e10cSrcweir my $langstring = "\!insertmacro MUI_LANGUAGE_PACK " . $nsislanguage . "\n"; 1333*cdf0e10cSrcweir if ( $nsislanguage eq "English" ) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir $alllangstring = $langstring . $alllangstring; 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir else 1338*cdf0e10cSrcweir { 1339*cdf0e10cSrcweir $alllangstring = $alllangstring . $langstring; 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir } 1342*cdf0e10cSrcweir 1343*cdf0e10cSrcweir $alllangstring =~ s/\s*$//; 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir replace_one_variable($templatefile, "ALLLANGUAGESPLACEHOLDER", $alllangstring); 1346*cdf0e10cSrcweir} 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir################################################################## 1349*cdf0e10cSrcweir# Windows: Collecting all identifier from mlf file 1350*cdf0e10cSrcweir################################################################## 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweirsub get_identifier 1353*cdf0e10cSrcweir{ 1354*cdf0e10cSrcweir my ( $mlffile ) = @_; 1355*cdf0e10cSrcweir 1356*cdf0e10cSrcweir my @identifier = (); 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$mlffile}; $i++ ) 1359*cdf0e10cSrcweir { 1360*cdf0e10cSrcweir my $oneline = ${$mlffile}[$i]; 1361*cdf0e10cSrcweir 1362*cdf0e10cSrcweir if ( $oneline =~ /^\s*\[(.+)\]\s*$/ ) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir my $identifier = $1; 1365*cdf0e10cSrcweir push(@identifier, $identifier); 1366*cdf0e10cSrcweir } 1367*cdf0e10cSrcweir } 1368*cdf0e10cSrcweir 1369*cdf0e10cSrcweir return \@identifier; 1370*cdf0e10cSrcweir} 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir############################################################## 1373*cdf0e10cSrcweir# Returning the complete block in all languages 1374*cdf0e10cSrcweir# for a specified string 1375*cdf0e10cSrcweir############################################################## 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweirsub get_language_block_from_language_file 1378*cdf0e10cSrcweir{ 1379*cdf0e10cSrcweir my ($searchstring, $languagefile) = @_; 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir my @language_block = (); 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagefile}; $i++ ) 1384*cdf0e10cSrcweir { 1385*cdf0e10cSrcweir if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ ) 1386*cdf0e10cSrcweir { 1387*cdf0e10cSrcweir my $counter = $i; 1388*cdf0e10cSrcweir 1389*cdf0e10cSrcweir push(@language_block, ${$languagefile}[$counter]); 1390*cdf0e10cSrcweir $counter++; 1391*cdf0e10cSrcweir 1392*cdf0e10cSrcweir while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ ))) 1393*cdf0e10cSrcweir { 1394*cdf0e10cSrcweir push(@language_block, ${$languagefile}[$counter]); 1395*cdf0e10cSrcweir $counter++; 1396*cdf0e10cSrcweir } 1397*cdf0e10cSrcweir 1398*cdf0e10cSrcweir last; 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir return \@language_block; 1403*cdf0e10cSrcweir} 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir############################################################## 1406*cdf0e10cSrcweir# Returning a specific language string from the block 1407*cdf0e10cSrcweir# of all translations 1408*cdf0e10cSrcweir############################################################## 1409*cdf0e10cSrcweir 1410*cdf0e10cSrcweirsub get_language_string_from_language_block 1411*cdf0e10cSrcweir{ 1412*cdf0e10cSrcweir my ($language_block, $language) = @_; 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir my $newstring = ""; 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 1417*cdf0e10cSrcweir { 1418*cdf0e10cSrcweir if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 1419*cdf0e10cSrcweir { 1420*cdf0e10cSrcweir $newstring = $1; 1421*cdf0e10cSrcweir last; 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir } 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir if ( $newstring eq "" ) 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir $language = "en-US"; # defaulting to english 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$language_block}; $i++ ) 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ ) 1432*cdf0e10cSrcweir { 1433*cdf0e10cSrcweir $newstring = $1; 1434*cdf0e10cSrcweir last; 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir } 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir return $newstring; 1440*cdf0e10cSrcweir} 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir################################################################## 1443*cdf0e10cSrcweir# Windows: Replacing strings in NSIS nsh file 1444*cdf0e10cSrcweir# nsh file syntax: 1445*cdf0e10cSrcweir# !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis ausw�hlen" 1446*cdf0e10cSrcweir################################################################## 1447*cdf0e10cSrcweir 1448*cdf0e10cSrcweirsub replace_identifier_in_nshfile 1449*cdf0e10cSrcweir{ 1450*cdf0e10cSrcweir my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_; 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir if ( $installer::globals::nsis231 ) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir $newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions 1455*cdf0e10cSrcweir $newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$nshfile}; $i++ ) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ ) 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir my $oldstring = $1; 1463*cdf0e10cSrcweir ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/; 1464*cdf0e10cSrcweir my $infoline = "NSIS replacement in $nshfilename ($onelanguage): $oldstring \-\> $newstring\n"; 1465*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir } 1468*cdf0e10cSrcweir} 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir################################################################## 1471*cdf0e10cSrcweir# Windows: Replacing strings in NSIS nlf file 1472*cdf0e10cSrcweir# nlf file syntax (2 lines): 1473*cdf0e10cSrcweir# # ^DirSubText 1474*cdf0e10cSrcweir# Zielverzeichnis 1475*cdf0e10cSrcweir################################################################## 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweirsub replace_identifier_in_nlffile 1478*cdf0e10cSrcweir{ 1479*cdf0e10cSrcweir my ( $nlffile, $identifier, $newstring, $nlffilename, $onelanguage ) = @_; 1480*cdf0e10cSrcweir 1481*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$nlffile}; $i++ ) 1482*cdf0e10cSrcweir { 1483*cdf0e10cSrcweir if ( ${$nlffile}[$i] =~ /^\s*\#\s+\^\s*\Q$identifier\E\s*$/ ) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir my $next = $i+1; 1486*cdf0e10cSrcweir my $oldstring = ${$nlffile}[$next]; 1487*cdf0e10cSrcweir ${$nlffile}[$next] = $newstring . "\n"; 1488*cdf0e10cSrcweir $oldstring =~ s/\s*$//; 1489*cdf0e10cSrcweir my $infoline = "NSIS replacement in $nlffilename ($onelanguage): $oldstring \-\> $newstring\n"; 1490*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir } 1493*cdf0e10cSrcweir} 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir################################################################## 1496*cdf0e10cSrcweir# Windows: Translating the NSIS nsh and nlf file 1497*cdf0e10cSrcweir################################################################## 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweirsub translate_nsh_nlf_file 1500*cdf0e10cSrcweir{ 1501*cdf0e10cSrcweir my ($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage) = @_; 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir # Analyzing the mlf file, collecting all Identifier 1504*cdf0e10cSrcweir my $allidentifier = get_identifier($mlffile); 1505*cdf0e10cSrcweir 1506*cdf0e10cSrcweir $onelanguage = "en-US" if ( $nsislanguage eq "English" && $onelanguage ne "en-US"); 1507*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allidentifier}; $i++ ) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir my $identifier = ${$allidentifier}[$i]; 1510*cdf0e10cSrcweir my $language_block = get_language_block_from_language_file($identifier, $mlffile); 1511*cdf0e10cSrcweir my $newstring = get_language_string_from_language_block($language_block, $onelanguage); 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir # removing mask 1514*cdf0e10cSrcweir $newstring =~ s/\\\'/\'/g; 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir replace_identifier_in_nshfile($nshfile, $identifier, $newstring, $nshfilename, $onelanguage); 1517*cdf0e10cSrcweir replace_identifier_in_nlffile($nlffile, $identifier, $newstring, $nlffilename, $onelanguage); 1518*cdf0e10cSrcweir } 1519*cdf0e10cSrcweir} 1520*cdf0e10cSrcweir 1521*cdf0e10cSrcweir################################################################## 1522*cdf0e10cSrcweir# Converting utf 16 file to utf 8 1523*cdf0e10cSrcweir################################################################## 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweirsub convert_utf16_to_utf8 1526*cdf0e10cSrcweir{ 1527*cdf0e10cSrcweir my ( $filename ) = @_; 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir my @localfile = (); 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir my $savfilename = $filename . "_before.utf16"; 1532*cdf0e10cSrcweir installer::systemactions::copy_one_file($filename, $savfilename); 1533*cdf0e10cSrcweir 1534*cdf0e10cSrcweir# open( IN, "<:utf16", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1535*cdf0e10cSrcweir# open( IN, "<:para:crlf:uni", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1536*cdf0e10cSrcweir open( IN, "<:encoding(UTF16-LE)", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf16_to_utf8"); 1537*cdf0e10cSrcweir while ( $line = <IN> ) { 1538*cdf0e10cSrcweir push @localfile, $line; 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir close( IN ); 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir if ( open( OUT, ">:utf8", $filename ) ) 1543*cdf0e10cSrcweir { 1544*cdf0e10cSrcweir print OUT @localfile; 1545*cdf0e10cSrcweir close(OUT); 1546*cdf0e10cSrcweir } 1547*cdf0e10cSrcweir 1548*cdf0e10cSrcweir $savfilename = $filename . "_before.utf8"; 1549*cdf0e10cSrcweir installer::systemactions::copy_one_file($filename, $savfilename); 1550*cdf0e10cSrcweir} 1551*cdf0e10cSrcweir 1552*cdf0e10cSrcweir################################################################## 1553*cdf0e10cSrcweir# Converting utf 8 file to utf 16 1554*cdf0e10cSrcweir################################################################## 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweirsub convert_utf8_to_utf16 1557*cdf0e10cSrcweir{ 1558*cdf0e10cSrcweir my ( $filename ) = @_; 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir my @localfile = (); 1561*cdf0e10cSrcweir 1562*cdf0e10cSrcweir my $savfilename = $filename . "_after.utf8"; 1563*cdf0e10cSrcweir installer::systemactions::copy_one_file($filename, $savfilename); 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir open( IN, "<:utf8", $filename ) || installer::exiter::exit_program("ERROR: Cannot open file $filename for reading", "convert_utf8_to_utf16"); 1566*cdf0e10cSrcweir while ( $line = <IN> ) { 1567*cdf0e10cSrcweir push @localfile, $line; 1568*cdf0e10cSrcweir } 1569*cdf0e10cSrcweir close( IN ); 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir if ( open( OUT, ">:raw:encoding(UTF16-LE):crlf:utf8", $filename ) ) 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir print OUT @localfile; 1574*cdf0e10cSrcweir close(OUT); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir $savfilename = $filename . "_after.utf16"; 1578*cdf0e10cSrcweir installer::systemactions::copy_one_file($filename, $savfilename); 1579*cdf0e10cSrcweir} 1580*cdf0e10cSrcweir 1581*cdf0e10cSrcweir################################################################## 1582*cdf0e10cSrcweir# Converting text string to utf 16 1583*cdf0e10cSrcweir################################################################## 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweirsub convert_textstring_to_utf16 1586*cdf0e10cSrcweir{ 1587*cdf0e10cSrcweir my ( $textstring, $localnsisdir, $shortfilename ) = @_; 1588*cdf0e10cSrcweir 1589*cdf0e10cSrcweir my $filename = $localnsisdir . $installer::globals::separator . $shortfilename; 1590*cdf0e10cSrcweir my @filecontent = (); 1591*cdf0e10cSrcweir push(@filecontent, $textstring); 1592*cdf0e10cSrcweir installer::files::save_file($filename, \@filecontent); 1593*cdf0e10cSrcweir convert_utf8_to_utf16($filename); 1594*cdf0e10cSrcweir my $newfile = installer::files::read_file($filename); 1595*cdf0e10cSrcweir my $utf16string = ""; 1596*cdf0e10cSrcweir if ( ${$newfile}[0] ne "" ) { $utf16string = ${$newfile}[0]; } 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir return $utf16string; 1599*cdf0e10cSrcweir} 1600*cdf0e10cSrcweir 1601*cdf0e10cSrcweir################################################################## 1602*cdf0e10cSrcweir# Windows: Copying NSIS language files to local nsis directory 1603*cdf0e10cSrcweir################################################################## 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweirsub copy_and_translate_nsis_language_files 1606*cdf0e10cSrcweir{ 1607*cdf0e10cSrcweir my ($nsispath, $localnsisdir, $languagesarrayref, $allvariables) = @_; 1608*cdf0e10cSrcweir 1609*cdf0e10cSrcweir my $nlffilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Language\ files" . $installer::globals::separator; 1610*cdf0e10cSrcweir my $nshfilepath = $nsispath . $installer::globals::separator . "Contrib" . $installer::globals::separator . "Modern\ UI" . $installer::globals::separator . "Language files" . $installer::globals::separator; 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir my $infoline = ""; 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ ) 1615*cdf0e10cSrcweir { 1616*cdf0e10cSrcweir my $onelanguage = ${$languagesarrayref}[$i]; 1617*cdf0e10cSrcweir my $nsislanguage = nsis_language_converter($onelanguage); 1618*cdf0e10cSrcweir 1619*cdf0e10cSrcweir # Copying the nlf file 1620*cdf0e10cSrcweir my $sourcepath = $nlffilepath . $nsislanguage . "\.nlf"; 1621*cdf0e10cSrcweir if ( ! -f $sourcepath ) { installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); } 1622*cdf0e10cSrcweir my $nlffilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nlf"; 1623*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $nlffilename =~ s/\//\\/g; } 1624*cdf0e10cSrcweir installer::systemactions::copy_one_file($sourcepath, $nlffilename); 1625*cdf0e10cSrcweir 1626*cdf0e10cSrcweir # Copying the nsh file 1627*cdf0e10cSrcweir # In newer nsis versions, the nsh file is located next to the nlf file 1628*cdf0e10cSrcweir $sourcepath = $nshfilepath . $nsislanguage . "\.nsh"; 1629*cdf0e10cSrcweir if ( ! -f $sourcepath ) 1630*cdf0e10cSrcweir { 1631*cdf0e10cSrcweir # trying to find the nsh file next to the nlf file 1632*cdf0e10cSrcweir $sourcepath = $nlffilepath . $nsislanguage . "\.nsh"; 1633*cdf0e10cSrcweir if ( ! -f $sourcepath ) 1634*cdf0e10cSrcweir { 1635*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files"); 1636*cdf0e10cSrcweir } 1637*cdf0e10cSrcweir } 1638*cdf0e10cSrcweir my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh"; 1639*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; } 1640*cdf0e10cSrcweir installer::systemactions::copy_one_file($sourcepath, $nshfilename); 1641*cdf0e10cSrcweir 1642*cdf0e10cSrcweir # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN 1643*cdf0e10cSrcweir my $nshfile = installer::files::read_file($nshfilename); 1644*cdf0e10cSrcweir set_nsis_version($nshfile); 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir if ( $installer::globals::unicodensis ) 1647*cdf0e10cSrcweir { 1648*cdf0e10cSrcweir $infoline = "This is Unicode NSIS!\n"; 1649*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1650*cdf0e10cSrcweir convert_utf16_to_utf8($nshfilename); 1651*cdf0e10cSrcweir convert_utf16_to_utf8($nlffilename); 1652*cdf0e10cSrcweir $nshfile = installer::files::read_file($nshfilename); # read nsh file again 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir 1655*cdf0e10cSrcweir replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN"); 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir # find the ulf file for translation 1658*cdf0e10cSrcweir my $mlffile = get_translation_file($allvariables); 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir # Translate the files 1661*cdf0e10cSrcweir my $nlffile = installer::files::read_file($nlffilename); 1662*cdf0e10cSrcweir translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage); 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir installer::files::save_file($nshfilename, $nshfile); 1665*cdf0e10cSrcweir installer::files::save_file($nlffilename, $nlffile); 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir if ( $installer::globals::unicodensis ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir convert_utf8_to_utf16($nshfilename); 1670*cdf0e10cSrcweir convert_utf8_to_utf16($nlffilename); 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir} 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir################################################################## 1677*cdf0e10cSrcweir# Windows: Including the nsis path into the nsi template 1678*cdf0e10cSrcweir################################################################## 1679*cdf0e10cSrcweir 1680*cdf0e10cSrcweirsub put_nsis_path_into_template 1681*cdf0e10cSrcweir{ 1682*cdf0e10cSrcweir my ($templatefile, $nsisdir) = @_; 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir replace_one_variable($templatefile, "NSISPATHPLACEHOLDER", $nsisdir); 1685*cdf0e10cSrcweir} 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir################################################################## 1688*cdf0e10cSrcweir# Windows: Including the output path into the nsi template 1689*cdf0e10cSrcweir################################################################## 1690*cdf0e10cSrcweir 1691*cdf0e10cSrcweirsub put_output_path_into_template 1692*cdf0e10cSrcweir{ 1693*cdf0e10cSrcweir my ($templatefile, $downloaddir) = @_; 1694*cdf0e10cSrcweir 1695*cdf0e10cSrcweir if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; } 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir); 1698*cdf0e10cSrcweir} 1699*cdf0e10cSrcweir 1700*cdf0e10cSrcweir################################################################## 1701*cdf0e10cSrcweir# Windows: Only allow specific code for nsis 2.0.4 or nsis 2.3.1 1702*cdf0e10cSrcweir################################################################## 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweirsub put_version_specific_code_into_template 1705*cdf0e10cSrcweir{ 1706*cdf0e10cSrcweir my ($templatefile) = @_; 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir my $subst204 = ""; 1709*cdf0e10cSrcweir my $subst231 = ""; 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir if ( $installer::globals::nsis204 ) 1712*cdf0e10cSrcweir { 1713*cdf0e10cSrcweir $subst231 = ";"; 1714*cdf0e10cSrcweir } 1715*cdf0e10cSrcweir else 1716*cdf0e10cSrcweir { 1717*cdf0e10cSrcweir $subst204 = ";"; 1718*cdf0e10cSrcweir } 1719*cdf0e10cSrcweir 1720*cdf0e10cSrcweir replace_one_variable($templatefile, "\#204\#", $subst204); 1721*cdf0e10cSrcweir replace_one_variable($templatefile, "\#231\#", $subst231); 1722*cdf0e10cSrcweir} 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir################################################################## 1725*cdf0e10cSrcweir# Windows: Finding the path to the nsis SDK 1726*cdf0e10cSrcweir################################################################## 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweirsub get_path_to_nsis_sdk 1729*cdf0e10cSrcweir{ 1730*cdf0e10cSrcweir my $vol; 1731*cdf0e10cSrcweir my $dir; 1732*cdf0e10cSrcweir my $file; 1733*cdf0e10cSrcweir my $nsispath = ""; 1734*cdf0e10cSrcweir 1735*cdf0e10cSrcweir if ( $ENV{'NSIS_PATH'} ) { 1736*cdf0e10cSrcweir $nsispath = $ENV{'NSIS_PATH'}; 1737*cdf0e10cSrcweir } elsif ( $ENV{'SOLARROOT'} ) { 1738*cdf0e10cSrcweir $nsispath = $ENV{'SOLARROOT'} . $installer::globals::separator . "NSIS"; 1739*cdf0e10cSrcweir } else { 1740*cdf0e10cSrcweir # do we have nsis already in path ? 1741*cdf0e10cSrcweir @paths = split(/:/, $ENV{'PATH'}); 1742*cdf0e10cSrcweir foreach $paths (@paths) { 1743*cdf0e10cSrcweir $paths =~ s/[\/\\]+$//; # remove trailing slashes; 1744*cdf0e10cSrcweir $nsispath = $paths . "/nsis"; 1745*cdf0e10cSrcweir 1746*cdf0e10cSrcweir if ( -x $nsispath ) { 1747*cdf0e10cSrcweir $nsispath = $paths; 1748*cdf0e10cSrcweir last; 1749*cdf0e10cSrcweir } 1750*cdf0e10cSrcweir else { 1751*cdf0e10cSrcweir $nsispath = ""; 1752*cdf0e10cSrcweir } 1753*cdf0e10cSrcweir } 1754*cdf0e10cSrcweir } 1755*cdf0e10cSrcweir if ( $ENV{'NSISSDK_SOURCE'} ) { 1756*cdf0e10cSrcweir installer::logger::print_warning( "NSISSDK_SOURCE is deprecated. use NSIS_PATH instead.\n" ); 1757*cdf0e10cSrcweir $nsispath = $ENV{'NSISSDK_SOURCE'}; # overriding the NSIS SDK with NSISSDK_SOURCE 1758*cdf0e10cSrcweir } 1759*cdf0e10cSrcweir 1760*cdf0e10cSrcweir# if( ($^O =~ /cygwin/i) and $nsispath =~ /\\/ ) { 1761*cdf0e10cSrcweir# # We need a POSIX path for W32-4nt-cygwin-perl 1762*cdf0e10cSrcweir# $nsispath =~ s/\\/\\\\/g; 1763*cdf0e10cSrcweir# chomp( $nsispath = qx{cygpath -u "$nsispath"} ); 1764*cdf0e10cSrcweir# } 1765*cdf0e10cSrcweir 1766*cdf0e10cSrcweir if ( $nsispath eq "" ) 1767*cdf0e10cSrcweir { 1768*cdf0e10cSrcweir installer::logger::print_message( "... no Environment variable \"SOLARROOT\", \"NSIS_PATH\" or \"NSISSDK_SOURCE\" found and NSIS not found in path!", "get_path_to_nsis_sdk"); 1769*cdf0e10cSrcweir } elsif ( ! -d $nsispath ) 1770*cdf0e10cSrcweir { 1771*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk"); 1772*cdf0e10cSrcweir } 1773*cdf0e10cSrcweir 1774*cdf0e10cSrcweir return $nsispath; 1775*cdf0e10cSrcweir} 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir################################################################## 1778*cdf0e10cSrcweir# Windows: Executing NSIS to create the installation set 1779*cdf0e10cSrcweir################################################################## 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweirsub call_nsis 1782*cdf0e10cSrcweir{ 1783*cdf0e10cSrcweir my ( $nsispath, $nsifile ) = @_; 1784*cdf0e10cSrcweir 1785*cdf0e10cSrcweir my $makensisexe = $nsispath . $installer::globals::separator . "makensis.exe"; 1786*cdf0e10cSrcweir 1787*cdf0e10cSrcweir installer::logger::print_message( "... starting $makensisexe ... \n" ); 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $nsifile =~ s/\\/\//g; } 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir my $systemcall = "$makensisexe $nsifile |"; 1792*cdf0e10cSrcweir 1793*cdf0e10cSrcweir my $infoline = "Systemcall: $systemcall\n"; 1794*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1795*cdf0e10cSrcweir 1796*cdf0e10cSrcweir my @nsisoutput = (); 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir open (NSI, "$systemcall"); 1799*cdf0e10cSrcweir while (<NSI>) {push(@nsisoutput, $_); } 1800*cdf0e10cSrcweir close (NSI); 1801*cdf0e10cSrcweir 1802*cdf0e10cSrcweir my $returnvalue = $?; # $? contains the return value of the systemcall 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir if ($returnvalue) 1805*cdf0e10cSrcweir { 1806*cdf0e10cSrcweir $infoline = "ERROR: $systemcall !\n"; 1807*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1808*cdf0e10cSrcweir } 1809*cdf0e10cSrcweir else 1810*cdf0e10cSrcweir { 1811*cdf0e10cSrcweir $infoline = "Success: $systemcall\n"; 1812*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1813*cdf0e10cSrcweir } 1814*cdf0e10cSrcweir 1815*cdf0e10cSrcweir for ( my $i = 0; $i <= $#nsisoutput; $i++ ) { push( @installer::globals::logfileinfo, "$nsisoutput[$i]"); } 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir} 1818*cdf0e10cSrcweir 1819*cdf0e10cSrcweir################################################################################# 1820*cdf0e10cSrcweir# Replacing one variable in one files 1821*cdf0e10cSrcweir################################################################################# 1822*cdf0e10cSrcweir 1823*cdf0e10cSrcweirsub replace_one_variable_in_translationfile 1824*cdf0e10cSrcweir{ 1825*cdf0e10cSrcweir my ($translationfile, $variable, $searchstring) = @_; 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$translationfile}; $i++ ) 1828*cdf0e10cSrcweir { 1829*cdf0e10cSrcweir ${$translationfile}[$i] =~ s/\%$searchstring/$variable/g; 1830*cdf0e10cSrcweir } 1831*cdf0e10cSrcweir} 1832*cdf0e10cSrcweir 1833*cdf0e10cSrcweir################################################################################# 1834*cdf0e10cSrcweir# Replacing the variables in the translation file 1835*cdf0e10cSrcweir################################################################################# 1836*cdf0e10cSrcweir 1837*cdf0e10cSrcweirsub replace_variables 1838*cdf0e10cSrcweir{ 1839*cdf0e10cSrcweir my ($translationfile, $variableshashref) = @_; 1840*cdf0e10cSrcweir 1841*cdf0e10cSrcweir foreach $key (keys %{$variableshashref}) 1842*cdf0e10cSrcweir { 1843*cdf0e10cSrcweir my $value = $variableshashref->{$key}; 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir # special handling for PRODUCTVERSION, if $allvariables->{'POSTVERSIONEXTENSION'} 1846*cdf0e10cSrcweir if (( $key eq "PRODUCTVERSION" ) && ( $variableshashref->{'POSTVERSIONEXTENSION'} )) { $value = $value . " " . $variableshashref->{'POSTVERSIONEXTENSION'}; } 1847*cdf0e10cSrcweir 1848*cdf0e10cSrcweir replace_one_variable_in_translationfile($translationfile, $value, $key); 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir} 1851*cdf0e10cSrcweir 1852*cdf0e10cSrcweir######################################################### 1853*cdf0e10cSrcweir# Getting the translation file for the nsis installer 1854*cdf0e10cSrcweir######################################################### 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweirsub get_translation_file 1857*cdf0e10cSrcweir{ 1858*cdf0e10cSrcweir my ($allvariableshashref) = @_; 1859*cdf0e10cSrcweir my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename; 1860*cdf0e10cSrcweir if ( $installer::globals::unicodensis ) { $translationfilename = $translationfilename . ".uulf"; } 1861*cdf0e10cSrcweir else { $translationfilename = $translationfilename . ".mlf"; } 1862*cdf0e10cSrcweir if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); } 1863*cdf0e10cSrcweir my $translationfile = installer::files::read_file($translationfilename); 1864*cdf0e10cSrcweir replace_variables($translationfile, $allvariableshashref); 1865*cdf0e10cSrcweir 1866*cdf0e10cSrcweir my $infoline = "Reading translation file: $translationfilename\n"; 1867*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 1868*cdf0e10cSrcweir 1869*cdf0e10cSrcweir return $translationfile; 1870*cdf0e10cSrcweir} 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir#################################################### 1873*cdf0e10cSrcweir# Removing english, if it was added before 1874*cdf0e10cSrcweir#################################################### 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweirsub remove_english_for_nsis_installer 1877*cdf0e10cSrcweir{ 1878*cdf0e10cSrcweir my ($languagestringref, $languagesarrayref) = @_; 1879*cdf0e10cSrcweir 1880*cdf0e10cSrcweir # $$languagestringref =~ s/en-US_//; 1881*cdf0e10cSrcweir # shift(@{$languagesarrayref}); 1882*cdf0e10cSrcweir 1883*cdf0e10cSrcweir @{$languagesarrayref} = ("en-US"); # only english for NSIS installer! 1884*cdf0e10cSrcweir} 1885*cdf0e10cSrcweir 1886*cdf0e10cSrcweir#################################################### 1887*cdf0e10cSrcweir# Creating link tree for upload 1888*cdf0e10cSrcweir#################################################### 1889*cdf0e10cSrcweir 1890*cdf0e10cSrcweirsub create_link_tree 1891*cdf0e10cSrcweir{ 1892*cdf0e10cSrcweir my ($sourcedownloadfile, $destfilename, $versionstring) = @_; 1893*cdf0e10cSrcweir 1894*cdf0e10cSrcweir if ( ! $installer::globals::ooouploaddir ) { installer::exiter::exit_program("ERROR: Directory for OOo upload not defined!", "create_link_tree"); } 1895*cdf0e10cSrcweir my $versiondir = $installer::globals::ooouploaddir . $installer::globals::separator . $versionstring; 1896*cdf0e10cSrcweir my $infoline = "Directory for the link: $versiondir\n"; 1897*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 1898*cdf0e10cSrcweir 1899*cdf0e10cSrcweir if ( ! -d $versiondir ) { installer::systemactions::create_directory_structure($versiondir); } 1900*cdf0e10cSrcweir 1901*cdf0e10cSrcweir # inside directory $versiondir all links have to be created 1902*cdf0e10cSrcweir my $linkdestination = $versiondir . $installer::globals::separator . $destfilename; 1903*cdf0e10cSrcweir 1904*cdf0e10cSrcweir # If there is an older version of this file (link), it has to be removed 1905*cdf0e10cSrcweir if ( -f $linkdestination ) { unlink($linkdestination); } 1906*cdf0e10cSrcweir 1907*cdf0e10cSrcweir $infoline = "Creating hard link from $sourcedownloadfile to $linkdestination\n"; 1908*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 1909*cdf0e10cSrcweir installer::systemactions::hardlink_one_file($sourcedownloadfile, $linkdestination); 1910*cdf0e10cSrcweir} 1911*cdf0e10cSrcweir 1912*cdf0e10cSrcweir####################################################### 1913*cdf0e10cSrcweir# Setting supported platform for Sun OpenOffice.org 1914*cdf0e10cSrcweir# builds 1915*cdf0e10cSrcweir####################################################### 1916*cdf0e10cSrcweir 1917*cdf0e10cSrcweirsub is_supported_platform 1918*cdf0e10cSrcweir{ 1919*cdf0e10cSrcweir my $is_supported = 0; 1920*cdf0e10cSrcweir 1921*cdf0e10cSrcweir if (( $installer::globals::islinuxrpmbuild ) || 1922*cdf0e10cSrcweir ( $installer::globals::issolarissparcbuild ) || 1923*cdf0e10cSrcweir ( $installer::globals::issolarisx86build ) || 1924*cdf0e10cSrcweir ( $installer::globals::iswindowsbuild )) 1925*cdf0e10cSrcweir { 1926*cdf0e10cSrcweir $is_supported = 1; 1927*cdf0e10cSrcweir } 1928*cdf0e10cSrcweir 1929*cdf0e10cSrcweir return $is_supported; 1930*cdf0e10cSrcweir} 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir#################################################### 1933*cdf0e10cSrcweir# Creating download installation sets 1934*cdf0e10cSrcweir#################################################### 1935*cdf0e10cSrcweir 1936*cdf0e10cSrcweirsub create_download_sets 1937*cdf0e10cSrcweir{ 1938*cdf0e10cSrcweir my ($installationdir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref) = @_; 1939*cdf0e10cSrcweir 1940*cdf0e10cSrcweir my $infoline = ""; 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir my $force = 1; # print this message even in 'quiet' mode 1943*cdf0e10cSrcweir installer::logger::print_message( "\n******************************************\n" ); 1944*cdf0e10cSrcweir installer::logger::print_message( "... creating download installation set ...\n", $force ); 1945*cdf0e10cSrcweir installer::logger::print_message( "******************************************\n" ); 1946*cdf0e10cSrcweir 1947*cdf0e10cSrcweir installer::logger::include_header_into_logfile("Creating download installation sets:"); 1948*cdf0e10cSrcweir 1949*cdf0e10cSrcweir # special handling for installation sets, to which english was added automatically 1950*cdf0e10cSrcweir if ( $installer::globals::added_english ) { remove_english_for_nsis_installer($languagestringref, $languagesarrayref); } 1951*cdf0e10cSrcweir 1952*cdf0e10cSrcweir my $firstdir = $installationdir; 1953*cdf0e10cSrcweir installer::pathanalyzer::get_path_from_fullqualifiedname(\$firstdir); 1954*cdf0e10cSrcweir 1955*cdf0e10cSrcweir my $lastdir = $installationdir; 1956*cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$lastdir); 1957*cdf0e10cSrcweir 1958*cdf0e10cSrcweir if ( $lastdir =~ /\./ ) { $lastdir =~ s/\./_download_inprogress\./ } 1959*cdf0e10cSrcweir else { $lastdir = $lastdir . "_download_inprogress"; } 1960*cdf0e10cSrcweir 1961*cdf0e10cSrcweir # removing existing directory "_native_packed_inprogress" and "_native_packed_witherror" and "_native_packed" 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir my $downloaddir = $firstdir . $lastdir; 1964*cdf0e10cSrcweir 1965*cdf0e10cSrcweir if ( -d $downloaddir ) { installer::systemactions::remove_complete_directory($downloaddir); } 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir my $olddir = $downloaddir; 1968*cdf0e10cSrcweir $olddir =~ s/_inprogress/_witherror/; 1969*cdf0e10cSrcweir if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); } 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir $olddir = $downloaddir; 1972*cdf0e10cSrcweir $olddir =~ s/_inprogress//; 1973*cdf0e10cSrcweir if ( -d $olddir ) { installer::systemactions::remove_complete_directory($olddir); } 1974*cdf0e10cSrcweir 1975*cdf0e10cSrcweir # creating the new directory 1976*cdf0e10cSrcweir 1977*cdf0e10cSrcweir installer::systemactions::create_directory($downloaddir); 1978*cdf0e10cSrcweir 1979*cdf0e10cSrcweir $installer::globals::saveinstalldir = $downloaddir; 1980*cdf0e10cSrcweir 1981*cdf0e10cSrcweir # evaluating the name of the download file 1982*cdf0e10cSrcweir 1983*cdf0e10cSrcweir if ( $allvariableshashref->{'OOODOWNLOADNAME'} ) { $downloadname = set_download_filename($languagestringref, $allvariableshashref); } 1984*cdf0e10cSrcweir else { $downloadname = resolve_variables_in_downloadname($allvariableshashref, $downloadname, $languagestringref); } 1985*cdf0e10cSrcweir 1986*cdf0e10cSrcweir if ( ! $installer::globals::iswindowsbuild ) # Unix specific part 1987*cdf0e10cSrcweir { 1988*cdf0e10cSrcweir 1989*cdf0e10cSrcweir # getting the path of the getuid.so (only required for Solaris and Linux) 1990*cdf0e10cSrcweir my $getuidlibrary = ""; 1991*cdf0e10cSrcweir if (( $installer::globals::issolarisbuild ) || ( $installer::globals::islinuxbuild )) { $getuidlibrary = get_path_for_library($includepatharrayref); } 1992*cdf0e10cSrcweir 1993*cdf0e10cSrcweir if ( $allvariableshashref->{'OOODOWNLOADNAME'} ) 1994*cdf0e10cSrcweir { 1995*cdf0e10cSrcweir my $downloadfile = create_tar_gz_file_from_directory($installationdir, $getuidlibrary, $downloaddir, $downloadname); 1996*cdf0e10cSrcweir } 1997*cdf0e10cSrcweir else 1998*cdf0e10cSrcweir { 1999*cdf0e10cSrcweir # find and read setup script template 2000*cdf0e10cSrcweir my $scriptfilename = "downloadscript.sh"; 2001*cdf0e10cSrcweir 2002*cdf0e10cSrcweir my $scriptref = ""; 2003*cdf0e10cSrcweir 2004*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 2005*cdf0e10cSrcweir { 2006*cdf0e10cSrcweir $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); 2007*cdf0e10cSrcweir } 2008*cdf0e10cSrcweir else 2009*cdf0e10cSrcweir { 2010*cdf0e10cSrcweir $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$scriptfilename, $includepatharrayref, 0); 2011*cdf0e10cSrcweir } 2012*cdf0e10cSrcweir 2013*cdf0e10cSrcweir if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find script file $scriptfilename!", "create_download_sets"); } 2014*cdf0e10cSrcweir my $scriptfile = installer::files::read_file($$scriptref); 2015*cdf0e10cSrcweir 2016*cdf0e10cSrcweir $infoline = "Found script file $scriptfilename: $$scriptref \n"; 2017*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2018*cdf0e10cSrcweir 2019*cdf0e10cSrcweir # add product name into script template 2020*cdf0e10cSrcweir put_productname_into_script($scriptfile, $allvariableshashref); 2021*cdf0e10cSrcweir 2022*cdf0e10cSrcweir # replace linenumber in script template 2023*cdf0e10cSrcweir put_linenumber_into_script($scriptfile); 2024*cdf0e10cSrcweir 2025*cdf0e10cSrcweir # create tar file 2026*cdf0e10cSrcweir my $temporary_tarfile_name = $downloaddir . $installer::globals::separator . 'installset.tar'; 2027*cdf0e10cSrcweir my $size = tar_package($installationdir, $temporary_tarfile_name, $getuidlibrary); 2028*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Could not create tar file $temporary_tarfile_name!", "create_download_sets") unless $size; 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir # calling sum to determine checksum and size of the tar file 2031*cdf0e10cSrcweir my $sumout = call_sum($temporary_tarfile_name); 2032*cdf0e10cSrcweir 2033*cdf0e10cSrcweir # writing checksum and size into scriptfile 2034*cdf0e10cSrcweir put_checksum_and_size_into_script($scriptfile, $sumout); 2035*cdf0e10cSrcweir 2036*cdf0e10cSrcweir # saving the script file 2037*cdf0e10cSrcweir my $newscriptfilename = determine_scriptfile_name($downloadname); 2038*cdf0e10cSrcweir $newscriptfilename = save_script_file($downloaddir, $newscriptfilename, $scriptfile); 2039*cdf0e10cSrcweir 2040*cdf0e10cSrcweir installer::logger::print_message( "... including installation set into $newscriptfilename ... \n" ); 2041*cdf0e10cSrcweir # Append tar file to script 2042*cdf0e10cSrcweir include_tar_into_script($newscriptfilename, $temporary_tarfile_name); 2043*cdf0e10cSrcweir } 2044*cdf0e10cSrcweir } 2045*cdf0e10cSrcweir else # Windows specific part 2046*cdf0e10cSrcweir { 2047*cdf0e10cSrcweir my $localnsisdir = installer::systemactions::create_directories("nsis", $languagestringref); 2048*cdf0e10cSrcweir # push(@installer::globals::removedirs, $localnsisdir); 2049*cdf0e10cSrcweir 2050*cdf0e10cSrcweir # find nsis in the system 2051*cdf0e10cSrcweir my $nsispath = get_path_to_nsis_sdk(); 2052*cdf0e10cSrcweir 2053*cdf0e10cSrcweir if ( $nsispath eq "" ) { 2054*cdf0e10cSrcweir # If nsis is not found just skip the rest of this function 2055*cdf0e10cSrcweir # and do not create the NSIS file. 2056*cdf0e10cSrcweir $infoline = "\nNo NSIS SDK found. Skipping the generation of NSIS file.\n"; 2057*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 2058*cdf0e10cSrcweir installer::logger::print_message( "... no NSIS SDK found. Skipping the generation of NSIS file ... \n" ); 2059*cdf0e10cSrcweir return $downloaddir; 2060*cdf0e10cSrcweir } 2061*cdf0e10cSrcweir 2062*cdf0e10cSrcweir # copy language files into nsis directory and translate them 2063*cdf0e10cSrcweir copy_and_translate_nsis_language_files($nsispath, $localnsisdir, $languagesarrayref, $allvariableshashref); 2064*cdf0e10cSrcweir 2065*cdf0e10cSrcweir # find and read the nsi file template 2066*cdf0e10cSrcweir my $templatefilename = "downloadtemplate.nsi"; 2067*cdf0e10cSrcweir 2068*cdf0e10cSrcweir my $templateref = ""; 2069*cdf0e10cSrcweir 2070*cdf0e10cSrcweir if ( $installer::globals::include_pathes_read ) 2071*cdf0e10cSrcweir { 2072*cdf0e10cSrcweir $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$templatefilename, $includepatharrayref, 0); 2073*cdf0e10cSrcweir } 2074*cdf0e10cSrcweir else 2075*cdf0e10cSrcweir { 2076*cdf0e10cSrcweir $templateref = installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic(\$templatefilename, $includepatharrayref, 0); 2077*cdf0e10cSrcweir } 2078*cdf0e10cSrcweir 2079*cdf0e10cSrcweir if ($$templateref eq "") { installer::exiter::exit_program("ERROR: Could not find nsi template file $templatefilename!", "create_download_sets"); } 2080*cdf0e10cSrcweir my $templatefile = installer::files::read_file($$templateref); 2081*cdf0e10cSrcweir 2082*cdf0e10cSrcweir # add product name into script template 2083*cdf0e10cSrcweir put_windows_productname_into_template($templatefile, $allvariableshashref); 2084*cdf0e10cSrcweir put_banner_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref); 2085*cdf0e10cSrcweir put_welcome_bmp_into_template($templatefile, $includepatharrayref, $allvariableshashref); 2086*cdf0e10cSrcweir put_setup_ico_into_template($templatefile, $includepatharrayref, $allvariableshashref); 2087*cdf0e10cSrcweir put_publisher_into_template($templatefile); 2088*cdf0e10cSrcweir put_website_into_template($templatefile); 2089*cdf0e10cSrcweir put_javafilename_into_template($templatefile, $allvariableshashref); 2090*cdf0e10cSrcweir put_windows_productversion_into_template($templatefile, $allvariableshashref); 2091*cdf0e10cSrcweir put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir); 2092*cdf0e10cSrcweir put_outputfilename_into_template($templatefile, $downloadname); 2093*cdf0e10cSrcweir put_filelist_into_template($templatefile, $installationdir); 2094*cdf0e10cSrcweir put_language_list_into_template($templatefile, $languagesarrayref); 2095*cdf0e10cSrcweir put_nsis_path_into_template($templatefile, $localnsisdir); 2096*cdf0e10cSrcweir put_output_path_into_template($templatefile, $downloaddir); 2097*cdf0e10cSrcweir put_version_specific_code_into_template($templatefile); 2098*cdf0e10cSrcweir 2099*cdf0e10cSrcweir my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile); 2100*cdf0e10cSrcweir 2101*cdf0e10cSrcweir installer::logger::print_message( "... created NSIS file $nsifilename ... \n" ); 2102*cdf0e10cSrcweir 2103*cdf0e10cSrcweir # starting the NSIS SDK to create the download file 2104*cdf0e10cSrcweir call_nsis($nsispath, $nsifilename); 2105*cdf0e10cSrcweir } 2106*cdf0e10cSrcweir 2107*cdf0e10cSrcweir return $downloaddir; 2108*cdf0e10cSrcweir} 2109*cdf0e10cSrcweir 2110*cdf0e10cSrcweir#################################################### 2111*cdf0e10cSrcweir# Creating OOo upload tree 2112*cdf0e10cSrcweir#################################################### 2113*cdf0e10cSrcweir 2114*cdf0e10cSrcweirsub create_download_link_tree 2115*cdf0e10cSrcweir{ 2116*cdf0e10cSrcweir my ($downloaddir, $languagestringref, $allvariableshashref) = @_; 2117*cdf0e10cSrcweir 2118*cdf0e10cSrcweir my $infoline; 2119*cdf0e10cSrcweir 2120*cdf0e10cSrcweir installer::logger::print_message( "\n******************************************\n" ); 2121*cdf0e10cSrcweir installer::logger::print_message( "... creating download hard link ...\n" ); 2122*cdf0e10cSrcweir installer::logger::print_message( "******************************************\n" ); 2123*cdf0e10cSrcweir 2124*cdf0e10cSrcweir installer::logger::include_header_into_logfile("Creating download hard link:"); 2125*cdf0e10cSrcweir installer::logger::include_timestamp_into_logfile("\nPerformance Info: Creating hard link, start"); 2126*cdf0e10cSrcweir 2127*cdf0e10cSrcweir if ( is_supported_platform() ) 2128*cdf0e10cSrcweir { 2129*cdf0e10cSrcweir my $versionstring = ""; 2130*cdf0e10cSrcweir # Already defined $installer::globals::oooversionstring and $installer::globals::ooodownloadfilename ? 2131*cdf0e10cSrcweir 2132*cdf0e10cSrcweir if ( ! $installer::globals::oooversionstring ) { $versionstring = get_current_version(); } 2133*cdf0e10cSrcweir else { $versionstring = $installer::globals::oooversionstring; } 2134*cdf0e10cSrcweir 2135*cdf0e10cSrcweir # Is $versionstring empty? If yes, there is nothing to do now. 2136*cdf0e10cSrcweir 2137*cdf0e10cSrcweir $infoline = "Version string is set to: $versionstring\n"; 2138*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2139*cdf0e10cSrcweir 2140*cdf0e10cSrcweir if ( $versionstring ) 2141*cdf0e10cSrcweir { 2142*cdf0e10cSrcweir # Now the downloadfilename has to be set (if not already done) 2143*cdf0e10cSrcweir my $destdownloadfilename = ""; 2144*cdf0e10cSrcweir if ( ! $installer::globals::ooodownloadfilename ) { $destdownloadfilename = set_download_filename($languagestringref, $versionstring, $allvariableshashref); } 2145*cdf0e10cSrcweir else { $destdownloadfilename = $installer::globals::ooodownloadfilename; } 2146*cdf0e10cSrcweir 2147*cdf0e10cSrcweir if ( $destdownloadfilename ) 2148*cdf0e10cSrcweir { 2149*cdf0e10cSrcweir $destdownloadfilename = $destdownloadfilename . $installer::globals::downloadfileextension; 2150*cdf0e10cSrcweir 2151*cdf0e10cSrcweir $infoline = "Setting destination download file name: $destdownloadfilename\n"; 2152*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2153*cdf0e10cSrcweir 2154*cdf0e10cSrcweir my $sourcedownloadfile = $downloaddir . $installer::globals::separator . $installer::globals::downloadfilename; 2155*cdf0e10cSrcweir 2156*cdf0e10cSrcweir $infoline = "Setting source download file name: $sourcedownloadfile\n"; 2157*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2158*cdf0e10cSrcweir 2159*cdf0e10cSrcweir create_link_tree($sourcedownloadfile, $destdownloadfilename, $versionstring); 2160*cdf0e10cSrcweir # my $md5sumoutput = call_md5sum($downloadfile); 2161*cdf0e10cSrcweir # my $md5sum = get_md5sum($md5sumoutput); 2162*cdf0e10cSrcweir 2163*cdf0e10cSrcweir } 2164*cdf0e10cSrcweir } 2165*cdf0e10cSrcweir else 2166*cdf0e10cSrcweir { 2167*cdf0e10cSrcweir $infoline = "Version string is empty. Nothing to do!\n"; 2168*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2169*cdf0e10cSrcweir } 2170*cdf0e10cSrcweir } 2171*cdf0e10cSrcweir else 2172*cdf0e10cSrcweir { 2173*cdf0e10cSrcweir $infoline = "Platform not used for hard linking. Nothing to do!\n"; 2174*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 2175*cdf0e10cSrcweir } 2176*cdf0e10cSrcweir 2177*cdf0e10cSrcweir installer::logger::include_timestamp_into_logfile("Performance Info: Creating hard link, stop"); 2178*cdf0e10cSrcweir} 2179*cdf0e10cSrcweir 2180*cdf0e10cSrcweir1; 2181