file.pm (dca4887f) file.pm (1ba1fd99)
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

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

42##########################################################################
43
44sub assign_cab_to_files
45{
46 my ( $filesref ) = @_;
47
48 my $infoline = "";
49
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

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

42##########################################################################
43
44sub assign_cab_to_files
45{
46 my ( $filesref ) = @_;
47
48 my $infoline = "";
49
50 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
50 foreach my $file (@$filesref)
51 {
51 {
52 if ( ! exists(${$filesref}[$i]->{'modules'}) ) { installer::exiter::exit_program("ERROR: No module assignment found for ${$filesref}[$i]->{'gid'} !", "assign_cab_to_files"); }
53 my $module = ${$filesref}[$i]->{'modules'};
52 if ( ! exists($file->{'modules'}) )
53 {
54 installer::exiter::exit_program(
55 sprintf("ERROR: No module assignment found for %s", $file->{'gid'}),
56 "assign_cab_to_files");
57 }
58 my $module = $file->{'modules'};
54 # If modules contains a list of modules, only taking the first one.
55 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
56
59 # If modules contains a list of modules, only taking the first one.
60 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
61
57 if ( ! exists($installer::globals::allcabinetassigns{$module}) ) { installer::exiter::exit_program("ERROR: No cabinet file assigned to module \"$module\" (${$filesref}[$i]->{'gid'}) !", "assign_cab_to_files"); }
58 ${$filesref}[$i]->{'assignedcabinetfile'} = $installer::globals::allcabinetassigns{$module};
62 if ( ! exists($installer::globals::allcabinetassigns{$module}) )
63 {
64 installer::exiter::exit_program(
65 sprintf("ERROR: No cabinet file assigned to module \"%s\" %s",
66 $module,
67 $file->{'gid'}),
68 "assign_cab_to_files");
69 }
70 $file->{'assignedcabinetfile'} = $installer::globals::allcabinetassigns{$module};
59
60 # Counting the files in each cabinet file
71
72 # Counting the files in each cabinet file
61 if ( ! exists($installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}}) )
73 if ( ! exists($installer::globals::cabfilecounter{$file->{'assignedcabinetfile'}}) )
62 {
74 {
63 $installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}} = 1;
75 $installer::globals::cabfilecounter{$file->{'assignedcabinetfile'}} = 1;
64 }
65 else
66 {
76 }
77 else
78 {
67 $installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}}++;
79 $installer::globals::cabfilecounter{$file->{'assignedcabinetfile'}}++;
68 }
69 }
70
80 }
81 }
82
71 # logging the number of files in each cabinet file
72
73 $installer::logger::Lang->print("\n");
74 $installer::logger::Lang->print("Cabinet file content:\n");
75 my $cabfile;
76 foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
77 {
78 $infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile} files\n";
79 $installer::logger::Lang->print($infoline);
80 }
81
82 # assigning startsequencenumbers for each cab file
83 # assigning startsequencenumbers for each cab file
83
84
85 my %count = ();
84 my $offset = 1;
86 my $offset = 1;
85 foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
87 foreach my $cabfile ( sort keys %installer::globals::cabfilecounter )
86 {
87 my $filecount = $installer::globals::cabfilecounter{$cabfile};
88 {
89 my $filecount = $installer::globals::cabfilecounter{$cabfile};
90 $count{$cabfile} = $filecount;
88 $installer::globals::cabfilecounter{$cabfile} = $offset;
89 $offset = $offset + $filecount;
90
91 $installer::globals::lastsequence{$cabfile} = $offset - 1;
92 }
91 $installer::globals::cabfilecounter{$cabfile} = $offset;
92 $offset = $offset + $filecount;
93
94 $installer::globals::lastsequence{$cabfile} = $offset - 1;
95 }
93
94 # logging the start sequence numbers
95
96
96 $installer::logger::Lang->print("\n");
97 $installer::logger::Lang->print("Cabinet file start sequences:\n");
98 foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
99 {
100 $infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile}\n";
101 $installer::logger::Lang->print($infoline);
102 }
97 # logging the number of files in each cabinet file
103
98
104 # logging the last sequence numbers
105
106 $installer::logger::Lang->print("\n");
99 $installer::logger::Lang->print("\n");
107 $installer::logger::Lang->print("Cabinet file last sequences:\n");
108 foreach $cabfile ( sort keys %installer::globals::lastsequence )
100 $installer::logger::Lang->print("Cabinet files:\n");
101 foreach my $cabfile (sort keys %installer::globals::cabfilecounter)
109 {
102 {
110 $infoline = "$cabfile : $installer::globals::lastsequence{$cabfile}\n";
111 $installer::logger::Lang->print($infoline);
103 $installer::logger::Lang->printf(
104 "%-30s : %4s files, from %4d to %4d\n",
105 $cabfile,
106 $count{$cabfile},
107 $installer::globals::cabfilecounter{$cabfile},
108 $installer::globals::lastsequence{$cabfile});
112 }
113}
114
115##########################################################################
116# Assigning sequencenumbers to files. This is requrired,
117# if cabinet files shall be equivalent to packages.
118##########################################################################
119
120sub assign_sequencenumbers_to_files
121{
122 my ( $filesref ) = @_;
123
124 my %directaccess = ();
125 my %allassigns = ();
109 }
110}
111
112##########################################################################
113# Assigning sequencenumbers to files. This is requrired,
114# if cabinet files shall be equivalent to packages.
115##########################################################################
116
117sub assign_sequencenumbers_to_files
118{
119 my ( $filesref ) = @_;
120
121 my %directaccess = ();
122 my %allassigns = ();
126
123
127 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
128 {
129 my $onefile = ${$filesref}[$i];
130
131 # Keeping order in cabinet files
132 # -> collecting all files in one cabinet file
133 # -> sorting files and assigning numbers
134

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

156 my $cabfile;
157 foreach $cabfile ( sort keys %allassigns )
158 {
159 my $counter = $installer::globals::cabfilecounter{$cabfile};
160 my $dest;
161 foreach $dest ( sort keys %{$allassigns{$cabfile}} ) # <- sorting the destination!
162 {
163 my $directaccessnumber = $directaccess{$dest};
124 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
125 {
126 my $onefile = ${$filesref}[$i];
127
128 # Keeping order in cabinet files
129 # -> collecting all files in one cabinet file
130 # -> sorting files and assigning numbers
131

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

153 my $cabfile;
154 foreach $cabfile ( sort keys %allassigns )
155 {
156 my $counter = $installer::globals::cabfilecounter{$cabfile};
157 my $dest;
158 foreach $dest ( sort keys %{$allassigns{$cabfile}} ) # <- sorting the destination!
159 {
160 my $directaccessnumber = $directaccess{$dest};
164 ${$filesref}[$directaccessnumber]->{'assignedsequencenumber'} = $counter;
161 ${$filesref}[$directaccessnumber]->{'assignedsequencenumber'} = $counter;
165 $counter++;
166 }
167 }
168}
169
170#########################################################
171# Create a shorter version of a long component name,
172# because maximum length in msi database is 72.

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

368 # The filename sbasic.idx/OFFSETS is changed to OFFSETS, but OFFSETS is not unique.
369 # In this procedure names like OFFSETS5 are produced. And exactly this string has to be added to
370 # the array of all files.
371
372 my $uniquefilename = "";
373 my $counter = 0;
374
375 if ( $fileref->{'Name'} ) { $uniquefilename = $fileref->{'Name'}; }
162 $counter++;
163 }
164 }
165}
166
167#########################################################
168# Create a shorter version of a long component name,
169# because maximum length in msi database is 72.

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

365 # The filename sbasic.idx/OFFSETS is changed to OFFSETS, but OFFSETS is not unique.
366 # In this procedure names like OFFSETS5 are produced. And exactly this string has to be added to
367 # the array of all files.
368
369 my $uniquefilename = "";
370 my $counter = 0;
371
372 if ( $fileref->{'Name'} ) { $uniquefilename = $fileref->{'Name'}; }
373 # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
374 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$uniquefilename);
376
375
377 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$uniquefilename); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
378
379 # Reading unique filename with help of "Component_" in File table from old database
380 if (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::savedmapping{"$component/$uniquefilename"}) ))
381 {
382 # If we have a FTK mapping for this component/file, use it.
383 $installer::globals::savedmapping{"$component/$uniquefilename"} =~ m/^(.*);/;
384 $uniquefilename = $1;
385 $lcuniquefilename = lc($uniquefilename);
386 $installer::globals::alluniquefilenames{$uniquefilename} = 1;
387 $installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
388 return $uniquefilename;
389 }
390
391 $uniquefilename =~ s/\-/\_/g; # no "-" allowed
392 $uniquefilename =~ s/\@/\_/g; # no "@" allowed
393 $uniquefilename =~ s/\$/\_/g; # no "$" allowed
394 $uniquefilename =~ s/^\s*\./\_/g; # no "." at the beginning allowed allowed
395 $uniquefilename =~ s/^\s*\d/\_d/g; # no number at the beginning allowed allowed (even file "0.gif", replacing to "_d.gif")
396 $uniquefilename =~ s/org_openoffice_/ooo_/g; # shorten the unique file name
397
398 my $lcuniquefilename = lc($uniquefilename); # only lowercase names
399
400 my $newname = 0;
401
376 $uniquefilename =~ s/\-/\_/g; # no "-" allowed
377 $uniquefilename =~ s/\@/\_/g; # no "@" allowed
378 $uniquefilename =~ s/\$/\_/g; # no "$" allowed
379 $uniquefilename =~ s/^\s*\./\_/g; # no "." at the beginning allowed allowed
380 $uniquefilename =~ s/^\s*\d/\_d/g; # no number at the beginning allowed allowed (even file "0.gif", replacing to "_d.gif")
381 $uniquefilename =~ s/org_openoffice_/ooo_/g; # shorten the unique file name
382
383 my $lcuniquefilename = lc($uniquefilename); # only lowercase names
384
385 my $newname = 0;
386
402 if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}) &&
403 ! exists($installer::globals::savedrevmapping{$lcuniquefilename}) )
387 if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}))
404 {
405 $installer::globals::alluniquefilenames{$uniquefilename} = 1;
406 $installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
407 $newname = 1;
408 }
409
410 if ( ! $newname )
411 {

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

426 else
427 {
428 $uniquefilename = $uniquefilenamebase . $counter;
429 }
430
431 $newname = 0;
432 $lcuniquefilename = lc($uniquefilename); # only lowercase names
433
388 {
389 $installer::globals::alluniquefilenames{$uniquefilename} = 1;
390 $installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
391 $newname = 1;
392 }
393
394 if ( ! $newname )
395 {

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

410 else
411 {
412 $uniquefilename = $uniquefilenamebase . $counter;
413 }
414
415 $newname = 0;
416 $lcuniquefilename = lc($uniquefilename); # only lowercase names
417
434 if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}) &&
435 ! exists($installer::globals::savedrevmapping{$lcuniquefilename}) )
418 if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}))
436 {
437 $installer::globals::alluniquefilenames{$uniquefilename} = 1;
438 $installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
439 $newname = 1;
440 }
441 }
442 until ( $newname )
443 }

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

453
454sub generate_filename_for_filetable ($$)
455{
456 my ($fileref, $shortnamesref) = @_;
457
458 my $returnstring = "";
459
460 my $filename = $fileref->{'Name'};
419 {
420 $installer::globals::alluniquefilenames{$uniquefilename} = 1;
421 $installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
422 $newname = 1;
423 }
424 }
425 until ( $newname )
426 }

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

436
437sub generate_filename_for_filetable ($$)
438{
439 my ($fileref, $shortnamesref) = @_;
440
441 my $returnstring = "";
442
443 my $filename = $fileref->{'Name'};
444
445 # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
446 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$filename);
461
447
462 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$filename); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
448 my $shortstring = installer::windows::idtglobal::make_eight_three_conform_with_hash($filename, "file", $shortnamesref);
463
449
464 my $shortstring;
465
466 # Reading short string with help of "FileName" in File table from old database
467 if (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::savedmapping{"$fileref->{'componentname'}/$filename"}) ))
468 {
469 $installer::globals::savedmapping{"$fileref->{'componentname'}/$filename"} =~ m/.*;(.*)/;
470 if ($1 ne '')
471 {
472 $shortstring = $1;
473 }
474 else
475 {
476 $shortstring = installer::windows::idtglobal::make_eight_three_conform_with_hash($filename, "file", $shortnamesref);
477 }
478 }
450 if ( $shortstring eq $filename )
451 {
452 # nothing changed
453 $returnstring = $filename;
454 }
479 else
455 else
480 {
481 $shortstring = installer::windows::idtglobal::make_eight_three_conform_with_hash($filename, "file", $shortnamesref);
482 }
456 {
457 $returnstring = $shortstring . "\|" . $filename;
458 }
483
459
484 if ( $shortstring eq $filename ) { $returnstring = $filename; } # nothing changed
485 else {$returnstring = $shortstring . "\|" . $filename; }
486
487 return $returnstring;
488}
489
490#########################################
491# Returning the filesize of a file
492#########################################
493
494sub get_filesize

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

519sub get_fileversion
520{
521 my ($onefile, $allvariables, $styles) = @_;
522
523 my $fileversion = "";
524
525 if ( $allvariables->{'USE_FILEVERSION'} )
526 {
460 return $returnstring;
461}
462
463#########################################
464# Returning the filesize of a file
465#########################################
466
467sub get_filesize

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

492sub get_fileversion
493{
494 my ($onefile, $allvariables, $styles) = @_;
495
496 my $fileversion = "";
497
498 if ( $allvariables->{'USE_FILEVERSION'} )
499 {
527 if ( ! $allvariables->{'LIBRARYVERSION'} ) { installer::exiter::exit_program("ERROR: USE_FILEVERSION is set, but not LIBRARYVERSION", "get_fileversion"); }
500 if ( ! $allvariables->{'LIBRARYVERSION'} )
501 {
502 installer::exiter::exit_program("ERROR: USE_FILEVERSION is set, but not LIBRARYVERSION", "get_fileversion");
503 }
528 my $libraryversion = $allvariables->{'LIBRARYVERSION'};
529 if ( $libraryversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
530 {
531 my $major = $1;
532 my $minor = $2;
533 my $micro = $3;
534 my $concat = 100 * $minor + $micro;
535 $libraryversion = $major . "\." . $concat;
536 }
537 my $vendornumber = 0;
504 my $libraryversion = $allvariables->{'LIBRARYVERSION'};
505 if ( $libraryversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
506 {
507 my $major = $1;
508 my $minor = $2;
509 my $micro = $3;
510 my $concat = 100 * $minor + $micro;
511 $libraryversion = $major . "\." . $concat;
512 }
513 my $vendornumber = 0;
538 if ( $allvariables->{'VENDORPATCHVERSION'} ) { $vendornumber = $allvariables->{'VENDORPATCHVERSION'}; }
514 if ( $allvariables->{'VENDORPATCHVERSION'} )
515 {
516 $vendornumber = $allvariables->{'VENDORPATCHVERSION'};
517 }
539 $fileversion = $libraryversion . "\." . $installer::globals::buildid . "\." . $vendornumber;
518 $fileversion = $libraryversion . "\." . $installer::globals::buildid . "\." . $vendornumber;
540 if ( $onefile->{'FileVersion'} ) { $fileversion = $onefile->{'FileVersion'}; } # overriding FileVersion in scp
541
542 # if ( $styles =~ /\bFONT\b/ )
543 # {
544 # my $newfileversion = installer::windows::font::get_font_version($onefile->{'sourcepath'});
545 # if ( $newfileversion != 0 ) { $fileversion = $newfileversion; }
546 # }
519 if ( $onefile->{'FileVersion'} )
520 {
521 # overriding FileVersion in scp
522 $fileversion = $onefile->{'FileVersion'};
523 }
547 }
548
524 }
525
549 if ( $installer::globals::prepare_winpatch ) { $fileversion = ""; } # Windows patches do not allow this version # -> who says so?
526 if ( $installer::globals::prepare_winpatch )
527 {
528 # Windows patches do not allow this version # -> who says so?
529 $fileversion = "";
530 }
550
551 return $fileversion;
552}
553
554#############################################
555# Returning the Windows language of a file
556#############################################
557

--- 322 unchanged lines hidden ---
531
532 return $fileversion;
533}
534
535#############################################
536# Returning the Windows language of a file
537#############################################
538

--- 322 unchanged lines hidden ---