1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28package installer::windows::patch;
29
30use installer::exiter;
31use installer::files;
32use installer::globals;
33use installer::windows::idtglobal;
34
35####################################################################################
36# Creating the file Upgrade.idt dynamically
37# Content:
38# UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
39####################################################################################
40
41sub update_patch_tables
42{
43	my ($basedir, $allvariables) = @_;
44
45	my $reglocatfile = "";
46	my $appsearchfile = "";
47
48	my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt";
49	my $appsearchfilename = $basedir . $installer::globals::separator . "AppSearc.idt";
50	my $signaturefilename = $basedir . $installer::globals::separator . "Signatur.idt";
51
52	if ( -f $reglocatfilename )
53	{
54		$reglocatfile = installer::files::read_file($reglocatfilename);
55	}
56	else
57	{
58		my @reglocattable = ();
59		$reglocatfile = \@reglocattable;
60		installer::windows::idtglobal::write_idt_header($reglocatfile, "reglocat");
61	}
62
63	if ( -f $appsearchfilename )
64	{
65		$appsearchfile = installer::files::read_file($appsearchfilename);
66	}
67	else
68	{
69		my @appsearchtable = ();
70		$appsearchfile = \@appsearchtable;
71		installer::windows::idtglobal::write_idt_header($appsearchfile, "appsearch");
72	}
73
74	if ( -f $signaturefilename )
75	{
76		$signaturefile = installer::files::read_file($signaturefilename);
77	}
78	else
79	{
80		my @signaturetable = ();
81		$signaturefile = \@signaturetable;
82		installer::windows::idtglobal::write_idt_header($signaturefile, "signatur");
83	}
84
85	# Writing content into this tables
86
87	if ( ! $allvariables->{'PATCHCODEFILE'} ) { installer::exiter::exit_program("ERROR: Variable PATCHCODEFILE must be defined for Windows patches!", "update_patch_tables"); }
88	my $patchcodesfilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $allvariables->{'PATCHCODEFILE'};
89	my $patchcodefile = installer::files::read_file($patchcodesfilename);
90
91	my $number = 0;
92
93	for ( my $i = 0; $i <= $#{$patchcodefile}; $i++ )
94	{
95		my $oneline = ${$patchcodefile}[$i];
96
97		if ( $oneline =~ /^\s*\#/ ) { next; }	# this is a comment line
98		if ( $oneline =~ /^\s*$/ ) { next; }
99
100		my $code = "";
101		if ( $oneline =~ /^\s*(\S+)\s/ ) { $code = $1; }
102
103		foreach my $name ( sort keys %installer::globals::installlocations )
104		{
105			$number++;
106			my $signature = "dir" . $number . "user";
107			my $rootvalue = "1";
108			my $registryname = "";
109			my $registryversion = "";
110
111			if ( $allvariables->{'SEARCHPRODUCTNAME'} ) { $registryname = $allvariables->{'SEARCHPRODUCTNAME'}; }
112			else { $registryname = $allvariables->{'PRODUCTNAME'}; }
113
114			if ( $allvariables->{'SEARCHPRODUCTVERSION'} ) { $registryversion = $allvariables->{'SEARCHPRODUCTVERSION'}; }
115			else { $registryversion = $allvariables->{'PRODUCTVERSION'}; }
116
117			my $key = "Software\\" . $allvariables->{'MANUFACTURER'} . "\\" . $registryname . "\\" . $registryversion . "\\" . $code;
118
119			my $type = 2;
120			my $property = $name;
121
122			$oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
123			push(@{$reglocatfile}, $oneline);
124
125			$oneline = $property . "\t" . $signature . "\n";
126			push(@{$appsearchfile}, $oneline);
127
128			$signature = "dir" . $number . "mach";
129			$rootvalue = "2";
130
131			$oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
132			push(@{$reglocatfile}, $oneline);
133
134			$oneline = $property . "\t" . $signature . "\n";
135			push(@{$appsearchfile}, $oneline);
136		}
137	}
138
139	# Saving the files
140
141	installer::files::save_file($reglocatfilename ,$reglocatfile);
142	my $infoline = "Updated idt file: $reglocatfilename\n";
143	push(@installer::globals::logfileinfo, $infoline);
144
145	installer::files::save_file($appsearchfilename ,$appsearchfile);
146	$infoline = "Updated idt file: $appsearchfilename\n";
147	push(@installer::globals::logfileinfo, $infoline);
148
149	installer::files::save_file($signaturefilename ,$signaturefile);
150	$infoline = "Updated idt file: $signaturefilename\n";
151	push(@installer::globals::logfileinfo, $infoline);
152
153}
154
1551;
156