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 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::windows::upgrade; 25 26use installer::exiter; 27use installer::files; 28use installer::globals; 29use installer::windows::idtglobal; 30 31#################################################################################### 32# Creating the file Upgrade.idt dynamically 33# Content: 34# UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty 35#################################################################################### 36 37sub create_upgrade_table 38{ 39 my ($basedir, $allvariableshashref) = @_; 40 41 my @upgradetable = (); 42 43 # fix for problematic OOo 1.9 versions 44 my $include_ooo_fix = 0; 45 my $ooomaxnew = ""; 46 if (($installer::globals::product =~ /^\s*OpenOffice/i ) && ( ! ( $installer::globals::product =~ /SDK/i )) && ( ! $installer::globals::languagepack )) 47 { 48 $include_ooo_fix = 1; 49 $ooomaxnew = "34.0.0"; 50 } 51 52 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade"); 53 54 # Setting also $installer::globals::msimajorproductversion, that is for example "3.0.0", to differ between old products for OOo 2.x and 55 # older products from OOo 3.x. The latter must be removed always, the removal of the first is controlled with a checkbox. 56 my $newline = $installer::globals::upgradecode . "\t" . "\t" . $installer::globals::msimajorproductversion . "\t" . "\t" . "0" . "\t" . "\t" . "OLDPRODUCTS" . "\n"; 57 push(@upgradetable, $newline); 58 59 # Setting all products, that must be removed. 60 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msimajorproductversion . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "257" . "\t" . "\t" . "OLDPRODUCTSSAMEMAJOR" . "\n"; 61 push(@upgradetable, $newline); 62 63 if ( ! $installer::globals::patch ) 64 { 65 # preventing downgrading 66 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . $ooomaxnew . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTS" . "\n"; 67 push(@upgradetable, $newline); 68 69 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . $ooomaxnew . "\t" . "\t" . "258" . "\t" . "\t" . "SAMEPRODUCTS" . "\n"; 70 push(@upgradetable, $newline); 71 72 if ( $include_ooo_fix ) 73 { 74 $newline = $installer::globals::upgradecode . "\t" . "35.0.0" . "\t" . "36.0.0" . "\t" . "\t" . "1" . "\t" . "\t" . "OLDPRODUCTS2" . "\n"; 75 push(@upgradetable, $newline); 76 } 77 78 # if (( $allvariableshashref->{'PATCHUPGRADECODE'} ) && ( ! $installer::globals::languagepack )) 79 # { 80 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "1" . "\t" . "\t" . "OLDPRODUCTSPATCH" . "\n"; 81 # push(@upgradetable, $newline); 82 # 83 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTSPATCH" . "\n"; 84 # push(@upgradetable, $newline); 85 # 86 # $newline = $allvariableshashref->{'PATCHUPGRADECODE'} . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "258" . "\t" . "\t" . "SAMEPRODUCTSPATCH" . "\n"; 87 # push(@upgradetable, $newline); 88 # } 89 90 # also searching for the beta 91 92 if (( $allvariableshashref->{'BETAUPGRADECODE'} ) && ( ! $installer::globals::languagepack )) 93 { 94 $newline = $allvariableshashref->{'BETAUPGRADECODE'} . "\t" . "1.0" . "\t" . "\t" . "\t" . "1" . "\t" . "\t" . "BETAPRODUCTS" . "\n"; 95 push(@upgradetable, $newline); 96 } 97 98 # also searching for the stub 99 100 if (( $allvariableshashref->{'STUBUPGRADECODE'} ) && ( ! $installer::globals::languagepack )) 101 { 102 $newline = $allvariableshashref->{'STUBUPGRADECODE'} . "\t" . "1.0" . "\t" . "\t" . "\t" . "1" . "\t" . "\t" . "STUBPRODUCTS" . "\n"; 103 push(@upgradetable, $newline); 104 } 105 106 # searching for all older patches and languagepacks (defined in a extra file) 107 108 if (( $allvariableshashref->{'REMOVE_UPGRADE_CODE_FILE'} ) && ( ! $installer::globals::languagepack )) 109 { 110 my $filename = $allvariableshashref->{'REMOVE_UPGRADE_CODE_FILE'}; 111 my $langpackcodefilename = $installer::globals::idttemplatepath . $installer::globals::separator . $filename; 112 if ( ! -f $langpackcodefilename ) { installer::exiter::exit_program("ERROR: Could not find file \"$langpackcodefilename\".", "create_upgrade_table"); } 113 114 my $filecontent = installer::files::read_file($langpackcodefilename); 115 my $newlines = analyze_file_for_upgrade_table($filecontent); 116 117 for ( my $i = 0; $i <= $#{$newlines}; $i++ ) { push(@upgradetable, ${$newlines}[$i]); } 118 } 119 } 120 121 # No upgrade for Beta versions! 122 123 if (( $allvariableshashref->{'PRODUCTEXTENSION'} eq "Beta" ) && ( ! $installer::globals::patch ) && ( ! $installer::globals::languagepack )) 124 { 125 @upgradetable = (); 126 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade"); 127 $installer::logger::Lang->printf("Beta product -> empty Upgrade table\n"); 128 } 129 130 # Saving the file 131 132 my $upgradetablename = $basedir . $installer::globals::separator . "Upgrade.idt"; 133 installer::files::save_file($upgradetablename ,\@upgradetable); 134 $installer::logger::Lang->printf("Created idt file: %s\n", $upgradetablename); 135} 136 137############################################################## 138# Reading the file with UpgradeCodes of old products, 139# that can be removed, if the user wants to remove them. 140############################################################## 141 142sub analyze_file_for_upgrade_table 143{ 144 my ($filecontent) = @_; 145 146 my @allnewlines = (); 147 148 for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) 149 { 150 my $line = ${$filecontent}[$i]; 151 if ( $line =~ /^\s*$/ ) { next; } # empty lines can be ignored 152 if ( $line =~ /^\s*\#/ ) { next; } # comment lines starting with a hash 153 154 if ( $line =~ /^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) { push(@allnewlines, $line); } 155 else { installer::exiter::exit_program("ERROR: Wrong syntax in file for upgrade table", "analyze_file_for_upgrade_table"); } 156 } 157 158 return \@allnewlines; 159} 160 1611; 162