xref: /trunk/main/solenv/bin/modules/installer/windows/patch.pm (revision d620b54767df0d2c7d9557af4be4c7303d55d13c)
19780544fSAndrew Rist#**************************************************************
2cdf0e10cSrcweir#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
19cdf0e10cSrcweir#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::windows::patch;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::exiter;
27cdf0e10cSrcweiruse installer::files;
28cdf0e10cSrcweiruse installer::globals;
29cdf0e10cSrcweiruse installer::windows::idtglobal;
30cdf0e10cSrcweir
31cdf0e10cSrcweir####################################################################################
32cdf0e10cSrcweir# Creating the file Upgrade.idt dynamically
33cdf0e10cSrcweir# Content:
34cdf0e10cSrcweir# UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
35cdf0e10cSrcweir####################################################################################
36cdf0e10cSrcweir
37cdf0e10cSrcweirsub update_patch_tables
38cdf0e10cSrcweir{
39cdf0e10cSrcweir    my ($basedir, $allvariables) = @_;
40cdf0e10cSrcweir
41cdf0e10cSrcweir    my $reglocatfile = "";
42cdf0e10cSrcweir    my $appsearchfile = "";
43cdf0e10cSrcweir
44cdf0e10cSrcweir    my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt";
45cdf0e10cSrcweir    my $appsearchfilename = $basedir . $installer::globals::separator . "AppSearc.idt";
46cdf0e10cSrcweir    my $signaturefilename = $basedir . $installer::globals::separator . "Signatur.idt";
47cdf0e10cSrcweir
48cdf0e10cSrcweir    if ( -f $reglocatfilename )
49cdf0e10cSrcweir    {
50cdf0e10cSrcweir        $reglocatfile = installer::files::read_file($reglocatfilename);
51cdf0e10cSrcweir    }
52cdf0e10cSrcweir    else
53cdf0e10cSrcweir    {
54cdf0e10cSrcweir        my @reglocattable = ();
55cdf0e10cSrcweir        $reglocatfile = \@reglocattable;
56cdf0e10cSrcweir        installer::windows::idtglobal::write_idt_header($reglocatfile, "reglocat");
57cdf0e10cSrcweir    }
58cdf0e10cSrcweir
59cdf0e10cSrcweir    if ( -f $appsearchfilename )
60cdf0e10cSrcweir    {
61cdf0e10cSrcweir        $appsearchfile = installer::files::read_file($appsearchfilename);
62cdf0e10cSrcweir    }
63cdf0e10cSrcweir    else
64cdf0e10cSrcweir    {
65cdf0e10cSrcweir        my @appsearchtable = ();
66cdf0e10cSrcweir        $appsearchfile = \@appsearchtable;
67cdf0e10cSrcweir        installer::windows::idtglobal::write_idt_header($appsearchfile, "appsearch");
68cdf0e10cSrcweir    }
69cdf0e10cSrcweir
70cdf0e10cSrcweir    if ( -f $signaturefilename )
71cdf0e10cSrcweir    {
72cdf0e10cSrcweir        $signaturefile = installer::files::read_file($signaturefilename);
73cdf0e10cSrcweir    }
74cdf0e10cSrcweir    else
75cdf0e10cSrcweir    {
76cdf0e10cSrcweir        my @signaturetable = ();
77cdf0e10cSrcweir        $signaturefile = \@signaturetable;
78cdf0e10cSrcweir        installer::windows::idtglobal::write_idt_header($signaturefile, "signatur");
79cdf0e10cSrcweir    }
80cdf0e10cSrcweir
81cdf0e10cSrcweir    # Writing content into this tables
82cdf0e10cSrcweir
83cdf0e10cSrcweir    if ( ! $allvariables->{'PATCHCODEFILE'} ) { installer::exiter::exit_program("ERROR: Variable PATCHCODEFILE must be defined for Windows patches!", "update_patch_tables"); }
84cdf0e10cSrcweir    my $patchcodesfilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $allvariables->{'PATCHCODEFILE'};
85cdf0e10cSrcweir    my $patchcodefile = installer::files::read_file($patchcodesfilename);
86cdf0e10cSrcweir
87cdf0e10cSrcweir    my $number = 0;
88cdf0e10cSrcweir
89cdf0e10cSrcweir    for ( my $i = 0; $i <= $#{$patchcodefile}; $i++ )
90cdf0e10cSrcweir    {
91cdf0e10cSrcweir        my $oneline = ${$patchcodefile}[$i];
92cdf0e10cSrcweir
93cdf0e10cSrcweir        if ( $oneline =~ /^\s*\#/ ) { next; }   # this is a comment line
94cdf0e10cSrcweir        if ( $oneline =~ /^\s*$/ ) { next; }
95cdf0e10cSrcweir
96cdf0e10cSrcweir        my $code = "";
97cdf0e10cSrcweir        if ( $oneline =~ /^\s*(\S+)\s/ ) { $code = $1; }
98cdf0e10cSrcweir
99cdf0e10cSrcweir        foreach my $name ( sort keys %installer::globals::installlocations )
100cdf0e10cSrcweir        {
101cdf0e10cSrcweir            $number++;
102cdf0e10cSrcweir            my $signature = "dir" . $number . "user";
103cdf0e10cSrcweir            my $rootvalue = "1";
104cdf0e10cSrcweir            my $registryname = "";
105cdf0e10cSrcweir            my $registryversion = "";
106cdf0e10cSrcweir
107cdf0e10cSrcweir            if ( $allvariables->{'SEARCHPRODUCTNAME'} ) { $registryname = $allvariables->{'SEARCHPRODUCTNAME'}; }
108cdf0e10cSrcweir            else { $registryname = $allvariables->{'PRODUCTNAME'}; }
109cdf0e10cSrcweir
110cdf0e10cSrcweir            if ( $allvariables->{'SEARCHPRODUCTVERSION'} ) { $registryversion = $allvariables->{'SEARCHPRODUCTVERSION'}; }
111cdf0e10cSrcweir            else { $registryversion = $allvariables->{'PRODUCTVERSION'}; }
112cdf0e10cSrcweir
113cdf0e10cSrcweir            my $key = "Software\\" . $allvariables->{'MANUFACTURER'} . "\\" . $registryname . "\\" . $registryversion . "\\" . $code;
114cdf0e10cSrcweir
115cdf0e10cSrcweir            my $type = 2;
116cdf0e10cSrcweir            my $property = $name;
117cdf0e10cSrcweir
118cdf0e10cSrcweir            $oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
119cdf0e10cSrcweir            push(@{$reglocatfile}, $oneline);
120cdf0e10cSrcweir
121cdf0e10cSrcweir            $oneline = $property . "\t" . $signature . "\n";
122cdf0e10cSrcweir            push(@{$appsearchfile}, $oneline);
123cdf0e10cSrcweir
124cdf0e10cSrcweir            $signature = "dir" . $number . "mach";
125cdf0e10cSrcweir            $rootvalue = "2";
126cdf0e10cSrcweir
127cdf0e10cSrcweir            $oneline = $signature . "\t" . $rootvalue . "\t" . $key . "\t" . $name . "\t" . $type . "\n";
128cdf0e10cSrcweir            push(@{$reglocatfile}, $oneline);
129cdf0e10cSrcweir
130cdf0e10cSrcweir            $oneline = $property . "\t" . $signature . "\n";
131cdf0e10cSrcweir            push(@{$appsearchfile}, $oneline);
132cdf0e10cSrcweir        }
133cdf0e10cSrcweir    }
134cdf0e10cSrcweir
135cdf0e10cSrcweir    # Saving the files
136cdf0e10cSrcweir
137cdf0e10cSrcweir    installer::files::save_file($reglocatfilename ,$reglocatfile);
138*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Updated idt file: %s\n", $reglocatfilename);
139cdf0e10cSrcweir
140cdf0e10cSrcweir    installer::files::save_file($appsearchfilename ,$appsearchfile);
141*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Updated idt file: %s\n", $appsearchfilename);
142cdf0e10cSrcweir
143cdf0e10cSrcweir    installer::files::save_file($signaturefilename ,$signaturefile);
144*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Updated idt file: %s\n", $signaturefilename);
145cdf0e10cSrcweir}
146cdf0e10cSrcweir
147cdf0e10cSrcweir1;
148