xref: /trunk/main/solenv/bin/modules/installer/windows/java.pm (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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::java;
29
30use installer::exiter;
31use installer::files;
32use installer::globals;
33use installer::windows::idtglobal;
34
35####################################################################################
36# Writing content into RegLocat.idt and AppSearc.idt to find Java on system
37####################################################################################
38
39sub update_java_tables
40{
41    my ($basedir, $allvariables) = @_;
42
43    my $reglocatfile = "";
44    my $appsearchfile = "";
45
46    my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt";
47    my $appsearchfilename = $basedir . $installer::globals::separator . "AppSearc.idt";
48    my $signaturefilename = $basedir . $installer::globals::separator . "Signatur.idt";
49
50    if ( -f $reglocatfilename )
51    {
52        $reglocatfile = installer::files::read_file($reglocatfilename);
53    }
54    else
55    {
56        my @reglocattable = ();
57        $reglocatfile = \@reglocattable;
58        installer::windows::idtglobal::write_idt_header($reglocatfile, "reglocat");
59    }
60
61    if ( -f $appsearchfilename )
62    {
63        $appsearchfile = installer::files::read_file($appsearchfilename);
64    }
65    else
66    {
67        my @appsearchtable = ();
68        $appsearchfile = \@appsearchtable;
69        installer::windows::idtglobal::write_idt_header($appsearchfile, "appsearch");
70    }
71
72    if ( -f $signaturefilename )
73    {
74        $signaturefile = installer::files::read_file($signaturefilename);
75    }
76    else
77    {
78        my @signaturetable = ();
79        $signaturefile = \@signaturetable;
80        installer::windows::idtglobal::write_idt_header($signaturefile, "signatur");
81    }
82
83    # Writing content into this tables
84    # Java version is saved in scp project
85    # $installer::globals::javafile was defined in installer::windows::idtglobal::add_childprojects
86
87    if ( ! $installer::globals::javafile->{'Javaversion'} ) { installer::exiter::exit_program("ERROR: \"Javaversion\" has to be defined in $installer::globals::javafile->{'gid'} in scp project!", "update_java_tables"); }
88
89    my $javastring = $installer::globals::javafile->{'Javaversion'};
90
91    my $signature = "JavaReg";
92    my $rootvalue = "2";
93    my $key = "Software\\JavaSoft\\Java Runtime Environment\\" . $javastring;
94    my $name = "JavaHome";
95    my $type = 2;
96    my $property = "JAVAPATH";
97
98    my $oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
99    push(@{$reglocatfile}, $oneline);
100
101    $oneline = $property . "\t" . $signature . "\n";
102    push(@{$appsearchfile}, $oneline);
103
104    # Saving the files
105
106    installer::files::save_file($reglocatfilename ,$reglocatfile);
107    my $infoline = "Updated idt file for Java: $reglocatfilename\n";
108    push(@installer::globals::logfileinfo, $infoline);
109
110    installer::files::save_file($appsearchfilename ,$appsearchfile);
111    $infoline = "Updated idt file for Java: $appsearchfilename\n";
112    push(@installer::globals::logfileinfo, $infoline);
113
114    installer::files::save_file($signaturefilename ,$signaturefile);
115    $infoline = "Updated idt file: $signaturefilename\n";
116    push(@installer::globals::logfileinfo, $infoline);
117
118}
119
1201;
121