3 # Copyright (C) 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: updatelibxml2.pl,v 1.3 2009/07/19 04:50:15 each 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 "../lib/bind9/win32/libbind9.dsp",
69 "../lib/bind9/win32/libbind9.mak",
70 "../lib/dns/win32/libdns.dsp",
71 "../lib/dns/win32/libdns.mak",
72 "../lib/isc/win32/libisc.dsp",
73 "../lib/isc/win32/libisc.mak",
74 "../lib/isc/win32/libisc.def",
75 "../lib/isccc/win32/libisccc.dsp",
76 "../lib/isccc/win32/libisccc.mak",
77 "../lib/isccfg/win32/libisccfg.dsp",
78 "../lib/isccfg/win32/libisccfg.mak");
80 # Locate the libxml2 directory
81 $substr = getdirectory
();
83 print "No directory found\n";
86 print "Found $substr directory\n";
90 #Update the list of files
93 foreach $file (@filelist) {
94 print "Updating file $file\n";
95 updatefile
($file, $substr, 1);
100 #Update the configuration to reflect libxml2 being absent
103 foreach $file (@filelist) {
104 print "Updating file $file\n";
105 updatefile
($file, $substr, 0);
110 # Function to find the libxml2 directory
115 opendir(DIR
,$path) || return (0);
116 @namelist = grep (/^libxml2-[0-9]+\.[0-9]+\.[0-9]+[a-z]*$/i, readdir(DIR
));
119 # Make sure we have something
120 if (scalar(@namelist) == 0) {
123 # Now see if we have a directory or just a file.
124 # Make sure we are case insensitive
125 foreach $file (sort {uc($a) cmp uc($b)} @namelist) {
126 if (-d
$path.$file) {
131 # If we have one use it otherwise report the error
132 # Note that we are only interested in the last one
133 # since the sort should have taken care of getting
135 if (defined($name)) {
143 # function to replace the libxml2 directory name with the latest one
145 my($filename, $substr, $line);
152 open (RFILE
, $filename) || die "Can't open file $filename: $!";
157 foreach $line (@Lines) {
159 $line =~ s/libxml2-[0-9]+\.[0-9]+\.[0-9]+[a-z]*/$substr/gi;
160 if ($filename =~ /\.mak$/) {
161 $line =~ s/^# (LIBXML=.*\/libxml2\.lib.*)$/\
1/;
162 } elsif ($filename =~ /\.dsp$/ ) {
163 $line =~ s/^!MESSAGE (LIBXML=.*\/libxml2\.lib.*)$/\
1/;
164 $line =~ s/^!MESSAGE (# ADD LINK32 .*\/libxml2\.lib.*)$/\
1/;
166 $line =~ s/^; (isc_socketmgr_renderxml)$/\1/;
167 $line =~ s/^; (isc_mem_renderxml)$/\1/;
168 $line =~ s/^; (isc_taskmgr_renderxml)$/\1/;
170 if ($filename =~ /\.mak$/) {
171 $line =~ s/^(LIBXML=.*\/libxml2.lib.*)$/# \1/i;
172 } elsif ($filename =~ /\.dsp$/ ) {
173 $line =~ s/^(# ADD LINK32 .*\/libxml2.lib.*)$/!MESSAGE \
1/i
;
174 $line =~ s/^(LIBXML=.*\/libxml2.lib.*)$/!MESSAGE \
1/i
;
176 $line =~ s/^(isc_socketmgr_renderxml)$/; \1/;
177 $line =~ s/^(isc_mem_renderxml)$/; \1/;
178 $line =~ s/^(isc_taskmgr_renderxml)$/; \1/;
183 open (RFILE
, ">$filename") || die "Can't open file $filename: $!";
184 foreach $line (@Lines) {
190 # update config.h to define or undefine HAVE_LIBXML2
192 my($havexml, $substr, $line);
197 open (RFILE
, "../config.h") || die "Can't open config.h";
201 foreach $line (@Lines) {
203 $line =~ s/^.*#undef HAVE_LIBXML2.*$/define HAVE_LIBXML2 1/;
205 $line =~ s/^#define HAVE_LIBXML2 .*$/\/\
* #undef HAVE_LIBXML2 \*\//;
209 open (RFILE
, ">../config.h") || die "Can't open config.h";
210 print "Updating file ../config.h\n";
211 foreach $line (@Lines) {