merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / modules / installer / windows / upgrade.pm
blob2a586dea0506797587f7d30590c0e0e59e9c8061
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: upgrade.pm,v $
11 # $Revision: 1.16 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::windows::upgrade;
34 use installer::exiter;
35 use installer::files;
36 use installer::globals;
37 use installer::windows::idtglobal;
39 ####################################################################################
40 # Creating the file Upgrade.idt dynamically
41 # Content:
42 # UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
43 ####################################################################################
45 sub create_upgrade_table
47 my ($basedir, $allvariableshashref) = @_;
49 my @upgradetable = ();
51 # fix for problematic OOo 1.9 versions
52 my $include_ooo_fix = 0;
53 my $ooomaxnew = "";
54 if (($installer::globals::product =~ /OpenOffice/i ) && ( ! ( $installer::globals::product =~ /SDK/i )) && ( ! $installer::globals::languagepack ))
56 $include_ooo_fix = 1;
57 $ooomaxnew = "34.0.0";
60 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade");
62 # Setting also $installer::globals::msimajorproductversion, that is for example "3.0.0", to differ between old products for OOo 2.x and
63 # older products from OOo 3.x. The latter must be removed always, the removal of the first is controlled with a checkbox.
64 my $newline = $installer::globals::upgradecode . "\t" . "\t" . $installer::globals::msimajorproductversion . "\t" . "\t" . "0" . "\t" . "\t" . "OLDPRODUCTS" . "\n";
65 push(@upgradetable, $newline);
67 # Setting all products, that must be removed.
68 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msimajorproductversion . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "257" . "\t" . "\t" . "OLDPRODUCTSSAMEMAJOR" . "\n";
69 push(@upgradetable, $newline);
71 if ( ! $installer::globals::patch )
73 # preventing downgrading
74 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . $ooomaxnew . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTS" . "\n";
75 push(@upgradetable, $newline);
77 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . $ooomaxnew . "\t" . "\t" . "258" . "\t" . "\t" . "SAMEPRODUCTS" . "\n";
78 push(@upgradetable, $newline);
80 if ( $include_ooo_fix )
82 $newline = $installer::globals::upgradecode . "\t" . "35.0.0" . "\t" . "36.0.0" . "\t" . "\t" . "1" . "\t" . "\t" . "OLDPRODUCTS2" . "\n";
83 push(@upgradetable, $newline);
86 # if (( $allvariableshashref->{'PATCHUPGRADECODE'} ) && ( ! $installer::globals::languagepack ))
87 # {
88 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "1" . "\t" . "\t" . "OLDPRODUCTSPATCH" . "\n";
89 # push(@upgradetable, $newline);
91 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTSPATCH" . "\n";
92 # push(@upgradetable, $newline);
94 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "258" . "\t" . "\t" . "SAMEPRODUCTSPATCH" . "\n";
95 # push(@upgradetable, $newline);
96 # }
98 # also searching for the beta
100 if (( $allvariableshashref->{'BETAUPGRADECODE'} ) && ( ! $installer::globals::languagepack ))
102 $newline = $allvariableshashref->{'BETAUPGRADECODE'} . "\t" . "1.0" . "\t" . "\t" . "\t" . "1" . "\t" . "\t" . "BETAPRODUCTS" . "\n";
103 push(@upgradetable, $newline);
106 # also searching for the stub
108 if (( $allvariableshashref->{'STUBUPGRADECODE'} ) && ( ! $installer::globals::languagepack ))
110 $newline = $allvariableshashref->{'STUBUPGRADECODE'} . "\t" . "1.0" . "\t" . "\t" . "\t" . "1" . "\t" . "\t" . "STUBPRODUCTS" . "\n";
111 push(@upgradetable, $newline);
114 # searching for all older patches and languagepacks (defined in a extra file)
116 if (( $allvariableshashref->{'REMOVE_UPGRADE_CODE_FILE'} ) && ( ! $installer::globals::languagepack ))
118 my $filename = $allvariableshashref->{'REMOVE_UPGRADE_CODE_FILE'};
119 my $langpackcodefilename = $installer::globals::idttemplatepath . $installer::globals::separator . $filename;
120 if ( ! -f $langpackcodefilename ) { installer::exiter::exit_program("ERROR: Could not find file \"$langpackcodefilename\".", "create_upgrade_table"); }
122 my $filecontent = installer::files::read_file($langpackcodefilename);
123 my $newlines = analyze_file_for_upgrade_table($filecontent);
125 for ( my $i = 0; $i <= $#{$newlines}; $i++ ) { push(@upgradetable, ${$newlines}[$i]); }
129 # No upgrade for Beta versions!
131 if (( $allvariableshashref->{'PRODUCTEXTENSION'} eq "Beta" ) && ( ! $installer::globals::patch ) && ( ! $installer::globals::languagepack ))
133 @upgradetable = ();
134 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade");
135 my $infoline = "Beta product -> empty Upgrade table\n";
136 push(@installer::globals::logfileinfo, $infoline);
139 # Saving the file
141 my $upgradetablename = $basedir . $installer::globals::separator . "Upgrade.idt";
142 installer::files::save_file($upgradetablename ,\@upgradetable);
143 my $infoline = "Created idt file: $upgradetablename\n";
144 push(@installer::globals::logfileinfo, $infoline);
147 ##############################################################
148 # Reading the file with UpgradeCodes of old products,
149 # that can be removed, if the user wants to remove them.
150 ##############################################################
152 sub analyze_file_for_upgrade_table
154 my ($filecontent) = @_;
156 my @allnewlines = ();
158 for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
160 my $line = ${$filecontent}[$i];
161 if ( $line =~ /^\s*$/ ) { next; } # empty lines can be ignored
162 if ( $line =~ /^\s*\#/ ) { next; } # comment lines starting with a hash
164 if ( $line =~ /^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) { push(@allnewlines, $line); }
165 else { installer::exiter::exit_program("ERROR: Wrong syntax in file for upgrade table", "analyze_file_for_upgrade_table"); }
168 return \@allnewlines;