msiglobal.pm (f5a0c083) msiglobal.pm (677600b0)
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

--- 117 unchanged lines hidden (view full) ---

126 }
127
128 $sourcepath =~ s/\Q$windowstemppath\E//;
129 $sourcepath =~ s/^\\//;
130
131 return $sourcepath;
132}
133
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

--- 117 unchanged lines hidden (view full) ---

126 }
127
128 $sourcepath =~ s/\Q$windowstemppath\E//;
129 $sourcepath =~ s/^\\//;
130
131 return $sourcepath;
132}
133
134##########################################################################
135# Returning the order of the sequences in the files array.
136##########################################################################
137
134
138sub get_sequenceorder
139{
140 my ($filesref) = @_;
141
142 my %order = ();
143
144 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
145 {
146 my $onefile = ${$filesref}[$i];
147 if ( ! $onefile->{'assignedsequencenumber'} ) { installer::exiter::exit_program("ERROR: No sequence number assigned to $onefile->{'gid'} ($onefile->{'uniquename'})!", "get_sequenceorder"); }
148 $order{$onefile->{'assignedsequencenumber'}} = $i;
149 }
150
151 return \%order;
152}
153
154##########################################################################
155# Generation the list, in which the source of the files is connected
156# with the cabinet destination file. Because more than one file needs
157# to be included into a cab file, this has to be done via ddf files.
158##########################################################################
159
135##########################################################################
136# Generation the list, in which the source of the files is connected
137# with the cabinet destination file. Because more than one file needs
138# to be included into a cab file, this has to be done via ddf files.
139##########################################################################
140
160sub generate_cab_file_list
141sub generate_cab_file_list ($$$$)
161{
162 my ($filesref, $installdir, $ddfdir, $allvariables) = @_;
163
142{
143 my ($filesref, $installdir, $ddfdir, $allvariables) = @_;
144
164 my @cabfilelist = ();
165
166 installer::logger::include_header_into_logfile("Generating ddf files");
167
145 installer::logger::include_header_into_logfile("Generating ddf files");
146
168 $installer::logger::Lang->add_timestamp("Performance Info: ddf file generation start");
147 if ( $^O =~ /cygwin/i )
148 {
149 installer::worker::generate_cygwin_pathes($filesref);
150 }
169
151
170 if ( $^O =~ /cygwin/i ) { installer::worker::generate_cygwin_pathes($filesref); }
152 # Make sure that all files point to the same cabinet file.
153 # Multiple cabinet files are not supported anymore.
154 my $cabinetfile = $filesref->[0]->{'cabinet'};
155 foreach my $onefile (@$filesref)
156 {
157 if ($onefile->{'cabinet'} ne $cabinetfile)
158 {
159 installer::exiter::exit_program(
160 "ERROR: multiple cabinet files are not supported",
161 "generate_cab_file_list");
162 }
163 }
171
164
172 if ( $installer::globals::fix_number_of_cab_files )
173 {
174 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
175 {
176 my $onefile = ${$filesref}[$i];
177 my $cabinetfile = $onefile->{'cabinet'};
178 my $sourcepath = $onefile->{'sourcepath'};
179 if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
180 my $uniquename = $onefile->{'uniquename'};
165 # Sort files on the sequence number.
166 my @sorted_files = sort {$a->{'sequencenumber'} <=> $b->{'sequencenumber'}} @$filesref;
181
167
182 my $styles = "";
183 my $doinclude = 1;
184 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
185 if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
186
168 my @ddffile = ();
169 write_ddf_file_header(\@ddffile, $cabinetfile, $installdir);
170 foreach my $onefile (@sorted_files)
171 {
172 my $styles = $onefile->{'Styles'} // "";
173 if ($styles =~ /\bDONT_PACK\b/)
174 {
175 $installer::logger::Lang->printf(" excluding '%s' from ddf\n", $onefile->{'uniquename'});
176 }
177
178 my $uniquename = $onefile->{'uniquename'};
179 my $sourcepath = $onefile->{'sourcepath'};
180 if ( $^O =~ /cygwin/i )
181 {
182 $sourcepath = $onefile->{'cyg_sourcepath'};
183 }
187
184
188 # to avoid lines with more than 256 characters, it can be useful to use relative pathes
189 if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
185 # to avoid lines with more than 256 characters, it can be useful to use relative pathes
186 if ($allvariables->{'RELATIVE_PATHES_IN_DDF'})
187 {
188 $sourcepath = make_relative_ddf_path($sourcepath);
189 }
190
190
191 # all files with the same cabinetfile are directly behind each other in the files collector
191 my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
192 push(@ddffile, $ddfline);
192
193
193 my @ddffile = ();
194 $installer::logger::Lang->printf(" adding '%s' with sequence %d to ddf\n",
195 $onefile->{'uniquename'},
196 $onefile->{'sequencenumber'});
197 }
198 # creating the DDF file
194
199
195 write_ddf_file_header(\@ddffile, $cabinetfile, $installdir);
196
197 my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
198 if ( $doinclude ) { push(@ddffile, $ddfline); }
200 my $ddffilename = $cabinetfile;
201 $ddffilename =~ s/.cab/.ddf/;
202 $ddfdir =~ s/\Q$installer::globals::separator\E\s*$//;
203 $ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
204
205 installer::files::save_file($ddffilename ,\@ddffile);
206 $installer::logger::Lang->print("Created ddf file: %s\n", $ddffilename);
199
207
200 my $nextfile = ${$filesref}[$i+1];
201 my $nextcabinetfile = "";
202
203 if ( $nextfile->{'cabinet'} ) { $nextcabinetfile = $nextfile->{'cabinet'}; }
204
205 while ( $nextcabinetfile eq $cabinetfile )
206 {
207 $sourcepath = $nextfile->{'sourcepath'};
208 if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; }
209 # to avoid lines with more than 256 characters, it can be useful to use relative pathes
210 if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
211 $uniquename = $nextfile->{'uniquename'};
212 my $localdoinclude = 1;
213 my $nextfilestyles = "";
214 if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; }
215 if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; }
216 $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
217 if ( $localdoinclude ) { push(@ddffile, $ddfline); }
218 $i++; # increasing the counter!
219 $nextfile = ${$filesref}[$i+1];
220 if ( $nextfile ) { $nextcabinetfile = $nextfile->{'cabinet'}; }
221 else { $nextcabinetfile = "_lastfile_"; }
222 }
223
224 # creating the DDF file
208 # lines in ddf files must not be longer than 256 characters
209 check_ddf_file(\@ddffile, $ddffilename);
225
210
226 my $ddffilename = $cabinetfile;
227 $ddffilename =~ s/.cab/.ddf/;
228 $ddfdir =~ s/\Q$installer::globals::separator\E\s*$//;
229 $ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
211 # collecting all ddf files
212 push(@installer::globals::allddffiles, $ddffilename);
230
213
231 installer::files::save_file($ddffilename ,\@ddffile);
232 my $infoline = "Created ddf file: $ddffilename\n";
233 $installer::logger::Lang->print($infoline);
234
235 # lines in ddf files must not be longer than 256 characters
236 check_ddf_file(\@ddffile, $ddffilename);
237
238 # Writing the makecab system call
239
240 my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n";
241
242 push(@cabfilelist, $oneline);
243
244 # collecting all ddf files
245 push(@installer::globals::allddffiles, $ddffilename);
246 }
247 }
248 elsif ( $installer::globals::one_cab_file )
249 {
250 my @ddffile = ();
251
252 my $cabinetfile = "";
253
254 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
255 {
256 my $onefile = ${$filesref}[$i];
257 $cabinetfile = $onefile->{'cabinet'};
258 my $sourcepath = $onefile->{'sourcepath'};
259 if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
260 my $uniquename = $onefile->{'uniquename'};
261
262 # to avoid lines with more than 256 characters, it can be useful to use relative pathes
263 if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
264
265 if ( $i == 0 ) { write_ddf_file_header(\@ddffile, $cabinetfile, $installdir); }
266
267 my $styles = "";
268 my $doinclude = 1;
269 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
270 if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
271
272 my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
273 if ( $doinclude ) { push(@ddffile, $ddfline); }
274 }
275
276 # creating the DDF file
277
278 my $ddffilename = $cabinetfile;
279 $ddffilename =~ s/.cab/.ddf/;
280 $ddfdir =~ s/[\/\\]\s*$//;
281 $ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
282
283 installer::files::save_file($ddffilename ,\@ddffile);
284 my $infoline = "Created ddf file: $ddffilename\n";
285 $installer::logger::Lang->print($infoline);
286
287 # lines in ddf files must not be longer than 256 characters
288 check_ddf_file(\@ddffile, $ddffilename);
289
290 # Writing the makecab system call
291
292 my $oneline = "makecab.exe /F " . $ddffilename . "\n";
293
294 push(@cabfilelist, $oneline);
295
296 # collecting all ddf files
297 push(@installer::globals::allddffiles, $ddffilename);
298 }
299 else
300 {
301 installer::exiter::exit_program("ERROR: No cab file specification in globals.pm !", "create_media_table");
302 }
303
304 $installer::logger::Lang->add_timestamp("Performance Info: ddf file generation end");
305
306 return \@cabfilelist; # contains all system calls for packaging process
214 # Writing the makecab system call
215 # Return a list with all system calls for packaging process.
216 my @cabfilelist = ("makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n");
217 return \@cabfilelist;
307}
308
218}
219
309########################################################################
310# Returning the file sequence of a specified file.
311########################################################################
312
220
313sub get_file_sequence
314{
315 my ($filesref, $uniquefilename) = @_;
316
221
317 my $sequence = "";
318 my $found_sequence = 0;
319
320 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
321 {
322 my $onefile = ${$filesref}[$i];
323 my $uniquename = $onefile->{'uniquename'};
324
325 if ( $uniquename eq $uniquefilename )
326 {
327 $sequence = $onefile->{'sequencenumber'};
328 $found_sequence = 1;
329 last;
330 }
331 }
332
333 if ( ! $found_sequence ) { installer::exiter::exit_program("ERROR: No sequence found for $uniquefilename !", "get_file_sequence"); }
334
335 return $sequence;
336}
337
338
339#################################################################
340# Returning the name of the msi database
341#################################################################
342
343sub get_msidatabasename
344{
345 my ($allvariableshashref, $language) = @_;
346

--- 1570 unchanged lines hidden ---
222#################################################################
223# Returning the name of the msi database
224#################################################################
225
226sub get_msidatabasename
227{
228 my ($allvariableshashref, $language) = @_;
229

--- 1570 unchanged lines hidden ---