git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Todd Zullinger <tmz@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Matthieu Moy" <git@matthieu-moy.fr>,
	"Petr Baudis" <pasky@ucw.cz>, "Jeff King" <peff@peff.net>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Jari Aalto" <jari.aalto@cante.net>,
	"Giuseppe Bilotta" <giuseppe.bilotta@gmail.com>,
	"Marcus Griep" <marcus@griep.us>
Subject: Re: [PATCH 3/8] perl: generalize the Git::LoadCPAN facility
Date: Sat, 17 Feb 2018 00:40:52 -0500	[thread overview]
Message-ID: <20180217054052.GU27038@zaya.teonanacatl.net> (raw)
In-Reply-To: <20180217004753.GS27038@zaya.teonanacatl.net>

I wrote:
> Hi Jonathan,
> 
> Jonathan Nieder wrote:
>> Todd Zullinger wrote:
> [...]
>>> +++ b/Makefile
>>> @@ -296,6 +296,9 @@ all::
>>>  #
>>>  # Define NO_PERL if you do not want Perl scripts or libraries at all.
>>>  #
>>> +# Define NO_PERL_CPAN_FALLBACKS if you do not want to install fallbacks for
>>> +# perl CPAN modules.
>> 
>> nit: Looking at this as a naive user, it's not obvious what kind of
>> fallbacks are meant. How about:
>> 
>> 	Define NO_PERL_CPAN_FALLBACKS if you do not want to install bundled
>> 	copies of CPAN modules that serve as a fallback in case the modules are
>> 	not available on the system.
>> 
>> Or perhaps:
>> 
>> 	Define HAVE_CPAN_MODULES if you have Error.pm and Mail::Address installed
>> 	and do not want to install the fallback copies from perl/FromCPAN.
> 
> Hmm, a positive variable like HAVE_CPAN_MODULES is
> appealing.
> 
> I don't know about listing the modules, as those seem likely
> to change and then the comment becomes stale.  It's nice to
> have a shorter name.  I could easily go back and forth.
> Hopefully some other folks will chime in with preferences.
> 
>> Would this patch need to update the loader to expect the modules in
>> the new location?
> 
> That's a good catch.  In checking how this ends up when not
> setting NO_PERL_CPAN_FALLBACKS, we end up installing
> FromCPAN at the root of $perllibdir rather than under the
> Git dir.
> 
> While we could probably fix Git::LoadCPAN, I doubt we want
> to pollute the namespace. ;) So we'll want to ensure the
> files get put in the right place from the start.  I'll try
> to fix that up.

I ended up adding a second variable to hold the FromCPAN
wildcard match, as I couldn't come up with any clean way to
do it in the same LIB_PERL{,_GEN} vars.

I tested it with and without NO_PERL_CPAN_FALLBACKS set and
with and without the system Error and Mail::Address modules
installed.  There's nothing which automatically removes the
perl/build/lib/Git/FromCPAN tree if make was run without
NO_PERL_CPAN_FALLBACKS set and then re-run with it.  I don't
know if that's something we'd care to support or not.  I
suspect it's simpler to require 'make clean' between such
runs.

(I had to restore the FromCPAN copy of Address.pm, as noted
in <87tvuif10e.fsf@evledraar.gmail.com>, of course.)

Here's what it looks like now (still subject to changing the
NO_PERL_CPAN_FALLBACKS variable).

---- 8> ----
From: Todd Zullinger <tmz@pobox.com>
Subject: [PATCH] Makefile: add NO_PERL_CPAN_FALLBACKS knob

We include some perl modules which are not part of the core perl
install, as a convenience.  This allows us to rely on those modules in
our perl-based tools and scripts without requiring users to install the
modules from CPAN or their operating system packages.

Users whose operating system provides these modules and packagers of Git
often don't want to ship or use these bundled modules.  Allow these
users to set NO_PERL_CPAN_FALLBACKS to avoid installing the bundled
modules.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
 Makefile                                    | 14 ++++++++++++++
 perl/{Git => }/FromCPAN/.gitattributes      |  0
 perl/{Git => }/FromCPAN/Error.pm            |  0
 perl/{Git => }/FromCPAN/Mail/.gitattributes |  0
 perl/{Git => }/FromCPAN/Mail/Address.pm     |  0
 5 files changed, 14 insertions(+)
 rename perl/{Git => }/FromCPAN/.gitattributes (100%)
 rename perl/{Git => }/FromCPAN/Error.pm (100%)
 rename perl/{Git => }/FromCPAN/Mail/.gitattributes (100%)
 rename perl/{Git => }/FromCPAN/Mail/Address.pm (100%)

diff --git a/Makefile b/Makefile
index bdd50069af..49244fb116 100644
--- a/Makefile
+++ b/Makefile
@@ -296,6 +296,10 @@ all::
 #
 # Define NO_PERL if you do not want Perl scripts or libraries at all.
 #
+# Define NO_PERL_CPAN_FALLBACKS if you do not want to install bundled
+# copies of CPAN modules that serve as a fallback in case the modules are
+# not available on the system.
+#
 # Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
 # but /usr/bin/python2.7 on some platforms).
 #
@@ -2300,15 +2304,25 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
 
 LIB_PERL := $(wildcard perl/Git.pm perl/Git/*.pm perl/Git/*/*.pm perl/Git/*/*/*.pm)
 LIB_PERL_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_PERL))
+ifndef NO_PERL_CPAN_FALLBACKS
+LIB_CPAN := $(wildcard perl/FromCPAN/*.pm perl/FromCPAN/*/*.pm)
+LIB_CPAN_GEN := $(patsubst perl/%.pm,perl/build/lib/Git/%.pm,$(LIB_CPAN))
+endif
 
 ifndef NO_PERL
 all:: $(LIB_PERL_GEN)
+ifndef NO_PERL_CPAN_FALLBACKS
+all:: $(LIB_CPAN_GEN)
+endif
 endif
 
 perl/build/lib/%.pm: perl/%.pm
 	$(QUIET_GEN)mkdir -p $(dir $@) && \
 	sed -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' < $< > $@
 
+perl/build/lib/Git/FromCPAN/%.pm: perl/FromCPAN/%.pm
+	$(QUIET_GEN)mkdir -p $(dir $@) && cp $< $@
+
 perl/build/man/man3/Git.3pm: perl/Git.pm
 	$(QUIET_GEN)mkdir -p $(dir $@) && \
 	pod2man $< $@
diff --git a/perl/Git/FromCPAN/.gitattributes b/perl/FromCPAN/.gitattributes
similarity index 100%
rename from perl/Git/FromCPAN/.gitattributes
rename to perl/FromCPAN/.gitattributes
diff --git a/perl/Git/FromCPAN/Error.pm b/perl/FromCPAN/Error.pm
similarity index 100%
rename from perl/Git/FromCPAN/Error.pm
rename to perl/FromCPAN/Error.pm
diff --git a/perl/Git/FromCPAN/Mail/.gitattributes b/perl/FromCPAN/Mail/.gitattributes
similarity index 100%
rename from perl/Git/FromCPAN/Mail/.gitattributes
rename to perl/FromCPAN/Mail/.gitattributes
diff --git a/perl/Git/FromCPAN/Mail/Address.pm b/perl/FromCPAN/Mail/Address.pm
similarity index 100%
rename from perl/Git/FromCPAN/Mail/Address.pm
rename to perl/FromCPAN/Mail/Address.pm
-- 
2.16.2

I thought about using '$(INSTALL) -m 644' instead of 'cp' to
allow users to set 'INSTALL = install -p' to preserve the
timestamp of the FromCPAN files, but that would only be
useful to users installing from the same tarball version
multiple times.  The intersection of users who care that
much about consistent timestamps and don't care about using
system perl modules seems small.

-- 
Todd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A person who smiles in the face of adversity ... probably has a
scapegoat.


  reply	other threads:[~2018-02-17  5:40 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 22:21 [PATCH 0/8] various perl fixes Ævar Arnfjörð Bjarmason
2018-02-14 22:21 ` [PATCH 1/8] perl: *.pm files should not have the executable bit Ævar Arnfjörð Bjarmason
2018-02-14 22:41   ` Jonathan Nieder
2018-02-25 19:01     ` Ævar Arnfjörð Bjarmason
2018-02-14 22:21 ` [PATCH 2/8] perl: move CPAN loader wrappers to another namespace Ævar Arnfjörð Bjarmason
2018-02-14 22:43   ` Jonathan Nieder
2018-02-14 22:21 ` [PATCH 3/8] perl: generalize the Git::LoadCPAN facility Ævar Arnfjörð Bjarmason
2018-02-14 22:57   ` Jonathan Nieder
2018-02-15  5:09     ` Todd Zullinger
2018-02-25 18:56     ` Ævar Arnfjörð Bjarmason
2018-02-25 19:05       ` Randall S. Becker
2018-02-15  4:53   ` Todd Zullinger
2018-02-15 20:41     ` Ævar Arnfjörð Bjarmason
2018-02-15 21:23       ` Todd Zullinger
2018-02-16 14:39         ` Ævar Arnfjörð Bjarmason
2018-02-16 17:55           ` Todd Zullinger
2018-02-16 22:03             ` Jonathan Nieder
2018-02-17  0:47               ` Todd Zullinger
2018-02-17  5:40                 ` Todd Zullinger [this message]
2018-02-14 22:21 ` [PATCH 4/8] perl: update our ancient copy of Error.pm Ævar Arnfjörð Bjarmason
2018-02-14 23:03   ` Jonathan Nieder
2018-02-15 20:46     ` Ævar Arnfjörð Bjarmason
2018-02-14 22:21 ` [PATCH 5/8] perl: update our copy of Mail::Address Ævar Arnfjörð Bjarmason
2018-02-14 23:46   ` Jonathan Nieder
2018-02-15  9:32     ` Matthieu Moy
2018-02-15 20:31       ` Ævar Arnfjörð Bjarmason
2018-02-14 22:21 ` [PATCH 6/8] git-send-email: unconditionally use Net::{SMTP,Domain} Ævar Arnfjörð Bjarmason
2018-02-14 23:49   ` Jonathan Nieder
2018-02-15 20:43     ` Ævar Arnfjörð Bjarmason
2018-02-14 22:21 ` [PATCH 7/8] gitweb: hard-depend on the Digest::MD5 5.8 module Ævar Arnfjörð Bjarmason
2018-02-14 23:52   ` Jonathan Nieder
2018-02-14 22:21 ` [PATCH 8/8] perl: hard-depend on the File::{Temp,Spec} modules Ævar Arnfjörð Bjarmason
2018-02-14 23:54   ` Jonathan Nieder
2018-02-15 20:42     ` Ævar Arnfjörð Bjarmason
2018-02-15 21:33       ` Junio C Hamano
2018-02-25 19:46 ` [PATCH v2 00/13] various perl fixes Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2018-03-05 19:01     ` Junio C Hamano
2018-03-03 15:38   ` [PATCH v3 01/13] perl: *.pm files should not have the executable bit Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 02/13] Git.pm: remove redundant "use strict" from sub-package Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 03/13] Git.pm: add the "use warnings" pragma Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 04/13] gitweb: hard-depend on the Digest::MD5 5.8 module Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 05/13] Git.pm: hard-depend on the File::{Temp,Spec} modules Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 06/13] git-send-email: unconditionally use Net::{SMTP,Domain} Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 07/13] perl: update our ancient copy of Error.pm Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 08/13] perl: update our copy of Mail::Address Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 09/13] perl: move CPAN loader wrappers to another namespace Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 10/13] perl: generalize the Git::LoadCPAN facility Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 11/13] perl: move the perl/Git/FromCPAN tree to perl/FromCPAN Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 12/13] Makefile: add NO_PERL_CPAN_FALLBACKS knob Ævar Arnfjörð Bjarmason
2018-03-03 15:38   ` [PATCH v3 13/13] perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 01/13] perl: *.pm files should not have the executable bit Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 02/13] Git.pm: remove redundant "use strict" from sub-package Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 03/13] Git.pm: add the "use warnings" pragma Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 04/13] gitweb: hard-depend on the Digest::MD5 5.8 module Ævar Arnfjörð Bjarmason
2018-02-25 20:00   ` Eric Sunshine
2018-02-25 19:46 ` [PATCH v2 05/13] Git.pm: hard-depend on the File::{Temp,Spec} modules Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 06/13] git-send-email: unconditionally use Net::{SMTP,Domain} Ævar Arnfjörð Bjarmason
2018-02-25 20:03   ` Eric Sunshine
2018-02-25 19:46 ` [PATCH v2 07/13] perl: update our ancient copy of Error.pm Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 08/13] perl: update our copy of Mail::Address Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 09/13] perl: move CPAN loader wrappers to another namespace Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 10/13] perl: generalize the Git::LoadCPAN facility Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 11/13] perl: move the perl/Git/FromCPAN tree to perl/FromCPAN Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 12/13] Makefile: add NO_PERL_CPAN_FALLBACKS knob Ævar Arnfjörð Bjarmason
2018-02-25 19:46 ` [PATCH v2 13/13] perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180217054052.GU27038@zaya.teonanacatl.net \
    --to=tmz@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@matthieu-moy.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=giuseppe.bilotta@gmail.com \
    --cc=jari.aalto@cante.net \
    --cc=jrnieder@gmail.com \
    --cc=marcus@griep.us \
    --cc=pasky@ucw.cz \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).