download.pm (b91f0f7e) download.pm (b871de36)
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

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

890 $unicodestring = $unicodestring . substr($string, $i, 1);
891 $unicodestring = $unicodestring . chr(0);
892 }
893
894 return $unicodestring;
895}
896
897##################################################################
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

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

890 $unicodestring = $unicodestring . substr($string, $i, 1);
891 $unicodestring = $unicodestring . chr(0);
892 }
893
894 return $unicodestring;
895}
896
897##################################################################
898# Windows: Setting nsis version is necessary because of small
899# changes in nsis from version 2.0.4 to 2.3.1
900##################################################################
901
902sub set_nsis_version
903{
904 my ($nshfile) = @_;
905
906 my $searchstring = "\$\{LangFileString\}"; # occurs only in nsis 2.3.1 or similar
907
908 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
909 {
910 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
911 {
912 # this is nsis 2.3.1 or similar
913 $installer::globals::nsis231 = 1;
914 $installer::globals::unicodensis = 0;
915 last;
916 }
917 }
918
919 # checking unicode version
920 $searchstring = convert_to_unicode($searchstring);
921
922 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
923 {
924 if ( ${$nshfile}[$i] =~ /\Q$searchstring\E/ )
925 {
926 # this is nsis 2.3.1 or similar
927 $installer::globals::nsis231 = 1;
928 $installer::globals::unicodensis = 1;
929 last;
930 }
931 }
932
933 if ( ! $installer::globals::nsis231 ) { $installer::globals::nsis204 = 1; }
934}
935
936##################################################################
937# Windows: Including the product name into nsi template
938##################################################################
939
940sub put_windows_productname_into_template
941{
942 my ($templatefile, $variableshashref) = @_;
943
944 my $productname = $variableshashref->{'PRODUCTNAME'};

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

1103
1104 my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'};
1105
1106 my $locallangs = $$languagestringref;
1107 $locallangs =~ s/_/ /g;
1108 if (length($locallangs) > $installer::globals::max_lang_length) { $locallangs = "multi lingual"; }
1109
1110 if ( ! $installer::globals::languagepack ) { $productpath = $productpath . " (" . $locallangs . ")"; }
898# Windows: Including the product name into nsi template
899##################################################################
900
901sub put_windows_productname_into_template
902{
903 my ($templatefile, $variableshashref) = @_;
904
905 my $productname = $variableshashref->{'PRODUCTNAME'};

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

1064
1065 my $productpath = $variableshashref->{'PROPERTYTABLEPRODUCTNAME'};
1066
1067 my $locallangs = $$languagestringref;
1068 $locallangs =~ s/_/ /g;
1069 if (length($locallangs) > $installer::globals::max_lang_length) { $locallangs = "multi lingual"; }
1070
1071 if ( ! $installer::globals::languagepack ) { $productpath = $productpath . " (" . $locallangs . ")"; }
1111
1112 # if (( $installer::globals::languagepack ) && ( $installer::globals::unicodensis )) { $productpath = convert_textstring_to_utf16($productpath, $localnsisdir, "stringhelper.txt"); }
1113
1072
1114 replace_one_variable($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath);
1115}
1116
1117##################################################################
1118# Windows: Including download file name into nsi template
1119##################################################################
1120
1121sub put_outputfilename_into_template

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

1406# Windows: Replacing strings in NSIS nsh file
1407# nsh file syntax:
1408# !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis ausw�hlen"
1409##################################################################
1410
1411sub replace_identifier_in_nshfile
1412{
1413 my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1073 replace_one_variable($templatefile, "PRODUCTPATHPLACEHOLDER", $productpath);
1074}
1075
1076##################################################################
1077# Windows: Including download file name into nsi template
1078##################################################################
1079
1080sub put_outputfilename_into_template

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

1365# Windows: Replacing strings in NSIS nsh file
1366# nsh file syntax:
1367# !define MUI_TEXT_DIRECTORY_TITLE "Zielverzeichnis ausw�hlen"
1368##################################################################
1369
1370sub replace_identifier_in_nshfile
1371{
1372 my ( $nshfile, $identifier, $newstring, $nshfilename, $onelanguage ) = @_;
1414
1415 if ( $installer::globals::nsis231 )
1416 {
1417 $newstring =~ s/\\r/\$\\r/g; # \r -> $\r in modern nsis versions
1418 $newstring =~ s/\\n/\$\\n/g; # \n -> $\n in modern nsis versions
1419 }
1420
1421 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1422 {
1423 if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1424 {
1425 my $oldstring = $1;
1426 ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1427 $installer::logger::Lang->printf("NSIS replacement in %s (%s): \-\> %s\n",

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

1604 installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1605 }
1606 }
1607 my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh";
1608 if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; }
1609 installer::systemactions::copy_one_file($sourcepath, $nshfilename);
1610
1611 # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1373
1374 for ( my $i = 0; $i <= $#{$nshfile}; $i++ )
1375 {
1376 if ( ${$nshfile}[$i] =~ /\s+\Q$identifier\E\s+\"(.+)\"\s*$/ )
1377 {
1378 my $oldstring = $1;
1379 ${$nshfile}[$i] =~ s/\Q$oldstring\E/$newstring/;
1380 $installer::logger::Lang->printf("NSIS replacement in %s (%s): \-\> %s\n",

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

1557 installer::exiter::exit_program("ERROR: Could not find nsis file: $sourcepath!", "copy_and_translate_nsis_language_files");
1558 }
1559 }
1560 my $nshfilename = $localnsisdir . $installer::globals::separator . $nsislanguage . "_pack.nsh";
1561 if ( $^O =~ /cygwin/i ) { $nshfilename =~ s/\//\\/g; }
1562 installer::systemactions::copy_one_file($sourcepath, $nshfilename);
1563
1564 # Changing the macro name in nsh file: MUI_LANGUAGEFILE_BEGIN -> MUI_LANGUAGEFILE_PACK_BEGIN
1612 my $nshfile = installer::files::read_file($nshfilename);
1613 set_nsis_version($nshfile);
1614
1615 if ( $installer::globals::unicodensis )
1616 {
1617 $installer::logger::Lang->printf("This is Unicode NSIS!\n");
1618 convert_utf16_to_utf8($nshfilename);
1619 convert_utf16_to_utf8($nlffilename);
1620 $nshfile = installer::files::read_file($nshfilename); # read nsh file again
1621 }
1622
1565 convert_utf16_to_utf8($nshfilename);
1566 convert_utf16_to_utf8($nlffilename);
1567 my $nshfile = installer::files::read_file($nshfilename);
1623 replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1624
1625 # find the ulf file for translation
1626 my $mlffile = get_translation_file($allvariables);
1627
1628 # Translate the files
1629 my $nlffile = installer::files::read_file($nlffilename);
1630 translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1631
1632 installer::files::save_file($nshfilename, $nshfile);
1633 installer::files::save_file($nlffilename, $nlffile);
1634
1568 replace_one_variable($nshfile, "MUI_LANGUAGEFILE_BEGIN", "MUI_LANGUAGEFILE_PACK_BEGIN");
1569
1570 # find the ulf file for translation
1571 my $mlffile = get_translation_file($allvariables);
1572
1573 # Translate the files
1574 my $nlffile = installer::files::read_file($nlffilename);
1575 translate_nsh_nlf_file($nshfile, $nlffile, $mlffile, $onelanguage, $nshfilename, $nlffilename, $nsislanguage);
1576
1577 installer::files::save_file($nshfilename, $nshfile);
1578 installer::files::save_file($nlffilename, $nlffile);
1579
1635 if ( $installer::globals::unicodensis )
1636 {
1637 convert_utf8_to_utf16($nshfilename);
1638 convert_utf8_to_utf16($nlffilename);
1639 }
1580 convert_utf8_to_utf16($nshfilename);
1581 convert_utf8_to_utf16($nlffilename);
1640 }
1641
1642}
1643
1644##################################################################
1645# Windows: Including the nsis path into the nsi template
1646##################################################################
1647

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

1661 my ($templatefile, $downloaddir) = @_;
1662
1663 if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; }
1664
1665 replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1666}
1667
1668##################################################################
1582 }
1583
1584}
1585
1586##################################################################
1587# Windows: Including the nsis path into the nsi template
1588##################################################################
1589

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

1603 my ($templatefile, $downloaddir) = @_;
1604
1605 if ( $^O =~ /cygwin/i ) { $downloaddir =~ s/\//\\/g; }
1606
1607 replace_one_variable($templatefile, "OUTPUTDIRPLACEHOLDER", $downloaddir);
1608}
1609
1610##################################################################
1669# Windows: Only allow specific code for nsis 2.0.4 or nsis 2.3.1
1670##################################################################
1671
1672sub put_version_specific_code_into_template
1673{
1674 my ($templatefile) = @_;
1675
1676 my $subst204 = "";
1677 my $subst231 = "";
1678
1679 if ( $installer::globals::nsis204 )
1680 {
1681 $subst231 = ";";
1682 }
1683 else
1684 {
1685 $subst204 = ";";
1686 }
1687
1688 replace_one_variable($templatefile, "\#204\#", $subst204);
1689 replace_one_variable($templatefile, "\#231\#", $subst231);
1690}
1691
1692##################################################################
1693# Windows: Finding the path to the nsis SDK
1694##################################################################
1695
1696sub get_path_to_nsis_sdk
1697{
1611# Windows: Finding the path to the nsis SDK
1612##################################################################
1613
1614sub get_path_to_nsis_sdk
1615{
1698 my $vol;
1699 my $dir;
1700 my $file;
1701 my $nsispath = "";
1702
1703 if ( $ENV{'NSIS_PATH'} )
1704 {
1705 $nsispath = $ENV{'NSIS_PATH'};
1706 }
1616 my $nsispath = "";
1617
1618 if ( $ENV{'NSIS_PATH'} )
1619 {
1620 $nsispath = $ENV{'NSIS_PATH'};
1621 }
1707 elsif ( $ENV{'SOLARROOT'} )
1708 {
1709 $nsispath = $ENV{'SOLARROOT'} . $installer::globals::separator . "NSIS";
1710 }
1711 else
1712 {
1713 # do we have nsis already in path ?
1714 my @paths = split(/:/, $ENV{'PATH'});
1715 foreach my $path (@paths)
1716 {
1717 $path =~ s/[\/\\]+$//; # remove trailing slashes;
1718 $nsispath = $path . "/nsis";
1719
1720 if ( -x $nsispath )
1721 {
1722 $nsispath = $path;
1723 last;
1724 }
1725 else
1726 {
1727 $nsispath = "";
1728 }
1729 }
1730 }
1731 if ( $ENV{'NSISSDK_SOURCE'} )
1732 {
1733 installer::logger::print_warning( "NSISSDK_SOURCE is deprecated. use NSIS_PATH instead.\n" );
1734 $nsispath = $ENV{'NSISSDK_SOURCE'}; # overriding the NSIS SDK with NSISSDK_SOURCE
1735 }
1736
1737# if( ($^O =~ /cygwin/i) and $nsispath =~ /\\/ ) {
1738# # We need a POSIX path for W32-4nt-cygwin-perl
1739# $nsispath =~ s/\\/\\\\/g;
1740# chomp( $nsispath = qx{cygpath -u "$nsispath"} );
1741# }
1742
1743 if ( $nsispath eq "" )
1744 {
1622 if ( $nsispath eq "" )
1623 {
1745 $installer::logger::Info->print("... no Environment variable \"SOLARROOT\", \"NSIS_PATH\" or \"NSISSDK_SOURCE\" found and NSIS not found in path!\n");
1624 $installer::logger::Info->print("... no Environment variable \"NSIS_PATH\"!\n");
1746 }
1747 elsif ( ! -d $nsispath )
1748 {
1749 installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1750 }
1751
1752 return $nsispath;
1753}

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

1828
1829#########################################################
1830# Getting the translation file for the nsis installer
1831#########################################################
1832
1833sub get_translation_file
1834{
1835 my ($allvariableshashref) = @_;
1625 }
1626 elsif ( ! -d $nsispath )
1627 {
1628 installer::exiter::exit_program("ERROR: NSIS path $nsispath does not exist!", "get_path_to_nsis_sdk");
1629 }
1630
1631 return $nsispath;
1632}

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

1707
1708#########################################################
1709# Getting the translation file for the nsis installer
1710#########################################################
1711
1712sub get_translation_file
1713{
1714 my ($allvariableshashref) = @_;
1836 my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename;
1837 if ( $installer::globals::unicodensis ) { $translationfilename = $translationfilename . ".uulf"; }
1838 else { $translationfilename = $translationfilename . ".mlf"; }
1715 my $translationfilename = $installer::globals::idtlanguagepath . $installer::globals::separator . $installer::globals::nsisfilename . ".uulf";
1839 if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1840 my $translationfile = installer::files::read_file($translationfilename);
1841 replace_variables($translationfile, $allvariableshashref);
1842
1843 $installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename);
1844
1845 return $translationfile;
1846}

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

2066 put_javafilename_into_template($templatefile, $allvariableshashref);
2067 put_windows_productversion_into_template($templatefile, $allvariableshashref);
2068 put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
2069 put_outputfilename_into_template($templatefile, $downloadname);
2070 put_filelist_into_template($templatefile, $installationdir);
2071 put_language_list_into_template($templatefile, $languagesarrayref);
2072 put_nsis_path_into_template($templatefile, $localnsisdir);
2073 put_output_path_into_template($templatefile, $downloaddir);
1716 if ( ! -f $translationfilename ) { installer::exiter::exit_program("ERROR: Could not find language file $translationfilename!", "get_translation_file"); }
1717 my $translationfile = installer::files::read_file($translationfilename);
1718 replace_variables($translationfile, $allvariableshashref);
1719
1720 $installer::logger::Lang->printf("Reading translation file: %s\n", $translationfilename);
1721
1722 return $translationfile;
1723}

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

1943 put_javafilename_into_template($templatefile, $allvariableshashref);
1944 put_windows_productversion_into_template($templatefile, $allvariableshashref);
1945 put_windows_productpath_into_template($templatefile, $allvariableshashref, $languagestringref, $localnsisdir);
1946 put_outputfilename_into_template($templatefile, $downloadname);
1947 put_filelist_into_template($templatefile, $installationdir);
1948 put_language_list_into_template($templatefile, $languagesarrayref);
1949 put_nsis_path_into_template($templatefile, $localnsisdir);
1950 put_output_path_into_template($templatefile, $downloaddir);
2074 put_version_specific_code_into_template($templatefile);
2075
2076 my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile);
2077
2078 $installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename);
2079
2080 # starting the NSIS SDK to create the download file
2081 call_nsis($nsispath, $nsifilename);
2082 }

--- 70 unchanged lines hidden ---
1951
1952 my $nsifilename = save_script_file($localnsisdir, $templatefilename, $templatefile);
1953
1954 $installer::logger::Info->printf("... created NSIS file %s ... \n", $nsifilename);
1955
1956 # starting the NSIS SDK to create the download file
1957 call_nsis($nsispath, $nsifilename);
1958 }

--- 70 unchanged lines hidden ---