xref: /AOO41X/main/solenv/bin/modules/installer/followme.pm (revision fe22d2cfc602815794415026f1317bd625db6f83)
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::Info->printf("... creating \"follow me\" info file %s.\n", $downloadinfofilename);
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::Info->print("\n");
111    $installer::logger::Info->printf("... reading \"follow me\" info file %s\n", $filename);
112
113    my %contenthash = ();
114
115    my $finalinstalldir = "";
116    my $downloadname = "";
117    my $currentinstallnumber = "";
118    my $loggingdir = "";
119    my $installlogdir = "";
120    my $languagestring = "";
121    my @includepatharray = ();
122    my @languagesarray = ();
123    my %allvariableshash = ();
124
125    # Global variables can be set directly
126
127    my $filecontent = installer::files::read_file($filename);
128
129    # First line has to contain the string "finalinstalldir:".
130    # Otherwise this is not a correct file.
131
132
133    if ( ! ( ${$filecontent}[0] =~ /s*finalinstalldir:\s*(.*?)\s*$/ )) { installer::exiter::exit_program("ERROR: Not a correct download info file: $filename", "read_download_info"); }
134
135    for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
136    {
137        my $line = ${$filecontent}[$i];
138
139        if ( $line =~ /^\s*finalinstalldir:\s*(.*?)\s*$/ ) { $finalinstalldir = $1; }
140        if( $^O =~ /cygwin/i ) { $finalinstalldir =~ s/\\/\//; }
141        if ( $line =~ /^\s*downloadname:\s*(.*?)\s*$/ ) { $downloadname = $1; }
142        if ( $line =~ /^\s*currentinstallnumber:\s*(.*?)\s*$/ ) { $currentinstallnumber = $1; }
143        if ( $line =~ /^\s*loggingdir:\s*(.*?)\s*$/ ) { $loggingdir = $1; }
144        if( $^O =~ /cygwin/i ) { $loggingdir =~ s/\\/\//; }
145        if ( $line =~ /^\s*installlogdir:\s*(.*?)\s*$/ ) { $installlogdir = $1; }
146        if( $^O =~ /cygwin/i ) { $installlogdir =~ s/\\/\//; }
147        if ( $line =~ /^\s*languagestring:\s*(.*?)\s*$/ ) { $languagestring = $1; }
148        if ( $line =~ /^\s*languagesarray:\s*(.*?)\s*$/ ) { push(@languagesarray, $1); }
149        if ( $line =~ /^\s*includepatharray:\s*(.*?)\s*$/ )
150        {
151            my $path = $1;
152            if( $^O =~ /cygwin/i ) { $path  =~ s/\\/\//; }
153            push(@includepatharray, $path . "\n");
154        }
155        if ( $line =~ /^\s*allvariableshash:\s*(.*?)\s*:\s*(.*?)\s*$/ ) { $allvariableshash{$1} = $2; }
156        if ( $line =~ /^\s*globals:(.*?)\s*:\s*(.*?)\s*$/ )
157        {
158            my $name = $1;
159            my $value = $2;
160            if ( $name eq "updatepack" ) { $installer::globals::updatepack = $value; }
161            if ( $name eq "added_english" ) { $installer::globals::added_english = $value; }
162            if ( $name eq "iswindowsbuild" ) { $installer::globals::iswindowsbuild = $value; }
163            if ( $name eq "issolarisbuild" ) { $installer::globals::issolarisbuild = $value; }
164            if ( $name eq "issolarispkgbuild" ) { $installer::globals::issolarispkgbuild = $value; }
165            if ( $name eq "issolarissparcbuild" ) { $installer::globals::issolarissparcbuild = $value; }
166            if ( $name eq "issolarisx86build" ) { $installer::globals::issolarisx86build = $value; }
167            if ( $name eq "isfreebsdpkgbuild" ) { $installer::globals::isfreebsdpkgbuild = $value; }
168            if ( $name eq "islinuxbuild" ) { $installer::globals::islinuxbuild = $value; }
169            if ( $name eq "islinuxrpmbuild" ) { $installer::globals::islinuxrpmbuild = $value; }
170            if ( $name eq "islinuxintelrpmbuild" ) { $installer::globals::islinuxintelrpmbuild = $value; }
171            if ( $name eq "islinuxppcrpmbuild" ) { $installer::globals::islinuxppcrpmbuild = $value; }
172            if ( $name eq "islinuxx86_64rpmbuild" ) { $installer::globals::islinuxx86_64rpmbuild = $value; }
173            if ( $name eq "islinuxdebbuild" ) { $installer::globals::islinuxdebbuild = $value; }
174            if ( $name eq "islinuxinteldebbuild" ) { $installer::globals::islinuxinteldebbuild = $value; }
175            if ( $name eq "islinuxppcdebbuild" ) { $installer::globals::islinuxppcdebbuild = $value; }
176            if ( $name eq "islinuxx86_64debbuild" ) { $installer::globals::islinuxx86_64debbuild = $value; }
177            if ( $name eq "issolaris" ) { $installer::globals::issolaris = $value; }
178            if ( $name eq "islinux" ) { $installer::globals::islinux = $value; }
179            if ( $name eq "unpackpath" ) { $installer::globals::unpackpath = $value; }
180            if( $^O =~ /cygwin/i ) { $installer::globals::unpackpath =~ s/\\/\//; }
181            if ( $name eq "idttemplatepath" ) { $installer::globals::idttemplatepath = $value; }
182            if( $^O =~ /cygwin/i ) { $installer::globals::idttemplatepath =~ s/\\/\//; }
183            if ( $name eq "idtlanguagepath" ) { $installer::globals::idtlanguagepath = $value; }
184            if( $^O =~ /cygwin/i ) { $installer::globals::idtlanguagepath =~ s/\\/\//; }
185            if ( $name eq "logfilename" ) { $installer::globals::logfilename = $value; }
186            if ( $name eq "product" ) { $installer::globals::product = $value; }
187            if ( $name eq "patch" ) { $installer::globals::patch = $value; }
188            if ( $name eq "languagepack" ) { $installer::globals::languagepack = $value; }
189            if ( $name eq "installertypedir" ) { $installer::globals::installertypedir = $value; }
190            if ( $name eq "max_lang_length" ) { $installer::globals::max_lang_length = $value; }
191            if ( $name eq "compiler" ) { $installer::globals::compiler = $value; }
192            if ( $name eq "product" ) { $installer::globals::product = $value; }
193            if ( $name eq "minor" ) { $installer::globals::minor = $value; }
194            if ( $name eq "lastminor" ) { $installer::globals::lastminor = $value; }
195            if ( $name eq "nsisfilename" ) { $installer::globals::nsisfilename = $value; }
196        }
197    }
198
199    $contenthash{'finalinstalldir'} = $finalinstalldir;
200    $contenthash{'downloadname'} = $downloadname;
201    $contenthash{'currentinstallnumber'} = $currentinstallnumber;
202    $contenthash{'loggingdir'} = $loggingdir;
203    $contenthash{'installlogdir'} = $installlogdir;
204    $contenthash{'languagestring'} = $languagestring;
205    $contenthash{'languagesarray'} = \@languagesarray;
206    $contenthash{'includepatharray'} = \@includepatharray;
207    $contenthash{'allvariableshash'} = \%allvariableshash;
208
209    return \%contenthash;
210}
211
2121;
213