git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Find .pm files automatically (was Re: Fix git-svn tests for SVN 1.7.5.)

From
Michael G Schwern <schwern@pobox.com>
Date
Jul 17, 2012, 23:05 UTC
Message-ID
<5005EFC5.8060105@pobox.com>
In-Reply-To
<20120717174446.GA14244@burratino>
On 2012.7.17 10:44 AM, Jonathan Nieder wrote:
Show 6 quoted lines
> 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" <schwern@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!
Previous: Michael G SchwernNext: Jonathan Nieder
Message 6 of 34 in “Fix git-svn tests for SVN 1.7.5.”
  1. Michael G SchwernJul 17, 2012
  2. Jonathan NiederJul 17, 2012
  3. Michael G SchwernJul 17, 2012
  4. Extract Git classes from git-svn (4/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  5. Extract Git classes from git-svn (5/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  6. Find .pm files automatically (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  7. Jonathan NiederJul 18, 2012
  8. Michael G SchwernJul 18, 2012
  9. Jonathan NiederJul 18, 2012
  10. Extract Git classes from git-svn (2/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  11. Jonathan NiederJul 18, 2012
  12. Eric WongJul 18, 2012
  13. Michael G SchwernJul 19, 2012
  14. Extract Git classes from git-svn (3/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  15. Jonathan NiederJul 18, 2012
  16. Extract Git classes from git-svn (6/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  17. Extract Git classes from git-svn (7/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  18. Extract Git classes from git-svn (8/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  19. Extract Git classes from git-svn (9/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  20. Extract Git classes from git-svn (10/10) (was Re: Fix git-svn tests for SVN 1.7.5.)Michael G Schwern, Jul 17, 2012
  21. Ben WaltonJul 21, 2012
  22. Jonathan NiederJul 17, 2012
  23. Junio C HamanoJul 18, 2012
  24. Thiago FarinaJul 19, 2012
  25. Michael G SchwernJul 24, 2012
  26. Jonathan NiederJul 24, 2012
  27. Eric WongJul 25, 2012
  28. Michael G SchwernJul 25, 2012
  29. OT: mail-based interfaces and web-based interfaces (Re: Extract Git classes from git-svn (1/10))Jonathan Nieder, Jul 25, 2012
  30. Michael G SchwernJul 25, 2012
  31. Eric WongJul 25, 2012
  32. Michael G SchwernJul 26, 2012
  33. Jonathan NiederJul 26, 2012
  34. Eric WongJul 26, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.