1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
|
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: msiglobal.pm,v $
#
# $Revision: 1.51 $
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
package installer::windows::msiglobal;
use Cwd;
use Digest::MD5;
use installer::converter;
use installer::exiter;
use installer::files;
use installer::globals;
use installer::logger;
use installer::pathanalyzer;
use installer::remover;
use installer::scriptitems;
use installer::systemactions;
use installer::worker;
use installer::windows::idtglobal;
use installer::windows::language;
###########################################################################
# Generating the header of the ddf file.
# The usage of ddf files is needed, because makecab.exe can only include
# one sourcefile into a cab file
###########################################################################
sub write_ddf_file_header
{
my ($ddffileref, $cabinetfile, $installdir) = @_;
my $oneline;
$oneline = ".Set CabinetName1=" . $cabinetfile . "\n";
push(@{$ddffileref} ,$oneline);
$oneline = ".Set ReservePerCabinetSize=128\n"; # This reserves space for a digital signature.
push(@{$ddffileref} ,$oneline);
$oneline = ".Set MaxDiskSize=CDROM\n"; # This allows the .cab file to be as large as needed.
push(@{$ddffileref} ,$oneline);
$oneline = ".Set CompressionType=LZX\n";
push(@{$ddffileref} ,$oneline);
$oneline = ".Set Compress=ON\n";
push(@{$ddffileref} ,$oneline);
$oneline = ".Set CompressionLevel=$installer::globals::cabfilecompressionlevel\n";
push(@{$ddffileref} ,$oneline);
$oneline = ".Set Cabinet=ON\n";
push(@{$ddffileref} ,$oneline);
$oneline = ".Set DiskDirectoryTemplate=" . $installdir . "\n";
push(@{$ddffileref} ,$oneline);
}
##########################################################################
# Lines in ddf files must not contain more than 256 characters
##########################################################################
sub check_ddf_file
{
my ( $ddffile, $ddffilename ) = @_;
my $maxlength = 0;
my $maxline = 0;
my $linelength = 0;
my $linenumber = 0;
for ( my $i = 0; $i <= $#{$ddffile}; $i++ )
{
my $oneline = ${$ddffile}[$i];
$linelength = length($oneline);
$linenumber = $i + 1;
if ( $linelength > 256 )
{
installer::exiter::exit_program("ERROR \"$ddffilename\" line $linenumber: Lines in ddf files must not contain more than 256 characters!", "check_ddf_file");
}
if ( $linelength > $maxlength )
{
$maxlength = $linelength;
$maxline = $linenumber;
}
}
my $infoline = "Check of ddf file \"$ddffilename\": Maximum length \"$maxlength\" in line \"$maxline\" (allowed line length: 256 characters)\n";
push(@installer::globals::logfileinfo, $infoline);
}
##########################################################################
# Lines in ddf files must not be longer than 256 characters.
# Therefore it can be useful to use relative pathes. Then it is
# necessary to change into temp directory before calling
# makecab.exe.
##########################################################################
sub make_relative_ddf_path
{
my ( $sourcepath ) = @_;
my $windowstemppath = $installer::globals::temppath;
if ( $^O =~ /cygwin/i )
{
$windowstemppath = $installer::globals::cyg_temppath;
}
$sourcepath =~ s/\Q$windowstemppath\E//;
$sourcepath =~ s/^\\//;
return $sourcepath;
}
##########################################################################
# Returning the order of the sequences in the files array.
##########################################################################
sub get_sequenceorder
{
my ($filesref) = @_;
my %order = ();
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $onefile = ${$filesref}[$i];
if ( ! $onefile->{'assignedsequencenumber'} ) { installer::exiter::exit_program("ERROR: No sequence number assigned to $onefile->{'gid'} ($onefile->{'uniquename'})!", "get_sequenceorder"); }
$order{$onefile->{'assignedsequencenumber'}} = $i;
}
return \%order;
}
##########################################################################
# Generation the list, in which the source of the files is connected
# with the cabinet destination file. Because more than one file needs
# to be included into a cab file, this has to be done via ddf files.
##########################################################################
sub generate_cab_file_list
{
my ($filesref, $installdir, $ddfdir, $allvariables) = @_;
my @cabfilelist = ();
installer::logger::include_header_into_logfile("Generating ddf files");
installer::logger::include_timestamp_into_logfile("Performance Info: ddf file generation start");
if ( $^O =~ /cygwin/i ) { installer::worker::generate_cygwin_pathes($filesref); }
if ( $installer::globals::use_packages_for_cabs )
{
my $sequenceorder = get_sequenceorder($filesref);
my $counter = 1;
my $currentcabfile = "";
while ( ( exists($sequenceorder->{$counter}) ) || ( exists($installer::globals::allmergemodulefilesequences{$counter}) ) ) # Taking care of files from merge modules
{
if ( exists($installer::globals::allmergemodulefilesequences{$counter}) )
{
# Skipping this sequence, it is not included in $filesref, because it is assigned to a file from a merge module.\n";
$counter++;
next;
}
# Files with increasing sequencerorder are included in one cab file
my $onefile = ${$filesref}[$sequenceorder->{$counter}];
my $cabinetfile = $onefile->{'assignedcabinetfile'};
my $sourcepath = $onefile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
my $uniquename = $onefile->{'uniquename'};
my $styles = "";
my $doinclude = 1;
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
# all files with the same cabinetfile have increasing sequencenumbers
my @ddffile = ();
write_ddf_file_header(\@ddffile, $cabinetfile, $installdir);
my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $doinclude ) { push(@ddffile, $ddfline); }
$counter++; # increasing the counter
my $nextfile = "";
my $nextcabinetfile = "";
if ( exists($sequenceorder->{$counter}) ) { $nextfile = ${$filesref}[$sequenceorder->{$counter}]; }
if ( $nextfile->{'assignedcabinetfile'} ) { $nextcabinetfile = $nextfile->{'assignedcabinetfile'}; }
while ( $nextcabinetfile eq $cabinetfile )
{
$sourcepath = $nextfile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
$uniquename = $nextfile->{'uniquename'};
my $localdoinclude = 1;
my $nextfilestyles = "";
if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; }
if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; }
$ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $localdoinclude ) { push(@ddffile, $ddfline); }
$counter++; # increasing the counter!
$nextcabinetfile = "_lastfile_";
if ( exists($sequenceorder->{$counter}) )
{
$nextfile = ${$filesref}[$sequenceorder->{$counter}];
$nextcabinetfile = $nextfile->{'assignedcabinetfile'};
}
}
# creating the DDF file
my $ddffilename = $cabinetfile;
$ddffilename =~ s/.cab/.ddf/;
$ddfdir =~ s/\Q$installer::globals::separator\E\s*$//;
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
installer::files::save_file($ddffilename ,\@ddffile);
my $infoline = "Created ddf file: $ddffilename\n";
push(@installer::globals::logfileinfo, $infoline);
# lines in ddf files must not be longer than 256 characters
check_ddf_file(\@ddffile, $ddffilename);
# Writing the makecab system call
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n";
push(@cabfilelist, $oneline);
# collecting all ddf files
push(@installer::globals::allddffiles, $ddffilename);
}
}
elsif ((( $installer::globals::cab_file_per_component ) || ( $installer::globals::fix_number_of_cab_files )) && ( $installer::globals::updatedatabase ))
{
my $sequenceorder = get_sequenceorder($filesref);
my $counter = 1;
my $currentcabfile = "";
while ( ( exists($sequenceorder->{$counter}) ) || ( exists($installer::globals::allmergemodulefilesequences{$counter}) ) ) # Taking care of files from merge modules
{
# if ( exists($installer::globals::allmergemodulefilesequences{$counter}) )
# {
# # Skipping this sequence, it is not included in $filesref, because it is assigned to a file from a merge module.\n";
# $counter++;
# next;
# }
my $onefile = ${$filesref}[$sequenceorder->{$counter}];
$counter++;
my $cabinetfile = $onefile->{'cabinet'};
my $sourcepath = $onefile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
my $uniquename = $onefile->{'uniquename'};
my $styles = "";
my $doinclude = 1;
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
my @ddffile = ();
write_ddf_file_header(\@ddffile, $cabinetfile, $installdir);
my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $doinclude ) { push(@ddffile, $ddfline); }
my $nextfile = "";
if ( ${$filesref}[$sequenceorder->{$counter}] ) { $nextfile = ${$filesref}[$sequenceorder->{$counter}]; }
my $nextcabinetfile = "";
if ( $nextfile->{'cabinet'} ) { $nextcabinetfile = $nextfile->{'cabinet'}; }
while ( $nextcabinetfile eq $cabinetfile )
{
$sourcepath = $nextfile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
$uniquename = $nextfile->{'uniquename'};
my $localdoinclude = 1;
my $nextfilestyles = "";
if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; }
if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; }
$ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $localdoinclude ) { push(@ddffile, $ddfline); }
$counter++; # increasing the counter!
$nextfile = "";
$nextcabinetfile = "_lastfile_";
if (( exists($sequenceorder->{$counter}) ) && ( ${$filesref}[$sequenceorder->{$counter}] ))
{
$nextfile = ${$filesref}[$sequenceorder->{$counter}];
$nextcabinetfile = $nextfile->{'cabinet'};
}
}
# creating the DDF file
my $ddffilename = $cabinetfile;
$ddffilename =~ s/.cab/.ddf/;
$ddfdir =~ s/\Q$installer::globals::separator\E\s*$//;
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
installer::files::save_file($ddffilename ,\@ddffile);
my $infoline = "Created ddf file: $ddffilename\n";
push(@installer::globals::logfileinfo, $infoline);
# lines in ddf files must not be longer than 256 characters
check_ddf_file(\@ddffile, $ddffilename);
# Writing the makecab system call
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n";
push(@cabfilelist, $oneline);
# collecting all ddf files
push(@installer::globals::allddffiles, $ddffilename);
}
}
elsif (( $installer::globals::cab_file_per_component ) || ( $installer::globals::fix_number_of_cab_files ))
{
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $onefile = ${$filesref}[$i];
my $cabinetfile = $onefile->{'cabinet'};
my $sourcepath = $onefile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
my $uniquename = $onefile->{'uniquename'};
my $styles = "";
my $doinclude = 1;
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
# all files with the same cabinetfile are directly behind each other in the files collector
my @ddffile = ();
write_ddf_file_header(\@ddffile, $cabinetfile, $installdir);
my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $doinclude ) { push(@ddffile, $ddfline); }
my $nextfile = ${$filesref}[$i+1];
my $nextcabinetfile = "";
if ( $nextfile->{'cabinet'} ) { $nextcabinetfile = $nextfile->{'cabinet'}; }
while ( $nextcabinetfile eq $cabinetfile )
{
$sourcepath = $nextfile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; }
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
$uniquename = $nextfile->{'uniquename'};
my $localdoinclude = 1;
my $nextfilestyles = "";
if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; }
if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; }
$ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $localdoinclude ) { push(@ddffile, $ddfline); }
$i++; # increasing the counter!
$nextfile = ${$filesref}[$i+1];
if ( $nextfile ) { $nextcabinetfile = $nextfile->{'cabinet'}; }
else { $nextcabinetfile = "_lastfile_"; }
}
# creating the DDF file
my $ddffilename = $cabinetfile;
$ddffilename =~ s/.cab/.ddf/;
$ddfdir =~ s/\Q$installer::globals::separator\E\s*$//;
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
installer::files::save_file($ddffilename ,\@ddffile);
my $infoline = "Created ddf file: $ddffilename\n";
push(@installer::globals::logfileinfo, $infoline);
# lines in ddf files must not be longer than 256 characters
check_ddf_file(\@ddffile, $ddffilename);
# Writing the makecab system call
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n";
push(@cabfilelist, $oneline);
# collecting all ddf files
push(@installer::globals::allddffiles, $ddffilename);
}
}
elsif (( $installer::globals::one_cab_file ) && ( $installer::globals::updatedatabase ))
{
my $sequenceorder = get_sequenceorder($filesref);
my $counter = 1;
my $currentcabfile = "";
while ( ( exists($sequenceorder->{$counter}) ) || ( exists($installer::globals::allmergemodulefilesequences{$counter}) ) ) # Taking care of files from merge modules
{
if ( exists($installer::globals::allmergemodulefilesequences{$counter}) )
{
# Skipping this sequence, it is not included in $filesref, because it is assigned to a file from a merge module.\n";
$counter++;
next;
}
my $onefile = ${$filesref}[$sequenceorder->{$counter}];
$cabinetfile = $onefile->{'cabinet'};
my $sourcepath = $onefile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
my $uniquename = $onefile->{'uniquename'};
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
if ( $counter == 1 ) { write_ddf_file_header(\@ddffile, $cabinetfile, $installdir); }
my $styles = "";
my $doinclude = 1;
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $doinclude ) { push(@ddffile, $ddfline); }
$counter++; # increasing the counter
}
# creating the DDF file
my $ddffilename = $cabinetfile;
$ddffilename =~ s/.cab/.ddf/;
$ddfdir =~ s/[\/\\]\s*$//;
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
installer::files::save_file($ddffilename ,\@ddffile);
my $infoline = "Created ddf file: $ddffilename\n";
push(@installer::globals::logfileinfo, $infoline);
# lines in ddf files must not be longer than 256 characters
check_ddf_file(\@ddffile, $ddffilename);
# Writing the makecab system call
# my $oneline = "makecab.exe /F " . $ddffilename . "\n";
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n";
push(@cabfilelist, $oneline);
# collecting all ddf files
push(@installer::globals::allddffiles, $ddffilename);
}
elsif ( $installer::globals::one_cab_file )
{
my @ddffile = ();
my $cabinetfile = "";
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $onefile = ${$filesref}[$i];
$cabinetfile = $onefile->{'cabinet'};
my $sourcepath = $onefile->{'sourcepath'};
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; }
my $uniquename = $onefile->{'uniquename'};
# to avoid lines with more than 256 characters, it can be useful to use relative pathes
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} ) { $sourcepath = make_relative_ddf_path($sourcepath); }
if ( $i == 0 ) { write_ddf_file_header(\@ddffile, $cabinetfile, $installdir); }
my $styles = "";
my $doinclude = 1;
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; };
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; }
my $ddfline = "\"" . $sourcepath . "\"" . " " . $uniquename . "\n";
if ( $doinclude ) { push(@ddffile, $ddfline); }
}
# creating the DDF file
my $ddffilename = $cabinetfile;
$ddffilename =~ s/.cab/.ddf/;
$ddfdir =~ s/[\/\\]\s*$//;
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename;
installer::files::save_file($ddffilename ,\@ddffile);
my $infoline = "Created ddf file: $ddffilename\n";
push(@installer::globals::logfileinfo, $infoline);
# lines in ddf files must not be longer than 256 characters
check_ddf_file(\@ddffile, $ddffilename);
# Writing the makecab system call
my $oneline = "makecab.exe /F " . $ddffilename . "\n";
push(@cabfilelist, $oneline);
# collecting all ddf files
push(@installer::globals::allddffiles, $ddffilename);
}
else
{
installer::exiter::exit_program("ERROR: No cab file specification in globals.pm !", "create_media_table");
}
installer::logger::include_timestamp_into_logfile("Performance Info: ddf file generation end");
return \@cabfilelist; # contains all system calls for packaging process
}
########################################################################
# Returning the file sequence of a specified file.
########################################################################
sub get_file_sequence
{
my ($filesref, $uniquefilename) = @_;
my $sequence = "";
my $found_sequence = 0;
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $onefile = ${$filesref}[$i];
my $uniquename = $onefile->{'uniquename'};
if ( $uniquename eq $uniquefilename )
{
$sequence = $onefile->{'sequencenumber'};
$found_sequence = 1;
last;
}
}
if ( ! $found_sequence ) { installer::exiter::exit_program("ERROR: No sequence found for $uniquefilename !", "get_file_sequence"); }
return $sequence;
}
########################################################################
# For update and patch reasons the pack order needs to be saved.
# The pack order is saved in the ddf files; the names and locations
# of the ddf files are saved in @installer::globals::allddffiles.
# The outputfile "packorder.txt" can be saved in
# $installer::globals::infodirectory .
########################################################################
sub save_packorder
{
installer::logger::include_header_into_logfile("Saving pack order");
installer::logger::include_timestamp_into_logfile("Performance Info: saving pack order start");
my $packorderfilename = "packorder.txt";
$packorderfilename = $installer::globals::infodirectory . $installer::globals::separator . $packorderfilename;
my @packorder = ();
my $headerline = "\# Syntax\: Filetable_Sequence Cabinetfilename Physical_FileName Unique_FileName\n\n";
push(@packorder, $headerline);
for ( my $i = 0; $i <= $#installer::globals::allddffiles; $i++ )
{
my $ddffilename = $installer::globals::allddffiles[$i];
my $ddffile = installer::files::read_file($ddffilename);
my $cabinetfile = "";
for ( my $j = 0; $j <= $#{$ddffile}; $j++ )
{
my $oneline = ${$ddffile}[$j];
# Getting the Cabinet file name
if ( $oneline =~ /^\s*\.Set\s+CabinetName.*\=(.*?)\s*$/ ) { $cabinetfile = $1; }
if ( $oneline =~ /^\s*\.Set\s+/ ) { next; }
if ( $oneline =~ /^\s*\"(.*?)\"\s+(.*?)\s*$/ )
{
my $sourcefile = $1;
my $uniquefilename = $2;
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$sourcefile);
# Using the hash created in create_files_table for performance reasons to get the sequence number
my $filesequence = "";
if ( exists($installer::globals::uniquefilenamesequence{$uniquefilename}) ) { $filesequence = $installer::globals::uniquefilenamesequence{$uniquefilename}; }
else { installer::exiter::exit_program("ERROR: No sequence number value for $uniquefilename !", "save_packorder"); }
my $line = $filesequence . "\t" . $cabinetfile . "\t" . $sourcefile . "\t" . $uniquefilename . "\n";
push(@packorder, $line);
}
}
}
installer::files::save_file($packorderfilename ,\@packorder);
installer::logger::include_timestamp_into_logfile("Performance Info: saving pack order end");
}
#################################################################
# Returning the name of the msi database
#################################################################
sub get_msidatabasename
{
my ($allvariableshashref, $language) = @_;
my $databasename = $allvariableshashref->{'PRODUCTNAME'} . $allvariableshashref->{'PRODUCTVERSION'};
$databasename = lc($databasename);
$databasename =~ s/\.//g;
$databasename =~ s/\-//g;
$databasename =~ s/\s//g;
# possibility to overwrite the name with variable DATABASENAME
if ( $allvariableshashref->{'DATABASENAME'} )
{
$databasename = $allvariableshashref->{'DATABASENAME'};
}
if ( $language )
{
if (!($language eq ""))
{
$databasename .= "_$language";
}
}
$databasename .= ".msi";
return $databasename;
}
#################################################################
# Creating the msi database
# This works only on Windows
#################################################################
sub create_msi_database
{
my ($idtdirbase ,$msifilename) = @_;
# -f : path containing the idt files
# -d : msi database, including path
# -c : create database
# -i : include the following tables ("*" includes all available tables)
my $msidb = "msidb.exe"; # Has to be in the path
my $extraslash = ""; # Has to be set for non-ActiveState perl
installer::logger::include_header_into_logfile("Creating msi database");
$idtdirbase = installer::converter::make_path_conform($idtdirbase);
$msifilename = installer::converter::make_path_conform($msifilename);
if ( $^O =~ /cygwin/i ) {
# msidb.exe really wants backslashes. (And double escaping because system() expands the string.)
$idtdirbase =~ s/\//\\\\/g;
$msifilename =~ s/\//\\\\/g;
$extraslash = "\\";
}
my $systemcall = $msidb . " -f " . $idtdirbase . " -d " . $msifilename . " -c " . "-i " . $extraslash . "*";
my $returnvalue = system($systemcall);
my $infoline = "Systemcall: $systemcall\n";
push( @installer::globals::logfileinfo, $infoline);
if ($returnvalue)
{
$infoline = "ERROR: Could not execute $msidb!\n";
push( @installer::globals::logfileinfo, $infoline);
}
else
{
$infoline = "Success: Executed $msidb successfully!\n";
push( @installer::globals::logfileinfo, $infoline);
}
}
#####################################################################
# Returning the value from sis.mlf for Summary Information Stream
#####################################################################
sub get_value_from_sis_lng
{
my ($language, $languagefile, $searchstring) = @_;
my $language_block = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $languagefile);
my $newstring = installer::windows::idtglobal::get_language_string_from_language_block($language_block, $language, $searchstring);
$newstring = "\"" . $newstring . "\"";
return $newstring;
}
#################################################################
# Returning the msi version for the Summary Information Stream
#################################################################
sub get_msiversion_for_sis
{
my $msiversion = "200";
return $msiversion;
}
#################################################################
# Returning the word count for the Summary Information Stream
#################################################################
sub get_wordcount_for_sis
{
my $wordcount = "0";
return $wordcount;
}
#################################################################
# Returning the codepage for the Summary Information Stream
#################################################################
sub get_codepage_for_sis
{
my ( $language ) = @_;
my $codepage = installer::windows::language::get_windows_encoding($language);
# Codepage 65001 does not work in Summary Information Stream
if ( $codepage == 65001 ) { $codepage = 0; }
# my $codepage = "1252"; # determine dynamically in a function
# my $codepage = "65001"; # UTF-8
return $codepage;
}
#################################################################
# Returning the template for the Summary Information Stream
#################################################################
sub get_template_for_sis
{
my ( $language ) = @_;
my $windowslanguage = installer::windows::language::get_windows_language($language);
my $value = "\"Intel;" . $windowslanguage; # adding the Windows language
$value = $value . "\""; # adding ending '"'
return $value ;
}
#################################################################
# Returning the PackageCode for the Summary Information Stream
#################################################################
sub get_packagecode_for_sis
{
# always generating a new package code for each package
my $guidref = get_guid_list(1, 1); # only one GUID shall be generated
${$guidref}[0] =~ s/\s*$//; # removing ending spaces
my $guid = "\{" . ${$guidref}[0] . "\}";
my $infoline = "PackageCode: $guid\n";
push( @installer::globals::logfileinfo, $infoline);
return $guid;
}
#################################################################
# Returning the title for the Summary Information Stream
#################################################################
sub get_title_for_sis
{
my ( $language, $languagefile, $searchstring ) = @_;
my $title = get_value_from_sis_lng($language, $languagefile, $searchstring );
return $title;
}
#################################################################
# Returning the author for the Summary Information Stream
#################################################################
sub get_author_for_sis
{
my $author = $installer::globals::longmanufacturer;
$author = "\"" . $author . "\"";
return $author;
}
#################################################################
# Returning the subject for the Summary Information Stream
#################################################################
sub get_subject_for_sis
{
my ( $allvariableshashref ) = @_;
my $subject = $allvariableshashref->{'PRODUCTNAME'} . " " . $allvariableshashref->{'PRODUCTVERSION'};
$subject = "\"" . $subject . "\"";
return $subject;
}
#################################################################
# Returning the comment for the Summary Information Stream
#################################################################
sub get_comment_for_sis
{
my ( $language, $languagefile, $searchstring ) = @_;
my $comment = get_value_from_sis_lng($language, $languagefile, $searchstring );
return $comment;
}
#################################################################
# Returning the keywords for the Summary Information Stream
#################################################################
sub get_keywords_for_sis
{
my ( $language, $languagefile, $searchstring ) = @_;
my $keywords = get_value_from_sis_lng($language, $languagefile, $searchstring );
return $keywords;
}
######################################################################
# Returning the application name for the Summary Information Stream
######################################################################
sub get_appname_for_sis
{
my ( $language, $languagefile, $searchstring ) = @_;
my $appname = get_value_from_sis_lng($language, $languagefile, $searchstring );
return $appname;
}
######################################################################
# Returning the security for the Summary Information Stream
######################################################################
sub get_security_for_sis
{
my $security = "0";
return $security;
}
#################################################################
# Writing the Summary information stream into the msi database
# This works only on Windows
#################################################################
sub write_summary_into_msi_database
{
my ($msifilename, $language, $languagefile, $allvariableshashref) = @_;
# -g : requrired msi version
# -c : codepage
# -p : template
installer::logger::include_header_into_logfile("Writing summary information stream");
my $msiinfo = "msiinfo.exe"; # Has to be in the path
my $sislanguage = "en-US"; # title, comment, keyword and appname alway in english
my $msiversion = get_msiversion_for_sis();
my $codepage = get_codepage_for_sis($language);
my $template = get_template_for_sis($language);
my $guid = get_packagecode_for_sis();
my $title = get_title_for_sis($sislanguage,$languagefile, "OOO_SIS_TITLE");
my $author = get_author_for_sis();
my $subject = get_subject_for_sis($allvariableshashref);
my $comment = get_comment_for_sis($sislanguage,$languagefile, "OOO_SIS_COMMENT");
my $keywords = get_keywords_for_sis($sislanguage,$languagefile, "OOO_SIS_KEYWORDS");
my $appname = get_appname_for_sis($sislanguage,$languagefile, "OOO_SIS_APPNAME");
my $security = get_security_for_sis();
my $wordcount = get_wordcount_for_sis();
$msifilename = installer::converter::make_path_conform($msifilename);
my $systemcall = $msiinfo . " " . $msifilename . " -g " . $msiversion . " -c " . $codepage
. " -p " . $template . " -v " . $guid . " -t " . $title . " -a " . $author
. " -j " . $subject . " -o " . $comment . " -k " . $keywords . " -n " . $appname
. " -u " . $security . " -w " . $wordcount;
my $returnvalue = system($systemcall);
my $infoline = "Systemcall: $systemcall\n";
push( @installer::globals::logfileinfo, $infoline);
if ($returnvalue)
{
$infoline = "ERROR: Could not execute $msiinfo!\n";
push( @installer::globals::logfileinfo, $infoline);
}
else
{
$infoline = "Success: Executed $msiinfo successfully!\n";
push( @installer::globals::logfileinfo, $infoline);
}
}
#########################################################################
# For more than one language in the installation set:
# Use one database and create Transformations for all other languages
#########################################################################
sub create_transforms
{
my ($languagesarray, $defaultlanguage, $installdir, $allvariableshashref) = @_;
installer::logger::include_header_into_logfile("Creating Transforms");
my $msitran = "msitran.exe"; # Has to be in the path
$installdir = installer::converter::make_path_conform($installdir);
# Syntax for creating a transformation
# msitran.exe -g <baseDB> <referenceDB> <transformfile> [<errorhandling>}
my $basedbname = get_msidatabasename($allvariableshashref, $defaultlanguage);
$basedbname = $installdir . $installer::globals::separator . $basedbname;
my $errorhandling = "f"; # Suppress "change codepage" error
# Iterating over all files
foreach ( @{$languagesarray} )
{
my $onelanguage = $_;
if ( $onelanguage eq $defaultlanguage ) { next; }
my $referencedbname = get_msidatabasename($allvariableshashref, $onelanguage);
$referencedbname = $installdir . $installer::globals::separator . $referencedbname;
my $transformfile = $installdir . $installer::globals::separator . "trans_" . $onelanguage . ".mst";
my $systemcall = $msitran . " " . " -g " . $basedbname . " " . $referencedbname . " " . $transformfile . " " . $errorhandling;
my $returnvalue = system($systemcall);
my $infoline = "Systemcall: $systemcall\n";
push( @installer::globals::logfileinfo, $infoline);
# Problem: msitran.exe in version 4.0 always returns "1", even if no failure occured.
# Therefore it has to be checked, if this is version 4.0. If yes, if the mst file
# exists and if it is larger than 0 bytes. If this is true, then no error occured.
# File Version of msitran.exe: 4.0.6000.16384 has checksum: "b66190a70145a57773ec769e16777b29".
# Same for msitran.exe from wntmsci12: "aa25d3445b94ffde8ef0c1efb77a56b8"
if ($returnvalue)
{
$infoline = "WARNING: Returnvalue of $msitran is not 0. Checking version of $msitran!\n";
push( @installer::globals::logfileinfo, $infoline);
open(FILE, "<$installer::globals::msitranpath") or die "ERROR: Can't open $installer::globals::msitranpath for creating file hash";
binmode(FILE);
my $digest = Digest::MD5->new->addfile(*FILE)->hexdigest;
close(FILE);
my @problemchecksums = ("b66190a70145a57773ec769e16777b29", "aa25d3445b94ffde8ef0c1efb77a56b8");
my $isproblemchecksum = 0;
foreach my $problemchecksum ( @problemchecksums )
{
$infoline = "Checksum of problematic MsiTran.exe: $problemchecksum\n";
push( @installer::globals::logfileinfo, $infoline);
$infoline = "Checksum of used MsiTran.exe: $digest\n";
push( @installer::globals::logfileinfo, $infoline);
if ( $digest eq $problemchecksum ) { $isproblemchecksum = 1; }
}
if ( $isproblemchecksum )
{
# Check existence of mst
if ( -f $transformfile )
{
$infoline = "File $transformfile exists.\n";
push( @installer::globals::logfileinfo, $infoline);
my $filesize = ( -s $transformfile );
$infoline = "Size of $transformfile: $filesize\n";
push( @installer::globals::logfileinfo, $infoline);
if ( $filesize > 0 )
{
$infoline = "Info: Returnvalue $returnvalue of $msitran is no problem :-) .\n";
push( @installer::globals::logfileinfo, $infoline);
$returnvalue = 0; # reset the error
}
else
{
$infoline = "Filesize indicates that an error occured.\n";
push( @installer::globals::logfileinfo, $infoline);
}
}
else
{
$infoline = "File $transformfile does not exist -> An error occured.\n";
push( @installer::globals::logfileinfo, $infoline);
}
}
else
{
$infoline = "This is not a problematic version of msitran.exe. Therefore the error is not caused by problematic msitran.exe.\n";
push( @installer::globals::logfileinfo, $infoline);
}
}
if ($returnvalue)
{
$infoline = "ERROR: Could not execute $msitran!\n";
push( @installer::globals::logfileinfo, $infoline);
}
else
{
$infoline = "Success: Executed $msitran successfully!\n";
push( @installer::globals::logfileinfo, $infoline);
}
# The reference database can be deleted
my $result = unlink($referencedbname);
# $result contains the number of deleted files
if ( $result == 0 )
{
$infoline = "ERROR: Could not remove file $$referencedbname !\n";
push( @installer::globals::logfileinfo, $infoline);
installer::exiter::exit_program($infoline, "create_transforms");
}
}
}
#########################################################################
# The default language msi database does not need to contain
# the language in the database name. Therefore the file
# is renamed. Example: "openofficeorg20_01.msi" to "openofficeorg20.msi"
#########################################################################
sub rename_msi_database_in_installset
{
my ($defaultlanguage, $installdir, $allvariableshashref) = @_;
installer::logger::include_header_into_logfile("Renaming msi database");
my $olddatabasename = get_msidatabasename($allvariableshashref, $defaultlanguage);
$olddatabasename = $installdir . $installer::globals::separator . $olddatabasename;
my $newdatabasename = get_msidatabasename($allvariableshashref);
$installer::globals::shortmsidatabasename = $newdatabasename;
$newdatabasename = $installdir . $installer::globals::separator . $newdatabasename;
installer::systemactions::rename_one_file($olddatabasename, $newdatabasename);
$installer::globals::msidatabasename = $newdatabasename;
}
#########################################################################
# Adding the language to the name of the msi databasename,
# if this is required (ADDLANGUAGEINDATABASENAME)
#########################################################################
sub add_language_to_msi_database
{
my ($defaultlanguage, $installdir, $allvariables) = @_;
my $languagestring = $defaultlanguage;
if ( $allvariables->{'USELANGUAGECODE'} ) { $languagestring = installer::windows::language::get_windows_language($defaultlanguage); }
my $newdatabasename = $installer::globals::shortmsidatabasename;
$newdatabasename =~ s/\.msi\s*$/_$languagestring\.msi/;
$installer::globals::shortmsidatabasename = $newdatabasename;
$newdatabasename = $installdir . $installer::globals::separator . $newdatabasename;
my $olddatabasename = $installer::globals::msidatabasename;
installer::systemactions::rename_one_file($olddatabasename, $newdatabasename);
$installer::globals::msidatabasename = $newdatabasename;
}
##########################################################################
# Writing the databasename into the setup.ini.
##########################################################################
sub put_databasename_into_setupini
{
my ($setupinifile, $allvariableshashref) = @_;
my $databasename = get_msidatabasename($allvariableshashref);
my $line = "database=" . $databasename . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the path to the instmsiw.exe into setup.ini
##########################################################################
sub put_instmsiwpath_into_setupini
{
my ($setupinifile) = @_;
my $instmsiwexepath = "instmsiw.exe";
my $line = "instmsiw=" . $instmsiwexepath . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the path to the instmsia.exe into setup.ini
##########################################################################
sub put_instmsiapath_into_setupini
{
my ($setupinifile) = @_;
my $instmsiaexepath = "instmsia.exe";
my $line = "instmsia=" . $instmsiaexepath . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the required msi version into setup.ini
##########################################################################
sub put_msiversion_into_setupini
{
my ($setupinifile) = @_;
my $msiversion = "2.0";
my $line = "msiversion=" . $msiversion . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the productname into setup.ini
##########################################################################
sub put_productname_into_setupini
{
my ($setupinifile, $allvariableshashref) = @_;
my $productname = $allvariableshashref->{'PRODUCTNAME'};
my $line = "productname=" . $productname . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the productcode into setup.ini
##########################################################################
sub put_productcode_into_setupini
{
my ($setupinifile) = @_;
my $productcode = $installer::globals::productcode;
my $line = "productcode=" . $productcode . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the ProductVersion from Property table into setup.ini
##########################################################################
sub put_productversion_into_setupini
{
my ($setupinifile) = @_;
my $line = "productversion=" . $installer::globals::msiproductversion . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the key for Minor Upgrades into setup.ini
##########################################################################
sub put_upgradekey_into_setupini
{
my ($setupinifile) = @_;
if ( $installer::globals::minorupgradekey ne "" )
{
my $line = "upgradekey=" . $installer::globals::minorupgradekey . "\n";
push(@{$setupinifile}, $line);
}
}
##########################################################################
# Writing the number of languages into setup.ini
##########################################################################
sub put_languagecount_into_setupini
{
my ($setupinifile, $languagesarray) = @_;
my $languagecount = $#{$languagesarray} + 1;
my $line = "count=" . $languagecount . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the defaultlanguage into setup.ini
##########################################################################
sub put_defaultlanguage_into_setupini
{
my ($setupinifile, $defaultlanguage) = @_;
my $windowslanguage = installer::windows::language::get_windows_language($defaultlanguage);
my $line = "default=" . $windowslanguage . "\n";
push(@{$setupinifile}, $line);
}
##########################################################################
# Writing the information about transformations into setup.ini
##########################################################################
sub put_transforms_into_setupini
{
my ($setupinifile, $onelanguage, $counter) = @_;
my $windowslanguage = installer::windows::language::get_windows_language($onelanguage);
my $transformfilename = "trans_" . $onelanguage . ".mst";
my $line = "lang" . $counter . "=" . $windowslanguage . "," . $transformfilename . "\n";
push(@{$setupinifile}, $line);
}
###################################################
# Including Windows line ends in ini files
# Profiles on Windows shall have \r\n line ends
###################################################
sub include_windows_lineends
{
my ($onefile) = @_;
for ( my $i = 0; $i <= $#{$onefile}; $i++ )
{
${$onefile}[$i] =~ s/\r?\n$/\r\n/;
}
}
##########################################################################
# Generation the file setup.ini, that is used by the loader setup.exe.
##########################################################################
sub create_setup_ini
{
my ($languagesarray, $defaultlanguage, $installdir, $allvariableshashref) = @_;
installer::logger::include_header_into_logfile("Creating setup.ini");
my $setupinifilename = $installdir . $installer::globals::separator . "setup.ini";
my @setupinifile = ();
my $setupinifile = \@setupinifile;
my $line = "\[setup\]\n";
push(@setupinifile, $line);
put_databasename_into_setupini($setupinifile, $allvariableshashref);
put_instmsiwpath_into_setupini($setupinifile);
put_instmsiapath_into_setupini($setupinifile);
put_msiversion_into_setupini($setupinifile);
put_productname_into_setupini($setupinifile, $allvariableshashref);
put_productcode_into_setupini($setupinifile);
put_productversion_into_setupini($setupinifile);
put_upgradekey_into_setupini($setupinifile);
$line = "\[languages\]\n";
push(@setupinifile, $line);
put_languagecount_into_setupini($setupinifile, $languagesarray);
put_defaultlanguage_into_setupini($setupinifile, $defaultlanguage);
if ( $#{$languagesarray} > 0 ) # writing the transforms information
{
my $counter = 1;
for ( my $i = 0; $i <= $#{$languagesarray}; $i++ )
{
if ( ${$languagesarray}[$i] eq $defaultlanguage ) { next; }
put_transforms_into_setupini($setupinifile, ${$languagesarray}[$i], $counter);
$counter++;
}
}
if ( $installer::globals::iswin && $installer::globals::plat =~ /cygwin/i) # Windows line ends only for Cygwin
{
include_windows_lineends($setupinifile);
}
installer::files::save_file($setupinifilename, $setupinifile);
$infoline = "Generated file $setupinifilename !\n";
push( @installer::globals::logfileinfo, $infoline);
}
#################################################################
# Copying the files defined as ScpActions into the
# installation set.
#################################################################
sub copy_scpactions_into_installset
{
my ($defaultlanguage, $installdir, $allscpactions) = @_;
installer::logger::include_header_into_logfile("Copying ScpAction files into installation set");
for ( my $i = 0; $i <= $#{$allscpactions}; $i++ )
{
my $onescpaction = ${$allscpactions}[$i];
if ( $onescpaction->{'Name'} eq "loader.exe" ) { next; } # do not copy this ScpAction loader
# only copying language independent files or files with the correct language (the defaultlanguage)
my $filelanguage = $onescpaction->{'specificlanguage'};
if ( ($filelanguage eq $defaultlanguage) || ($filelanguage eq "") )
{
my $sourcefile = $onescpaction->{'sourcepath'};
my $destfile = $installdir . $installer::globals::separator . $onescpaction->{'DestinationName'};
installer::systemactions::copy_one_file($sourcefile, $destfile);
}
}
}
#################################################################
# Copying the files for the Windows installer into the
# installation set (setup.exe, instmsia.exe, instmsiw.exe).
#################################################################
sub copy_windows_installer_files_into_installset
{
my ($installdir, $includepatharrayref, $allvariables) = @_;
installer::logger::include_header_into_logfile("Copying Windows installer files into installation set");
@copyfile = ();
push(@copyfile, "instmsia.exe");
push(@copyfile, "instmsiw.exe");
push(@copyfile, "loader2.exe");
if ( $allvariables->{'NOLOADERREQUIRED'} ) { @copyfile = (); }
for ( my $i = 0; $i <= $#copyfile; $i++ )
{
my $filename = $copyfile[$i];
my $sourcefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$filename, $includepatharrayref, 1);
if ( ! -f $$sourcefileref ) { installer::exiter::exit_program("ERROR: msi file not found: $$sourcefileref !", "copy_windows_installer_files_into_installset"); }
my $destfile;
if ( $copyfile[$i] eq "loader2.exe" ) { $destfile = "setup.exe"; } # renaming the loader
else { $destfile = $copyfile[$i]; }
$destfile = $installdir . $installer::globals::separator . $destfile;
installer::systemactions::copy_one_file($$sourcefileref, $destfile);
}
}
#################################################################
# Copying MergeModules for the Windows installer into the
# installation set. The list of MergeModules is located
# in %installer::globals::copy_msm_files
#################################################################
sub copy_merge_modules_into_installset
{
my ($installdir) = @_;
installer::logger::include_header_into_logfile("Copying Merge files into installation set");
my $cabfile;
foreach $cabfile ( keys %installer::globals::copy_msm_files )
{
my $sourcefile = $installer::globals::copy_msm_files{$cabfile};
my $destfile = $installdir . $installer::globals::separator . $cabfile;
installer::systemactions::copy_one_file($sourcefile, $destfile);
}
}
#################################################################
# Copying the child projects into the
# installation set
#################################################################
sub copy_child_projects_into_installset
{
my ($installdir, $allvariables) = @_;
my $sourcefile = "";
my $destdir = "";
# adding Java
if ( $allvariables->{'JAVAPRODUCT'} )
{
$sourcefile = $installer::globals::javafile->{'sourcepath'};
$destdir = $installdir . $installer::globals::separator . $installer::globals::javafile->{'Subdir'};
if ( ! -d $destdir) { installer::systemactions::create_directory($destdir); }
installer::systemactions::copy_one_file($sourcefile, $destdir);
}
if ( $allvariables->{'UREPRODUCT'} )
{
$sourcefile = $installer::globals::urefile->{'sourcepath'};
$destdir = $installdir . $installer::globals::separator . $installer::globals::urefile->{'Subdir'};
if ( ! -d $destdir) { installer::systemactions::create_directory($destdir); }
installer::systemactions::copy_one_file($sourcefile, $destdir);
}
}
#################################################################
# Getting a list of GUID using uuidgen.exe.
# This works only on Windows
#################################################################
sub get_guid_list
{
my ($number, $log) = @_;
if ( $log ) { installer::logger::include_header_into_logfile("Generating $number GUID"); }
my $uuidgen = "uuidgen.exe"; # Has to be in the path
# "-c" for uppercase output
# my $systemcall = "$uuidgen -n$number -c |";
my $systemcall = "$uuidgen -n$number |";
open (UUIDGEN, "$systemcall" ) or die("uuidgen is missing.");
my @uuidlist = <UUIDGEN>;
close (UUIDGEN);
my $infoline = "Systemcall: $systemcall\n";
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); }
my $comparenumber = $#uuidlist + 1;
if ( $comparenumber == $number )
{
$infoline = "Success: Executed $uuidgen successfully!\n";
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); }
}
else
{
$infoline = "ERROR: Could not execute $uuidgen successfully!\n";
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); }
}
# uppercase, no longer "-c", because this is only supported in uuidgen.exe v.1.01
for ( my $i = 0; $i <= $#uuidlist; $i++ ) { $uuidlist[$i] = uc($uuidlist[$i]); }
return \@uuidlist;
}
#################################################################
# Calculating a GUID with a string using md5.
#################################################################
sub calculate_guid
{
my ( $string ) = @_;
my $guid = "";
my $md5 = Digest::MD5->new;
$md5->add($string);
my $digest = $md5->hexdigest;
$digest = uc($digest);
# my $id = pack("A32", $digest);
my ($first, $second, $third, $fourth, $fifth) = unpack ('A8 A4 A4 A4 A12', $digest);
$guid = "$first-$second-$third-$fourth-$fifth";
return $guid;
}
#################################################################
# Filling the component hash with the values of the
# component file.
#################################################################
sub fill_component_hash
{
my ($componentfile) = @_;
my %components = ();
for ( my $i = 0; $i <= $#{$componentfile}; $i++ )
{
my $line = ${$componentfile}[$i];
if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ )
{
my $key = $1;
my $value = $2;
$components{$key} = $value;
}
}
return \%components;
}
#################################################################
# Creating a new component file, if new guids were generated.
#################################################################
sub create_new_component_file
{
my ($componenthash) = @_;
my @componentfile = ();
my $key;
foreach $key (keys %{$componenthash})
{
my $value = $componenthash->{$key};
my $input = "$key\t$value\n";
push(@componentfile ,$input);
}
return \@componentfile;
}
#################################################################
# Filling real component GUID into the component table.
# This works only on Windows
#################################################################
sub set_uuid_into_component_table
{
my ($idtdirbase, $allvariables) = @_;
my $componenttablename = $idtdirbase . $installer::globals::separator . "Componen.idt";
my $componenttable = installer::files::read_file($componenttablename);
# For update and patch reasons (small update) the GUID of an existing component must not change!
# The collection of component GUIDs is saved in the directory $installer::globals::idttemplatepath in the file "components.txt"
my $infoline = "";
my $counter = 0;
# my $componentfile = installer::files::read_file($installer::globals::componentfilename);
# my $componenthash = fill_component_hash($componentfile);
for ( my $i = 3; $i <= $#{$componenttable}; $i++ ) # ignoring the first three lines
{
my $oneline = ${$componenttable}[$i];
my $componentname = "";
if ( $oneline =~ /^\s*(\S+?)\t/ ) { $componentname = $1; }
my $uuid = "";
# if ( $componenthash->{$componentname} )
# {
# $uuid = $componenthash->{$componentname};
# }
# else
# {
if ( exists($installer::globals::calculated_component_guids{$componentname}))
{
$uuid = $installer::globals::calculated_component_guids{$componentname};
}
else
{
# Calculating new GUID with the help of the component name.
my $useooobaseversion = 1;
if ( exists($installer::globals::base_independent_components{$componentname})) { $useooobaseversion = 0; }
my $sourcestring = $componentname;
if ( $useooobaseversion )
{
if ( ! exists($allvariables->{'OOOBASEVERSION'}) ) { installer::exiter::exit_program("ERROR: Could not find variable \"OOOBASEVERSION\" (required value for GUID creation)!", "set_uuid_into_component_table"); }
$sourcestring = $sourcestring . "_" . $allvariables->{'OOOBASEVERSION'};
}
$uuid = calculate_guid($sourcestring);
$counter++;
# checking, if there is a conflict with an already created guid
if ( exists($installer::globals::allcalculated_guids{$uuid}) ) { installer::exiter::exit_program("ERROR: \"$uuid\" was already created before!", "set_uuid_into_component_table"); }
$installer::globals::allcalculated_guids{$uuid} = 1;
$installer::globals::calculated_component_guids{$componentname} = $uuid;
# Setting new uuid
# $componenthash->{$componentname} = $uuid;
# Setting flag
# $installer::globals::created_new_component_guid = 1; # this is very important!
}
# }
${$componenttable}[$i] =~ s/COMPONENTGUID/$uuid/;
}
installer::files::save_file($componenttablename, $componenttable);
# if ( $installer::globals::created_new_component_guid )
# {
# # create new component file!
# $componentfile = create_new_component_file($componenthash);
# installer::worker::sort_array($componentfile);
#
# # To avoid conflict the components file cannot be saved at the same place
# # All important data have to be saved in the directory: $installer::globals::infodirectory
# my $localcomponentfilename = $installer::globals::componentfilename;
# installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$localcomponentfilename);
# $localcomponentfilename = $installer::globals::infodirectory . $installer::globals::separator . $localcomponentfilename;
# installer::files::save_file($localcomponentfilename, $componentfile);
#
# # installer::files::save_file($installer::globals::componentfilename, $componentfile); # version using new file in solver
#
# $infoline = "COMPONENTCODES: Created $counter new GUIDs for components ! \n";
# push( @installer::globals::logfileinfo, $infoline);
# }
# else
# {
# $infoline = "SUCCESS COMPONENTCODES: All component codes exist! \n";
# push( @installer::globals::logfileinfo, $infoline);
# }
}
#################################################################
# Include all cab files into the msi database.
# This works only on Windows
#################################################################
sub include_cabs_into_msi
{
my ($installdir) = @_;
installer::logger::include_header_into_logfile("Including cabs into msi database");
my $from = cwd();
my $to = $installdir;
chdir($to);
my $infoline = "Changing into directory: $to";
push( @installer::globals::logfileinfo, $infoline);
my $msidb = "msidb.exe"; # Has to be in the path
my $extraslash = ""; # Has to be set for non-ActiveState perl
my $msifilename = $installer::globals::msidatabasename;
$msifilename = installer::converter::make_path_conform($msifilename);
if ( $ENV{'USE_SHELL'} ne "4nt" ) {
# msidb.exe really wants backslashes. (And double escaping because system() expands the string.)
$idtdirbase =~ s/\//\\\\/g;
$msifilename =~ s/\//\\\\/g;
$extraslash = "\\";
}
my $allcabfiles = installer::systemactions::find_file_with_file_extension("cab", $installdir);
for ( my $i = 0; $i <= $#{$allcabfiles}; $i++ )
{
my $systemcall = $msidb . " -d " . $msifilename . " -a " . ${$allcabfiles}[$i];
my $returnvalue = system($systemcall);
$infoline = "Systemcall: $systemcall\n";
push( @installer::globals::logfileinfo, $infoline);
if ($returnvalue)
{
$infoline = "ERROR: Could not execute $systemcall !\n";
push( @installer::globals::logfileinfo, $infoline);
}
else
{
$infoline = "Success: Executed $systemcall successfully!\n";
push( @installer::globals::logfileinfo, $infoline);
}
# deleting the cab file
unlink(${$allcabfiles}[$i]);
$infoline = "Deleted cab file: ${$allcabfiles}[$i]\n";
push( @installer::globals::logfileinfo, $infoline);
}
$infoline = "Changing back into directory: $from";
push( @installer::globals::logfileinfo, $infoline);
chdir($from);
}
#################################################################
# Executing the created batch file to pack all files.
# This works only on Windows
#################################################################
sub execute_packaging
{
my ($localpackjobref, $loggingdir, $allvariables) = @_;
installer::logger::include_header_into_logfile("Packaging process");
installer::logger::include_timestamp_into_logfile("Performance Info: Execute packaging start");
my $infoline = "";
my $from = cwd();
my $to = $loggingdir;
chdir($to);
$infoline = "chdir: $to \n";
push( @installer::globals::logfileinfo, $infoline);
# if the ddf file contains relative pathes, it is necessary to change into the temp directory
if ( $allvariables->{'RELATIVE_PATHES_IN_DDF'} )
{
$to = $installer::globals::temppath;
chdir($to);
$infoline = "chdir: $to \n";
push( @installer::globals::logfileinfo, $infoline);
}
# changing the tmp directory, because makecab.exe generates temporary cab files
my $origtemppath = "";
if ( $ENV{'TMP'} ) { $origtemppath = $ENV{'TMP'}; }
$ENV{'TMP'} = $installer::globals::temppath; # setting TMP to the new unique directory!
my $maxmakecabcalls = 3;
my $allmakecabcalls = $#{$localpackjobref} + 1;
for ( my $i = 0; $i <= $#{$localpackjobref}; $i++ )
{
my $systemcall = ${$localpackjobref}[$i];
my $callscounter = $i + 1;
installer::logger::print_message( "... makecab.exe ($callscounter/$allmakecabcalls) ... \n" );
# my $returnvalue = system($systemcall);
for ( my $n = 1; $n <= $maxmakecabcalls; $n++ )
{
my @ddfoutput = ();
$infoline = "Systemcall: $systemcall";
push( @installer::globals::logfileinfo, $infoline);
open (DDF, "$systemcall");
while (<DDF>) {push(@ddfoutput, $_); }
close (DDF);
my $returnvalue = $?; # $? contains the return value of the systemcall
if ($returnvalue)
{
if ( $n < $maxmakecabcalls )
{
installer::logger::print_message( "makecab_error (Try $n): Trying again \n" );
$infoline = "makecab_error (Try $n): $systemcall !";
}
else
{
installer::logger::print_message( "ERROR (Try $n): Abort packing \n" );
$infoline = "ERROR (Try $n): $systemcall !";
}
push( @installer::globals::logfileinfo, $infoline);
# for ( my $j = 0; $j <= $#ddfoutput; $j++ ) { push( @installer::globals::logfileinfo, "$ddfoutput[$j]"); }
for ( my $m = 0; $m <= $#ddfoutput; $m++ )
{
if ( $ddfoutput[$m] =~ /(ERROR\:.*?)\s*$/ )
{
$infoline = $1 . "\n";
if ( $n < $maxmakecabcalls ) { $infoline =~ s/ERROR\:/makecab_error\:/i; }
installer::logger::print_message( $infoline );
push( @installer::globals::logfileinfo, $infoline);
}
}
if ( $n == $maxmakecabcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "execute_packaging"); }
}
else
{
# installer::logger::print_message( "Success (Try $n): \"$systemcall\"\n" );
$infoline = "Success (Try $n): $systemcall";
push( @installer::globals::logfileinfo, $infoline);
last;
}
}
}
installer::logger::include_timestamp_into_logfile("Performance Info: Execute packaging end");
# setting back to the original tmp directory
$ENV{'TMP'} = $origtemppath;
chdir($from);
$infoline = "chdir: $from \n";
push( @installer::globals::logfileinfo, $infoline);
}
###############################################################
# Setting the global variables ProductCode and the UpgradeCode
###############################################################
sub set_global_code_variables
{
my ( $languagesref, $languagestringref, $allvariableshashref, $alloldproperties ) = @_;
# In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
# and the UpgradeCode for the product are defined.
# The name "codes.txt" can be overwritten in Product definition with CODEFILENAME .
# Default $installer::globals::codefilename is defined in parameter.pm.
if ( $allvariableshashref->{'CODEFILENAME'} )
{
$installer::globals::codefilename = $installer::globals::idttemplatepath . $installer::globals::separator . $allvariableshashref->{'CODEFILENAME'};
installer::files::check_file($installer::globals::codefilename);
}
my $infoline = "Using Codes file: $installer::globals::codefilename \n";
push( @installer::globals::logfileinfo, $infoline);
my $codefile = installer::files::read_file($installer::globals::codefilename);
my $isopensource = 0;
if ( $allvariableshashref->{'OPENSOURCE'} ) { $isopensource = $allvariableshashref->{'OPENSOURCE'}; }
my $onelanguage = "";
if ( $#{$languagesref} > 0 ) # more than one language
{
if (( ${$languagesref}[1] =~ /jp/ ) ||
( ${$languagesref}[1] =~ /ko/ ) ||
( ${$languagesref}[1] =~ /zh/ ))
{
$onelanguage = "multiasia";
}
else
{
$onelanguage = "multiwestern";
}
}
else # only one language
{
$onelanguage = ${$languagesref}[0];
}
# ProductCode must not change, if Windows patches shall be applied
if ( $installer::globals::updatedatabase )
{
$installer::globals::productcode = $alloldproperties->{'ProductCode'};
}
elsif ( $installer::globals::prepare_winpatch )
{
# ProductCode has to be specified in each language
my $searchstring = "PRODUCTCODE";
my $codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile);
$installer::globals::productcode = installer::windows::idtglobal::get_code_from_code_block($codeblock, $onelanguage);
} else {
my $guidref = get_guid_list(1, 1); # only one GUID shall be generated
${$guidref}[0] =~ s/\s*$//; # removing ending spaces
$installer::globals::productcode = "\{" . ${$guidref}[0] . "\}";
}
if ( $installer::globals::patch ) # patch upgrade codes are defined in soffice.lst
{
if ( $allvariableshashref->{'PATCHUPGRADECODE'} ) { $installer::globals::upgradecode = $allvariableshashref->{'PATCHUPGRADECODE'}; }
else { installer::exiter::exit_program("ERROR: PATCHUPGRADECODE not defined in list file!", "set_global_code_variables"); }
}
else
{
# UpgradeCode can take english as default, if not defined in specified language
$searchstring = "UPGRADECODE"; # searching in the codes.txt file
$codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile);
$installer::globals::upgradecode = installer::windows::idtglobal::get_language_string_from_language_block($codeblock, $onelanguage, "");
}
# if (( $installer::globals::productcode eq "" ) && ( ! $isopensource )) { installer::exiter::exit_program("ERROR: ProductCode for language $onelanguage not defined in $installer::globals::codefilename !", "set_global_code_variables"); }
if ( $installer::globals::upgradecode eq "" ) { installer::exiter::exit_program("ERROR: UpgradeCode not defined in $installer::globals::codefilename !", "set_global_code_variables"); }
$infoline = "Setting ProductCode to: $installer::globals::productcode \n";
push( @installer::globals::logfileinfo, $infoline);
$infoline = "Setting UpgradeCode to: $installer::globals::upgradecode \n";
push( @installer::globals::logfileinfo, $infoline);
# Adding both variables into the variables array
$allvariableshashref->{'PRODUCTCODE'} = $installer::globals::productcode;
$allvariableshashref->{'UPGRADECODE'} = $installer::globals::upgradecode;
$infoline = "Defined variable PRODUCTCODE: $installer::globals::productcode \n";
push( @installer::globals::logfileinfo, $infoline);
$infoline = "Defined variable UPGRADECODE: $installer::globals::upgradecode \n";
push( @installer::globals::logfileinfo, $infoline);
}
###############################################################
# Setting the product version used in property table and
# upgrade table. Saving in global variable $msiproductversion
###############################################################
sub set_msiproductversion
{
my ( $allvariables ) = @_;
my $productversion = $allvariables->{'PRODUCTVERSION'};
if (( $productversion =~ /^\s*\d+\s*$/ ) && ( $productversion > 255 )) { $productversion = $productversion%256; }
if ( $productversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
{
$productversion = $1 . "\." . $2 . $3 . "\." . $installer::globals::buildid;
}
elsif ( $productversion =~ /^\s*(\d+)\.(\d+)\s*$/ )
{
$productversion = $1 . "\." . $2 . "\." . $installer::globals::buildid;
}
else
{
$productversion = $productversion . "\." . "00" . "\." . $installer::globals::buildid;
}
$installer::globals::msiproductversion = $productversion;
# Setting $installer::globals::msimajorproductversion, to differ between old version in upgrade table
if ( $installer::globals::msiproductversion =~ /^\s*(\d+)\./ )
{
my $major = $1;
$installer::globals::msimajorproductversion = $major . "\.0\.0";
}
}
#################################################################################
# Including the msi product version into the bootstrap.ini, Windows only
#################################################################################
sub put_msiproductversion_into_bootstrapfile
{
my ($filesref) = @_;
for ( my $i = 0; $i <= $#{$filesref}; $i++ )
{
my $onefile = ${$filesref}[$i];
if ( $onefile->{'gid'} eq "gid_Profile_Version_Ini" )
{
my $file = installer::files::read_file($onefile->{'sourcepath'});
for ( my $j = 0; $j <= $#{$file}; $j++ )
{
${$file}[$j] =~ s/\<msiproductversion\>/$installer::globals::msiproductversion/;
}
installer::files::save_file($onefile->{'sourcepath'}, $file);
last;
}
}
}
####################################################################################
# Updating the file Property.idt dynamically
# Content:
# Property Value
####################################################################################
sub update_reglocat_table
{
my ($basedir, $allvariables) = @_;
my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt";
# Only do something, if this file exists
if ( -f $reglocatfilename )
{
my $reglocatfile = installer::files::read_file($reglocatfilename);
my $layername = "";
if ( $allvariables->{'REGISTRYLAYERNAME'} )
{
$layername = $allvariables->{'REGISTRYLAYERNAME'};
}
else
{
for ( my $i = 0; $i <= $#{$reglocatfile}; $i++ )
{
if ( ${$reglocatfile}[$i] =~ /\bLAYERNAMETEMPLATE\b/ )
{
installer::exiter::exit_program("ERROR: Variable \"REGISTRYLAYERNAME\" has to be defined", "update_reglocat_table");
}
}
}
if ( $layername ne "" )
{
# Updating the layername in
for ( my $i = 0; $i <= $#{$reglocatfile}; $i++ )
{
${$reglocatfile}[$i] =~ s/\bLAYERNAMETEMPLATE\b/$layername/;
}
# Saving the file
installer::files::save_file($reglocatfilename ,$reglocatfile);
my $infoline = "Updated idt file: $reglocatfilename\n";
push(@installer::globals::logfileinfo, $infoline);
}
}
}
##########################################################################
# Reading saved mappings in Files.idt and Director.idt.
# This is required, if installation sets shall be created,
# that can be used for creation of msp files.
##########################################################################
sub read_saved_mappings
{
installer::logger::include_header_into_logfile("Reading saved mappings from older installation sets:");
installer::logger::include_timestamp_into_logfile("Performance Info: Reading saved mappings start");
if ( $installer::globals::previous_idt_dir )
{
my @errorlines = ();
my $errorstring = "";
my $error_occured = 0;
my $file_error_occured = 0;
my $dir_error = 0;
my $idtdir = $installer::globals::previous_idt_dir;
$idtdir =~ s/\Q$installer::globals::separator\E\s*$//;
# Reading File.idt
my $idtfile = $idtdir . $installer::globals::separator . "File.idt";
push( @installer::globals::globallogfileinfo, "\nAnalyzing file: $idtfile\n" );
if ( ! -f $idtfile ) { push( @installer::globals::globallogfileinfo, "Warning: File $idtfile does not exist!\n" ); }
my $n = 0;
open (F, "<$idtfile") || installer::exiter::exit_program("ERROR: Cannot open file $idtfile for reading", "read_saved_mappings");
<F>; <F>; <F>;
while (<F>)
{
m/^([^\t]+)\t([^\t]+)\t((.*)\|)?([^\t]*)/;
print "AAA1: \$1: $1, \$2: $2, \$3: $3, \$4: $4, \$5: $5\n";
next if ("$1" eq "$5") && (!defined($3));
my $lc1 = lc($1);
if ( exists($installer::globals::savedmapping{"$2/$5"}))
{
if ( ! $file_error_occured )
{
$errorstring = "\nErrors in $idtfile: \n";
push(@errorlines, $errorstring);
}
$errorstring = "Duplicate savedmapping{" . "$2/$5}\n";
push(@errorlines, $errorstring);
$error_occured = 1;
$file_error_occured = 1;
}
if ( exists($installer::globals::savedrevmapping{$lc1}))
{
if ( ! $file_error_occured )
{
$errorstring = "\nErrors in $idtfile: \n";
push(@errorlines, $errorstring);
}
$errorstring = "Duplicate savedrevmapping{" . "$lc1}\n";
push(@errorlines, $errorstring);
$error_occured = 1;
$file_error_occured = 1;
}
my $shortname = $4 || '';
# Don't reuse illegal 8.3 mappings that we used to generate in 2.0.4
if (index($shortname, '.') > 8 ||
(index($shortname, '.') == -1 && length($shortname) > 8))
{
$shortname = '';
}
if (( $shortname ne '' ) && ( index($shortname, '~') > 0 ) && ( exists($installer::globals::savedrev83mapping{$shortname}) ))
{
if ( ! $file_error_occured )
{
$errorstring = "\nErrors in $idtfile: \n";
push(@errorlines, $errorstring);
}
$errorstring = "Duplicate savedrev83mapping{" . "$shortname}\n";
push(@errorlines, $errorstring);
$error_occured = 1;
$file_error_occured = 1;
}
$installer::globals::savedmapping{"$2/$5"} = "$1;$shortname";
$installer::globals::savedrevmapping{lc($1)} = "$2/$5";
$installer::globals::savedrev83mapping{$shortname} = "$2/$5" if $shortname ne '';
$n++;
}
close (F);
push( @installer::globals::globallogfileinfo, "Read $n old file table key or 8.3 name mappings from $idtfile\n" );
# Reading Director.idt
$idtfile = $idtdir . $installer::globals::separator . "Director.idt";
push( @installer::globals::globallogfileinfo, "\nAnalyzing file $idtfile\n" );
if ( ! -f $idtfile ) { push( @installer::globals::globallogfileinfo, "Warning: File $idtfile does not exist!\n" ); }
$n = 0;
open (F, "<$idtfile") || installer::exiter::exit_program("ERROR: Cannot open file $idtfile for reading", "read_saved_mappings");
<F>; <F>; <F>;
while (<F>)
{
m/^([^\t]+)\t([^\t]+)\t(([^~]+~\d.*)\|)?([^\t]*)/;
next if (!defined($3));
my $lc1 = lc($1);
print "AAA2: \$1: $1, \$2: $2, \$3: $3\n";
if ( exists($installer::globals::saved83dirmapping{$1}) )
{
if ( ! $dir_error_occured )
{
$errorstring = "\nErrors in $idtfile: \n";
push(@errorlines, $errorstring);
}
$errorstring = "Duplicate saved83dirmapping{" . "$1}\n";
push(@errorlines, $errorstring);
$error_occured = 1;
$dir_error_occured = 1;
}
$installer::globals::saved83dirmapping{$1} = $4;
$n++;
}
close (F);
push( @installer::globals::globallogfileinfo, "Read $n old directory 8.3 name mappings from $idtfile\n" );
# Analyzing errors
if ( $error_occured )
{
for ( my $i = 0; $i <= $#errorlines; $i++ )
{
print "$errorlines[$i]";
push( @installer::globals::globallogfileinfo, "$errorlines[$i]");
}
installer::exiter::exit_program("ERROR: Duplicate entries in saved mappings!", "read_saved_mappings");
}
} else {
# push( @installer::globals::globallogfileinfo, "WARNING: Windows patch shall be prepared, but PREVIOUS_IDT_DIR is not set!\n" );
installer::exiter::exit_program("ERROR: Windows patch shall be prepared, but environment variable PREVIOUS_IDT_DIR is not set!", "read_saved_mappings");
}
installer::logger::include_timestamp_into_logfile("Performance Info: Reading saved mappings end");
}
1;
|