Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / followme.pm
blob72faab6792c0f41265d8f197da14b12914529da9
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: environment.pm,v $
11 # $Revision: 1.14 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::followme;
34 use File::Spec;
35 use installer::exiter;
36 use installer::files;
37 use installer::globals;
38 use installer::logger;
39 use installer::systemactions;
41 ####################################################
42 # Creating a file, that contains all information
43 # to create a follow up process.
44 ####################################################
46 sub save_followme_info
48 my ($finalinstalldir, $includepatharrayref, $allvariableshashref, $downloadname, $languagestringref, $languagesarrayref, $current_install_number, $loggingdir, $installlogdir) = @_;
50 my $downloadinfofilename = $installer::globals::logfilename;
51 if ( $installer::globals::updatepack ) { $downloadinfofilename =~ s/log_/log_$current_install_number\_/; }
52 $downloadinfofilename =~ s/log_/follow_me_/;
54 # Creating directory
55 my $downloadinfodir = installer::systemactions::create_directory_next_to_directory($finalinstalldir, "follow_me");
57 my @filecontent = ();
59 push(@filecontent, "finalinstalldir: $finalinstalldir\n");
60 push(@filecontent, "downloadname: $downloadname\n");
61 push(@filecontent, "currentinstallnumber: $current_install_number\n");
62 push(@filecontent, "loggingdir: $loggingdir\n");
63 push(@filecontent, "installlogdir: $installlogdir\n");
64 push(@filecontent, "languagestring: $$languagestringref\n");
65 foreach my $element ( @{$languagesarrayref} ) { push(@filecontent, "languagesarray: $element\n"); }
66 foreach my $path ( @{$includepatharrayref} ) { push(@filecontent, "includepatharray: $path"); }
67 foreach my $key ( sort keys %{$allvariableshashref} ) { push(@filecontent, "allvariableshash: $key : $allvariableshashref->{$key}\n"); }
68 push(@filecontent, "globals:updatepack: $installer::globals::updatepack\n");
69 push(@filecontent, "globals:added_english: $installer::globals::added_english\n");
70 push(@filecontent, "globals:iswindowsbuild: $installer::globals::iswindowsbuild\n");
71 push(@filecontent, "globals:issolarisbuild: $installer::globals::issolarisbuild\n");
72 push(@filecontent, "globals:issolarispkgbuild: $installer::globals::issolarispkgbuild\n");
73 push(@filecontent, "globals:issolarissparcbuild: $installer::globals::issolarissparcbuild\n");
74 push(@filecontent, "globals:issolarisx86build: $installer::globals::issolarisx86build\n");
75 push(@filecontent, "globals:isfreebsdpkgbuild: $installer::globals::isfreebsdpkgbuild\n");
76 push(@filecontent, "globals:islinuxbuild: $installer::globals::islinuxbuild\n");
77 push(@filecontent, "globals:islinuxrpmbuild: $installer::globals::islinuxrpmbuild\n");
78 push(@filecontent, "globals:islinuxintelrpmbuild: $installer::globals::islinuxintelrpmbuild\n");
79 push(@filecontent, "globals:islinuxppcrpmbuild: $installer::globals::islinuxppcrpmbuild\n");
80 push(@filecontent, "globals:islinuxx86_64rpmbuild: $installer::globals::islinuxx86_64rpmbuild\n");
81 push(@filecontent, "globals:islinuxdebbuild: $installer::globals::islinuxdebbuild\n");
82 push(@filecontent, "globals:islinuxinteldebbuild: $installer::globals::islinuxinteldebbuild\n");
83 push(@filecontent, "globals:islinuxppcdebbuild: $installer::globals::islinuxppcdebbuild\n");
84 push(@filecontent, "globals:islinuxx86_64debbuild: $installer::globals::islinuxx86_64debbuild\n");
85 push(@filecontent, "globals:issolaris: $installer::globals::issolaris\n");
86 push(@filecontent, "globals:islinux: $installer::globals::islinux\n");
87 push(@filecontent, "globals:unpackpath: $installer::globals::unpackpath\n");
88 push(@filecontent, "globals:idttemplatepath: $installer::globals::idttemplatepath\n");
89 push(@filecontent, "globals:idtlanguagepath: $installer::globals::idtlanguagepath\n");
90 push(@filecontent, "globals:logfilename: $installer::globals::logfilename\n");
91 push(@filecontent, "globals:product: $installer::globals::product\n");
92 push(@filecontent, "globals:patch: $installer::globals::patch\n");
93 push(@filecontent, "globals:languagepack: $installer::globals::languagepack\n");
94 push(@filecontent, "globals:installertypedir: $installer::globals::installertypedir\n");
95 push(@filecontent, "globals:max_lang_length: $installer::globals::max_lang_length\n");
96 push(@filecontent, "globals:compiler: $installer::globals::compiler\n");
97 push(@filecontent, "globals:product: $installer::globals::product\n");
98 push(@filecontent, "globals:minor: $installer::globals::minor\n");
99 push(@filecontent, "globals:lastminor: $installer::globals::lastminor\n");
100 push(@filecontent, "globals:nsisfilename: $installer::globals::nsisfilename\n");
102 # Saving file
103 installer::files::save_file($downloadinfodir . $installer::globals::separator . $downloadinfofilename, \@filecontent);
104 installer::logger::print_message( "... creating \"follow me\" info file $downloadinfofilename.\n" );
107 ####################################################
108 # Reading the file, that contains all information
109 # to create a follow up process.
110 ####################################################
112 sub read_followme_info
114 my ( $filename ) = @_;
116 if ( ! -f $filename ) { installer::exiter::exit_program("ERROR: Could not find file: $filename", "read_download_info"); }
118 installer::logger::print_message( "\n... reading \"follow me\" info file $filename\n" );
120 my %contenthash = ();
122 my $finalinstalldir = "";
123 my $downloadname = "";
124 my $currentinstallnumber = "";
125 my $loggingdir = "";
126 my $installlogdir = "";
127 my $languagestring = "";
128 my @includepatharray = ();
129 my @languagesarray = ();
130 my %allvariableshash = ();
132 # Global variables can be set directly
134 my $filecontent = installer::files::read_file($filename);
136 # First line has to contain the string "finalinstalldir:".
137 # Otherwise this is not a correct file.
140 if ( ! ( ${$filecontent}[0] =~ /s*finalinstalldir:\s*(.*?)\s*$/ )) { installer::exiter::exit_program("ERROR: Not a correct download info file: $filename", "read_download_info"); }
142 for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
144 my $line = ${$filecontent}[$i];
146 if ( $line =~ /^\s*finalinstalldir:\s*(.*?)\s*$/ ) { $finalinstalldir = $1; }
147 if( $^O =~ /cygwin/i ) { $finalinstalldir =~ s/\\/\//; }
148 if ( $line =~ /^\s*downloadname:\s*(.*?)\s*$/ ) { $downloadname = $1; }
149 if ( $line =~ /^\s*currentinstallnumber:\s*(.*?)\s*$/ ) { $currentinstallnumber = $1; }
150 if ( $line =~ /^\s*loggingdir:\s*(.*?)\s*$/ ) { $loggingdir = $1; }
151 if( $^O =~ /cygwin/i ) { $loggingdir =~ s/\\/\//; }
152 if ( $line =~ /^\s*installlogdir:\s*(.*?)\s*$/ ) { $installlogdir = $1; }
153 if( $^O =~ /cygwin/i ) { $installlogdir =~ s/\\/\//; }
154 if ( $line =~ /^\s*languagestring:\s*(.*?)\s*$/ ) { $languagestring = $1; }
155 if ( $line =~ /^\s*languagesarray:\s*(.*?)\s*$/ ) { push(@languagesarray, $1); }
156 if ( $line =~ /^\s*includepatharray:\s*(.*?)\s*$/ )
158 my $path = $1;
159 if( $^O =~ /cygwin/i ) { $path =~ s/\\/\//; }
160 push(@includepatharray, $path . "\n");
162 if ( $line =~ /^\s*allvariableshash:\s*(.*?)\s*:\s*(.*?)\s*$/ ) { $allvariableshash{$1} = $2; }
163 if ( $line =~ /^\s*globals:(.*?)\s*:\s*(.*?)\s*$/ )
165 my $name = $1;
166 my $value = $2;
167 if ( $name eq "updatepack" ) { $installer::globals::updatepack = $value; }
168 if ( $name eq "added_english" ) { $installer::globals::added_english = $value; }
169 if ( $name eq "iswindowsbuild" ) { $installer::globals::iswindowsbuild = $value; }
170 if ( $name eq "issolarisbuild" ) { $installer::globals::issolarisbuild = $value; }
171 if ( $name eq "issolarispkgbuild" ) { $installer::globals::issolarispkgbuild = $value; }
172 if ( $name eq "issolarissparcbuild" ) { $installer::globals::issolarissparcbuild = $value; }
173 if ( $name eq "issolarisx86build" ) { $installer::globals::issolarisx86build = $value; }
174 if ( $name eq "isfreebsdpkgbuild" ) { $installer::globals::isfreebsdpkgbuild = $value; }
175 if ( $name eq "islinuxbuild" ) { $installer::globals::islinuxbuild = $value; }
176 if ( $name eq "islinuxrpmbuild" ) { $installer::globals::islinuxrpmbuild = $value; }
177 if ( $name eq "islinuxintelrpmbuild" ) { $installer::globals::islinuxintelrpmbuild = $value; }
178 if ( $name eq "islinuxppcrpmbuild" ) { $installer::globals::islinuxppcrpmbuild = $value; }
179 if ( $name eq "islinuxx86_64rpmbuild" ) { $installer::globals::islinuxx86_64rpmbuild = $value; }
180 if ( $name eq "islinuxdebbuild" ) { $installer::globals::islinuxdebbuild = $value; }
181 if ( $name eq "islinuxinteldebbuild" ) { $installer::globals::islinuxinteldebbuild = $value; }
182 if ( $name eq "islinuxppcdebbuild" ) { $installer::globals::islinuxppcdebbuild = $value; }
183 if ( $name eq "islinuxx86_64debbuild" ) { $installer::globals::islinuxx86_64debbuild = $value; }
184 if ( $name eq "issolaris" ) { $installer::globals::issolaris = $value; }
185 if ( $name eq "islinux" ) { $installer::globals::islinux = $value; }
186 if ( $name eq "unpackpath" ) { $installer::globals::unpackpath = $value; }
187 if( $^O =~ /cygwin/i ) { $installer::globals::unpackpath =~ s/\\/\//; }
188 if ( $name eq "idttemplatepath" ) { $installer::globals::idttemplatepath = $value; }
189 if( $^O =~ /cygwin/i ) { $installer::globals::idttemplatepath =~ s/\\/\//; }
190 if ( $name eq "idtlanguagepath" ) { $installer::globals::idtlanguagepath = $value; }
191 if( $^O =~ /cygwin/i ) { $installer::globals::idtlanguagepath =~ s/\\/\//; }
192 if ( $name eq "logfilename" ) { $installer::globals::logfilename = $value; }
193 if ( $name eq "product" ) { $installer::globals::product = $value; }
194 if ( $name eq "patch" ) { $installer::globals::patch = $value; }
195 if ( $name eq "languagepack" ) { $installer::globals::languagepack = $value; }
196 if ( $name eq "installertypedir" ) { $installer::globals::installertypedir = $value; }
197 if ( $name eq "max_lang_length" ) { $installer::globals::max_lang_length = $value; }
198 if ( $name eq "compiler" ) { $installer::globals::compiler = $value; }
199 if ( $name eq "product" ) { $installer::globals::product = $value; }
200 if ( $name eq "minor" ) { $installer::globals::minor = $value; }
201 if ( $name eq "lastminor" ) { $installer::globals::lastminor = $value; }
202 if ( $name eq "nsisfilename" ) { $installer::globals::nsisfilename = $value; }
206 $contenthash{'finalinstalldir'} = $finalinstalldir;
207 $contenthash{'downloadname'} = $downloadname;
208 $contenthash{'currentinstallnumber'} = $currentinstallnumber;
209 $contenthash{'loggingdir'} = $loggingdir;
210 $contenthash{'installlogdir'} = $installlogdir;
211 $contenthash{'languagestring'} = $languagestring;
212 $contenthash{'languagesarray'} = \@languagesarray;
213 $contenthash{'includepatharray'} = \@includepatharray;
214 $contenthash{'allvariableshash'} = \%allvariableshash;
216 return \%contenthash;