1#!/usr/bin/perl
2
3# These are the patches to apply.
4# Paths in patch files are relative to the root of the CPAN project
5my (@patchesToApply) = (
6    # <rdar://problem/9559834> CPANInternal-103 (and earlier?) no longer builds
7    # Disables all HTTP-Proxy tests which seem to depend on external web servers.
8    './PatchFiles/HTTP-Proxy.diff',
9    './PatchFiles/HTTP-Proxy-0.25/t/Utils.pm.diff',
10
11    # <rdar://problem/8302449> CPANInternal build ignores test failure in Path-Class
12    # A long-standing oversight in the Makefile caused test results for all Module::Build modules
13    # to be ignored. This patch disables a test which is broken when OBJROOT is somewhere in /tmp/.
14    # A long-standing failure which is probably safe to ignore.
15    './PatchFiles/Path-Class.diff',
16
17    # <rdar://problem/7812410> CBL Tiger can't find _normalize_tai_seconds
18    # DateTime's Build.PL is patched to accept linker/compiler flags. Without these, the
19    # DateTime.bundle will build thin (esp. important for Tiger)
20    './PatchFiles/DateTime-Build.PL.diff',
21
22	# <rdar://problem/7817393> CPANInternal JSON-Any project fails running buildit on SnowLeopard
23	# The test fails because it sets the pretty_print option on the JSON object, which results in a
24	# trailing return placed in the 'actual' value, but is not specified in the 'expected' value.
25	'./PatchFiles/JSON-Any-02-JSON-XS.t.diff',
26
27    # We used to patch DBD-SQLite-1.07, but now that we've updated to
28    # DBD-SQLite-1.13, this isn't necessary.
29    # --- Unused: ---
30    # DBD-SQLite-1.07 puts up a warning about being incompatible with SQLite2
31    # and then prompts whether to continue - the default is no, which is what
32    # happens with buildit
33    # We could probably work around this in the Makefile but in order to keep
34    # that as general as possible, this patch just changes the default to
35    # yes
36    # Also, work around unitialized variable warnings in dbdimp.c
37    #'./PatchFiles/DBD-SQLite.diff',
38    
39    './PatchFiles/Krb5-1.9/Makefile.PL.diff',
40
41    ## the self test trys to connect to a unreliable server. 
42    ## so we skip those test
43    # disabled 3/9/2010 by DJW (<rdar://problem/7720374> Upgrade httpProxy on buildcentral to a newer version)
44    # './PatchFiles/23connect.t.diff',      
45
46    ## expat has to be set up for XML-Parser
47    './PatchFiles/Makefile.PL.diff', 
48
49    ## SOAP::Lite applied a patch for version .65 that
50    ## does not work as advertised. The previous 
51    ## code worked as expected. 
52    #'./PatchFiles/Lite.pm.diff', 
53    
54    # <rdar://problem/5460193> SOAP::Lite isn't compressing
55    './PatchFiles/SOAP-Transport-HTTP.pm.diff',
56
57    # <rdar://problem/6319392> SS2 fails to submit when submission notes contain "http:"
58    './PatchFiles/SOAP-Lite-Serializer.pm.diff',
59
60    # <rdar://problem/8419125> update CPAN modules to avoid perl 5.12 deprecation warnings
61	# <rdar://problem/8453094> SOAP::Lite.pm should be patched at build time
62    # Fixed in SOAP::Lite-0.
63	'./PatchFiles/SOAP-Lite.pm.diff',
64
65   ## JSON-Syck is replaced by YAML-Syck 0.82 which includes JSON-Syck
66   ## 0.21.  It doesn't require this patch.
67   ## --- Unused: ---
68   ## JSON-Syck: in syck.h there is a test on the flag
69   ## HAVE_STDLIB_H which is not set, however the lib does
70   ## exist. Without this library the extension will not bulid
71   ## so removed the existence test and always include the lib
72   #   './PatchFiles/syck.h.diff',
73
74   # 4546994 version perl module builds thin
75   # A Module::Build bug prevents us from doing this in the Makefile
76   # (see http://rt.cpan.org/Public/Bug/Display.html?id=19232)
77   # Fixed in version-0.2808
78   #'./PatchFiles/version.diff',                   
79
80    # Create a default .inflectrc file for Lingua-EN-Inflect
81    # indicating that the plural of hongo is hongos
82    './PatchFiles/inflectrc.diff',
83
84    # Fix an error attempting to locate the default .inflectrc
85    # file in Lingua-EN-Inflect
86    './PatchFiles/Inflect.pm.diff',
87
88    # Added krb5_set_default_realm function to Authen::Krb5.xs
89    # <rdar://problem/8370128> CPANInternal-94 project fails to build with LLVM compiler 2.0.
90    './PatchFiles/Authen-Krb5.diff',
91
92    # DBIx-Class-Storage-DBI doesn't like to txn_commit when AutoCommit
93    # is NOT on ... odd really. Simple patch to workaround this
94    './PatchFiles/DBIx-Class-Storage-DBI.pm.diff',
95
96
97    # Net-IP installs a couple of executable perl scripts into
98    # /usr/bin which we don't need or want to ship...
99    './PatchFiles/Net-IP-Makefile.PL.diff',
100    
101    # Address a bogus warning we see in SnowLeopard inside Class::Std (6783174)
102    './PatchFiles/Class-Std.diff',
103    './PatchFiles/Class-Std-0.011/lib/Class/Std.pm.diff',
104
105    # Net::Daemon patch for CPAN bug 39759 
106    # http://rt.cpan.org/Public/Bug/Display.html?id=39759
107    './PatchFiles/Net-Daemon-Daemon.pm.diff',
108
109    # Temporarily disable Net::Daemon ithread tests
110    './PatchFiles/Net-Daemon-t-ithread.t.diff',
111
112    # Temporarily disable Net::Daemon ithreadm tests 
113    './PatchFiles/Net-Daemon-t-ithreadm.t.diff',
114
115    # The First Rule of Sys::Syslog is: You do not call "setlogsock". 
116    # The Second Rule of Sys::Syslog is: You do not call "setlogsock". 
117    # In the chroot environment, there is no unix domain socket for syslog
118    # without launchd plist hackery and other build-time implications.  
119    # Don't call setlogsock to force the use of /var/run/syslog if it doesn't exist.
120    './PatchFiles/Net-Daemon-Log.pm.diff',
121    './PatchFiles/Net-Daemon-0.48/lib/Net/Daemon/Log.pm.diff',
122
123    # PlRPC tests fail due to failure to create a server inside the chroot
124    # environment on 5.8/Leopard (see Net::Daemon, above).  Temporarily disable.
125    './PatchFiles/PlRPC-t-methods.t',
126
127    # IPC::LDT changes - replace use of fields / pseudohash with Perl 5.10
128    # compatible hash; add can_read method as implemented in Evolution's site_perl_custom.
129    './PatchFiles/IPC-LDT-LDT.pm.diff',
130    './PatchFiles/IPC-LDT-2.03/LDT.pm.diff',
131
132    # Make JSON::RPC happy with CumulusDB. It shouldn't pass in $self needlessly.
133    './PatchFiles/JSON-RPC-Server.pm.diff',
134    './PatchFiles/JSON-RPC-0.96/lib/JSON/RPC/Server.pm.diff',
135
136    # The Apache2-SOAP test suite must be run as a non-privileged user otherwise
137    # the tests fail.
138    # We as root so the tests must be disabled.
139    # <rdar://problem/12886612> XBS-15: CPAN Module Apache::SOAP Build Error
140    './PatchFiles/Apache2-SOAP-0.73/Makefile.PL.diff',
141);
142
143
144foreach my $patchFile (@patchesToApply) {
145    &applyPatch($patchFile);
146}
147exit(0);
148
149# Subroutine that applies the patches
150sub applyPatch
151{
152    my ($patchFile) = @_;
153    
154    my ($status) = system("/usr/bin/patch -p0 < \"$patchFile\"");
155    if ($status != 0) {
156        print "Unable to apply $patchFile\n";
157        exit($status >> 8);
158    }
159}
160