3 # Copyright (C) 2009, 2010 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: updatelibxml2.pl,v 1.5 2010/08/13 23:47:04 tbox Exp $
20 # This script locates the latest version of libxml2 in the grandparent
21 # directory and updates the build scripts to use that version.
22 # Copied from updateopenssl.pl.
27 # List of files that need to be updated with the actual version of the
29 @filelist = ("SetupLibs.bat",
30 "../lib/dns/win32/libdns.mak",
31 "../lib/dns/win32/libdns.dsp",
32 "../bin/check/win32/checktool.dsp",
33 "../bin/check/win32/namedcheckconf.dsp",
34 "../bin/check/win32/namedcheckconf.mak",
35 "../bin/check/win32/namedcheckzone.dsp",
36 "../bin/check/win32/namedcheckzone.mak",
37 "../bin/confgen/win32/confgentool.dsp",
38 "../bin/confgen/win32/ddnsconfgen.dsp",
39 "../bin/confgen/win32/ddnsconfgen.mak",
40 "../bin/confgen/win32/rndcconfgen.dsp",
41 "../bin/confgen/win32/rndcconfgen.mak",
42 "../bin/dig/win32/dig.dsp",
43 "../bin/dig/win32/dig.mak",
44 "../bin/dig/win32/dighost.dsp",
45 "../bin/dig/win32/host.dsp",
46 "../bin/dig/win32/host.mak",
47 "../bin/dig/win32/nslookup.dsp",
48 "../bin/dig/win32/nslookup.mak",
49 "../bin/dnssec/win32/dnssectool.dsp",
50 "../bin/dnssec/win32/dsfromkey.dsp",
51 "../bin/dnssec/win32/dsfromkey.mak",
52 "../bin/dnssec/win32/keyfromlabel.dsp",
53 "../bin/dnssec/win32/keyfromlabel.mak",
54 "../bin/dnssec/win32/keygen.dsp",
55 "../bin/dnssec/win32/keygen.mak",
56 "../bin/dnssec/win32/revoke.dsp",
57 "../bin/dnssec/win32/revoke.mak",
58 "../bin/dnssec/win32/settime.dsp",
59 "../bin/dnssec/win32/settime.mak",
60 "../bin/dnssec/win32/signzone.dsp",
61 "../bin/dnssec/win32/signzone.mak",
62 "../bin/named/win32/named.dsp",
63 "../bin/named/win32/named.mak",
64 "../bin/nsupdate/win32/nsupdate.dsp",
65 "../bin/nsupdate/win32/nsupdate.mak",
66 "../bin/rndc/win32/rndc.dsp",
67 "../bin/rndc/win32/rndc.mak",
68 "../bin/tools/win32/journalprint.dsp",
69 "../bin/tools/win32/journalprint.mak",
70 "../lib/bind9/win32/libbind9.dsp",
71 "../lib/bind9/win32/libbind9.mak",
72 "../lib/dns/win32/libdns.dsp",
73 "../lib/dns/win32/libdns.mak",
74 "../lib/isc/win32/libisc.dsp",
75 "../lib/isc/win32/libisc.mak",
76 "../lib/isc/win32/libisc.def",
77 "../lib/isccc/win32/libisccc.dsp",
78 "../lib/isccc/win32/libisccc.mak",
79 "../lib/isccfg/win32/libisccfg.dsp",
80 "../lib/isccfg/win32/libisccfg.mak");
82 # Locate the libxml2 directory
83 $substr = getdirectory();
85 print "No directory found\n";
88 print "Found $substr directory\n";
92 #Update the list of files
95 foreach $file (@filelist) {
96 print "Updating file $file\n";
97 updatefile($file, $substr, 1);
102 #Update the configuration to reflect libxml2 being absent
105 foreach $file (@filelist) {
106 print "Updating file $file\n";
107 updatefile($file, $substr, 0);
112 # Function to find the libxml2 directory
117 opendir(DIR,$path) || return (0);
118 @namelist = grep (/^libxml2-[0-9]+\.[0-9]+\.[0-9]+[a-z]*$/i, readdir(DIR));
121 # Make sure we have something
122 if (scalar(@namelist) == 0) {
125 # Now see if we have a directory or just a file.
126 # Make sure we are case insensitive
127 foreach $file (sort {uc($a) cmp uc($b)} @namelist) {
128 if (-d $path.$file) {
133 # If we have one use it otherwise report the error
134 # Note that we are only interested in the last one
135 # since the sort should have taken care of getting
137 if (defined($name)) {
145 # function to replace the libxml2 directory name with the latest one
147 my($filename, $substr, $line);
154 open (RFILE, $filename) || die "Can't open file $filename: $!";
159 foreach $line (@Lines) {
161 $line =~ s/libxml2-[0-9]+\.[0-9]+\.[0-9]+[a-z]*/$substr/gi;
162 if ($filename =~ /\.mak$/) {
163 $line =~ s/^# (LIBXML=.*\/libxml2\.lib.*)$/\1/;
164 } elsif ($filename =~ /\.dsp$/ ) {
165 $line =~ s/^!MESSAGE (LIBXML=.*\/libxml2\.lib.*)$/\1/;
166 $line =~ s/^!MESSAGE (# ADD LINK32 .*\/libxml2\.lib.*)$/\1/;
168 $line =~ s/^; (isc_socketmgr_renderxml)$/\1/;
169 $line =~ s/^; (isc_mem_renderxml)$/\1/;
170 $line =~ s/^; (isc_taskmgr_renderxml)$/\1/;
172 if ($filename =~ /\.mak$/) {
173 $line =~ s/^(LIBXML=.*\/libxml2.lib.*)$/# \1/i;
174 } elsif ($filename =~ /\.dsp$/ ) {
175 $line =~ s/^(# ADD LINK32 .*\/libxml2.lib.*)$/!MESSAGE \1/i;
176 $line =~ s/^(LIBXML=.*\/libxml2.lib.*)$/!MESSAGE \1/i;
178 $line =~ s/^(isc_socketmgr_renderxml)$/; \1/;
179 $line =~ s/^(isc_mem_renderxml)$/; \1/;
180 $line =~ s/^(isc_taskmgr_renderxml)$/; \1/;
185 open (RFILE, ">$filename") || die "Can't open file $filename: $!";
186 foreach $line (@Lines) {
192 # update config.h to define or undefine HAVE_LIBXML2
194 my($havexml, $substr, $line);
199 open (RFILE, "../config.h") || die "Can't open config.h";
203 foreach $line (@Lines) {
205 $line =~ s/^.*#undef HAVE_LIBXML2.*$/define HAVE_LIBXML2 1/;
207 $line =~ s/^#define HAVE_LIBXML2 .*$/\/\* #undef HAVE_LIBXML2 \*\//;
211 open (RFILE, ">../config.h") || die "Can't open config.h";
212 print "Updating file ../config.h\n";
213 foreach $line (@Lines) {