On 2012.7.17 10:44 AM, Jonathan Nieder wrote:
> My advice would be to send five or so of the patches that you would
> like to be reviewed first, inline, one per message, in reply to this
> message so we can start to work on that.  Presumably the patches do
> not regress git-svn's behavior but only make it saner, so even if this
> is not a complete fix it should allow us to get started.  See
> Documentation/SubmittingPatches for more hints.

Ok, here goes.

First patch overhauls perl/Makefile.PL to make it easier to add .pm files,
which I'm going to be doing a lot of.  Instead of having to manually add to
the %pm hash, it scans for .pm files.

It also moves Error.pm into a bundle directory.  This both makes it just
another directory to scan (or not scan), but it also makes it possible to
bundle additional modules in the future.  ExtUtils::MakeMaker uses this
technique itself.

You still have to remember to add them to the other Makefile.

This is available as a branch.
https://github.com/schwern/git/tree/git-svn/easier_modules


>From 47a723a860cded6b16a716ea74c5bc029ee5b0ac Mon Sep 17 00:00:00 2001
From: "Michael G. Schwern" <schw...@pobox.com>
Date: Thu, 12 Jul 2012 00:05:38 -0700
Subject: [PATCH 01/11] Make the process of adding a module less blecherous.

* Scan for .pm files and build %pms rather than having to do it by hand.
* Move the bundled Error into its own directory so we can bundle other modules.

In addition...
* Add all the .pm files to the all dependency in the alternative Makefile
---
 perl/Makefile                                     |  6 ++--
 perl/Makefile.PL                                  | 42 +++++++++++++----------
 perl/{private-Error.pm => bundles/Error/Error.pm} |  0
 perl/bundles/README                               | 10 ++++++
 4 files changed, 36 insertions(+), 22 deletions(-)
 rename perl/{private-Error.pm => bundles/Error/Error.pm} (100%)
 create mode 100644 perl/bundles/README

diff --git a/perl/Makefile b/perl/Makefile
index 6ca7d47..4f25930 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -33,7 +33,7 @@ modules += Git/SVN/Prompt
 modules += Git/SVN/Ra

 $(makfile): ../GIT-CFLAGS Makefile
-       echo all: private-Error.pm Git.pm Git/I18N.pm > $@
+       echo all: bundles/Error/Error.pm $(modules) > $@
        set -e; \
        for i in $(modules); \
        do \
@@ -49,7 +49,7 @@ $(makfile): ../GIT-CFLAGS Makefile
        done
        echo '  $(RM) blib/lib/Error.pm' >> $@
        '$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
-       echo '  cp private-Error.pm blib/lib/Error.pm' >> $@
+       echo '  cp bundles/Error/Error.pm blib/lib/Error.pm' >> $@
        echo install: >> $@
        set -e; \
        for i in $(modules); \
@@ -66,7 +66,7 @@ $(makfile): ../GIT-CFLAGS Makefile
        done
        echo '  $(RM) "$$(DESTDIR)$(instdir_SQ)/Error.pm"' >> $@
        '$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
-       echo '  cp private-Error.pm "$$(DESTDIR)$(instdir_SQ)/Error.pm"' >> $@
+       echo '  cp bundles/Error/Error.pm "$$(DESTDIR)$(instdir_SQ)/Error.pm"' 
>> $@
        echo instlibdir: >> $@
        echo '  echo $(instdir_SQ)' >> $@
 else
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index b54b04a..000d370 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -2,11 +2,16 @@ use strict;
 use warnings;
 use ExtUtils::MakeMaker;
 use Getopt::Long;
+use File::Find;
+
+# Don't forget to update the perl/Makefile, too.
+# Don't forget to test with NO_PERL_MAKEMAKER=YesPlease

 # Sanity: die at first unknown option
 Getopt::Long::Configure qw/ pass_through /;

-GetOptions("localedir=s" => \my $localedir);
+my $localedir = '';
+GetOptions("localedir=s" => \$localedir);

 sub MY::postamble {
        return <<'MAKE_FRAG';
@@ -24,27 +29,25 @@ endif
 MAKE_FRAG
 }

-# XXX. When editing this list:
-#
-# * Please update perl/Makefile, too.
-# * Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
-my %pm = (
-       'Git.pm' => '$(INST_LIBDIR)/Git.pm',
-       'Git/I18N.pm' => '$(INST_LIBDIR)/Git/I18N.pm',
-       'Git/SVN/Memoize/YAML.pm' => '$(INST_LIBDIR)/Git/SVN/Memoize/YAML.pm',
-       'Git/SVN/Fetcher.pm' => '$(INST_LIBDIR)/Git/SVN/Fetcher.pm',
-       'Git/SVN/Editor.pm' => '$(INST_LIBDIR)/Git/SVN/Editor.pm',
-       'Git/SVN/Prompt.pm' => '$(INST_LIBDIR)/Git/SVN/Prompt.pm',
-       'Git/SVN/Ra.pm' => '$(INST_LIBDIR)/Git/SVN/Ra.pm',
-);
-
+my @pmlibdirs = ("Git");
 # We come with our own bundled Error.pm. It's not in the set of default
 # Perl modules so install it if it's not available on the system yet.
-eval { require Error };
-if ($@ || $Error::VERSION < 0.15009) {
-       $pm{'private-Error.pm'} = '$(INST_LIBDIR)/Error.pm';
+if ( !eval { require Error } || $Error::VERSION < 0.15009) {
+    push @pmlibdirs, "bundles/Error";
 }

+
+# Find all the .pm files in @pmlibdirs which includes our bundled modules.
+my %pms;
+find sub {
+    return unless /\.pm$/;
+
+    my $inst = $File::Find::name;
+    $inst =~ s{bundles/[^/]+/?}{};
+    $pms{$File::Find::name} = '$(INST_LIBDIR)/'.$inst;
+}, @pmlibdirs;
+
+
 # redirect stdout, otherwise the message "Writing perl.mak for Git"
 # disrupts the output for the target 'instlibdir'
 open STDOUT, ">&STDERR";
@@ -52,8 +55,9 @@ open STDOUT, ">&STDERR";
 WriteMakefile(
        NAME            => 'Git',
        VERSION_FROM    => 'Git.pm',
-       PM              => \%pm,
+       PM              => \%pms,
        PM_FILTER       => qq[\$(PERL) -pe 
"s<\\Q++LOCALEDIR++\\E><$localedir>"],
        MAKEFILE        => 'perl.mak',
        INSTALLSITEMAN3DIR => '$(SITEPREFIX)/share/man/man3'
 );
+
diff --git a/perl/private-Error.pm b/perl/bundles/Error/Error.pm
similarity index 100%
rename from perl/private-Error.pm
rename to perl/bundles/Error/Error.pm
diff --git a/perl/bundles/README b/perl/bundles/README
new file mode 100644
index 0000000..8a9ce39
--- /dev/null
+++ b/perl/bundles/README
@@ -0,0 +1,10 @@
+This is any Perl modules we might want to bundle because Perl doesn't (or 
didn't)
+ship with them.  Each directory is a distribution containing all the PM files.
+
+For example, if you wanted to bundle URI...
+1) mkdir bundles/URI/
+
+2) build URI & cp -r blib/lib/* into bundles/URI
+
+3) add bundles/URI to @pmlibdirs in the Makefile.PL with the
+   appropriate check for existance and high enough version
-- 
1.7.11.1




-- 
Alligator sandwich, and make it snappy!
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to