updateopenssl.pl 3.13 KB
Newer Older
Mark Andrews's avatar
Mark Andrews committed
1
2
#!/usr/bin/perl
#
Automatic Updater's avatar
Automatic Updater committed
3
# Copyright (C) 2006, 2007, 2009, 2010  Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
4
#
Automatic Updater's avatar
Automatic Updater committed
5
# Permission to use, copy, modify, and/or distribute this software for any
Mark Andrews's avatar
Mark Andrews committed
6
7
8
9
10
11
12
13
14
15
16
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

17
# $Id: updateopenssl.pl,v 1.14 2010/12/22 04:05:41 marka Exp $
Mark Andrews's avatar
Mark Andrews committed
18
19
20
21
22
23

# updateopenssl.pl
# This script locates the latest version of OpenSSL in the grandparent
# directory and updates the build scripts to use that version.
#
# Path and directory
Mark Andrews's avatar
Mark Andrews committed
24
$path = "..\\..\\";
Mark Andrews's avatar
Mark Andrews committed
25
26
27

# List of files that need to be updated with the actual version of the
# openssl directory
28
29
@filelist = ("SetupLibs.bat",
	     "../lib/dns/win32/libdns.mak",
30
31
32
             "../lib/dns/win32/libdns.dsp",
	     "../bin/named/win32/named.mak",
	     "../bin/named/win32/named.dsp");
Mark Andrews's avatar
Mark Andrews committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

# Locate the openssl directory
$substr = getdirectory();
if ($substr eq 0) {
     print "No directory found\n";
}
else {
     print "Found $substr directory\n";
}
#Update the list of files
if ($substr ne 0) {
   $ind = 0;
   foreach $file (@filelist) {
        print "Updating file $file\n";
	updatefile($file, $substr);
	$ind++;
   }
}

# Function to find the
sub getdirectory {
    my(@namelist);
    my($file, $name);
    my($cnt);
    opendir(DIR,$path) || die "No Directory: $!";
58
    @namelist = grep (/^openssl-[0-9]+\.[0-9]+\.[0-9]+[a-z]{0,1}$/i, readdir(DIR));
Mark Andrews's avatar
Mark Andrews committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
    closedir(DIR);

    # Make sure we have something
    if (scalar(@namelist) == 0) {
        return (0);
    }
    # Now see if we have a directory or just a file.
    # Make sure we are case insensitive
    foreach $file (sort {uc($a) cmp uc($b)} @namelist) {
        if (-d $path.$file) {
           $name = $file;
        }
    }

    # If we have one use it otherwise report the error
    # Note that we are only interested in the last one
    # since the sort should have taken care of getting
    # the latest
    if (defined($name)) {
        return ($name);
    }
    else {
        return (0);
    }
}

# function to replace the openssl directory name with the latest one
sub updatefile {
        my($filename, $substr, $line);
        my(@Lines);

        $filename = $_[0];
        $substr   = $_[1];

        open (RFILE, $filename) || die "Can't open file $filename: $!";
        @Lines = <RFILE>;
        close (RFILE);

        # Replace the string
        foreach $line (@Lines) {
99
                $line =~ s/openssl-[0-9]+\.[0-9]+\.[0-9]+[a-z]{0,1}/$substr/gi;
Mark Andrews's avatar
Mark Andrews committed
100
101
102
103
104
105
106
107
108
        }
        #update the file
        open (RFILE, ">$filename") || die "Can't open file $filename: $!";
        foreach $line (@Lines) {
               print RFILE $line;
        }
        close(RFILE);
}