Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / windows / idtglobal.pm
blob8cbfcb24b2b8a096c39166290bce2b5653cca26d
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::windows::idtglobal;
21 use Cwd;
22 use installer::converter;
23 use installer::exiter;
24 use installer::files;
25 use installer::globals;
26 use installer::pathanalyzer;
27 use installer::remover;
28 use installer::scriptitems;
29 use installer::systemactions;
30 use installer::windows::language;
32 ##############################################################
33 # Shorten the gid for a feature.
34 # Attention: Maximum length is 38
35 ##############################################################
37 sub shorten_feature_gid
39 my ($stringref) = @_;
41 $$stringref =~ s/gid_Module_/gm_/;
42 $$stringref =~ s/_Extension_/_ex_/;
43 $$stringref =~ s/_Root_/_r_/;
44 $$stringref =~ s/_Prg_/_p_/;
45 $$stringref =~ s/_Optional_/_o_/;
46 $$stringref =~ s/_Tools_/_tl_/;
47 $$stringref =~ s/_Wrt_Flt_/_w_f_/;
48 $$stringref =~ s/_Productivity_/_pr_/;
49 # $$stringref =~ s/_Replacement_/_rpl_/; # native373 fix
52 ############################################
53 # Getting the next free number, that
54 # can be added.
55 # Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
56 ############################################
58 sub get_next_free_number
60 my ($name, $shortnamesref) = @_;
62 my $counter = 0;
63 my $dontsave = 0;
64 my $alreadyexists;
65 my ($newname, $shortname);
69 $alreadyexists = 0;
70 $counter++;
71 $newname = $name . $counter;
73 for ( my $i = 0; $i <= $#{$shortnamesref}; $i++ )
75 $shortname = ${$shortnamesref}[$i];
77 if ( uc($shortname) eq uc($newname) ) # case insensitive
79 $alreadyexists = 1;
80 last;
84 until (!($alreadyexists));
86 if (( $counter > 9 ) && ( length($name) > 6 )) { $dontsave = 1; }
87 if (( $counter > 99 ) && ( length($name) > 5 )) { $dontsave = 1; }
89 if (!($dontsave))
91 push(@{$shortnamesref}, $newname); # adding the new shortname to the array of shortnames
94 return $counter
97 ############################################
98 # Getting the next free number, that
99 # can be added.
100 # Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
101 ############################################
103 sub get_next_free_number_with_hash
105 my ($name, $shortnamesref, $ext) = @_;
107 my $counter = 0;
108 my $dontsave = 0;
109 my $saved = 0;
110 my $alreadyexists;
111 my ($newname, $shortname);
115 $alreadyexists = 0;
116 $counter++;
117 $newname = $name . $counter;
118 $newname = uc($newname); # case insensitive, always upper case
119 if ( exists($shortnamesref->{$newname}) ||
120 exists($installer::globals::savedrev83mapping{$newname.$ext}) )
122 $alreadyexists = 1;
125 until (!($alreadyexists));
127 if (( $counter > 9 ) && ( length($name) > 6 )) { $dontsave = 1; }
128 if (( $counter > 99 ) && ( length($name) > 5 )) { $dontsave = 1; }
130 if (!($dontsave))
132 $shortnamesref->{$newname} = 1; # adding the new shortname to the array of shortnames, always uppercase
133 $saved = 1;
136 return ( $counter, $saved )
139 #########################################
140 # 8.3 for filenames and directories
141 #########################################
143 sub make_eight_three_conform
145 my ($inputstring, $pattern, $shortnamesref) = @_;
147 # all shortnames are collected in $shortnamesref, because of uniqueness
149 my ($name, $namelength, $number);
150 my $conformstring = "";
151 my $changed = 0;
153 if (( $inputstring =~ /^\s*(.*?)\.(.*?)\s*$/ ) && ( $pattern eq "file" )) # files with a dot
155 $name = $1;
156 my $extension = $2;
158 $namelength = length($name);
159 my $extensionlength = length($extension);
161 if ( $extensionlength > 3 )
163 # simply taking the first three letters
164 $extension = substr($extension, 0, 3); # name, offset, length
167 # Attention: readme.html -> README~1.HTM
169 if (( $namelength > 8 ) || ( $extensionlength > 3 ))
171 # taking the first six letters
172 $name = substr($name, 0, 6); # name, offset, length
173 $name =~ s/\s*$//; # removing ending whitespaces
174 $name = $name . "\~";
175 $number = get_next_free_number($name, $shortnamesref);
177 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
179 if ( $number > 9 )
181 $name = substr($name, 0, 5); # name, offset, length
182 $name =~ s/\s*$//; # removing ending whitespaces
183 $name = $name . "\~";
184 $number = get_next_free_number($name, $shortnamesref);
186 if ( $number > 99 )
188 $name = substr($name, 0, 4); # name, offset, length
189 $name =~ s/\s*$//; # removing ending whitespaces
190 $name = $name . "\~";
191 $number = get_next_free_number($name, $shortnamesref);
195 $name = $name . "$number";
197 $changed = 1;
200 $conformstring = $name . "\." . $extension;
202 if ( $changed ) { $conformstring= uc($conformstring); }
204 else # no dot in filename or directory (also used for shortcuts)
206 $name = $inputstring;
207 $namelength = length($name);
209 if ( $namelength > 8 )
211 # taking the first six letters
212 $name = substr($name, 0, 6); # name, offset, length
213 $name =~ s/\s*$//; # removing ending whitespaces
214 $name = $name . "\~";
215 $number = get_next_free_number($name, $shortnamesref);
217 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
219 if ( $number > 9 )
221 $name = substr($name, 0, 5); # name, offset, length
222 $name =~ s/\s*$//; # removing ending whitespaces
223 $name = $name . "\~";
224 $number = get_next_free_number($name, $shortnamesref);
226 if ( $number > 99 )
228 $name = substr($name, 0, 4); # name, offset, length
229 $name =~ s/\s*$//; # removing ending whitespaces
230 $name = $name . "\~";
231 $number = get_next_free_number($name, $shortnamesref);
235 $name = $name . "$number";
236 $changed = 1;
237 if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; } # in directories replacing "." with "_"
240 $conformstring = $name;
242 if ( $changed ) { $conformstring = uc($name); }
245 return $conformstring;
248 #########################################
249 # 8.3 for filenames and directories
250 # $shortnamesref is a hash in this case
251 # -> performance reasons
252 #########################################
254 sub make_eight_three_conform_with_hash
256 my ($inputstring, $pattern, $shortnamesref) = @_;
258 # all shortnames are collected in $shortnamesref, because of uniqueness (a hash!)
260 my ($name, $namelength, $number);
261 my $conformstring = "";
262 my $changed = 0;
263 my $saved;
265 if (( $inputstring =~ /^\s*(.*)\.(.*?)\s*$/ ) && ( $pattern eq "file" )) # files with a dot
267 # extension has to be non-greedy, but name is. This is important to find the last dot in the filename
268 $name = $1;
269 my $extension = $2;
271 if ( $name =~ /^\s*(.*?)\s*$/ ) { $name = $1; } # now the name is also non-greedy
272 $name =~ s/\.//g; # no dots in 8+3 conform filename
274 $namelength = length($name);
275 my $extensionlength = length($extension);
277 if ( $extensionlength > 3 )
279 # simply taking the first three letters
280 $extension = substr($extension, 0, 3); # name, offset, length
281 $changed = 1;
284 # Attention: readme.html -> README~1.HTM
286 if (( $namelength > 8 ) || ( $extensionlength > 3 ))
288 # taking the first six letters, if filename is longer than 6 characters
289 if ( $namelength > 6 )
291 $name = substr($name, 0, 6); # name, offset, length
292 $name =~ s/\s*$//; # removing ending whitespaces
293 $name = $name . "\~";
294 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
296 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
298 if ( ! $saved )
300 $name = substr($name, 0, 5); # name, offset, length
301 $name =~ s/\s*$//; # removing ending whitespaces
302 $name = $name . "\~";
303 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
305 # if $number>99 the new name would be "abcde~100.xyz", which is 9+3, and therefore not allowed
307 if ( ! $saved )
309 $name = substr($name, 0, 4); # name, offset, length
310 $name =~ s/\s*$//; # removing ending whitespaces
311 $name = $name . "\~";
312 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
314 if ( ! $saved )
316 installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash");
321 $name = $name . "$number";
322 $changed = 1;
326 $conformstring = $name . "\." . $extension;
328 if ( $changed ) { $conformstring= uc($conformstring); }
330 else # no dot in filename or directory (also used for shortcuts)
332 $name = $inputstring;
333 $namelength = length($name);
335 if ( $namelength > 8 )
337 # taking the first six letters
338 $name = substr($name, 0, 6); # name, offset, length
339 $name =~ s/\s*$//; # removing ending whitespaces
340 $name = $name . "\~";
341 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
343 # if $number>9 the new name would be "abcdef~10", which is 9+0, and therefore not allowed
345 if ( ! $saved )
347 $name = substr($name, 0, 5); # name, offset, length
348 $name =~ s/\s*$//; # removing ending whitespaces
349 $name = $name . "\~";
350 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
352 # if $number>99 the new name would be "abcde~100", which is 9+0, and therefore not allowed
354 if ( ! $saved )
356 $name = substr($name, 0, 4); # name, offset, length
357 $name =~ s/\s*$//; # removing ending whitespaces
358 $name = $name . "\~";
359 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
361 if ( ! $saved ) { installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash"); }
365 $name = $name . "$number";
366 $changed = 1;
367 if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; } # in directories replacing "." with "_"
370 $conformstring = $name;
372 if ( $changed ) { $conformstring = uc($name); }
375 return $conformstring;
378 #########################################
379 # Writing the header for idt files
380 #########################################
382 sub write_idt_header
384 my ($idtref, $definestring) = @_;
386 my $oneline;
388 if ( $definestring eq "file" )
390 $oneline = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n";
391 push(@{$idtref}, $oneline);
392 $oneline = "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti4\n";
393 push(@{$idtref}, $oneline);
394 $oneline = "File\tFile\n";
395 push(@{$idtref}, $oneline);
398 if ( $definestring eq "filehash" )
400 $oneline = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n";
401 push(@{$idtref}, $oneline);
402 $oneline = "s72\ti2\ti4\ti4\ti4\ti4\n";
403 push(@{$idtref}, $oneline);
404 $oneline = "MsiFileHash\tFile_\n";
405 push(@{$idtref}, $oneline);
408 if ( $definestring eq "directory" )
410 $oneline = "Directory\tDirectory_Parent\tDefaultDir\n";
411 push(@{$idtref}, $oneline);
412 $oneline = "s72\tS72\tl255\n";
413 push(@{$idtref}, $oneline);
414 $oneline = "Directory\tDirectory\n";
415 push(@{$idtref}, $oneline);
418 if ( $definestring eq "component" )
420 $oneline = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n";
421 push(@{$idtref}, $oneline);
422 $oneline = "s72\tS38\ts72\ti2\tS255\tS72\n";
423 push(@{$idtref}, $oneline);
424 $oneline = "Component\tComponent\n";
425 push(@{$idtref}, $oneline);
428 if ( $definestring eq "feature" )
430 $oneline = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n";
431 push(@{$idtref}, $oneline);
432 $oneline = "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n";
433 push(@{$idtref}, $oneline);
434 $oneline = "65001\tFeature\tFeature\n";
435 push(@{$idtref}, $oneline);
438 if ( $definestring eq "featurecomponent" )
440 $oneline = "Feature_\tComponent_\n";
441 push(@{$idtref}, $oneline);
442 $oneline = "s38\ts72\n";
443 push(@{$idtref}, $oneline);
444 $oneline = "FeatureComponents\tFeature_\tComponent_\n";
445 push(@{$idtref}, $oneline);
448 if ( $definestring eq "media" )
450 $oneline = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n";
451 push(@{$idtref}, $oneline);
452 $oneline = "i2\ti4\tL64\tS255\tS32\tS72\n";
453 push(@{$idtref}, $oneline);
454 $oneline = "Media\tDiskId\n";
455 push(@{$idtref}, $oneline);
458 if ( $definestring eq "font" )
460 $oneline = "File_\tFontTitle\n";
461 push(@{$idtref}, $oneline);
462 $oneline = "s72\tS128\n";
463 push(@{$idtref}, $oneline);
464 $oneline = "Font\tFile_\n";
465 push(@{$idtref}, $oneline);
468 if ( $definestring eq "shortcut" )
470 $oneline = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n";
471 push(@{$idtref}, $oneline);
472 $oneline = "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n";
473 push(@{$idtref}, $oneline);
474 $oneline = "65001\tShortcut\tShortcut\n";
475 push(@{$idtref}, $oneline);
478 if ( $definestring eq "msishortcutproperty" )
480 $oneline = "MsiShortcutProperty\tShortcut_\tPropertyKey\tPropVariantValue\n";
481 push(@{$idtref}, $oneline);
482 $oneline = "s72\ts72\ts255\ts255\n";
483 push(@{$idtref}, $oneline);
484 $oneline = "MsiShortcutProperty\tMsiShortcutProperty\n";
485 push(@{$idtref}, $oneline);
488 if ( $definestring eq "registry" )
490 $oneline = "Registry\tRoot\tKey\tName\tValue\tComponent_\n";
491 push(@{$idtref}, $oneline);
492 $oneline = "s72\ti2\tl255\tL255\tL0\ts72\n";
493 push(@{$idtref}, $oneline);
494 $oneline = "Registry\tRegistry\n";
495 push(@{$idtref}, $oneline);
498 if ( $definestring eq "createfolder" )
500 $oneline = "Directory_\tComponent_\n";
501 push(@{$idtref}, $oneline);
502 $oneline = "s72\ts72\n";
503 push(@{$idtref}, $oneline);
504 $oneline = "CreateFolder\tDirectory_\tComponent_\n";
505 push(@{$idtref}, $oneline);
508 if ( $definestring eq "removefile" )
510 $oneline = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n";
511 push(@{$idtref}, $oneline);
512 $oneline = "s72\ts72\tL255\ts72\ti2\n";
513 push(@{$idtref}, $oneline);
514 $oneline = "RemoveFile\tFileKey\n";
515 push(@{$idtref}, $oneline);
518 if ( $definestring eq "upgrade" )
520 $oneline = "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n";
521 push(@{$idtref}, $oneline);
522 $oneline = "s38\tS20\tS20\tS255\ti4\tS255\ts72\n";
523 push(@{$idtref}, $oneline);
524 $oneline = "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n";
525 push(@{$idtref}, $oneline);
528 if ( $definestring eq "icon" )
530 $oneline = "Name\tData\n";
531 push(@{$idtref}, $oneline);
532 $oneline = "s72\tv0\n";
533 push(@{$idtref}, $oneline);
534 $oneline = "Icon\tName\n";
535 push(@{$idtref}, $oneline);
538 if ( $definestring eq "inifile" )
540 $oneline = "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n";
541 push(@{$idtref}, $oneline);
542 $oneline = "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n";
543 push(@{$idtref}, $oneline);
544 $oneline = "IniFile\tIniFile\n";
545 push(@{$idtref}, $oneline);
548 if ( $definestring eq "msiassembly" )
550 $oneline = "Component_\tFeature_\tFile_Manifest\tFile_Application\tAttributes\n";
551 push(@{$idtref}, $oneline);
552 $oneline = "s72\ts38\tS72\tS72\tI2\n";
553 push(@{$idtref}, $oneline);
554 $oneline = "MsiAssembly\tComponent_\n";
555 push(@{$idtref}, $oneline);
558 if ( $definestring eq "msiassemblyname" )
560 $oneline = "Component_\tName\tValue\n";
561 push(@{$idtref}, $oneline);
562 $oneline = "s72\ts255\ts255\n";
563 push(@{$idtref}, $oneline);
564 $oneline = "MsiAssemblyName\tComponent_\tName\n";
565 push(@{$idtref}, $oneline);
568 if ( $definestring eq "appsearch" )
570 $oneline = "Property\tSignature_\n";
571 push(@{$idtref}, $oneline);
572 $oneline = "s72\ts72\n";
573 push(@{$idtref}, $oneline);
574 $oneline = "AppSearch\tProperty\tSignature_\n";
575 push(@{$idtref}, $oneline);
578 if ( $definestring eq "reglocat" )
580 $oneline = "Signature_\tRoot\tKey\tName\tType\n";
581 push(@{$idtref}, $oneline);
582 $oneline = "s72\ti2\ts255\tS255\tI2\n";
583 push(@{$idtref}, $oneline);
584 $oneline = "RegLocator\tSignature_\n";
585 push(@{$idtref}, $oneline);
588 if ( $definestring eq "signatur" )
590 $oneline = "Signature\tFileName\tMinVersion\tMaxVersion\tMinSize\tMaxSize\tMinDate\tMaxDate\tLanguages\n";
591 push(@{$idtref}, $oneline);
592 $oneline = "s72\ts255\tS20\tS20\tI4\tI4\tI4\tI4\tS255\n";
593 push(@{$idtref}, $oneline);
594 $oneline = "Signature\tSignature\n";
595 push(@{$idtref}, $oneline);
600 ##############################################################
601 # Returning the name of the rranslation file for a
602 # given language.
603 # Sample: "01" oder "en-US" -> "1033.txt"
604 ##############################################################
606 sub get_languagefilename
608 my ($idtfilename, $basedir) = @_;
610 $idtfilename =~ s/\.idt/\.ulf/;
612 my $languagefilename = $basedir . $installer::globals::separator . $idtfilename;
614 return $languagefilename;
617 ##############################################################
618 # Returning the complete block in all languages
619 # for a specified string
620 ##############################################################
622 sub get_language_block_from_language_file
624 my ($searchstring, $languagefile) = @_;
626 my @language_block = ();
628 for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
630 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
632 my $counter = $i;
634 push(@language_block, ${$languagefile}[$counter]);
635 $counter++;
637 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
639 push(@language_block, ${$languagefile}[$counter]);
640 $counter++;
643 last;
647 return \@language_block;
650 ##############################################################
651 # Returning a specific language string from the block
652 # of all translations
653 ##############################################################
655 sub get_language_string_from_language_block
657 my ($language_block, $language, $oldstring) = @_;
659 my $newstring = "";
661 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
663 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
665 $newstring = $1;
666 $newstring =~ s/\\\"/\"/g; #un-escape quotes, fdo#59321
667 last;
671 if ( $newstring eq "" )
673 $language = "en-US"; # defaulting to english
675 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
677 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
679 $newstring = $1;
680 last;
685 return $newstring;
688 ##############################################################
689 # Returning a specific code from the block
690 # of all codes. No defaulting to english!
691 ##############################################################
693 sub get_code_from_code_block
695 my ($codeblock, $language) = @_;
697 my $newstring = "";
699 for ( my $i = 0; $i <= $#{$codeblock}; $i++ )
701 if ( ${$codeblock}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
703 $newstring = $1;
704 last;
708 return $newstring;
711 ##############################################################
712 # Translating an idt file
713 ##############################################################
715 sub translate_idtfile
717 my ($idtfile, $languagefile, $onelanguage) = @_;
719 for ( my $i = 0; $i <= $#{$idtfile}; $i++ )
721 my @allstrings = ();
723 my $oneline = ${$idtfile}[$i];
725 while ( $oneline =~ /\b(OOO_\w+)\b/ )
727 my $replacestring = $1;
728 push(@allstrings, $replacestring);
729 $oneline =~ s/$replacestring//;
732 my $oldstring;
734 foreach $oldstring (@allstrings)
736 my $language_block = get_language_block_from_language_file($oldstring, $languagefile);
737 my $newstring = get_language_string_from_language_block($language_block, $onelanguage, $oldstring);
739 ${$idtfile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq "" (there are empty strings for control.idt)
744 ##############################################################
745 # Copying all needed files to create a msi database
746 # into one language specific directory
747 ##############################################################
749 sub prepare_language_idt_directory
751 my ($destinationdir, $newidtdir, $onelanguage, $filesref, $iconfilecollector, $binarytablefiles, $allvariables) = @_;
753 # Copying all idt-files from the source $installer::globals::idttemplatepath to the destination $destinationdir
754 # Copying all files in the subdirectory "Binary"
755 # Copying all files in the subdirectory "Icon"
757 my $infoline = "";
759 installer::systemactions::copy_directory($installer::globals::idttemplatepath, $destinationdir);
761 if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Binary")
763 installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Binary");
764 installer::systemactions::copy_directory($installer::globals::idttemplatepath . $installer::globals::separator . "Binary", $destinationdir . $installer::globals::separator . "Binary");
767 installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Icon");
769 if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Icon")
771 installer::systemactions::copy_directory($installer::globals::idttemplatepath . $installer::globals::separator . "Icon", $destinationdir . $installer::globals::separator . "Icon");
774 # Copying all files in $iconfilecollector, that describe icons of folderitems
776 for ( my $i = 0; $i <= $#{$iconfilecollector}; $i++ )
778 my $iconfilename = ${$iconfilecollector}[$i];
779 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$iconfilename);
780 installer::systemactions::copy_one_file(${$iconfilecollector}[$i], $destinationdir . $installer::globals::separator . "Icon" . $installer::globals::separator . $iconfilename);
783 # Copying all files in $binarytablefiles in the binary directory
785 for ( my $i = 0; $i <= $#{$binarytablefiles}; $i++ )
787 my $binaryfile = ${$binarytablefiles}[$i];
788 my $binaryfilepath = $binaryfile->{'sourcepath'};
789 my $binaryfilename = $binaryfilepath;
790 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$binaryfilename);
791 installer::systemactions::copy_one_file($binaryfilepath, $destinationdir . $installer::globals::separator . "Binary" . $installer::globals::separator . $binaryfilename);
794 # Copying all new created and language independent idt-files to the destination $destinationdir.
795 # Example: "File.idt"
797 installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, "idt");
799 # Copying all new created and language dependent idt-files to the destination $destinationdir.
800 # Example: "Feature.idt.01"
802 installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, $onelanguage);
803 installer::systemactions::rename_files_with_fileextension($destinationdir, $onelanguage);
807 ##############################################################
808 # Returning the source path of the rtf licensefile for
809 # a specified language
810 ##############################################################
812 sub get_rtflicensefilesource
814 my ($language, $includepatharrayref) = @_;
816 my $licensefilename = "license_" . $language . ".rtf";
818 my $sourcefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $includepatharrayref, 1);
820 if ($$sourcefileref eq "") { installer::exiter::exit_program("ERROR: Could not find $licensefilename!", "get_rtflicensefilesource"); }
822 my $infoline = "Using licensefile: $$sourcefileref\n";
823 push( @installer::globals::logfileinfo, $infoline);
825 return $$sourcefileref;
828 ##############################################################
829 # A simple converter to create a license txt string from
830 # the rtf format
831 ##############################################################
833 sub make_string_licensetext
835 my ($licensefile) = @_;
837 my $rtf_licensetext = "";
839 for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
841 my $oneline = ${$licensefile}[$i];
842 $oneline =~ s/\s*$//g; # no whitespace at line end
844 $rtf_licensetext = $rtf_licensetext . $oneline . " ";
847 return $rtf_licensetext;
850 ##############################################################
851 # Including the license text into the table control.idt
852 ##############################################################
854 sub add_licensefile_to_database
856 my ($licensefile, $controltable) = @_;
858 # Nine tabs before the license text and two tabs after it
859 # The license text has to be included into the dialog
860 # LicenseAgreement into the control Memo.
862 my $foundlicenseline = 0;
863 my ($number, $line);
865 for ( my $i = 0; $i <= $#{$controltable}; $i++ )
867 $line = ${$controltable}[$i];
869 if ( $line =~ /^\s*\bLicenseAgreement\b\t\bMemo\t/ )
871 $foundlicenseline = 1;
872 $number = $i;
873 last;
877 if (!($foundlicenseline))
879 installer::exiter::exit_program("ERROR: Line for license file in Control.idt not found!", "add_licensefile_to_database");
881 else
883 my %control = ();
885 if ( $line =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
887 $control{'Dialog_'} = $1;
888 $control{'Control'} = $2;
889 $control{'Type'} = $3;
890 $control{'X'} = $4;
891 $control{'Y'} = $5;
892 $control{'Width'} = $6;
893 $control{'Height'} = $7;
894 $control{'Attributes'} = $8;
895 $control{'Property'} = $9;
896 $control{'Text'} = $10;
897 $control{'Control_Next'} = $11;
898 $control{'Help'} = $12;
900 else
902 installer::exiter::exit_program("ERROR: Could not split line correctly!", "add_licensefile_to_database");
905 my $licensetext = make_string_licensetext($licensefile);
907 $control{'Text'} = $licensetext;
909 my $newline = $control{'Dialog_'} . "\t" . $control{'Control'} . "\t" . $control{'Type'} . "\t" .
910 $control{'X'} . "\t" . $control{'Y'} . "\t" . $control{'Width'} . "\t" .
911 $control{'Height'} . "\t" . $control{'Attributes'} . "\t" . $control{'Property'} . "\t" .
912 $control{'Text'} . "\t" . $control{'Control_Next'} . "\t" . $control{'Help'} . "\n";
914 ${$controltable}[$number] = $newline
918 ###################################################################
919 # Determining the last position in a sequencetable
920 # into the tables CustomAc.idt and InstallE.idt.
921 ###################################################################
923 sub get_last_position_in_sequencetable
925 my ($sequencetable) = @_;
927 my $position = 0;
929 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
931 my $line = ${$sequencetable}[$i];
933 if ( $line =~ /^\s*\w+\t.*\t\s*(\d+)\s$/ )
935 my $newposition = $1;
936 if ( $newposition > $position ) { $position = $newposition; }
940 return $position;
943 #########################################################################
944 # Determining the position of a specified Action in the sequencetable
945 #########################################################################
947 sub get_position_in_sequencetable
949 my ($action, $sequencetable) = @_;
951 my $position = 0;
953 $action =~ s/^\s*behind_//;
955 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
957 my $line = ${$sequencetable}[$i];
959 if ( $line =~ /^\s*(\w+)\t.*\t\s*(\d+)\s$/ )
961 my $compareaction = $1;
962 $position = $2;
963 if ( $compareaction eq $action ) { last; }
967 return $position;
970 ################################################################################################
971 # Including the CustomAction for the configuration
972 # into the tables CustomAc.idt and InstallE.idt.
974 # CustomAc.idt: ExecutePkgchk 82 pkgchk.exe -s
975 # InstallE.idt: ExecutePkgchk Not REMOVE="ALL" 3175
977 # CustomAc.idt: ExecuteQuickstart 82 install_quickstart.exe
978 # InstallE.idt: ExecuteQuickstart &gm_o_Quickstart=3 3200
980 # CustomAc.idt: ExecuteInstallRegsvrex 82 regsvrex.exe shlxthdl.dll
981 # InstallE.idt: ExecuteInstallRegsvrex Not REMOVE="ALL" 3225
983 # CustomAc.idt: ExecuteUninstallRegsvrex 82 regsvrex.exe /u shlxthdl.dll
984 # InstallE.idt: ExecuteUninstallRegsvrex REMOVE="ALL" 690
986 # CustomAc.idt: Regmsdocmsidll1 1 reg4msdocmsidll Reg4MsDocEntry
987 # InstallU.idt: Regmsdocmsidll1 Not REMOVE="ALL" 610
989 # CustomAc.idt: Regmsdocmsidll2 1 reg4msdocmsidll Reg4MsDocEntry
990 # InstallE.idt: Regmsdocmsidll2 Not REMOVE="ALL" 3160
991 ################################################################################################
993 sub set_custom_action
995 my ($customactionidttable, $actionname, $actionflags, $exefilename, $actionparameter, $inbinarytable, $filesref, $customactionidttablename, $styles) = @_;
997 my $included_customaction = 0;
998 my $infoline = "";
999 my $customaction_exefilename = $exefilename;
1000 my $uniquename = "";
1002 # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1003 if ( $styles =~ /\bNO_FILE\b/ )
1005 my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1006 push(@{$customactionidttable}, $line);
1008 $infoline = "Added $actionname CustomAction into table $customactionidttablename (NO_FILE has been set)\n";
1009 push(@installer::globals::logfileinfo, $infoline);
1011 $included_customaction = 1;
1012 return $included_customaction;
1015 # is the $exefilename a library that is included into the binary table
1017 if ( $inbinarytable ) { $customaction_exefilename =~ s/\.//; } # this is the entry in the binary table ("abc.dll" -> "abcdll")
1019 # is the $exefilename included into the product?
1021 my $contains_file = 0;
1023 # All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1024 # Both must be added together
1025 my $localfilesref = [@installer::globals::binarytableonlyfiles, @{$filesref}];
1027 for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1029 my $onefile = ${$localfilesref}[$i];
1030 my $filename = "";
1031 if ( exists($onefile->{'Name'}) )
1033 $filename = $onefile->{'Name'};
1035 if ( $filename eq $exefilename )
1037 $contains_file = 1;
1038 $uniquename = ${$localfilesref}[$i]->{'uniquename'};
1039 last;
1042 else
1044 installer::exiter::exit_program("ERROR: Did not find \"Name\" for file \"$onefile->{'uniquename'}\" ($onefile->{'gid'})!", "set_custom_action");
1048 if ( $contains_file )
1050 # Now the CustomAction can be included into the CustomAc.idt
1052 if ( ! $inbinarytable ) { $customaction_exefilename = $uniquename; } # the unique file name has to be added to the custom action table
1054 my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1055 push(@{$customactionidttable}, $line);
1057 $included_customaction = 1;
1060 if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $customactionidttablename\n"; }
1061 else { $infoline = "Did not add $actionname CustomAction into table $customactionidttablename\n"; }
1062 push(@installer::globals::logfileinfo, $infoline);
1064 return $included_customaction;
1067 ####################################################################
1068 # Adding a Custom Action to InstallExecuteTable or InstallUITable
1069 ####################################################################
1071 sub add_custom_action_to_install_table
1073 my ($installtable, $exefilename, $actionname, $actioncondition, $position, $filesref, $installtablename, $styles) = @_;
1075 my $included_customaction = 0;
1076 my $feature = "";
1077 my $infoline = "";
1079 # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1080 if ( $styles =~ /\bNO_FILE\b/ )
1082 # then the InstallE.idt.idt or InstallU.idt.idt
1083 $actioncondition =~ s/FEATURETEMPLATE/$feature/g; # only execute Custom Action, if feature of the file is installed
1085 my $actionposition = 0;
1087 if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1088 elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1089 else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1091 my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1092 push(@{$installtable}, $line);
1094 $infoline = "Added $actionname CustomAction into table $installtablename (NO_FILE has been set)\n";
1095 push(@installer::globals::logfileinfo, $infoline);
1096 return;
1099 my $contains_file = 0;
1101 # All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1102 # Both must be added together
1103 my $localfilesref = [@installer::globals::binarytableonlyfiles, @{$filesref}];
1105 for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1107 my $filename = ${$localfilesref}[$i]->{'Name'};
1109 if ( $filename eq $exefilename )
1111 $contains_file = 1;
1113 # Determining the feature of the file
1115 if ( ${$localfilesref}[$i] ) { $feature = ${$localfilesref}[$i]->{'modules'}; }
1117 # If modules contains a list of modules, only taking the first one.
1118 if ( $feature =~ /^\s*(.*?)\,/ ) { $feature = $1; }
1119 # Attention: Maximum feature length is 38!
1120 shorten_feature_gid(\$feature);
1122 last;
1126 if ( $contains_file )
1128 # then the InstallE.idt.idt or InstallU.idt.idt
1130 $actioncondition =~ s/FEATURETEMPLATE/$feature/g; # only execute Custom Action, if feature of the file is installed
1132 # my $actionposition = 0;
1133 # if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1134 # elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1135 # else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1136 # my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1138 my $positiontemplate = "";
1139 if ( $position =~ /^\s*\d+\s*$/ ) { $positiontemplate = $position; } # setting the position directly, number defined in scp2
1140 else { $positiontemplate = "POSITIONTEMPLATE_" . $position; }
1142 my $line = $actionname . "\t" . $actioncondition . "\t" . $positiontemplate . "\n";
1143 push(@{$installtable}, $line);
1145 $included_customaction = 1;
1148 if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $installtablename\n"; }
1149 else { $infoline = "Did not add $actionname CustomAction into table $installtablename\n"; }
1150 push(@installer::globals::logfileinfo, $infoline);
1154 ##################################################################
1155 # A line in the table ControlEvent connects a Control
1156 # with a Custom Action
1157 #################################################################
1159 sub connect_custom_action_to_control
1161 my ( $table, $tablename, $dialog, $control, $event, $argument, $condition, $ordering) = @_;
1163 my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $argument. "\t" . $condition. "\t" . $ordering . "\n";
1165 push(@{$table}, $line);
1167 $line =~ s/\s*$//g;
1169 $infoline = "Added line \"$line\" into table $tablename\n";
1170 push(@installer::globals::logfileinfo, $infoline);
1173 ##################################################################
1174 # A line in the table ControlCondition connects a Control state
1175 # with a condition
1176 ##################################################################
1178 sub connect_condition_to_control
1180 my ( $table, $tablename, $dialog, $control, $event, $condition) = @_;
1182 my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $condition. "\n";
1184 push(@{$table}, $line);
1186 $line =~ s/\s*$//g;
1188 $infoline = "Added line \"$line\" into table $tablename\n";
1189 push(@installer::globals::logfileinfo, $infoline);
1192 ##################################################################
1193 # Searching for a sequencenumber in InstallUISequence table
1194 # "ExecuteAction" must be the last action
1195 ##################################################################
1197 sub get_free_number_in_uisequence_table
1199 my ( $installuitable ) = @_;
1201 # determining the sequence of "ExecuteAction"
1203 my $executeactionnumber = 0;
1205 for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1207 if ( ${$installuitable}[$i] =~ /^\s*(\w+)\t\w*\t(\d+)\s*$/ )
1209 my $actionname = $1;
1210 my $actionnumber = $2;
1212 if ( $actionname eq "ExecuteAction" )
1214 $executeactionnumber = $actionnumber;
1215 last;
1220 if ( $executeactionnumber == 0 ) { installer::exiter::exit_program("ERROR: Did not find \"ExecuteAction\" in InstallUISequence table!", "get_free_number_in_uisequence_table"); }
1222 # determining the sequence of the action before "ExecuteAction"
1224 my $lastactionnumber = 0;
1226 for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1228 if ( ${$installuitable}[$i] =~ /^\s*\w+\t\w*\t(\d+)\s*$/ )
1230 my $actionnumber = $1;
1232 if (( $actionnumber > $lastactionnumber ) && ( $actionnumber != $executeactionnumber ))
1234 $lastactionnumber = $actionnumber;
1239 # the new number can now be calculated
1241 my $newnumber = 0;
1243 if ((( $lastactionnumber + $executeactionnumber ) % 2 ) == 0 ) { $newnumber = ( $lastactionnumber + $executeactionnumber ) / 2; }
1244 else { $newnumber = ( $lastactionnumber + $executeactionnumber -1 ) / 2; }
1246 return $newnumber;
1249 #############################################################
1250 # Including the new subdir into the directory table
1251 #############################################################
1253 sub include_subdirname_into_directory_table
1255 my ($dirname, $directorytable, $directorytablename, $onefile) = @_;
1257 my $subdir = "";
1258 if ( $onefile->{'Subdir'} ) { $subdir = $onefile->{'Subdir'}; }
1259 if ( $subdir eq "" ) { installer::exiter::exit_program("ERROR: No \"Subdir\" defined for $onefile->{'Name'}", "include_subdirname_into_directory_table"); }
1261 # program INSTALLLOCATION program -> subjava INSTALLLOCATION program:java
1263 my $uniquename = "";
1264 my $parent = "";
1265 my $name = "";
1267 my $includedline = 0;
1269 my $newdir = "";
1271 for ( my $i = 0; $i <= $#{$directorytable}; $i++ )
1274 if ( ${$directorytable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\s*$/ )
1276 $uniquename = $1;
1277 $parent = $2;
1278 $name = $3;
1280 if ( $dirname eq $name )
1282 my $newuniquename = "sub" . $subdir;
1283 $newdir = $newuniquename;
1284 my $newparent = "INSTALLLOCATION";
1285 my $newname = $name . "\:" . $subdir;
1286 my $newline =
1287 $line = "$newuniquename\t$newparent\t$newname\n";
1288 push(@{$directorytable}, $line);
1289 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1290 $infoline = "Added $line into directory table $directorytablename\n";
1291 push(@installer::globals::logfileinfo, $infoline);
1293 $includedline = 1;
1294 last;
1299 if ( ! $includedline ) { installer::exiter::exit_program("ERROR: Could not include new subdirectory into directory table for file $onefile->{'Name'}!", "include_subdirname_into_directory_table"); }
1301 return $newdir;
1304 ##################################################################
1305 # Including the new sub directory into the component table
1306 ##################################################################
1308 sub include_subdir_into_componenttable
1310 my ($subdir, $onefile, $componenttable) = @_;
1312 my $componentname = $onefile->{'componentname'};
1314 my $changeddirectory = 0;
1316 for ( my $i = 0; $i <= $#{$componenttable}; $i++ )
1318 if ( ${$componenttable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1320 my $localcomponentname = $1;
1321 my $directory = $3;
1323 if ( $componentname eq $localcomponentname )
1325 my $oldvalue = ${$componenttable}[$i];
1326 ${$componenttable}[$i] =~ s/\b\Q$directory\E\b/$subdir/;
1327 my $newvalue = ${$componenttable}[$i];
1329 installer::remover::remove_leading_and_ending_whitespaces(\$oldvalue);
1330 installer::remover::remove_leading_and_ending_whitespaces(\$newvalue);
1331 $infoline = "Change in Component table: From \"$oldvalue\" to \"$newvalue\"\n";
1332 push(@installer::globals::logfileinfo, $infoline);
1334 $changeddirectory = 1;
1335 last;
1340 if ( ! $changeddirectory ) { installer::exiter::exit_program("ERROR: Could not change directory for component: $onefile->{'Name'}!", "include_subdir_into_componenttable"); }
1344 ##################################################################
1345 # Setting the condition, that at least one module is selected.
1346 # All modules with flag SHOW_MULTILINGUAL_ONLY were already
1347 # collected. In table ControlE.idt, the string
1348 # LANGUAGECONDITIONINSTALL needs to be replaced.
1349 # Also for APPLICATIONCONDITIONINSTALL for the applications
1350 # with flag APPLICATIONMODULE.
1351 ##################################################################
1353 sub set_multilanguageonly_condition
1355 my ( $languageidtdir ) = @_;
1357 my $onefilename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
1358 my $onefile = installer::files::read_file($onefilename);
1360 # Language modules
1362 my $condition = "";
1364 foreach my $module ( sort keys %installer::globals::multilingual_only_modules )
1366 $condition = $condition . " &$module=3 Or";
1369 $condition =~ s/^\s*//;
1370 $condition =~ s/\s*Or\s*$//; # removing the ending "Or"
1372 if ( $condition eq "" ) { $condition = "1"; }
1374 for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1376 ${$onefile}[$j] =~ s/LANGUAGECONDITIONINSTALL/$condition/;
1379 # Application modules
1381 $condition = "";
1383 foreach my $module ( sort keys %installer::globals::application_modules )
1385 $condition = $condition . " &$module=3 Or";
1388 $condition =~ s/^\s*//;
1389 $condition =~ s/\s*Or\s*$//; # removing the ending "Or"
1391 if ( $condition eq "" ) { $condition = "1"; }
1393 for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1395 ${$onefile}[$j] =~ s/APPLICATIONCONDITIONINSTALL/$condition/;
1398 installer::files::save_file($onefilename, $onefile);
1401 #############################################
1402 # Putting array values into hash
1403 #############################################
1405 sub fill_assignment_hash
1407 my ($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray) = @_;
1409 my $max = $parameter - 1;
1411 if ( $max != $#{$assignmentarray} )
1413 my $definedparameter = $#{$assignmentarray} + 1;
1414 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Wrong parameter in scp. For table $tablename $parameter parameter are required ! You defined: $definedparameter", "fill_assignment_hash");
1417 for ( my $i = 0; $i <= $#{$assignmentarray}; $i++ )
1419 my $counter = $i + 1;
1420 my $key = "parameter". $counter;
1422 my $localvalue = ${$assignmentarray}[$i];
1423 installer::remover::remove_leading_and_ending_quotationmarks(\$localvalue);
1424 $localvalue =~ s/\\\"/\"/g;
1425 $localvalue =~ s/\\\!/\!/g;
1426 $localvalue =~ s/\\\&/\&/g;
1427 $localvalue =~ s/\\\</\</g;
1428 $localvalue =~ s/\\\>/\>/g;
1429 $assignmenthashref->{$key} = $localvalue;
1433 ##########################################################################
1434 # Checking the assignment of a Windows CustomAction and putting it
1435 # into a hash
1436 ##########################################################################
1438 sub create_customaction_assignment_hash
1440 my ($gid, $name, $key, $assignmentarray) = @_;
1442 my %assignment = ();
1443 my $assignmenthashref = \%assignment;
1445 my $tablename = ${$assignmentarray}[0];
1446 installer::remover::remove_leading_and_ending_quotationmarks(\$tablename);
1448 my $tablename_defined = 0;
1449 my $parameter = 0;
1451 if ( $tablename eq "InstallUISequence" )
1453 $tablename_defined = 1;
1454 $parameter = 3;
1455 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
1458 if ( $tablename eq "InstallExecuteSequence" )
1460 $tablename_defined = 1;
1461 $parameter = 3;
1462 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
1465 if ( $tablename eq "AdminExecuteSequence" )
1467 $tablename_defined = 1;
1468 $parameter = 3;
1469 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
1472 if ( $tablename eq "ControlEvent" )
1474 $tablename_defined = 1;
1475 $parameter = 7;
1476 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
1479 if ( $tablename eq "ControlCondition" )
1481 $tablename_defined = 1;
1482 $parameter = 5;
1483 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
1486 if ( ! $tablename_defined )
1488 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $tablename ! Currently supported: InstallUISequence, InstallExecuteSequence, ControlEvent, ControlCondition", "create_customaction_assignment_hash");
1491 return $assignmenthashref;
1494 ##########################################################################
1495 # Finding the position of a specified CustomAction.
1496 # If the CustomAction is not found, the return value is "-1".
1497 # If the CustomAction position is not defined yet,
1498 # the return value is also "-1".
1499 ##########################################################################
1501 sub get_customaction_position
1503 my ($action, $sequencetable) = @_;
1505 my $position = -1;
1507 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1509 my $line = ${$sequencetable}[$i];
1511 if ( $line =~ /^\s*([\w\.]+)\t.*\t\s*(\d+)\s$/ ) # matching only, if position is a number!
1513 my $compareaction = $1;
1514 my $localposition = $2;
1516 if ( $compareaction eq $action )
1518 $position = $localposition;
1519 last;
1524 return $position;
1527 ##########################################################################
1528 # Setting the position of CustomActions in sequence tables.
1529 # Replacing all occurrences of "POSITIONTEMPLATE_"
1530 ##########################################################################
1532 sub set_positions_in_table
1534 my ( $sequencetable, $tablename ) = @_;
1536 my $infoline = "\nSetting positions in table \"$tablename\".\n";
1537 push(@installer::globals::logfileinfo, $infoline);
1539 # Step 1: Resolving all occurrences of "POSITIONTEMPLATE_end"
1541 my $lastposition = get_last_position_in_sequencetable($sequencetable);
1543 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1545 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*POSITIONTEMPLATE_end\s*$/ )
1547 my $customaction = $1;
1548 $lastposition = $lastposition + 25;
1549 ${$sequencetable}[$i] =~ s/POSITIONTEMPLATE_end/$lastposition/;
1550 $infoline = "Setting position \"$lastposition\" for custom action \"$customaction\".\n";
1551 push(@installer::globals::logfileinfo, $infoline);
1555 # Step 2: Resolving all occurrences of "POSITIONTEMPLATE_abc" or "POSITIONTEMPLATE_behind_abc"
1556 # where abc is the name of the reference Custom Action.
1557 # This has to be done, until there is no more occurrence of POSITIONTEMPLATE (success)
1558 # or there is no replacement in one circle (failure).
1560 my $template_exists = 0;
1561 my $template_replaced = 0;
1562 my $counter = 0;
1566 $template_exists = 0;
1567 $template_replaced = 0;
1568 $counter++;
1570 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1572 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
1574 my $onename = $1;
1575 my $templatename = $2;
1576 my $positionname = $templatename;
1577 my $customaction = $templatename;
1578 $customaction =~ s/POSITIONTEMPLATE_//;
1579 $template_exists = 1;
1581 # Trying to find the correct number.
1582 # This can fail, if the custom action has no number
1584 my $setbehind = 0;
1585 if ( $customaction =~ /^\s*behind_(.*?)\s*$/ )
1587 $customaction = $1;
1588 $setbehind = 1;
1591 my $position = get_customaction_position($customaction, $sequencetable);
1593 if ( $position >= 0 ) # Found CustomAction and is has a position. Otherwise return value is "-1".
1595 my $newposition = 0;
1596 if ( $setbehind ) { $newposition = $position + 2; }
1597 else { $newposition = $position - 2; }
1598 ${$sequencetable}[$i] =~ s/$templatename/$newposition/;
1599 $template_replaced = 1;
1600 $infoline = "Setting position \"$newposition\" for custom action \"$onename\" (scp: \"$positionname\" at position $position).\n";
1601 push(@installer::globals::logfileinfo, $infoline);
1603 else
1605 $infoline = "Could not assign position for custom action \"$onename\" yet (scp: \"$positionname\").\n";
1606 push(@installer::globals::logfileinfo, $infoline);
1610 } while (( $template_exists ) && ( $template_replaced ));
1612 # An error occurred, because templates still exist, but could not be replaced.
1613 # Reason:
1614 # 1. Wrong name of CustomAction in scp2 (typo?)
1615 # 2. Circular dependencies of CustomActions (A after B and B after A)
1617 # Problem: It is allowed, that a CustomAction is defined in scp2 in a library that is
1618 # part of product ABC, but this CustomAction is not used in this product
1619 # and the reference CustomAction is not part of this product.
1620 # Therefore this cannot be an error, but only produce a warning. The assigned number
1621 # must be the last sequence number.
1623 if (( $template_exists ) && ( ! $template_replaced ))
1625 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1627 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
1629 my $customactionname = $1;
1630 my $fulltemplate = $2;
1631 my $template = $fulltemplate;
1632 $template =~ s/POSITIONTEMPLATE_//;
1633 $lastposition = $lastposition + 25;
1634 ${$sequencetable}[$i] =~ s/$fulltemplate/$lastposition/;
1635 $infoline = "WARNING: Setting position \"$lastposition\" for custom action \"$customactionname\". Could not find CustomAction \"$template\".\n";
1636 push(@installer::globals::logfileinfo, $infoline);
1642 ##########################################################################
1643 # Setting the Windows custom actions into different tables
1644 # CustomAc.idt, InstallE.idt, InstallU.idt, ControlE.idt, ControlC.idt
1645 ##########################################################################
1647 sub addcustomactions
1649 my ($languageidtdir, $customactions, $filesarray) = @_;
1651 installer::logger::include_timestamp_into_logfile("\nPerformance Info: addcustomactions start\n");
1653 my $customactionidttablename = $languageidtdir . $installer::globals::separator . "CustomAc.idt";
1654 my $customactionidttable = installer::files::read_file($customactionidttablename);
1655 my $installexecutetablename = $languageidtdir . $installer::globals::separator . "InstallE.idt";
1656 my $installexecutetable = installer::files::read_file($installexecutetablename);
1657 my $adminexecutetablename = $languageidtdir . $installer::globals::separator . "AdminExe.idt";
1658 my $adminexecutetable = installer::files::read_file($adminexecutetablename);
1659 my $installuitablename = $languageidtdir . $installer::globals::separator . "InstallU.idt";
1660 my $installuitable = installer::files::read_file($installuitablename);
1661 my $controleventtablename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
1662 my $controleventtable = installer::files::read_file($controleventtablename);
1663 my $controlconditiontablename = $languageidtdir . $installer::globals::separator . "ControlC.idt";
1664 my $controlconditiontable = installer::files::read_file($controlconditiontablename);
1666 # Iterating over all Windows custom actions
1668 for ( my $i = 0; $i <= $#{$customactions}; $i++ )
1670 my $customaction = ${$customactions}[$i];
1671 my $name = $customaction->{'Name'};
1672 my $typ = $customaction->{'Typ'};
1673 my $source = $customaction->{'Source'};
1674 my $target = $customaction->{'Target'};
1675 my $inbinarytable = $customaction->{'Inbinarytable'};
1676 my $gid = $customaction->{'gid'};
1678 my $styles = "";
1679 if ( $customaction->{'Styles'} ) { $styles = $customaction->{'Styles'}; }
1681 my $added_customaction = set_custom_action($customactionidttable, $name, $typ, $source, $target, $inbinarytable, $filesarray, $customactionidttablename, $styles);
1683 if ( $added_customaction )
1685 # If the CustomAction was added into the CustomAc.idt, it can be connected to the installation.
1686 # There are currently two different ways for doing this:
1687 # 1. Using "add_custom_action_to_install_table", which adds the CustomAction to the install sequences,
1688 # which are saved in InstallE.idt and InstallU.idt
1689 # 2. Using "connect_custom_action_to_control" and "connect_custom_action_to_control". The first method
1690 # connects a CustomAction to a control in ControlE.idt. The second method sets a condition for a control,
1691 # which might be influenced by the CustomAction. This happens in ControlC.idt.
1693 # Any Windows CustomAction can have a lot of different assignments.
1695 for ( my $j = 1; $j <= 50; $j++ )
1697 my $key = "Assignment" . $j;
1698 my $value = "";
1699 if ( $customaction->{$key} )
1701 $value = $customaction->{$key};
1703 else { last; }
1705 # $value is now a comma separated list
1706 if ( $value =~ /^\s*\(\s*(.*)\s*\);?\s*$/ ) { $value = $1; }
1707 my $assignmentarray = installer::converter::convert_stringlist_into_array(\$value, ",");
1708 my $assignment = create_customaction_assignment_hash($gid, $name, $key, $assignmentarray);
1710 if ( $assignment->{'parameter1'} eq "InstallExecuteSequence" )
1712 add_custom_action_to_install_table($installexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installexecutetablename, $styles);
1714 elsif ( $assignment->{'parameter1'} eq "AdminExecuteSequence" )
1716 add_custom_action_to_install_table($adminexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $adminexecutetablename, $styles);
1718 elsif ( $assignment->{'parameter1'} eq "InstallUISequence" )
1720 add_custom_action_to_install_table($installuitable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installuitablename, $styles);
1722 elsif ( $assignment->{'parameter1'} eq "ControlEvent" )
1724 connect_custom_action_to_control($controleventtable, $controleventtablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'}, $assignment->{'parameter6'}, $assignment->{'parameter7'});
1726 elsif ( $assignment->{'parameter1'} eq "ControlCondition" )
1728 connect_condition_to_control($controlconditiontable, $controlconditiontablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'});
1730 else
1732 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $assignmenthashref->{'parameter1'} ! Currently supported: InstallUISequence, InstallESequence, ControlEvent, ControlCondition", "addcustomactions");
1738 # Setting the positions in the tables
1740 set_positions_in_table($installexecutetable, $installexecutetablename);
1741 set_positions_in_table($installuitable, $installuitablename);
1742 set_positions_in_table($adminexecutetable, $adminexecutetablename);
1744 # Saving the files
1746 installer::files::save_file($customactionidttablename, $customactionidttable);
1747 installer::files::save_file($installexecutetablename, $installexecutetable);
1748 installer::files::save_file($adminexecutetablename, $adminexecutetable);
1749 installer::files::save_file($installuitablename, $installuitable);
1750 installer::files::save_file($controleventtablename, $controleventtable);
1751 installer::files::save_file($controlconditiontablename, $controlconditiontable);
1753 my $infoline = "Updated idt file: $customactionidttablename\n";
1754 push(@installer::globals::logfileinfo, $infoline);
1755 $infoline = "Updated idt file: $installexecutetablename\n";
1756 push(@installer::globals::logfileinfo, $infoline);
1757 $infoline = "Updated idt file: $adminexecutetablename\n";
1758 push(@installer::globals::logfileinfo, $infoline);
1759 $infoline = "Updated idt file: $installuitablename\n";
1760 push(@installer::globals::logfileinfo, $infoline);
1761 $infoline = "Updated idt file: $controleventtablename\n";
1762 push(@installer::globals::logfileinfo, $infoline);
1763 $infoline = "Updated idt file: $controlconditiontablename\n";
1764 push(@installer::globals::logfileinfo, $infoline);
1766 installer::logger::include_timestamp_into_logfile("\nPerformance Info: addcustomactions end\n");
1769 ##########################################################################
1770 # Setting bidi attributes in idt tables
1771 ##########################################################################
1773 sub setbidiattributes
1775 my ($languageidtdir, $onelanguage) = @_;
1777 # Editing the files Dialog.idt and Control.idt
1779 my $dialogfilename = $languageidtdir . $installer::globals::separator . "Dialog.idt";
1780 my $controlfilename = $languageidtdir . $installer::globals::separator . "Control.idt";
1782 my $dialogfile = installer::files::read_file($dialogfilename);
1783 my $controlfile = installer::files::read_file($controlfilename);
1785 # Searching attributes in Dialog.idt and adding "896".
1786 # Attributes are in column 6 (from 10).
1788 my $bidiattribute = 896;
1789 for ( my $i = 0; $i <= $#{$dialogfile}; $i++ )
1791 if ( $i < 3 ) { next; }
1792 if ( ${$dialogfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1794 my $one = $1;
1795 my $two = $2;
1796 my $three = $3;
1797 my $four = $4;
1798 my $five = $5;
1799 my $attribute = $6;
1800 my $seven = $7;
1801 my $eight = $8;
1802 $attribute = $attribute + $bidiattribute;
1803 ${$dialogfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$attribute\t$seven\t$eight\n";
1807 # Searching attributes in Control.idt and adding "224".
1808 # Attributes are in column 8 (from 12).
1810 $bidiattribute = 224;
1811 for ( my $i = 0; $i <= $#{$controlfile}; $i++ )
1813 if ( $i < 3 ) { next; }
1814 if ( ${$controlfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1816 my $one = $1;
1817 my $two = $2;
1818 my $three = $3;
1819 my $four = $4;
1820 my $five = $5;
1821 my $six = $6;
1822 my $seven = $7;
1823 my $attribute = $8;
1824 my $nine = $9;
1825 my $ten = $10;
1826 my $eleven = $11;
1827 my $twelve = $12;
1828 $attribute = $attribute + $bidiattribute;
1829 ${$controlfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$six\t$seven\t$attribute\t$nine\t$ten\t$eleven\t$twelve\n";
1833 # Saving the file
1835 installer::files::save_file($dialogfilename, $dialogfile);
1836 $infoline = "Set bidi support in idt file \"$dialogfilename\" for language $onelanguage\n";
1837 push(@installer::globals::logfileinfo, $infoline);
1839 installer::files::save_file($controlfilename, $controlfile);
1840 $infoline = "Set bidi support in idt file \"$controlfilename\" for language $onelanguage\n";
1841 push(@installer::globals::logfileinfo, $infoline);