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

Re: [PATCH 3/8] perl: generalize the Git::LoadCPAN facility

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 15, 2018, 20:41 UTC
Message-ID
<87sha2f0j1.fsf@evledraar.gmail.com>
In-Reply-To
<20180215045301.GC27038@zaya.teonanacatl.net>
On Thu, Feb 15 2018, Todd Zullinger jotted:
Show 94 quoted lines
> Hi Ævar,
>
> Ævar Arnfjörð Bjarmason wrote:
>> +Git::LoadCPAN - Wrapper for loading modules from the CPAN (OS) or Git's own copy
>> +
>> +=head1 DESCRIPTION
>> +
>> +The Perl code in Git depends on some modules from the CPAN, but we
>> +don't want to make those a hard requirement for anyone building from
>> +source.
>> +
>> +Therefore the L<Git::LoadCPAN> namespace shipped with Git contains
>> +wrapper modules like C<Git::LoadCPAN::Module::Name> that will first
>> +attempt to load C<Module::Name> from the OS, and if that doesn't work
>> +will fall back on C<Git::FromCPAN::Module::Name> shipped with Git
>> +itself.
>> +
>> +Usually OS's will not ship with Git's Git::FromCPAN tree at all,
>> +preferring to use their own packaging of CPAN modules instead.
>
> This is something I wondered about.  What's the recommended
> method to ensure git packaged for an OS/distribution doesn't
> ever use the fallbacks?  Remove $perllibdir/Git/FromCPAN
> after make install?
>
> If so, would it be useful to add a Makefile knob to not
> install the FromCPAN bits, which may be generally useful to
> packagers?
>
> Something like the following, perhaps?
>
> (I'd feel bad suggesting this without a patch, after all the
> work you've already done to simplify and improve the perl
> bits.)
>
> ---- 8< ----
> From: Todd Zullinger <tmz@pobox.com>
> Date: Wed, 14 Feb 2018 23:00:30 -0500
> Subject: [PATCH] Makefile: add NO_PERL_CPAN to disable fallback module install
>
> As noted in perl/Git/LoadCPAN.pm, operating system packages often don't
> want to ship Git::FromCPAN tree at all, preferring to use their own
> packaging of CPAN modules instead.  Allow such packagers to set
> NO_PERL_CPAN to easily avoid installing these fallback perl CPAN
> modules.
>
> Signed-off-by: Todd Zullinger <tmz@pobox.com>
> ---
>  Makefile | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 5bcd83ddf3..c4e035e5bf 100644
> --- a/Makefile
> +++ 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 if you do not want to install fallbacks for perl CPAN
> +# modules.
> +#
>  # Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
>  # but /usr/bin/python2.7 on some platforms).
>  #
> @@ -2572,6 +2575,7 @@ ifndef NO_GETTEXT
>  endif
>  ifndef NO_PERL
>  	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
> +	test -z "$(NO_PERL_CPAN)" || rm -rf perl/build/lib/Git/FromCPAN
>  	(cd perl/build/lib && $(TAR) cf - .) | \
>  	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
>  	$(MAKE) -C gitweb install
> --
> 2.16.1
>
> I don't particularly like NO_PERL_CPAN, but I'm confident
> someone else will suggest an obviously better name.
>
> I thought about moving the 'rm -rf Git/FromCPAN' after the
> tar/untar, to keep the files in place for the tests.  No
> tests seem to rely on those local files, so I stuck with
> removing them before.  That diff was:
>
> --- a/Makefile
> +++ b/Makefile
> @@ -2574,6 +2574,7 @@
>  	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
>  	(cd perl/build/lib && $(TAR) cf - .) | \
>  	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
> +	test -n "$(NO_PERL_CPAN)" && rm -rf '$(DESTDIR_SQ)$(perllibdir_SQ)'/Git/FromCPAN
>  	$(MAKE) -C gitweb install
>  endif
>  ifndef NO_TCLTK

That makes sense, I'll incorporate that in a re-roll. I like NO_PERL_CPAN_FALLBACKS or just NO_CPAN_FALLBACKS better.

I'd really like to find some solution that works differently though, because with this approach we'll run the full test suite against a system where our fallbacks will be in place (although if the OS distributor has done as promised we won't use them), and then just remove this at 'make install' time, also meaning we'll re-gen it before running 'make install' again, only to rm it again.

The former issue we could deal with by munging the Git::LoadCPAN file so it knows about NO_PERL_CPAN_FALLBACKS, and will always refuse to use the fallbacks if that's set. That's a good idea anyway, because right now if you e.g. uninstall Error.pm on Debian (which strips the CPAN fallbacks) you get a cryptic "BUG: ..." message, it should instead say "we couldn't get this module the OS promised we'd have" or something to that effect.

The latter is trickier, I don't see an easy way to coerce the Makefile into not copying the FromCPAN directory without going back to a hardcoded list again, the easiest thing is probably to turn that:

    $(TAR) cf - .)
Into:
    $(TAR) cf - $(find ... -not ....)

Or something like that to get all the stuff that isn't the Git/FromCPAN directory.

Other suggestions most welcome.
Previous: Todd ZullingerNext: Todd Zullinger
Message 16 of 66 in “various perl fixes”
  1. 0/8 various perl fixesÆvar Arnfjörð Bjarmason, Feb 14, 2018
  2. 1/8 perl: *.pm files should not have the executable bitÆvar Arnfjörð Bjarmason, Feb 14, 2018
  3. Jonathan NiederFeb 14, 2018
  4. Ævar Arnfjörð BjarmasonFeb 25, 2018
  5. 2/8 perl: move CPAN loader wrappers to another namespaceÆvar Arnfjörð Bjarmason, Feb 14, 2018
  6. Jonathan NiederFeb 14, 2018
  7. 4/8 perl: update our ancient copy of Error.pmÆvar Arnfjörð Bjarmason, Feb 14, 2018
  8. Jonathan NiederFeb 14, 2018
  9. Ævar Arnfjörð BjarmasonFeb 15, 2018
  10. 3/8 perl: generalize the Git::LoadCPAN facilityÆvar Arnfjörð Bjarmason, Feb 14, 2018
  11. Jonathan NiederFeb 14, 2018
  12. Todd ZullingerFeb 15, 2018
  13. Ævar Arnfjörð BjarmasonFeb 25, 2018
  14. Randall S. BeckerFeb 25, 2018
  15. Todd ZullingerFeb 15, 2018
  16. Ævar Arnfjörð BjarmasonFeb 15, 2018
  17. Todd ZullingerFeb 15, 2018
  18. Ævar Arnfjörð BjarmasonFeb 16, 2018
  19. Todd ZullingerFeb 16, 2018
  20. Jonathan NiederFeb 16, 2018
  21. Todd ZullingerFeb 17, 2018
  22. Todd ZullingerFeb 17, 2018
  23. 6/8 git-send-email: unconditionally use Net::{SMTP,Domain}Ævar Arnfjörð Bjarmason, Feb 14, 2018
  24. Jonathan NiederFeb 14, 2018
  25. Ævar Arnfjörð BjarmasonFeb 15, 2018
  26. 7/8 gitweb: hard-depend on the Digest::MD5 5.8 moduleÆvar Arnfjörð Bjarmason, Feb 14, 2018
  27. Jonathan NiederFeb 14, 2018
  28. 5/8 perl: update our copy of Mail::AddressÆvar Arnfjörð Bjarmason, Feb 14, 2018
  29. Jonathan NiederFeb 14, 2018
  30. Matthieu MoyFeb 15, 2018
  31. Ævar Arnfjörð BjarmasonFeb 15, 2018
  32. 8/8 perl: hard-depend on the File::{Temp,Spec} modulesÆvar Arnfjörð Bjarmason, Feb 14, 2018
  33. Jonathan NiederFeb 14, 2018
  34. Ævar Arnfjörð BjarmasonFeb 15, 2018
  35. Junio C HamanoFeb 15, 2018
  36. 00/13 various perl fixesÆvar Arnfjörð Bjarmason, Feb 25, 2018
  37. 01/13 perl: *.pm files should not have the executable bitÆvar Arnfjörð Bjarmason, Feb 25, 2018
  38. 02/13 Git.pm: remove redundant "use strict" from sub-packageÆvar Arnfjörð Bjarmason, Feb 25, 2018
  39. 03/13 Git.pm: add the "use warnings" pragmaÆvar Arnfjörð Bjarmason, Feb 25, 2018
  40. 04/13 gitweb: hard-depend on the Digest::MD5 5.8 moduleÆvar Arnfjörð Bjarmason, Feb 25, 2018
  41. Eric SunshineFeb 25, 2018
  42. 05/13 Git.pm: hard-depend on the File::{Temp,Spec} modulesÆvar Arnfjörð Bjarmason, Feb 25, 2018
  43. 07/13 perl: update our ancient copy of Error.pmÆvar Arnfjörð Bjarmason, Feb 25, 2018
  44. 06/13 git-send-email: unconditionally use Net::{SMTP,Domain}Ævar Arnfjörð Bjarmason, Feb 25, 2018
  45. Eric SunshineFeb 25, 2018
  46. 09/13 perl: move CPAN loader wrappers to another namespaceÆvar Arnfjörð Bjarmason, Feb 25, 2018
  47. 08/13 perl: update our copy of Mail::AddressÆvar Arnfjörð Bjarmason, Feb 25, 2018
  48. 10/13 perl: generalize the Git::LoadCPAN facilityÆvar Arnfjörð Bjarmason, Feb 25, 2018
  49. 11/13 perl: move the perl/Git/FromCPAN tree to perl/FromCPANÆvar Arnfjörð Bjarmason, Feb 25, 2018
  50. 13/13 perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKSÆvar Arnfjörð Bjarmason, Feb 25, 2018
  51. 12/13 Makefile: add NO_PERL_CPAN_FALLBACKS knobÆvar Arnfjörð Bjarmason, Feb 25, 2018
  52. 00/13 various perl fixesÆvar Arnfjörð Bjarmason, Mar 3, 2018
  53. 01/13 perl: *.pm files should not have the executable bitÆvar Arnfjörð Bjarmason, Mar 3, 2018
  54. 02/13 Git.pm: remove redundant "use strict" from sub-packageÆvar Arnfjörð Bjarmason, Mar 3, 2018
  55. 04/13 gitweb: hard-depend on the Digest::MD5 5.8 moduleÆvar Arnfjörð Bjarmason, Mar 3, 2018
  56. 05/13 Git.pm: hard-depend on the File::{Temp,Spec} modulesÆvar Arnfjörð Bjarmason, Mar 3, 2018
  57. 03/13 Git.pm: add the "use warnings" pragmaÆvar Arnfjörð Bjarmason, Mar 3, 2018
  58. 06/13 git-send-email: unconditionally use Net::{SMTP,Domain}Ævar Arnfjörð Bjarmason, Mar 3, 2018
  59. 10/13 perl: generalize the Git::LoadCPAN facilityÆvar Arnfjörð Bjarmason, Mar 3, 2018
  60. 11/13 perl: move the perl/Git/FromCPAN tree to perl/FromCPANÆvar Arnfjörð Bjarmason, Mar 3, 2018
  61. 12/13 Makefile: add NO_PERL_CPAN_FALLBACKS knobÆvar Arnfjörð Bjarmason, Mar 3, 2018
  62. 13/13 perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKSÆvar Arnfjörð Bjarmason, Mar 3, 2018
  63. 08/13 perl: update our copy of Mail::AddressÆvar Arnfjörð Bjarmason, Mar 3, 2018
  64. 09/13 perl: move CPAN loader wrappers to another namespaceÆvar Arnfjörð Bjarmason, Mar 3, 2018
  65. 07/13 perl: update our ancient copy of Error.pmÆvar Arnfjörð Bjarmason, Mar 3, 2018
  66. Junio C HamanoMar 5, 2018

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.