19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::followme; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse File::Spec; 27cdf0e10cSrcweiruse installer::exiter; 28cdf0e10cSrcweiruse installer::files; 29cdf0e10cSrcweiruse installer::globals; 30cdf0e10cSrcweiruse installer::logger; 31cdf0e10cSrcweiruse installer::systemactions; 32cdf0e10cSrcweir 33cdf0e10cSrcweir#################################################### 34cdf0e10cSrcweir# Creating a file, that contains all information 35cdf0e10cSrcweir# to create a follow up process. 36cdf0e10cSrcweir#################################################### 37cdf0e10cSrcweir 38cdf0e10cSrcweirsub save_followme_info 39cdf0e10cSrcweir{ 40cdf0e10cSrcweir my ($finalinstalldir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref, $current_install_number, $loggingdir, $installlogdir) = @_; 41cdf0e10cSrcweir 42cdf0e10cSrcweir my $downloadinfofilename = $installer::globals::logfilename; 43cdf0e10cSrcweir if ( $installer::globals::updatepack ) { $downloadinfofilename =~ s/log_/log_$current_install_number\_/; } 44cdf0e10cSrcweir $downloadinfofilename =~ s/log_/follow_me_/; 45cdf0e10cSrcweir 46cdf0e10cSrcweir # Creating directory 47cdf0e10cSrcweir my $downloadinfodir = installer::systemactions::create_directory_next_to_directory($finalinstalldir, "follow_me"); 48cdf0e10cSrcweir 49cdf0e10cSrcweir my @filecontent = (); 50cdf0e10cSrcweir 51cdf0e10cSrcweir push(@filecontent, "finalinstalldir: $finalinstalldir\n"); 52cdf0e10cSrcweir push(@filecontent, "downloadname: $downloadname\n"); 53cdf0e10cSrcweir push(@filecontent, "currentinstallnumber: $current_install_number\n"); 54cdf0e10cSrcweir push(@filecontent, "loggingdir: $loggingdir\n"); 55cdf0e10cSrcweir push(@filecontent, "installlogdir: $installlogdir\n"); 56cdf0e10cSrcweir push(@filecontent, "languagestring: $$languagestringref\n"); 57cdf0e10cSrcweir foreach my $element ( @{$languagesarrayref} ) { push(@filecontent, "languagesarray: $element\n"); } 58cdf0e10cSrcweir foreach my $path ( @{$includepatharrayref} ) { push(@filecontent, "includepatharray: $path"); } 59cdf0e10cSrcweir foreach my $key ( sort keys %{$allvariableshashref} ) { push(@filecontent, "allvariableshash: $key : $allvariableshashref->{$key}\n"); } 60cdf0e10cSrcweir push(@filecontent, "globals:updatepack: $installer::globals::updatepack\n"); 61cdf0e10cSrcweir push(@filecontent, "globals:added_english: $installer::globals::added_english\n"); 62cdf0e10cSrcweir push(@filecontent, "globals:iswindowsbuild: $installer::globals::iswindowsbuild\n"); 63cdf0e10cSrcweir push(@filecontent, "globals:issolarisbuild: $installer::globals::issolarisbuild\n"); 64cdf0e10cSrcweir push(@filecontent, "globals:issolarispkgbuild: $installer::globals::issolarispkgbuild\n"); 65cdf0e10cSrcweir push(@filecontent, "globals:issolarissparcbuild: $installer::globals::issolarissparcbuild\n"); 66cdf0e10cSrcweir push(@filecontent, "globals:issolarisx86build: $installer::globals::issolarisx86build\n"); 67cdf0e10cSrcweir push(@filecontent, "globals:isfreebsdpkgbuild: $installer::globals::isfreebsdpkgbuild\n"); 68cdf0e10cSrcweir push(@filecontent, "globals:islinuxbuild: $installer::globals::islinuxbuild\n"); 69cdf0e10cSrcweir push(@filecontent, "globals:islinuxrpmbuild: $installer::globals::islinuxrpmbuild\n"); 70cdf0e10cSrcweir push(@filecontent, "globals:islinuxintelrpmbuild: $installer::globals::islinuxintelrpmbuild\n"); 71cdf0e10cSrcweir push(@filecontent, "globals:islinuxppcrpmbuild: $installer::globals::islinuxppcrpmbuild\n"); 72cdf0e10cSrcweir push(@filecontent, "globals:islinuxx86_64rpmbuild: $installer::globals::islinuxx86_64rpmbuild\n"); 73cdf0e10cSrcweir push(@filecontent, "globals:islinuxdebbuild: $installer::globals::islinuxdebbuild\n"); 74cdf0e10cSrcweir push(@filecontent, "globals:islinuxinteldebbuild: $installer::globals::islinuxinteldebbuild\n"); 75cdf0e10cSrcweir push(@filecontent, "globals:islinuxppcdebbuild: $installer::globals::islinuxppcdebbuild\n"); 76cdf0e10cSrcweir push(@filecontent, "globals:islinuxx86_64debbuild: $installer::globals::islinuxx86_64debbuild\n"); 77cdf0e10cSrcweir push(@filecontent, "globals:issolaris: $installer::globals::issolaris\n"); 78cdf0e10cSrcweir push(@filecontent, "globals:islinux: $installer::globals::islinux\n"); 79cdf0e10cSrcweir push(@filecontent, "globals:unpackpath: $installer::globals::unpackpath\n"); 80cdf0e10cSrcweir push(@filecontent, "globals:idttemplatepath: $installer::globals::idttemplatepath\n"); 81cdf0e10cSrcweir push(@filecontent, "globals:idtlanguagepath: $installer::globals::idtlanguagepath\n"); 82cdf0e10cSrcweir push(@filecontent, "globals:logfilename: $installer::globals::logfilename\n"); 83cdf0e10cSrcweir push(@filecontent, "globals:product: $installer::globals::product\n"); 84cdf0e10cSrcweir push(@filecontent, "globals:patch: $installer::globals::patch\n"); 85cdf0e10cSrcweir push(@filecontent, "globals:languagepack: $installer::globals::languagepack\n"); 86cdf0e10cSrcweir push(@filecontent, "globals:installertypedir: $installer::globals::installertypedir\n"); 87cdf0e10cSrcweir push(@filecontent, "globals:max_lang_length: $installer::globals::max_lang_length\n"); 88cdf0e10cSrcweir push(@filecontent, "globals:compiler: $installer::globals::compiler\n"); 89cdf0e10cSrcweir push(@filecontent, "globals:product: $installer::globals::product\n"); 90cdf0e10cSrcweir push(@filecontent, "globals:minor: $installer::globals::minor\n"); 91cdf0e10cSrcweir push(@filecontent, "globals:lastminor: $installer::globals::lastminor\n"); 92cdf0e10cSrcweir push(@filecontent, "globals:nsisfilename: $installer::globals::nsisfilename\n"); 93cdf0e10cSrcweir 94cdf0e10cSrcweir # Saving file 95cdf0e10cSrcweir installer::files::save_file($downloadinfodir . $installer::globals::separator . $downloadinfofilename, \@filecontent); 96*b274bc22SAndre Fischer $installer::logger::Info->printf("... creating \"follow me\" info file %s.\n", $downloadinfofilename); 97cdf0e10cSrcweir} 98cdf0e10cSrcweir 99cdf0e10cSrcweir#################################################### 100cdf0e10cSrcweir# Reading the file, that contains all information 101cdf0e10cSrcweir# to create a follow up process. 102cdf0e10cSrcweir#################################################### 103cdf0e10cSrcweir 104cdf0e10cSrcweirsub read_followme_info 105cdf0e10cSrcweir{ 106cdf0e10cSrcweir my ( $filename ) = @_; 107cdf0e10cSrcweir 108cdf0e10cSrcweir if ( ! -f $filename ) { installer::exiter::exit_program("ERROR: Could not find file: $filename", "read_download_info"); } 109cdf0e10cSrcweir 110*b274bc22SAndre Fischer $installer::logger::Info->print("\n"); 111*b274bc22SAndre Fischer $installer::logger::Info->printf("... reading \"follow me\" info file %s\n", $filename); 112cdf0e10cSrcweir 113cdf0e10cSrcweir my %contenthash = (); 114cdf0e10cSrcweir 115cdf0e10cSrcweir my $finalinstalldir = ""; 116cdf0e10cSrcweir my $downloadname = ""; 117cdf0e10cSrcweir my $currentinstallnumber = ""; 118cdf0e10cSrcweir my $loggingdir = ""; 119cdf0e10cSrcweir my $installlogdir = ""; 120cdf0e10cSrcweir my $languagestring = ""; 121cdf0e10cSrcweir my @includepatharray = (); 122cdf0e10cSrcweir my @languagesarray = (); 123cdf0e10cSrcweir my %allvariableshash = (); 124cdf0e10cSrcweir 125cdf0e10cSrcweir # Global variables can be set directly 126cdf0e10cSrcweir 127cdf0e10cSrcweir my $filecontent = installer::files::read_file($filename); 128cdf0e10cSrcweir 129cdf0e10cSrcweir # First line has to contain the string "finalinstalldir:". 130cdf0e10cSrcweir # Otherwise this is not a correct file. 131cdf0e10cSrcweir 132cdf0e10cSrcweir 133cdf0e10cSrcweir if ( ! ( ${$filecontent}[0] =~ /s*finalinstalldir:\s*(.*?)\s*$/ )) { installer::exiter::exit_program("ERROR: Not a correct download info file: $filename", "read_download_info"); } 134cdf0e10cSrcweir 135cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir my $line = ${$filecontent}[$i]; 138cdf0e10cSrcweir 139cdf0e10cSrcweir if ( $line =~ /^\s*finalinstalldir:\s*(.*?)\s*$/ ) { $finalinstalldir = $1; } 140cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $finalinstalldir =~ s/\\/\//; } 141cdf0e10cSrcweir if ( $line =~ /^\s*downloadname:\s*(.*?)\s*$/ ) { $downloadname = $1; } 142cdf0e10cSrcweir if ( $line =~ /^\s*currentinstallnumber:\s*(.*?)\s*$/ ) { $currentinstallnumber = $1; } 143cdf0e10cSrcweir if ( $line =~ /^\s*loggingdir:\s*(.*?)\s*$/ ) { $loggingdir = $1; } 144cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $loggingdir =~ s/\\/\//; } 145cdf0e10cSrcweir if ( $line =~ /^\s*installlogdir:\s*(.*?)\s*$/ ) { $installlogdir = $1; } 146cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $installlogdir =~ s/\\/\//; } 147cdf0e10cSrcweir if ( $line =~ /^\s*languagestring:\s*(.*?)\s*$/ ) { $languagestring = $1; } 148cdf0e10cSrcweir if ( $line =~ /^\s*languagesarray:\s*(.*?)\s*$/ ) { push(@languagesarray, $1); } 149cdf0e10cSrcweir if ( $line =~ /^\s*includepatharray:\s*(.*?)\s*$/ ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir my $path = $1; 152cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $path =~ s/\\/\//; } 153cdf0e10cSrcweir push(@includepatharray, $path . "\n"); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir if ( $line =~ /^\s*allvariableshash:\s*(.*?)\s*:\s*(.*?)\s*$/ ) { $allvariableshash{$1} = $2; } 156cdf0e10cSrcweir if ( $line =~ /^\s*globals:(.*?)\s*:\s*(.*?)\s*$/ ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir my $name = $1; 159cdf0e10cSrcweir my $value = $2; 160cdf0e10cSrcweir if ( $name eq "updatepack" ) { $installer::globals::updatepack = $value; } 161cdf0e10cSrcweir if ( $name eq "added_english" ) { $installer::globals::added_english = $value; } 162cdf0e10cSrcweir if ( $name eq "iswindowsbuild" ) { $installer::globals::iswindowsbuild = $value; } 163cdf0e10cSrcweir if ( $name eq "issolarisbuild" ) { $installer::globals::issolarisbuild = $value; } 164cdf0e10cSrcweir if ( $name eq "issolarispkgbuild" ) { $installer::globals::issolarispkgbuild = $value; } 165cdf0e10cSrcweir if ( $name eq "issolarissparcbuild" ) { $installer::globals::issolarissparcbuild = $value; } 166cdf0e10cSrcweir if ( $name eq "issolarisx86build" ) { $installer::globals::issolarisx86build = $value; } 167cdf0e10cSrcweir if ( $name eq "isfreebsdpkgbuild" ) { $installer::globals::isfreebsdpkgbuild = $value; } 168cdf0e10cSrcweir if ( $name eq "islinuxbuild" ) { $installer::globals::islinuxbuild = $value; } 169cdf0e10cSrcweir if ( $name eq "islinuxrpmbuild" ) { $installer::globals::islinuxrpmbuild = $value; } 170cdf0e10cSrcweir if ( $name eq "islinuxintelrpmbuild" ) { $installer::globals::islinuxintelrpmbuild = $value; } 171cdf0e10cSrcweir if ( $name eq "islinuxppcrpmbuild" ) { $installer::globals::islinuxppcrpmbuild = $value; } 172cdf0e10cSrcweir if ( $name eq "islinuxx86_64rpmbuild" ) { $installer::globals::islinuxx86_64rpmbuild = $value; } 173cdf0e10cSrcweir if ( $name eq "islinuxdebbuild" ) { $installer::globals::islinuxdebbuild = $value; } 174cdf0e10cSrcweir if ( $name eq "islinuxinteldebbuild" ) { $installer::globals::islinuxinteldebbuild = $value; } 175cdf0e10cSrcweir if ( $name eq "islinuxppcdebbuild" ) { $installer::globals::islinuxppcdebbuild = $value; } 176cdf0e10cSrcweir if ( $name eq "islinuxx86_64debbuild" ) { $installer::globals::islinuxx86_64debbuild = $value; } 177cdf0e10cSrcweir if ( $name eq "issolaris" ) { $installer::globals::issolaris = $value; } 178cdf0e10cSrcweir if ( $name eq "islinux" ) { $installer::globals::islinux = $value; } 179cdf0e10cSrcweir if ( $name eq "unpackpath" ) { $installer::globals::unpackpath = $value; } 180cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $installer::globals::unpackpath =~ s/\\/\//; } 181cdf0e10cSrcweir if ( $name eq "idttemplatepath" ) { $installer::globals::idttemplatepath = $value; } 182cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $installer::globals::idttemplatepath =~ s/\\/\//; } 183cdf0e10cSrcweir if ( $name eq "idtlanguagepath" ) { $installer::globals::idtlanguagepath = $value; } 184cdf0e10cSrcweir if( $^O =~ /cygwin/i ) { $installer::globals::idtlanguagepath =~ s/\\/\//; } 185cdf0e10cSrcweir if ( $name eq "logfilename" ) { $installer::globals::logfilename = $value; } 186cdf0e10cSrcweir if ( $name eq "product" ) { $installer::globals::product = $value; } 187cdf0e10cSrcweir if ( $name eq "patch" ) { $installer::globals::patch = $value; } 188cdf0e10cSrcweir if ( $name eq "languagepack" ) { $installer::globals::languagepack = $value; } 189cdf0e10cSrcweir if ( $name eq "installertypedir" ) { $installer::globals::installertypedir = $value; } 190cdf0e10cSrcweir if ( $name eq "max_lang_length" ) { $installer::globals::max_lang_length = $value; } 191cdf0e10cSrcweir if ( $name eq "compiler" ) { $installer::globals::compiler = $value; } 192cdf0e10cSrcweir if ( $name eq "product" ) { $installer::globals::product = $value; } 193cdf0e10cSrcweir if ( $name eq "minor" ) { $installer::globals::minor = $value; } 194cdf0e10cSrcweir if ( $name eq "lastminor" ) { $installer::globals::lastminor = $value; } 195cdf0e10cSrcweir if ( $name eq "nsisfilename" ) { $installer::globals::nsisfilename = $value; } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir $contenthash{'finalinstalldir'} = $finalinstalldir; 200cdf0e10cSrcweir $contenthash{'downloadname'} = $downloadname; 201cdf0e10cSrcweir $contenthash{'currentinstallnumber'} = $currentinstallnumber; 202cdf0e10cSrcweir $contenthash{'loggingdir'} = $loggingdir; 203cdf0e10cSrcweir $contenthash{'installlogdir'} = $installlogdir; 204cdf0e10cSrcweir $contenthash{'languagestring'} = $languagestring; 205cdf0e10cSrcweir $contenthash{'languagesarray'} = \@languagesarray; 206cdf0e10cSrcweir $contenthash{'includepatharray'} = \@includepatharray; 207cdf0e10cSrcweir $contenthash{'allvariableshash'} = \%allvariableshash; 208cdf0e10cSrcweir 209cdf0e10cSrcweir return \%contenthash; 210cdf0e10cSrcweir} 211cdf0e10cSrcweir 212cdf0e10cSrcweir1; 213