Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / windows / upgrade.pm
blob54838212404c608195a11e2454aac46bb2e6d5a0
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::windows::upgrade;
21 use installer::exiter;
22 use installer::files;
23 use installer::globals;
24 use installer::windows::idtglobal;
26 ####################################################################################
27 # Creating the file Upgrade.idt dynamically
28 # Content:
29 # UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
30 ####################################################################################
32 sub create_upgrade_table
34 my ($basedir, $allvariableshashref) = @_;
36 my @upgradetable = ();
38 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade");
40 # Setting all products, that must be removed.
41 my $newline = $installer::globals::upgradecode . "\t" . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "513" . "\t" . "\t" . "OLDPRODUCTS" . "\n";
42 push(@upgradetable, $newline);
44 # preventing downgrading
45 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTS" . "\n";
46 push(@upgradetable, $newline);
48 # Saving the file
50 my $upgradetablename = $basedir . $installer::globals::separator . "Upgrade.idt";
51 installer::files::save_file($upgradetablename ,\@upgradetable);
52 my $infoline = "Created idt file: $upgradetablename\n";
53 push(@installer::globals::logfileinfo, $infoline);
56 ##############################################################
57 # Reading the file with UpgradeCodes of old products,
58 # that can be removed, if the user wants to remove them.
59 ##############################################################
61 sub analyze_file_for_upgrade_table
63 my ($filecontent) = @_;
65 my @allnewlines = ();
67 for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
69 my $line = ${$filecontent}[$i];
70 if ( $line =~ /^\s*$/ ) { next; } # empty lines can be ignored
71 if ( $line =~ /^\s*\#/ ) { next; } # comment lines starting with a hash
73 if ( $line =~ /^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) { push(@allnewlines, $line); }
74 else { installer::exiter::exit_program("ERROR: Wrong syntax in file for upgrade table", "analyze_file_for_upgrade_table"); }
77 return \@allnewlines;