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
7    # Address a bogus warning we see in SnowLeopard inside Class::Std (6783174)
8    './PatchFiles/Class-Std-0.011/lib/Class/Std.pm.diff',
9
10    # <rdar://problem/9559834> CPANInternal-103 (and earlier?) no longer builds
11    # Disables all HTTP-Proxy tests which seem to depend on external web servers.
12    './PatchFiles/HTTP-Proxy-0.25/t/Utils.pm.diff',
13
14    # IPC::LDT changes - replace use of fields / pseudohash with Perl 5.10
15    # compatible hash; add can_read method as implemented in Evolution's site_perl_custom.
16    './PatchFiles/IPC-LDT-2.03/LDT.pm.diff',
17    './PatchFiles/IPC-LDT-2.03/t/data.t.diff',
18    './PatchFiles/IPC-LDT-2.03/t/mixed.t.diff',
19
20    # Eliminate dependency on the JSON module
21    './PatchFiles/JSON-RPC-0.96/META.yml.diff',
22    './PatchFiles/JSON-RPC-0.96/Makefile.PL.diff',
23    './PatchFiles/JSON-RPC-0.96/lib/JSON/RPC/Client.pm.diff',
24    # Make JSON::RPC happy with CumulusDB. It shouldn't pass in $self needlessly.
25    './PatchFiles/JSON-RPC-0.96/lib/JSON/RPC/Server.pm.diff',
26    './PatchFiles/JSON-RPC-0.96/t/02_server.t.diff',
27
28    # Added krb5_set_default_realm function to Authen::Krb5.xs
29    # <rdar://problem/8370128> CPANInternal-94 project fails to build with LLVM compiler 2.0.
30    './PatchFiles/Authen-Krb5.diff',
31    './PatchFiles/Krb5-1.9/Makefile.PL.diff',
32
33    # Fix for https://github.com/mschilli/log4perl/issues/27
34    './PatchFiles/Log-Log4perl-1.40/lib/Log/Log4perl/Appender/File.pm.diff',
35
36    # The First Rule of Sys::Syslog is: You do not call "setlogsock". 
37    # The Second Rule of Sys::Syslog is: You do not call "setlogsock". 
38    # In the chroot environment, there is no unix domain socket for syslog
39    # without launchd plist hackery and other build-time implications.  
40    # Don't call setlogsock to force the use of /var/run/syslog if it doesn't exist.
41    './PatchFiles/Net-Daemon-0.48/lib/Net/Daemon/Log.pm.diff',
42
43    # Eliminate dependency on the JSON module
44    './PatchFiles/Pod-ProjectDocs-0.40/META.yml.diff',
45    './PatchFiles/Pod-ProjectDocs-0.40/Makefile.PL.diff',
46    './PatchFiles/Pod-ProjectDocs-0.40/lib/Pod/ProjectDocs.pm.diff'
47);
48
49
50foreach my $patchFile (@patchesToApply) {
51    &applyPatch($patchFile);
52}
53exit(0);
54
55# Subroutine that applies the patches
56sub applyPatch
57{
58    my ($patchFile) = @_;
59    
60    my ($status) = system("/usr/bin/patch -p0 < \"$patchFile\"");
61    if ($status != 0) {
62        print "Unable to apply $patchFile\n";
63        exit($status >> 8);
64    }
65}
66