summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-10-24 22:52:12 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-10-24 22:52:12 +0000
commitf90aeba984bb8f1e834bf1a9fe6a80b292a63248 (patch)
tree91fdaeae4da7471108eb38a7483032b3bc46a3dc /utils
parent6c49c9380a3ae59c517c6f8500ec2c5da9c38d5a (diff)
downloadnetsurf-f90aeba984bb8f1e834bf1a9fe6a80b292a63248.tar.gz
netsurf-f90aeba984bb8f1e834bf1a9fe6a80b292a63248.tar.bz2
Appease ancient Perl installs.
svn path=/trunk/netsurf/; revision=13079
Diffstat (limited to 'utils')
-rwxr-xr-xutils/svn-testament.pl32
1 files changed, 27 insertions, 5 deletions
diff --git a/utils/svn-testament.pl b/utils/svn-testament.pl
index 7257f58fc..96bbd7c44 100755
--- a/utils/svn-testament.pl
+++ b/utils/svn-testament.pl
@@ -1,7 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use File::Temp;
=head1
@@ -25,9 +24,33 @@ if ( -d ".svn" ) {
$svn_present = 1;
}
+sub compat_tmpnam {
+ # File::Temp was introduced in Perl 5.6.1
+ my $have_file_tmp = eval { require File::Temp };
+
+ if ( ! $have_file_tmp ) {
+ return "$$.svnt";
+ } else {
+ return File::Temp::tmpnam();
+ }
+}
+
+sub compat_md5_hex {
+ # Digest::MD5 was introduced in Perl 5.7.1
+ my $have_digest_md5 = eval { require Digest::MD5 };
+ my $have_md5 = eval { require MD5 };
+ my $data = shift;
+
+ if ( ! $have_digest_md5 ) {
+ return MD5->hexhash($data);
+ } else {
+ return Digest::MD5->new->add($data)->hexdigest;
+ }
+}
+
sub gather_output {
my $cmd = shift;
- my $tmpfile = File::Temp::tmpnam();
+ my $tmpfile = compat_tmpnam();
local $/ = undef();
system("$cmd > $tmpfile");
open(my $CMDH, "<", $tmpfile);
@@ -133,8 +156,6 @@ foreach my $filename (sort keys %svnstatus) {
}
$testament .= " \\\n}\n";
-use Digest::MD5 qw(md5_hex);
-
my $oldcsum = "";
if ( -e $targetfile ) {
open(my $OLDVALUES, "<", $targetfile);
@@ -146,7 +167,7 @@ if ( -e $targetfile ) {
close($OLDVALUES);
}
-my $newcsum = md5_hex($testament);
+my $newcsum = compat_md5_hex($testament);
if ($oldcsum ne $newcsum) {
print "TESTMENT: $targetfile\n";
@@ -188,5 +209,6 @@ sub care_about_file {
return 0 if ($fn =~ /\.a$/); # Don't care for extraneous archive files
return 0 if ($fn =~ /\.md5$/); # Don't care for md5sum files
return 0 if ($fn =~ /\.map$/); # Don't care for map files
+ return 0 if ($fn =~ /\.svnt$/); # Don't care for testament temp files
return 1;
}