Debian Codegraph @

solenv/bin/modules/installer/windows/upgrade.pm

raw
1 #
2 # This file is part of the LibreOffice project.
3 #
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/.
7 #
8 # This file incorporates work covered by the following license notice:
9 #
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 .
17 #
18
19 package installer::windows::upgrade;
20
21 use strict;
22 use warnings;
23
24 use installer::exiter;
25 use installer::files;
26 use installer::globals;
27 use installer::windows::idtglobal;
28
29 ####################################################################################
30 # Creating the file Upgrade.idt dynamically
31 # Content:
32 # UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
33 ####################################################################################
34
35 sub create_upgrade_table
36 {
37 my ($basedir, $allvariableshashref) = @_;
38
39 my @upgradetable = ();
40
41 installer::windows::idtglobal::write_idt_header(\@upgradetable, "upgrade");
42
43 # Setting all products, that must be removed.
44 my $newline = $installer::globals::upgradecode . "\t" . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "513" . "\t" . "\t" . "OLDPRODUCTS" . "\n";
45 push(@upgradetable, $newline);
46
47 # preventing downgrading
48 $newline = $installer::globals::upgradecode . "\t" . $installer::globals::msiproductversion . "\t" . "\t" . "\t" . "2" . "\t" . "\t" . "NEWPRODUCTS" . "\n";
49 push(@upgradetable, $newline);
50
51 # Saving the file
52
53 my $upgradetablename = $basedir . $installer::globals::separator . "Upgrade.idt";
54 installer::files::save_file($upgradetablename ,\@upgradetable);
55 my $infoline = "Created idt file: $upgradetablename\n";
56 push(@installer::globals::logfileinfo, $infoline);
57 }
58
59 ##############################################################
60 # Reading the file with UpgradeCodes of old products,
61 # that can be removed, if the user wants to remove them.
62 ##############################################################
63
64 sub analyze_file_for_upgrade_table
65 {
66 my ($filecontent) = @_;
67
68 my @allnewlines = ();
69
70 for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
71 {
72 my $line = ${$filecontent}[$i];
73 if ( $line =~ /^\s*$/ ) { next; } # empty lines can be ignored
74 if ( $line =~ /^\s*\#/ ) { next; } # comment lines starting with a hash
75
76 if ( $line =~ /^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) { push(@allnewlines, $line); }
77 else { installer::exiter::exit_program("ERROR: Wrong syntax in file for upgrade table", "analyze_file_for_upgrade_table"); }
78 }
79
80 return \@allnewlines;
81 }
82
83 1;