msiglobal.pm (1ba1fd99) msiglobal.pm (9f91b7e3)
1#**************************************************************
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance

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

32use installer::logger;
33use installer::pathanalyzer;
34use installer::remover;
35use installer::scriptitems;
36use installer::systemactions;
37use installer::worker;
38use installer::windows::idtglobal;
39use installer::windows::language;
1#**************************************************************
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance

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

32use installer::logger;
33use installer::pathanalyzer;
34use installer::remover;
35use installer::scriptitems;
36use installer::systemactions;
37use installer::worker;
38use installer::windows::idtglobal;
39use installer::windows::language;
40use installer::patch::ReleasesList;
41
40use strict;
41
42###########################################################################
43# Generating the header of the ddf file.
44# The usage of ddf files is needed, because makecab.exe can only include
45# one sourcefile into a cab file
46###########################################################################
47

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

493#################################################################
494# Returning the PackageCode for the Summary Information Stream
495#################################################################
496
497sub get_packagecode_for_sis
498{
499 # always generating a new package code for each package
500
42use strict;
43
44###########################################################################
45# Generating the header of the ddf file.
46# The usage of ddf files is needed, because makecab.exe can only include
47# one sourcefile into a cab file
48###########################################################################
49

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

495#################################################################
496# Returning the PackageCode for the Summary Information Stream
497#################################################################
498
499sub get_packagecode_for_sis
500{
501 # always generating a new package code for each package
502
501 my $guidref = get_guid_list(1, 1); # only one GUID shall be generated
503 my $guid = "\{" . create_guid() . "\}";
502
504
503 ${$guidref}[0] =~ s/\s*$//; # removing ending spaces
504
505 my $guid = "\{" . ${$guidref}[0] . "\}";
506
507 my $infoline = "PackageCode: $guid\n";
508 $installer::logger::Lang->print($infoline);
509
510 return $guid;
511}
512
513#################################################################
514# Returning the title for the Summary Information Stream

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

1122 {
1123 $sourcefile = $installer::globals::urefile->{'sourcepath'};
1124 $destdir = $installdir . $installer::globals::separator . $installer::globals::urefile->{'Subdir'};
1125 if ( ! -d $destdir) { installer::systemactions::create_directory($destdir); }
1126 installer::systemactions::copy_one_file($sourcefile, $destdir);
1127 }
1128}
1129
505 my $infoline = "PackageCode: $guid\n";
506 $installer::logger::Lang->print($infoline);
507
508 return $guid;
509}
510
511#################################################################
512# Returning the title for the Summary Information Stream

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

1120 {
1121 $sourcefile = $installer::globals::urefile->{'sourcepath'};
1122 $destdir = $installdir . $installer::globals::separator . $installer::globals::urefile->{'Subdir'};
1123 if ( ! -d $destdir) { installer::systemactions::create_directory($destdir); }
1124 installer::systemactions::copy_one_file($sourcefile, $destdir);
1125 }
1126}
1127
1130#################################################################
1131# Getting a list of GUID using uuidgen.exe.
1132# This works only on Windows
1133#################################################################
1134
1128
1135sub get_guid_list
1136{
1137 my ($number, $log) = @_;
1138
1129
1139 if ( $log ) { installer::logger::include_header_into_logfile("Generating $number GUID"); }
1140
1141 my $uuidgen = "uuidgen.exe"; # Has to be in the path
1142
1143 # "-c" for uppercase output
1144
1145 # my $systemcall = "$uuidgen -n$number -c |";
1146 my $systemcall = "$uuidgen -n$number |";
1147 open (UUIDGEN, "$systemcall" ) or die("uuidgen is missing.");
1148 my @uuidlist = <UUIDGEN>;
1149 close (UUIDGEN);
1130=head2 create_guid ()
1150
1131
1151 my $infoline = "Systemcall: $systemcall\n";
1152 if ( $log ) { $installer::logger::Lang->print($infoline); }
1153
1154 my $comparenumber = $#uuidlist + 1;
1155
1156 if ( $comparenumber == $number )
1157 {
1158 $infoline = "Success: Executed $uuidgen successfully!\n";
1159 if ( $log ) { $installer::logger::Lang->print($infoline); }
1160 }
1161 else
1162 {
1163 $infoline = "ERROR: Could not execute $uuidgen successfully!\n";
1164 if ( $log ) { $installer::logger::Lang->print($infoline); }
1165 }
1166
1167 # uppercase, no longer "-c", because this is only supported in uuidgen.exe v.1.01
1168 for ( my $i = 0; $i <= $#uuidlist; $i++ ) { $uuidlist[$i] = uc($uuidlist[$i]); }
1169
1170 return \@uuidlist;
1132 Create a single UUID aka GUID via calling the external executable 'uuidgen'.
1133 There are Perl modules for that, but do they exist on the build bots?
1134
1135=cut
1136sub create_guid ()
1137{
1138 my $uuid = qx("uuidgen");
1139 $uuid =~ s/\s*$//;
1140 return uc($uuid);
1171}
1172
1173#################################################################
1174# Calculating a GUID with a string using md5.
1175#################################################################
1176
1177sub calculate_guid
1178{

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

1183 my $md5 = Digest::MD5->new;
1184 $md5->add($string);
1185 my $digest = $md5->hexdigest;
1186 $digest = uc($digest);
1187
1188 # my $id = pack("A32", $digest);
1189 my ($first, $second, $third, $fourth, $fifth) = unpack ('A8 A4 A4 A4 A12', $digest);
1190 $guid = "$first-$second-$third-$fourth-$fifth";
1141}
1142
1143#################################################################
1144# Calculating a GUID with a string using md5.
1145#################################################################
1146
1147sub calculate_guid
1148{

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

1153 my $md5 = Digest::MD5->new;
1154 $md5->add($string);
1155 my $digest = $md5->hexdigest;
1156 $digest = uc($digest);
1157
1158 # my $id = pack("A32", $digest);
1159 my ($first, $second, $third, $fourth, $fifth) = unpack ('A8 A4 A4 A4 A12', $digest);
1160 $guid = "$first-$second-$third-$fourth-$fifth";
1161
1162 $installer::logger::Lang->printf("guid for '%s' is %s\n",
1163 $string, $guid);
1191
1192 return $guid;
1193}
1194
1195#################################################################
1196# Calculating a ID with a string using md5 (very fast).
1197#################################################################
1198

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

1259 return \@componentfile;
1260}
1261
1262#################################################################
1263# Filling real component GUID into the component table.
1264# This works only on Windows
1265#################################################################
1266
1164
1165 return $guid;
1166}
1167
1168#################################################################
1169# Calculating a ID with a string using md5 (very fast).
1170#################################################################
1171

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

1232 return \@componentfile;
1233}
1234
1235#################################################################
1236# Filling real component GUID into the component table.
1237# This works only on Windows
1238#################################################################
1239
1267sub set_uuid_into_component_table
1240sub __set_uuid_into_component_table
1268{
1269 my ($idtdirbase, $allvariables) = @_;
1270
1271 my $componenttablename = $idtdirbase . $installer::globals::separator . "Componen.idt";
1272
1273 my $componenttable = installer::files::read_file($componenttablename);
1274
1275 # For update and patch reasons (small update) the GUID of an existing component must not change!

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

1298 if ( exists($installer::globals::calculated_component_guids{$componentname}))
1299 {
1300 $uuid = $installer::globals::calculated_component_guids{$componentname};
1301 }
1302 else
1303 {
1304 # Calculating new GUID with the help of the component name.
1305 my $useooobaseversion = 1;
1241{
1242 my ($idtdirbase, $allvariables) = @_;
1243
1244 my $componenttablename = $idtdirbase . $installer::globals::separator . "Componen.idt";
1245
1246 my $componenttable = installer::files::read_file($componenttablename);
1247
1248 # For update and patch reasons (small update) the GUID of an existing component must not change!

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

1271 if ( exists($installer::globals::calculated_component_guids{$componentname}))
1272 {
1273 $uuid = $installer::globals::calculated_component_guids{$componentname};
1274 }
1275 else
1276 {
1277 # Calculating new GUID with the help of the component name.
1278 my $useooobaseversion = 1;
1306 if ( exists($installer::globals::base_independent_components{$componentname})) { $useooobaseversion = 0; }
1279 if ( exists($installer::globals::base_independent_components{$componentname}))
1280 {
1281 $useooobaseversion = 0;
1282 }
1307 my $sourcestring = $componentname;
1308
1309 if ( $useooobaseversion )
1310 {
1283 my $sourcestring = $componentname;
1284
1285 if ( $useooobaseversion )
1286 {
1311 if ( ! exists($allvariables->{'OOOBASEVERSION'}) ) { installer::exiter::exit_program("ERROR: Could not find variable \"OOOBASEVERSION\" (required value for GUID creation)!", "set_uuid_into_component_table"); }
1287 if ( ! exists($allvariables->{'OOOBASEVERSION'}) )
1288 {
1289 installer::exiter::exit_program(
1290 "ERROR: Could not find variable \"OOOBASEVERSION\" (required value for GUID creation)!",
1291 "set_uuid_into_component_table");
1292 }
1312 $sourcestring = $sourcestring . "_" . $allvariables->{'OOOBASEVERSION'};
1313 }
1314 $uuid = calculate_guid($sourcestring);
1315 $counter++;
1316
1317 # checking, if there is a conflict with an already created guid
1293 $sourcestring = $sourcestring . "_" . $allvariables->{'OOOBASEVERSION'};
1294 }
1295 $uuid = calculate_guid($sourcestring);
1296 $counter++;
1297
1298 # checking, if there is a conflict with an already created guid
1318 if ( exists($installer::globals::allcalculated_guids{$uuid}) ) { installer::exiter::exit_program("ERROR: \"$uuid\" was already created before!", "set_uuid_into_component_table"); }
1299 if ( exists($installer::globals::allcalculated_guids{$uuid}) )
1300 {
1301 installer::exiter::exit_program(
1302 "ERROR: \"$uuid\" was already created before!",
1303 "set_uuid_into_component_table");
1304 }
1319 $installer::globals::allcalculated_guids{$uuid} = 1;
1320 $installer::globals::calculated_component_guids{$componentname} = $uuid;
1321
1322 # Setting new uuid
1323 # $componenthash->{$componentname} = $uuid;
1324
1325 # Setting flag
1326 # $installer::globals::created_new_component_guid = 1; # this is very important!

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

1626 # setting back to the original tmp directory
1627 $ENV{'TMP'} = $origtemppath;
1628
1629 chdir($from);
1630 $infoline = "chdir: $from \n";
1631 $installer::logger::Lang->print($infoline);
1632}
1633
1305 $installer::globals::allcalculated_guids{$uuid} = 1;
1306 $installer::globals::calculated_component_guids{$componentname} = $uuid;
1307
1308 # Setting new uuid
1309 # $componenthash->{$componentname} = $uuid;
1310
1311 # Setting flag
1312 # $installer::globals::created_new_component_guid = 1; # this is very important!

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

1612 # setting back to the original tmp directory
1613 $ENV{'TMP'} = $origtemppath;
1614
1615 chdir($from);
1616 $infoline = "chdir: $from \n";
1617 $installer::logger::Lang->print($infoline);
1618}
1619
1634###############################################################
1635# Setting the global variables ProductCode and the UpgradeCode
1636###############################################################
1637
1620
1638sub set_global_code_variables ($$)
1621=head2 get_source_codes($languagesref)
1622
1623 Return product code and upgrade code from the source version.
1624 When no source version is defined then return undef for both.
1625
1626=cut
1627sub get_source_codes ($)
1639{
1628{
1640 my ($languagesref, $allvariableshashref) = @_;
1629 my ($languagesref) = @_;
1630
1631 if ( ! defined $installer::globals::source_version)
1632 {
1633 return;
1634 }
1641
1635
1642 # In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
1643 # and the UpgradeCode for the product are defined.
1644 # The name "codes.txt" can be overwritten in Product definition with CODEFILENAME .
1645 # Default $installer::globals::codefilename is defined in parameter.pm.
1646
1647 if ( $allvariableshashref->{'CODEFILENAME'} )
1648 {
1649 $installer::globals::codefilename = $installer::globals::idttemplatepath . $installer::globals::separator . $allvariableshashref->{'CODEFILENAME'};
1650 installer::files::check_file($installer::globals::codefilename);
1651 }
1636 my $onelanguage = installer::languages::get_key_language($languagesref);
1652
1637
1653 my $infoline = "Using Codes file: $installer::globals::codefilename \n";
1654 $installer::logger::Lang->print($infoline);
1638 my $release_data = installer::patch::ReleasesList::Instance()
1639 ->{$installer::globals::source_version}
1640 ->{$installer::globals::packageformat};
1641 if (defined $release_data)
1642 {
1643 my $language_data = $release_data->{$onelanguage};
1644 if (defined $language_data)
1645 {
1646 $installer::logger::Lang->printf("source product code is %s\n", $language_data->{'product-code'});
1647 $installer::logger::Lang->printf("source upgrade code is %s\n", $release_data->{'upgrade-code'});
1655
1648
1656 my $codefile = installer::files::read_file($installer::globals::codefilename);
1649 return (
1650 $language_data->{'product-code'},
1651 $release_data->{'upgrade-code'}
1652 );
1653 }
1654 else
1655 {
1656 $installer::logger::Info->printf(
1657 "Warning: can not access information about previous version %s and language %s\n",
1658 $installer::globals::source_version,
1659 $onelanguage);
1660 return (undef,undef);
1661 }
1662 }
1663 else
1664 {
1665 $installer::logger::Info->printf("Warning: can not access information about previous version %s\n",
1666 $installer::globals::source_version);
1667 return (undef,undef);
1668 }
1669}
1657
1670
1658 my $isopensource = 0;
1659 if ( $allvariableshashref->{'OPENSOURCE'} ) { $isopensource = $allvariableshashref->{'OPENSOURCE'}; }
1660
1671
1661 my $onelanguage = "";
1662
1663 if ( $#{$languagesref} > 0 ) # more than one language
1664 {
1665 if (( $installer::globals::added_english ) && ( $#{$languagesref} == 1 )) # only multilingual because of added English
1666 {
1667 $onelanguage = ${$languagesref}[1]; # setting the first language, that is not english
1668 }
1669 else
1670 {
1671 if (( ${$languagesref}[1] =~ /jp/ ) ||
1672 ( ${$languagesref}[1] =~ /ko/ ) ||
1673 ( ${$languagesref}[1] =~ /zh/ ))
1674 {
1675 $onelanguage = "multiasia";
1676 }
1677 else
1678 {
1679 $onelanguage = "multiwestern";
1680 }
1681 }
1682 }
1683 else # only one language
1684 {
1685 $onelanguage = ${$languagesref}[0];
1686 }
1687
1672
1688 # ProductCode must not change, if Windows patches shall be applied
1689 if ( $installer::globals::prepare_winpatch )
1690 {
1691 # ProductCode has to be specified in each language
1692 my $searchstring = "PRODUCTCODE";
1693 my $codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile);
1694 $installer::globals::productcode = installer::windows::idtglobal::get_code_from_code_block($codeblock, $onelanguage);
1695 } else {
1696 my $guidref = get_guid_list(1, 1); # only one GUID shall be generated
1697 ${$guidref}[0] =~ s/\s*$//; # removing ending spaces
1698 $installer::globals::productcode = "\{" . ${$guidref}[0] . "\}";
1699 }
1700
1673
1701 if ( $installer::globals::patch ) # patch upgrade codes are defined in soffice.lst
1702 {
1703 if ( $allvariableshashref->{'PATCHUPGRADECODE'} ) { $installer::globals::upgradecode = $allvariableshashref->{'PATCHUPGRADECODE'}; }
1704 else { installer::exiter::exit_program("ERROR: PATCHUPGRADECODE not defined in list file!", "set_global_code_variables"); }
1705 }
1706 else
1707 {
1708 # UpgradeCode can take english as default, if not defined in specified language
1674=head2 set_global_code_variables ($languagesref, $allvariableshashref)
1709
1675
1710 my $searchstring = "UPGRADECODE"; # searching in the codes.txt file
1711 my $codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile);
1712 $installer::globals::upgradecode = installer::windows::idtglobal::get_language_string_from_language_block($codeblock, $onelanguage, "");
1713 }
1714
1715 # 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"); }
1716 if ( $installer::globals::upgradecode eq "" ) { installer::exiter::exit_program("ERROR: UpgradeCode not defined in $installer::globals::codefilename !", "set_global_code_variables"); }
1676 Determine values for the product code and upgrade code of the target version.
1717
1677
1718 $infoline = "Setting ProductCode to: $installer::globals::productcode \n";
1719 $installer::logger::Lang->print($infoline);
1720 $infoline = "Setting UpgradeCode to: $installer::globals::upgradecode \n";
1721 $installer::logger::Lang->print($infoline);
1678 As perparation for building a Windows patch, certain conditions have to be fullfilled.
1679 - The upgrade code changes from old to new version
1680 - The product code remains the same
1681 In order to inforce that we have to access information about the source version.
1722
1682
1723 # Adding both variables into the variables array
1683 The resulting values are stored as global variables
1684 $installer::globals::productcode
1685 $installer::globals::upgradecode
1686 and as variables in the given hash
1687 $allvariableshashref->{'PRODUCTCODE'}
1688 $allvariableshashref->{'UPGRADECODE'}
1724
1689
1725 $allvariableshashref->{'PRODUCTCODE'} = $installer::globals::productcode;
1726 $allvariableshashref->{'UPGRADECODE'} = $installer::globals::upgradecode;
1690=cut
1691sub set_global_code_variables ($$)
1692{
1693 my ($languagesref, $allvariableshashref) = @_;
1727
1694
1728 $infoline = "Defined variable PRODUCTCODE: $installer::globals::productcode \n";
1729 $installer::logger::Lang->print($infoline);
1695 my ($source_product_code, $source_upgrade_code) = get_source_codes($languagesref);
1696 my ($target_product_code, $target_upgrade_code) = (undef, undef);
1697
1698 if (defined $source_product_code && defined $source_upgrade_code)
1699 {
1700 if ($installer::globals::is_major_release)
1701 {
1702 # For a major release we have to change the product code.
1703 $target_product_code = "{" . create_guid() . "}";
1704 $installer::logger::Lang->printf("building a major release, created new product code %s\n",
1705 $target_product_code);
1706
1707 # Let's do a paranoia check that the new and the old guids are
1708 # different. In reality the new guid really has to be
1709 # different from all other guids used for * codes, components,
1710 # etc.
1711 if ($target_product_code eq $source_product_code)
1712 {
1713 installer::logger::PrintError(
1714 "new GUID for product code is the same as the old product code but should be different.");
1715 }
1716 }
1717 else
1718 {
1719 # For minor or micro releases we have to keeep the old product code.
1720 $target_product_code = "{" . $source_product_code . "}";
1721 $installer::logger::Lang->printf("building a minor or micro release, reusing product code %s\n",
1722 $target_product_code);
1723 }
1730
1724
1731 $infoline = "Defined variable UPGRADECODE: $installer::globals::upgradecode \n";
1732 $installer::logger::Lang->print($infoline);
1725 $target_upgrade_code = "{" . create_guid() . "}";
1726 # Again, just one test for paranoia.
1727 if ($target_upgrade_code eq $source_upgrade_code)
1728 {
1729 installer::logger::PrintError(
1730 "new GUID for upgrade code is the same as the old upgrade code but should be different.");
1731 }
1732 }
1733 else
1734 {
1735 # There is no previous version with which to compare the product code.
1736 # Just create two new uuids.
1737 $target_product_code = "{" . create_guid() . "}";
1738 $target_upgrade_code = "{" . create_guid() . "}";
1739 }
1740
1741 $installer::globals::productcode = $target_product_code;
1742 $installer::globals::upgradecode = $target_upgrade_code;
1743 $allvariableshashref->{'PRODUCTCODE'} = $target_product_code;
1744 $allvariableshashref->{'UPGRADECODE'} = $target_upgrade_code;
1733
1745
1746 $installer::logger::Lang->printf("target product code is %s\n", $target_product_code);
1747 $installer::logger::Lang->printf("target upgrade code is %s\n", $target_upgrade_code);
1734}
1735
1748}
1749
1750
1751
1752
1736###############################################################
1737# Setting the product version used in property table and
1738# upgrade table. Saving in global variable $msiproductversion
1739###############################################################
1740
1741sub set_msiproductversion
1742{
1743 my ( $allvariables ) = @_;

--- 151 unchanged lines hidden ---
1753###############################################################
1754# Setting the product version used in property table and
1755# upgrade table. Saving in global variable $msiproductversion
1756###############################################################
1757
1758sub set_msiproductversion
1759{
1760 my ( $allvariables ) = @_;

--- 151 unchanged lines hidden ---