equal
deleted
inserted
replaced
21 use strict; |
21 use strict; |
22 use File::Spec; |
22 use File::Spec; |
23 use File::Copy; |
23 use File::Copy; |
24 use places; |
24 use places; |
25 use check_os; |
25 use check_os; |
|
26 use get_wordsize; |
26 |
27 |
27 sub compare_files($$) |
28 sub compare_files($$) |
28 { |
29 { |
29 my ($flhs,$frhs) = @_; |
30 my ($flhs,$frhs) = @_; |
30 my $delim = $/; |
31 my $delim = $/; |
39 return "$slhs" eq "$srhs"; |
40 return "$slhs" eq "$srhs"; |
40 } |
41 } |
41 |
42 |
42 sub apply_patch_file($) |
43 sub apply_patch_file($) |
43 { |
44 { |
|
45 my $patched = 0; |
44 my $patch_file = shift; |
46 my $patch_file = shift; |
45 my ($src_file, $dest_file); |
47 my ($src_file, $dest_file); |
46 my $epocroot = get_epocroot(); |
48 my $epocroot = get_epocroot(); |
47 my $patch_files_dir; |
49 my $patch_files_dir; |
48 if (os_is_windows()) { |
50 if (os_is_windows()) { |
52 } else { |
54 } else { |
53 die "*** Unsupported OS $^O ***"; |
55 die "*** Unsupported OS $^O ***"; |
54 } |
56 } |
55 $src_file = File::Spec->catfile($patch_files_dir,$patch_file); |
57 $src_file = File::Spec->catfile($patch_files_dir,$patch_file); |
56 if (! -f $src_file) { |
58 if (! -f $src_file) { |
57 die("*** Error: not found \"$src_file\" ***"); |
59 my $wordsize = get_host_wordsize(); |
|
60 $wordsize .= "bit"; |
|
61 if (-f "$src_file\.$wordsize") { |
|
62 print ">>> Using $wordsize variant of \"$src_file\"\n"; |
|
63 $src_file .= "\.$wordsize"; |
|
64 } else { |
|
65 die("*** Error: not found \"$src_file\" ***"); |
|
66 } |
58 } |
67 } |
59 if ($patch_file =~ /^\$/) { |
68 if ($patch_file =~ /^\$/) { |
60 my ($vol,$dir,$file) = File::Spec->splitpath($patch_file); |
69 my ($vol,$dir,$file) = File::Spec->splitpath($patch_file); |
61 my @dirs = File::Spec->splitdir($dir); |
70 my @dirs = File::Spec->splitdir($dir); |
62 my $topdir = shift(@dirs); |
71 my $topdir = shift(@dirs); |
71 print "??? Need patch \"$src_file\" -> \"$dest_file\" ??? \n"; |
80 print "??? Need patch \"$src_file\" -> \"$dest_file\" ??? \n"; |
72 if (! -f $dest_file) { |
81 if (! -f $dest_file) { |
73 print ">>> Yes. \"$dest_file\" does not exist\n"; |
82 print ">>> Yes. \"$dest_file\" does not exist\n"; |
74 print ">>> Copying \"$src_file\" to \"$dest_file\"n"; |
83 print ">>> Copying \"$src_file\" to \"$dest_file\"n"; |
75 copy($src_file,$dest_file) or die $!; |
84 copy($src_file,$dest_file) or die $!; |
|
85 $patched = 1; |
76 } |
86 } |
77 else { |
87 else { |
78 my $dif = !compare_files($src_file,$dest_file); |
88 my $dif = !compare_files($src_file,$dest_file); |
79 print "$dif\n"; |
89 print "$dif\n"; |
80 if (!$dif) { |
90 if (!$dif) { |
85 my $backup = $dest_file; |
95 my $backup = $dest_file; |
86 for (; -f ($backup .= '~');) {}; |
96 for (; -f ($backup .= '~');) {}; |
87 print ">>> Backing up \"$dest_file\" as \"$backup\"\n"; |
97 print ">>> Backing up \"$dest_file\" as \"$backup\"\n"; |
88 copy($dest_file,$backup) or die $!; |
98 copy($dest_file,$backup) or die $!; |
89 print ">>> Copying \"$src_file\" to \"$dest_file\"\n"; |
99 print ">>> Copying \"$src_file\" to \"$dest_file\"\n"; |
90 copy($src_file,$dest_file) or die $!; |
100 copy($src_file,$dest_file) or die $!; |
|
101 $patched = 1; |
91 } |
102 } |
92 } |
103 } |
|
104 return $patched; |
93 } |
105 } |
94 |
106 |
95 1; |
107 1; |
96 |
108 |
97 |
109 |