Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / windows / patch.pm
blobab68b11f345caa24988ea8dfd03f6a466353ce59
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: patch.pm,v $
11 # $Revision: 1.6 $
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::patch;
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 update_patch_tables
47 my ($basedir, $allvariables) = @_;
49 my $reglocatfile = "";
50 my $appsearchfile = "";
52 my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt";
53 my $appsearchfilename = $basedir . $installer::globals::separator . "AppSearc.idt";
54 my $signaturefilename = $basedir . $installer::globals::separator . "Signatur.idt";
56 if ( -f $reglocatfilename )
58 $reglocatfile = installer::files::read_file($reglocatfilename);
60 else
62 my @reglocattable = ();
63 $reglocatfile = \@reglocattable;
64 installer::windows::idtglobal::write_idt_header($reglocatfile, "reglocat");
67 if ( -f $appsearchfilename )
69 $appsearchfile = installer::files::read_file($appsearchfilename);
71 else
73 my @appsearchtable = ();
74 $appsearchfile = \@appsearchtable;
75 installer::windows::idtglobal::write_idt_header($appsearchfile, "appsearch");
78 if ( -f $signaturefilename )
80 $signaturefile = installer::files::read_file($signaturefilename);
82 else
84 my @signaturetable = ();
85 $signaturefile = \@signaturetable;
86 installer::windows::idtglobal::write_idt_header($signaturefile, "signatur");
89 # Writing content into this tables
91 if ( ! $allvariables->{'PATCHCODEFILE'} ) { installer::exiter::exit_program("ERROR: Variable PATCHCODEFILE must be defined for Windows patches!", "update_patch_tables"); }
92 my $patchcodesfilename = $installer::globals::idttemplatepath . $installer::globals::separator . $allvariables->{'PATCHCODEFILE'};
93 my $patchcodefile = installer::files::read_file($patchcodesfilename);
95 my $number = 0;
97 for ( my $i = 0; $i <= $#{$patchcodefile}; $i++ )
99 my $oneline = ${$patchcodefile}[$i];
101 if ( $oneline =~ /^\s*\#/ ) { next; } # this is a comment line
102 if ( $oneline =~ /^\s*$/ ) { next; }
104 my $code = "";
105 if ( $oneline =~ /^\s*(\S+)\s/ ) { $code = $1; }
107 foreach my $name ( sort keys %installer::globals::installlocations )
109 $number++;
110 my $signature = "dir" . $number . "user";
111 my $rootvalue = "1";
112 my $registryname = "";
113 my $registryversion = "";
115 if ( $allvariables->{'SEARCHPRODUCTNAME'} ) { $registryname = $allvariables->{'SEARCHPRODUCTNAME'}; }
116 else { $registryname = $allvariables->{'PRODUCTNAME'}; }
118 if ( $allvariables->{'SEARCHPRODUCTVERSION'} ) { $registryversion = $allvariables->{'SEARCHPRODUCTVERSION'}; }
119 else { $registryversion = $allvariables->{'PRODUCTVERSION'}; }
121 my $key = "Software\\" . $allvariables->{'MANUFACTURER'} . "\\" . $registryname . "\\" . $registryversion . "\\" . $code;
123 my $type = 2;
124 my $property = $name;
126 $oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
127 push(@{$reglocatfile}, $oneline);
129 $oneline = $property . "\t" . $signature . "\n";
130 push(@{$appsearchfile}, $oneline);
132 $signature = "dir" . $number . "mach";
133 $rootvalue = "2";
135 $oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
136 push(@{$reglocatfile}, $oneline);
138 $oneline = $property . "\t" . $signature . "\n";
139 push(@{$appsearchfile}, $oneline);
143 # Saving the files
145 installer::files::save_file($reglocatfilename ,$reglocatfile);
146 my $infoline = "Updated idt file: $reglocatfilename\n";
147 push(@installer::globals::logfileinfo, $infoline);
149 installer::files::save_file($appsearchfilename ,$appsearchfile);
150 $infoline = "Updated idt file: $appsearchfilename\n";
151 push(@installer::globals::logfileinfo, $infoline);
153 installer::files::save_file($signaturefilename ,$signaturefile);
154 $infoline = "Updated idt file: $signaturefilename\n";
155 push(@installer::globals::logfileinfo, $infoline);