Skip to content

Commit ae1644b

Browse files
committed
Merge branch 'ab/perl-fixes'
Clean-up to various pieces of Perl code we have. * ab/perl-fixes: perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS Makefile: add NO_PERL_CPAN_FALLBACKS knob perl: move the perl/Git/FromCPAN tree to perl/FromCPAN perl: generalize the Git::LoadCPAN facility perl: move CPAN loader wrappers to another namespace perl: update our copy of Mail::Address perl: update our ancient copy of Error.pm git-send-email: unconditionally use Net::{SMTP,Domain} Git.pm: hard-depend on the File::{Temp,Spec} modules gitweb: hard-depend on the Digest::MD5 5.8 module Git.pm: add the "use warnings" pragma Git.pm: remove redundant "use strict" from sub-package perl: *.pm files should not have the executable bit
2 parents e74737b + 1aca69c commit ae1644b

File tree

15 files changed

+431
-158
lines changed

15 files changed

+431
-158
lines changed

INSTALL

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Issues of note:
8888
export GIT_EXEC_PATH PATH GITPERLLIB
8989

9090
- By default (unless NO_PERL is provided) Git will ship various perl
91-
scripts & libraries it needs. However, for simplicity it doesn't
92-
use the ExtUtils::MakeMaker toolchain to decide where to place the
93-
perl libraries. Depending on the system this can result in the perl
91+
scripts. However, for simplicity it doesn't use the
92+
ExtUtils::MakeMaker toolchain to decide where to place the perl
93+
libraries. Depending on the system this can result in the perl
9494
libraries not being where you'd like them if they're expected to be
9595
used by things other than Git itself.
9696

@@ -102,6 +102,11 @@ Issues of note:
102102
Will result in e.g. perllibdir=/usr/share/perl/5.26.1 on Debian,
103103
perllibdir=/usr/share/perl5 (which we'd use by default) on CentOS.
104104

105+
- Unless NO_PERL is provided Git will ship various perl libraries it
106+
needs. Distributors of Git will usually want to set
107+
NO_PERL_CPAN_FALLBACKS if NO_PERL is not provided to use their own
108+
copies of the CPAN modules Git needs.
109+
105110
- Git is reasonably self-sufficient, but does depend on a few external
106111
programs and libraries. Git can be used without most of them by adding
107112
the approriate "NO_<LIBRARY>=YesPlease" to the make command line or

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ all::
296296
#
297297
# Define NO_PERL if you do not want Perl scripts or libraries at all.
298298
#
299+
# Define NO_PERL_CPAN_FALLBACKS if you do not want to install bundled
300+
# copies of CPAN modules that serve as a fallback in case the modules
301+
# are not available on the system. This option is intended for
302+
# distributions that want to use their packaged versions of Perl
303+
# modules, instead of the fallbacks shipped with Git.
304+
#
299305
# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
300306
# but /usr/bin/python2.7 on some platforms).
301307
#
@@ -2304,14 +2310,22 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
23042310

23052311
LIB_PERL := $(wildcard perl/Git.pm perl/Git/*.pm perl/Git/*/*.pm perl/Git/*/*/*.pm)
23062312
LIB_PERL_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_PERL))
2313+
LIB_CPAN := $(wildcard perl/FromCPAN/*.pm perl/FromCPAN/*/*.pm)
2314+
LIB_CPAN_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_CPAN))
23072315

23082316
ifndef NO_PERL
23092317
all:: $(LIB_PERL_GEN)
2318+
ifndef NO_PERL_CPAN_FALLBACKS
2319+
all:: $(LIB_CPAN_GEN)
2320+
endif
2321+
NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS))
23102322
endif
23112323

23122324
perl/build/lib/%.pm: perl/%.pm
23132325
$(QUIET_GEN)mkdir -p $(dir $@) && \
2314-
sed -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' < $< > $@
2326+
sed -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
2327+
-e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
2328+
< $< > $@
23152329

23162330
perl/build/man/man3/Git.3pm: perl/Git.pm
23172331
$(QUIET_GEN)mkdir -p $(dir $@) && \

contrib/examples/git-difftool.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use 5.008;
1414
use strict;
1515
use warnings;
16-
use Git::Error qw(:try);
16+
use Git::LoadCPAN::Error qw(:try);
1717
use File::Basename qw(dirname);
1818
use File::Copy;
1919
use File::Find;

git-send-email.perl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
use Term::ANSIColor;
2727
use File::Temp qw/ tempdir tempfile /;
2828
use File::Spec::Functions qw(catdir catfile);
29-
use Git::Error qw(:try);
29+
use Git::LoadCPAN::Error qw(:try);
3030
use Cwd qw(abs_path cwd);
3131
use Git;
3232
use Git::I18N;
33-
use Git::Mail::Address;
33+
use Net::Domain ();
34+
use Net::SMTP ();
35+
use Git::LoadCPAN::Mail::Address;
3436

3537
Getopt::Long::Configure qw/ pass_through /;
3638

@@ -1199,28 +1201,24 @@ sub valid_fqdn {
11991201
sub maildomain_net {
12001202
my $maildomain;
12011203

1202-
if (eval { require Net::Domain; 1 }) {
1203-
my $domain = Net::Domain::domainname();
1204-
$maildomain = $domain if valid_fqdn($domain);
1205-
}
1204+
my $domain = Net::Domain::domainname();
1205+
$maildomain = $domain if valid_fqdn($domain);
12061206

12071207
return $maildomain;
12081208
}
12091209

12101210
sub maildomain_mta {
12111211
my $maildomain;
12121212

1213-
if (eval { require Net::SMTP; 1 }) {
1214-
for my $host (qw(mailhost localhost)) {
1215-
my $smtp = Net::SMTP->new($host);
1216-
if (defined $smtp) {
1217-
my $domain = $smtp->domain;
1218-
$smtp->quit;
1213+
for my $host (qw(mailhost localhost)) {
1214+
my $smtp = Net::SMTP->new($host);
1215+
if (defined $smtp) {
1216+
my $domain = $smtp->domain;
1217+
$smtp->quit;
12191218

1220-
$maildomain = $domain if valid_fqdn($domain);
1219+
$maildomain = $domain if valid_fqdn($domain);
12211220

1222-
last if $maildomain;
1223-
}
1221+
last if $maildomain;
12241222
}
12251223
}
12261224

gitweb/INSTALL

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ Requirements
2929
------------
3030

3131
- Core git tools
32-
- Perl
32+
- Perl 5.8
3333
- Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
3434
- web server
3535

3636
The following optional Perl modules are required for extra features
37-
- Digest::MD5 - for gravatar support
3837
- CGI::Fast and FCGI - for running gitweb as FastCGI script
3938
- HTML::TagCloud - for fancy tag cloud in project list view
4039
- HTTP::Date or Time::ParseDate - to support If-Modified-Since for feeds

gitweb/gitweb.perl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use File::Find qw();
2121
use File::Basename qw(basename);
2222
use Time::HiRes qw(gettimeofday tv_interval);
23+
use Digest::MD5 qw(md5_hex);
24+
2325
binmode STDOUT, ':utf8';
2426

2527
if (!defined($CGI::VERSION) || $CGI::VERSION < 4.08) {
@@ -490,7 +492,6 @@ sub evaluate_uri {
490492
# Currently available providers are gravatar and picon.
491493
# If an unknown provider is specified, the feature is disabled.
492494

493-
# Gravatar depends on Digest::MD5.
494495
# Picon currently relies on the indiana.edu database.
495496

496497
# To enable system wide have in $GITWEB_CONFIG
@@ -1166,18 +1167,8 @@ sub configure_gitweb_features {
11661167
our @snapshot_fmts = gitweb_get_feature('snapshot');
11671168
@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
11681169

1169-
# check that the avatar feature is set to a known provider name,
1170-
# and for each provider check if the dependencies are satisfied.
1171-
# if the provider name is invalid or the dependencies are not met,
1172-
# reset $git_avatar to the empty string.
11731170
our ($git_avatar) = gitweb_get_feature('avatar');
1174-
if ($git_avatar eq 'gravatar') {
1175-
$git_avatar = '' unless (eval { require Digest::MD5; 1; });
1176-
} elsif ($git_avatar eq 'picon') {
1177-
# no dependencies
1178-
} else {
1179-
$git_avatar = '';
1180-
}
1171+
$git_avatar = '' unless $git_avatar =~ /^(?:gravatar|picon)$/s;
11811172

11821173
our @extra_branch_refs = gitweb_get_feature('extra-branch-refs');
11831174
@extra_branch_refs = filter_and_validate_refs (@extra_branch_refs);
@@ -2167,7 +2158,7 @@ sub gravatar_url {
21672158
my $size = shift;
21682159
$avatar_cache{$email} ||=
21692160
"//www.gravatar.com/avatar/" .
2170-
Digest::MD5::md5_hex($email) . "?s=";
2161+
md5_hex($email) . "?s=";
21712162
return $avatar_cache{$email} . $size;
21722163
}
21732164

perl/FromCPAN/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Error.pm whitespace=-blank-at-eof

0 commit comments

Comments
 (0)