No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / bind / dist / win32utils / updateopenssl.pl
blob2e4578e30da26ee0edc7809e263492dbf53befd0
1 #!/usr/bin/perl
3 # Copyright (C) 2006, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 # Id: updateopenssl.pl,v 1.11 2009/12/04 21:59:24 marka Exp
19 # updateopenssl.pl
20 # This script locates the latest version of OpenSSL in the grandparent
21 # directory and updates the build scripts to use that version.
23 # Path and directory
24 $path = "..\\..\\";
26 # List of files that need to be updated with the actual version of the
27 # openssl directory
28 @filelist = ("SetupLibs.bat",
29 "../lib/dns/win32/libdns.mak",
30 "../lib/dns/win32/libdns.dsp");
32 # Locate the openssl directory
33 $substr = getdirectory();
34 if ($substr eq 0) {
35 print "No directory found\n";
37 else {
38 print "Found $substr directory\n";
40 #Update the list of files
41 if ($substr ne 0) {
42 $ind = 0;
43 foreach $file (@filelist) {
44 print "Updating file $file\n";
45 updatefile($file, $substr);
46 $ind++;
50 # Function to find the
51 sub getdirectory {
52 my(@namelist);
53 my($file, $name);
54 my($cnt);
55 opendir(DIR,$path) || die "No Directory: $!";
56 @namelist = grep (/^openssl-[0-9]+\.[0-9]+\.[0-9]+[a-z]$/i, readdir(DIR));
57 closedir(DIR);
59 # Make sure we have something
60 if (scalar(@namelist) == 0) {
61 return (0);
63 # Now see if we have a directory or just a file.
64 # Make sure we are case insensitive
65 foreach $file (sort {uc($a) cmp uc($b)} @namelist) {
66 if (-d $path.$file) {
67 $name = $file;
71 # If we have one use it otherwise report the error
72 # Note that we are only interested in the last one
73 # since the sort should have taken care of getting
74 # the latest
75 if (defined($name)) {
76 return ($name);
78 else {
79 return (0);
83 # function to replace the openssl directory name with the latest one
84 sub updatefile {
85 my($filename, $substr, $line);
86 my(@Lines);
88 $filename = $_[0];
89 $substr = $_[1];
91 open (RFILE, $filename) || die "Can't open file $filename: $!";
92 @Lines = <RFILE>;
93 close (RFILE);
95 # Replace the string
96 foreach $line (@Lines) {
97 $line =~ s/openssl-[0-9]+\.[0-9]+\.[0-9]+[a-z]/$substr/gi;
99 #update the file
100 open (RFILE, ">$filename") || die "Can't open file $filename: $!";
101 foreach $line (@Lines) {
102 print RFILE $line;
104 close(RFILE);