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