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::downloadsigner; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse installer::exiter; 31*cdf0e10cSrcweiruse installer::files; 32*cdf0e10cSrcweiruse installer::globals; 33*cdf0e10cSrcweiruse installer::logger; 34*cdf0e10cSrcweiruse installer::pathanalyzer; 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir############################################ 37*cdf0e10cSrcweir# Parameter Operations 38*cdf0e10cSrcweir############################################ 39*cdf0e10cSrcweir 40*cdf0e10cSrcweirsub usage 41*cdf0e10cSrcweir{ 42*cdf0e10cSrcweir print <<Ende; 43*cdf0e10cSrcweir-------------------------------------------------------------------------------- 44*cdf0e10cSrcweirmake_download V1.0 45*cdf0e10cSrcweirThe following parameter are needed: 46*cdf0e10cSrcweir-d: Full path to the file containing the follow-me info or to a directory 47*cdf0e10cSrcweir containing the follow-me info files. In the latter case, all follow-me 48*cdf0e10cSrcweir info files are evaluated. If a directory is used, the successfully used 49*cdf0e10cSrcweir follow-me info files are renamed using a string "success". Files with 50*cdf0e10cSrcweir this string are ignored in repeated processes using "-d" with a 51*cdf0e10cSrcweir directory. 52*cdf0e10cSrcweir 53*cdf0e10cSrcweirThe following parameter are optional: 54*cdf0e10cSrcweir-nodownload: Only signing, no creation of download sets (Windows only) 55*cdf0e10cSrcweir-useminor: Important for installation sets, created without minor set 56*cdf0e10cSrcweir-writetotemp: Necessary, if you do not want to write into solver 57*cdf0e10cSrcweir This can be caused by missing privileges (Windows only) 58*cdf0e10cSrcweir-internalcabinet: Not only the cabinet files are signed, but also all 59*cdf0e10cSrcweir files included in the cabinet files (Windows only). 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir-sign: Uses signing mechanism to sign installation sets 62*cdf0e10cSrcweirIf \"-sign\" is set, the following two parameter are required: 63*cdf0e10cSrcweir-pfx: Full path to the pfx file 64*cdf0e10cSrcweir-pw: Full path to the file, containing the pfx password. 65*cdf0e10cSrcweir 66*cdf0e10cSrcweirExamples: 67*cdf0e10cSrcweir 68*cdf0e10cSrcweirSpecifying an installation set (with "-d"): 69*cdf0e10cSrcweir 70*cdf0e10cSrcweirperl make_download.pl -d <followmeinfofilename> 71*cdf0e10cSrcweir 72*cdf0e10cSrcweirperl make_download.pl -d <followmeinfofilename> 73*cdf0e10cSrcweir -sign 74*cdf0e10cSrcweir -pfx <pfxfilename> 75*cdf0e10cSrcweir -pw <passwordfilename> 76*cdf0e10cSrcweir 77*cdf0e10cSrcweiror without specifying an installation set: 78*cdf0e10cSrcweir 79*cdf0e10cSrcweirperl make_download.pl -d <followmedirectory> 80*cdf0e10cSrcweir -sign 81*cdf0e10cSrcweir -pfx <pfxfilename> 82*cdf0e10cSrcweir -pw <passwordfilename> 83*cdf0e10cSrcweir-------------------------------------------------------------------------------- 84*cdf0e10cSrcweirEnde 85*cdf0e10cSrcweir exit(-1); 86*cdf0e10cSrcweir} 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir##################################### 89*cdf0e10cSrcweir# Reading parameter 90*cdf0e10cSrcweir##################################### 91*cdf0e10cSrcweir 92*cdf0e10cSrcweirsub getparameter 93*cdf0e10cSrcweir{ 94*cdf0e10cSrcweir # installer::logger::print_message("Checking parameter"); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir while ( $#ARGV >= 0 ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir my $param = shift(@ARGV); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if ($param eq "-d") { $installer::globals::followmeinfofilename = shift(@ARGV); } 101*cdf0e10cSrcweir elsif ($param eq "-pw") { $installer::globals::pwfile = shift(@ARGV); } 102*cdf0e10cSrcweir elsif ($param eq "-pfx") { $installer::globals::pfxfile = shift(@ARGV); } 103*cdf0e10cSrcweir elsif ($param eq "-sign") { $installer::globals::dosign = 1; } 104*cdf0e10cSrcweir elsif ($param eq "-nodownload") { $installer::globals::nodownload = 1; } 105*cdf0e10cSrcweir elsif ($param eq "-writetotemp") { $installer::globals::writetotemp = 1; } 106*cdf0e10cSrcweir elsif ($param eq "-useminor") { $installer::globals::useminor = 1; } 107*cdf0e10cSrcweir elsif ($param eq "-internalcabinet") { $installer::globals::internal_cabinet_signing = 1; } 108*cdf0e10cSrcweir else 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir installer::logger::print_error( "unknown parameter: $param" ); 111*cdf0e10cSrcweir usage(); 112*cdf0e10cSrcweir exit(-1); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir} 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir##################################### 118*cdf0e10cSrcweir# Controlling required parameter 119*cdf0e10cSrcweir##################################### 120*cdf0e10cSrcweir 121*cdf0e10cSrcweirsub checkparameter 122*cdf0e10cSrcweir{ 123*cdf0e10cSrcweir if ( $installer::globals::followmeinfofilename eq "" ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir installer::logger::print_error( "Error: Required parameter is missing: -d\n" ); 126*cdf0e10cSrcweir usage(); 127*cdf0e10cSrcweir exit(-1); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir if ( $installer::globals::dosign ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir # -pfx and -pw have to be set 133*cdf0e10cSrcweir if ( $installer::globals::pfxfile eq "" ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir installer::logger::print_error( "Error: If \"-sign\" is set, a pfx file has to be specified: -pfx\n" ); 136*cdf0e10cSrcweir usage(); 137*cdf0e10cSrcweir exit(-1); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir # -pfx and -pw have to be set 141*cdf0e10cSrcweir if ( $installer::globals::pwfile eq "" ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir installer::logger::print_error( "Error: If \"-sign\" is set, a password file has to be specified: -pw\n" ); 144*cdf0e10cSrcweir usage(); 145*cdf0e10cSrcweir exit(-1); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir # and both files have to exist 149*cdf0e10cSrcweir if ( ! -f $installer::globals::pfxfile ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir installer::logger::print_error( "Error: pfx file \"$installer::globals::pfxfile\" does not exist.\n" ); 152*cdf0e10cSrcweir usage(); 153*cdf0e10cSrcweir exit(-1); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir if ( ! -f $installer::globals::pwfile ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir installer::logger::print_error( "Error: Password file \"$installer::globals::pwfile\" does not exist (-pw).\n" ); 159*cdf0e10cSrcweir usage(); 160*cdf0e10cSrcweir exit(-1); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir} 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir############################################# 166*cdf0e10cSrcweir# Setting the temporary path for the download 167*cdf0e10cSrcweir# and signing process 168*cdf0e10cSrcweir############################################# 169*cdf0e10cSrcweir 170*cdf0e10cSrcweirsub set_temp_path 171*cdf0e10cSrcweir{ 172*cdf0e10cSrcweir my $temppath = ""; 173*cdf0e10cSrcweir my $pid = $$; # process id 174*cdf0e10cSrcweir my $time = time(); # time 175*cdf0e10cSrcweir my $helperdir = "unpackdir_" . $pid . $time; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir if (( $ENV{'TMP'} ) || ( $ENV{'TEMP'} )) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir if ( $ENV{'TMP'} ) { $temppath = $ENV{'TMP'}; } 180*cdf0e10cSrcweir elsif ( $ENV{'TEMP'} ) { $temppath = $ENV{'TEMP'}; } 181*cdf0e10cSrcweir $temppath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes and backslashes 182*cdf0e10cSrcweir $temppath = $temppath . $installer::globals::separator . $helperdir; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir if( $^O =~ /cygwin/i ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir $temppath = qx{cygpath -w "$temppath"}; 187*cdf0e10cSrcweir $temppath =~ s/\\/\//g; 188*cdf0e10cSrcweir $temppath =~ s/\s*$//g; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir installer::systemactions::create_directory_structure($temppath); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir else 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir installer::logger::print_error( "Error: TMP and TEMP not defined. This is required for this process.\n" ); 196*cdf0e10cSrcweir usage(); 197*cdf0e10cSrcweir exit(-1); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir installer::logger::print_message( "\n... using output path: $temppath ...\n" ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir push(@installer::globals::removedirs, $temppath); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir return $temppath; 205*cdf0e10cSrcweir} 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir############################################# 208*cdf0e10cSrcweir# Setting output pathes to temp directory 209*cdf0e10cSrcweir# This are the: 210*cdf0e10cSrcweir# unpackpath and the loggingdir 211*cdf0e10cSrcweir############################################# 212*cdf0e10cSrcweir 213*cdf0e10cSrcweirsub set_output_pathes_to_temp 214*cdf0e10cSrcweir{ 215*cdf0e10cSrcweir my ($followmeinfohash, $temppath) = @_; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir $followmeinfohash->{'loggingdir'} = $temppath . $installer::globals::separator; 218*cdf0e10cSrcweir $installer::globals::unpackpath = $temppath; 219*cdf0e10cSrcweir} 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir############################################# 222*cdf0e10cSrcweir# Setting the minor into the pathes. This is 223*cdf0e10cSrcweir# required, if the original installation set 224*cdf0e10cSrcweir# was created without minor 225*cdf0e10cSrcweir# Value is always saved in 226*cdf0e10cSrcweir# $installer::globals::lastminor 227*cdf0e10cSrcweir# which is saved in the follow_me file 228*cdf0e10cSrcweir############################################# 229*cdf0e10cSrcweir 230*cdf0e10cSrcweirsub set_minor_into_pathes 231*cdf0e10cSrcweir{ 232*cdf0e10cSrcweir my ($followmeinfohash, $temppath) = @_; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir installer::logger::print_message( "\n... forcing into minor: $installer::globals::lastminor ...\n" ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir my @pathnames = ("bin", "doc", "inc", "lib", "pck", "res", "xml"); 237*cdf0e10cSrcweir my $sourcename = "src"; 238*cdf0e10cSrcweir my $srcpath = $installer::globals::separator . $sourcename . $installer::globals::separator; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir if ( $installer::globals::minor ne "" ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir installer::logger::print_message( "\n... already defined minor: $installer::globals::minor -> ignoring parameter \"-useminor\" ...\n" ); 243*cdf0e10cSrcweir return; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir # Affected pathes: 247*cdf0e10cSrcweir # $contenthash{'installlogdir'} 248*cdf0e10cSrcweir # $contenthash{'includepatharray'} 249*cdf0e10cSrcweir # $installer::globals::unpackpath 250*cdf0e10cSrcweir # $installer::globals::idttemplatepath 251*cdf0e10cSrcweir # $installer::globals::idtlanguagepath 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir installer::logger::include_header_into_logfile("Changing saved pathes to add the minor"); 254*cdf0e10cSrcweir my $infoline = "Old pathes:\n"; 255*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 256*cdf0e10cSrcweir $infoline = "\$followmeinfohash->{'installlogdir'}: $followmeinfohash->{'installlogdir'}\n"; 257*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 258*cdf0e10cSrcweir $infoline = "\$installer::globals::unpackpath: $installer::globals::unpackpath\n"; 259*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 260*cdf0e10cSrcweir $infoline = "\$installer::globals::idttemplatepath: $installer::globals::idttemplatepath\n"; 261*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 262*cdf0e10cSrcweir $infoline = "\$installer::globals::idtlanguagepath: $installer::globals::idtlanguagepath\n"; 263*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 264*cdf0e10cSrcweir $infoline = "Include pathes:\n"; 265*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 266*cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { push( @installer::globals::logfileinfo, $path); } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir foreach $onepath ( @pathnames ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir my $oldvalue = $installer::globals::separator . $onepath . $installer::globals::separator; 271*cdf0e10cSrcweir my $newvalue = $installer::globals::separator . $onepath . "\." . $installer::globals::lastminor . $installer::globals::separator; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir if (( $followmeinfohash->{'installlogdir'} =~ /\Q$oldvalue\E/ ) && ( ! ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ))) { $followmeinfohash->{'installlogdir'} =~ s/\Q$oldvalue\E/$newvalue/; } 274*cdf0e10cSrcweir if (( $installer::globals::unpackpath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ))) { $installer::globals::unpackpath =~ s/\Q$oldvalue\E/$newvalue/; } 275*cdf0e10cSrcweir if (( $installer::globals::idttemplatepath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idttemplatepath =~ s/\Q$oldvalue\E/$newvalue/; } 276*cdf0e10cSrcweir if (( $installer::globals::idtlanguagepath =~ /\Q$oldvalue\E/ ) && ( ! ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idtlanguagepath =~ s/\Q$oldvalue\E/$newvalue/; } 277*cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { if (( $path =~ /\Q$oldvalue\E/ ) && ( ! ( $path =~ /\Q$srcpath\E/ ))) { $path =~ s/\Q$oldvalue\E/$newvalue/; } } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir # Checking for the end of the path 280*cdf0e10cSrcweir $oldvalue = $installer::globals::separator . $onepath; 281*cdf0e10cSrcweir $newvalue = $installer::globals::separator . $onepath . "\." . $installer::globals::lastminor; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if (( $followmeinfohash->{'installlogdir'} =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ))) { $followmeinfohash->{'installlogdir'} =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 284*cdf0e10cSrcweir if (( $installer::globals::unpackpath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ))) { $installer::globals::unpackpath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 285*cdf0e10cSrcweir if (( $installer::globals::idttemplatepath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idttemplatepath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 286*cdf0e10cSrcweir if (( $installer::globals::idtlanguagepath =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ))) { $installer::globals::idtlanguagepath =~ s/\Q$oldvalue\E\s*$/$newvalue/; } 287*cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir if (( $path =~ /\Q$oldvalue\E\s*$/ ) && ( ! ( $path =~ /\Q$srcpath\E/ ))) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir $path =~ s/\Q$oldvalue\E\s*$/$newvalue/; 292*cdf0e10cSrcweir $path = $path . "\n"; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir # And now can follow the replacement for the source path "src". Subdirs like "bin" in the source tree 298*cdf0e10cSrcweir # must not get the minor. This is instead "src.m9/instsetoo_native/common.pro/bin/..." 299*cdf0e10cSrcweir # Directory "src" can never be the end of the path 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir my $newsrcpath = $installer::globals::separator . $sourcename . "\." . $installer::globals::lastminor . $installer::globals::separator; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if ( $followmeinfohash->{'installlogdir'} =~ /\Q$srcpath\E/ ) { $followmeinfohash->{'installlogdir'} =~ s/\Q$srcpath\E/$newsrcpath/; } 304*cdf0e10cSrcweir if ( $installer::globals::unpackpath =~ /\Q$srcpath\E/ ) { $installer::globals::unpackpath =~ s/\Q$srcpath\E/$newsrcpath/; } 305*cdf0e10cSrcweir if ( $installer::globals::idttemplatepath =~ /\Q$srcpath\E/ ) { $installer::globals::idttemplatepath =~ s/\Q$srcpath\E/$newsrcpath/; } 306*cdf0e10cSrcweir if ( $installer::globals::idtlanguagepath =~ /\Q$srcpath\E/ ) { $installer::globals::idtlanguagepath =~ s/\Q$srcpath\E/$newsrcpath/; } 307*cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { if ( $path =~ /\Q$srcpath\E/ ) { $path =~ s/\Q$srcpath\E/$newsrcpath/; } } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir $infoline = "\nNew pathes:\n"; 310*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 311*cdf0e10cSrcweir $infoline = "\$followmeinfohash->{'installlogdir'}: $followmeinfohash->{'installlogdir'}\n"; 312*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 313*cdf0e10cSrcweir $infoline = "\$installer::globals::unpackpath: $installer::globals::unpackpath\n"; 314*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 315*cdf0e10cSrcweir $infoline = "\$installer::globals::idttemplatepath: $installer::globals::idttemplatepath\n"; 316*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 317*cdf0e10cSrcweir $infoline = "\$installer::globals::idtlanguagepath: $installer::globals::idtlanguagepath\n"; 318*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 319*cdf0e10cSrcweir $infoline = "Include pathes:\n"; 320*cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 321*cdf0e10cSrcweir foreach my $path ( @{$followmeinfohash->{'includepatharray'}} ) { push( @installer::globals::logfileinfo, $path); } 322*cdf0e10cSrcweir} 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir############################################# 325*cdf0e10cSrcweir# Setting the name of the log file 326*cdf0e10cSrcweir############################################# 327*cdf0e10cSrcweir 328*cdf0e10cSrcweirsub setlogfilename 329*cdf0e10cSrcweir{ 330*cdf0e10cSrcweir if ( $installer::globals::dosign ) { $installer::globals::logfilename = "sign_and_download_" . $installer::globals::logfilename; } 331*cdf0e10cSrcweir else { $installer::globals::logfilename = "download_" . $installer::globals::logfilename; } 332*cdf0e10cSrcweir # reset the log file 333*cdf0e10cSrcweir @installer::globals::logfileinfo = (); 334*cdf0e10cSrcweir} 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir######################################################### 337*cdf0e10cSrcweir# Checking, if this is a task in a cws or 338*cdf0e10cSrcweir# on the master. Simple check of naming schema: 339*cdf0e10cSrcweir# CWS: follow_me_DEV300_m40_de.log 340*cdf0e10cSrcweir# Master: follow_me_4_DEV300_m40_en-US.log 341*cdf0e10cSrcweir######################################################### 342*cdf0e10cSrcweir 343*cdf0e10cSrcweirsub check_cws_build 344*cdf0e10cSrcweir{ 345*cdf0e10cSrcweir my ( $filename ) = @_; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir my $iscws = 1; 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir if ( $filename =~ /follow_me_\d+_/ ) { $iscws = 0; } 350*cdf0e10cSrcweir # if ( $filename =~ /log_\d+_/ ) { $iscws = 0; } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir return $iscws; 353*cdf0e10cSrcweir} 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir######################################################### 356*cdf0e10cSrcweir# Reading a specific key from a follow-me file 357*cdf0e10cSrcweir######################################################### 358*cdf0e10cSrcweir 359*cdf0e10cSrcweirsub get_property_from_file 360*cdf0e10cSrcweir{ 361*cdf0e10cSrcweir my ($followmefile, $key) = @_; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir my $value = ""; 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir my $filecontent = installer::files::read_file($followmefile); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir if ( ${$filecontent}[$i] =~ /^\s*\Q$key\E\s*\:\s*(.*?)\s*$/ ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir $value = $1; 372*cdf0e10cSrcweir last; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir return $value; 377*cdf0e10cSrcweir} 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir######################################################### 380*cdf0e10cSrcweir# Publishing the content of the product list 381*cdf0e10cSrcweir######################################################### 382*cdf0e10cSrcweir 383*cdf0e10cSrcweirsub publishproductlist 384*cdf0e10cSrcweir{ 385*cdf0e10cSrcweir my ($infofilelist) = @_; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir installer::logger::print_message( "\n... found products: ...\n" ); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$infofilelist}; $i++ ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir my $onefile = ${$infofilelist}[$i]; 392*cdf0e10cSrcweir installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$onefile); 393*cdf0e10cSrcweir installer::logger::print_message( "...... $onefile ...\n" ); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir installer::logger::print_message( "\n" ); 397*cdf0e10cSrcweir} 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir######################################################### 400*cdf0e10cSrcweir# Filtering all files, that have correct minor 401*cdf0e10cSrcweir# and work stamp. 402*cdf0e10cSrcweir# Master: follow_me_4_DEV300_m40_en-US.log 403*cdf0e10cSrcweir######################################################### 404*cdf0e10cSrcweir 405*cdf0e10cSrcweirsub filter_all_files_with_correct_settings 406*cdf0e10cSrcweir{ 407*cdf0e10cSrcweir my ($allfollowmefiles) = @_; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir my @allfiles = (); 410*cdf0e10cSrcweir my @allfiles2 = (); 411*cdf0e10cSrcweir my $maxhash = (); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir my $minor = ""; 414*cdf0e10cSrcweir my $workstamp = ""; 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if ( $ENV{'WORK_STAMP'} ) { $workstamp = $ENV{'WORK_STAMP'}; } 417*cdf0e10cSrcweir if ( $ENV{'UPDMINOR'} ) { $minor = $ENV{'UPDMINOR'}; } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir if ( $minor eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"UPDMINOR\" not set!", "filter_all_files_with_correct_settings"); } 420*cdf0e10cSrcweir if ( $workstamp eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"WORK_STAMP\" not set!", "filter_all_files_with_correct_settings"); } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if (( $onefile =~ /_\Q$minor\E_/i ) && ( $onefile =~ /_\Q$workstamp\E_/i )) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir push(@allfiles, $onefile); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir # also collecting maximum hash 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir if ( $onefile =~ /follow_me_(\d+)_\Q$workstamp\E_\Q$minor\E_([-\w]+)\.log\s*$/i ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir my $sequence = $1; 433*cdf0e10cSrcweir my $lang = $2; 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir if (( ! exists($maxhash{$lang})) || ( $maxhash{$lang} < $sequence )) { $maxhash{$lang} = $sequence; } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir # second run, because of sequence numbers 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir foreach my $onefile ( @allfiles ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir if ( $onefile =~ /follow_me_(\d+)_\Q$workstamp\E_\Q$minor\E_([-\w]+)\.log\s*$/i ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir my $sequence = $1; 447*cdf0e10cSrcweir my $lang = $2; 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir if ( $sequence == $maxhash{$lang} ) { push(@allfiles2, $onefile); } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir return ( \@allfiles2 ); 454*cdf0e10cSrcweir} 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir######################################################### 457*cdf0e10cSrcweir# Creating a list of products, that need to be signed 458*cdf0e10cSrcweir# or for which download sets need to be created. 459*cdf0e10cSrcweir######################################################### 460*cdf0e10cSrcweir 461*cdf0e10cSrcweirsub createproductlist 462*cdf0e10cSrcweir{ 463*cdf0e10cSrcweir # If "-d" specifies an installation set, there is only one product 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir my @infofilelist = (); 466*cdf0e10cSrcweir my @infofilelist2 = (); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir if ( -f $installer::globals::followmeinfofilename ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir push(@infofilelist, $installer::globals::followmeinfofilename); 471*cdf0e10cSrcweir # Saving info, that this is a file 472*cdf0e10cSrcweir $installer::globals::followme_from_directory = 0; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir elsif ( -d $installer::globals::followmeinfofilename ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir installer::logger::print_message( "\n... reading directory: $installer::globals::followmeinfofilename ...\n" ); 477*cdf0e10cSrcweir $installer::globals::followmeinfofilename =~ s/$installer::globals::separator\s*$//; 478*cdf0e10cSrcweir my $allfollowmefiles = installer::systemactions::find_file_with_file_extension("log", $installer::globals::followmeinfofilename); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir if ( ! ( $#{$allfollowmefiles} > -1 )) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! No follow-me file in directory \"$installer::globals::followmeinfofilename\"!.\n" ); 483*cdf0e10cSrcweir usage(); 484*cdf0e10cSrcweir exit(-1); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir # Saving info, that this is a directory 488*cdf0e10cSrcweir $installer::globals::followme_from_directory = 1; 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir # Collect all possible installation sets 491*cdf0e10cSrcweir # CWS: All installation sets 492*cdf0e10cSrcweir # Master: All installation sets with same major, minor and buildid. Additionally using the highest number. 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir my $iscws = check_cws_build(${$allfollowmefiles}[0]); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir if ( $iscws ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir # Simply read all follow-me files and check existence of installation sets 499*cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir my $fullfilename = $installer::globals::followmeinfofilename . $installer::globals::separator . $onefile; 502*cdf0e10cSrcweir my $installdir = get_property_from_file($fullfilename, "finalinstalldir"); 503*cdf0e10cSrcweir if (( $installdir ne "" ) && ( -d $installdir )) { push(@infofilelist2, $fullfilename); } 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir else 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir $allfollowmefiles = filter_all_files_with_correct_settings($allfollowmefiles); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir foreach my $onefile ( @{$allfollowmefiles} ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir my $fullfilename = $installer::globals::followmeinfofilename . $installer::globals::separator . $onefile; 513*cdf0e10cSrcweir # Check, if installation set still exists 514*cdf0e10cSrcweir my $installdir = get_property_from_file($fullfilename, "finalinstalldir"); 515*cdf0e10cSrcweir if (( $installdir ne "" ) && ( -d $installdir )) { push(@infofilelist2, $fullfilename); } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir # Removing all files, starting with "follow_me_success_" in their names. This have already been used successfully. 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir foreach my $onefile ( @infofilelist2 ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir if ( $onefile =~ /follow_me_success_/ ) { next; } 524*cdf0e10cSrcweir push(@infofilelist, $onefile); 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir # Checking, if there is content in the list 528*cdf0e10cSrcweir if ( ! ( $#infofilelist > -1 )) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! No installation set found for follow-me files in directory \"$installer::globals::followmeinfofilename\"!.\n" ); 531*cdf0e10cSrcweir usage(); 532*cdf0e10cSrcweir exit(-1); 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir else 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir installer::logger::print_error( "Error: Nothing to do! \"$installer::globals::followmeinfofilename\" is no file and no directory (-d).\n" ); 538*cdf0e10cSrcweir usage(); 539*cdf0e10cSrcweir exit(-1); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir return \@infofilelist; 543*cdf0e10cSrcweir} 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir############################################# 546*cdf0e10cSrcweir# Logging the content of the download hash 547*cdf0e10cSrcweir############################################# 548*cdf0e10cSrcweir 549*cdf0e10cSrcweirsub logfollowmeinfohash 550*cdf0e10cSrcweir{ 551*cdf0e10cSrcweir my ( $followmehash ) = @_; 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir print "\n*****************************************\n"; 554*cdf0e10cSrcweir print "Content of follow-me info file:\n"; 555*cdf0e10cSrcweir print "finalinstalldir: $followmehash->{'finalinstalldir'}\n"; 556*cdf0e10cSrcweir print "downloadname: $followmehash->{'downloadname'}\n"; 557*cdf0e10cSrcweir print "languagestring: $followmehash->{'languagestring'}\n"; 558*cdf0e10cSrcweir foreach my $lang ( @{$followmehash->{'languagesarray'}} ) { print "languagesarray: $lang\n"; } 559*cdf0e10cSrcweir foreach my $path ( @{$followmehash->{'includepatharray'}} ) { print "includepatharray: $path"; } 560*cdf0e10cSrcweir foreach my $key ( sort keys %{$followmehash->{'allvariableshash'}} ) { print "allvariableshash: $key : $followmehash->{'allvariableshash'}->{$key}\n"; } 561*cdf0e10cSrcweir} 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir######################################################################## 564*cdf0e10cSrcweir# Renaming the follow me info file, if it was successfully used. 565*cdf0e10cSrcweir# This can only be done, if the parameter "-d" was used with a 566*cdf0e10cSrcweir# directory, not a name. In this case the repeated use of parameter 567*cdf0e10cSrcweir# "-d" with this directory has to ignore this already successfully 568*cdf0e10cSrcweir# used file. 569*cdf0e10cSrcweir######################################################################## 570*cdf0e10cSrcweir 571*cdf0e10cSrcweirsub rename_followme_infofile 572*cdf0e10cSrcweir{ 573*cdf0e10cSrcweir my ( $filename ) = @_; 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir my $newfilename = $filename; 576*cdf0e10cSrcweir $newfilename =~ s/follow_me_/follow_me_success_/; # including "_success" after "follow_me" 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir if ( $filename ne $newfilename ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir my $returnvalue = rename($filename, $newfilename); 581*cdf0e10cSrcweir if ( $returnvalue ) { installer::logger::print_message( "\n... renamed file \"$filename\" to \"$newfilename\" ...\n" ); } 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir} 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir1; 586