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