As you can not use git URL in your cpanfile
, you can use Distroprefs to patch a package during installation. I do not know if this works with cpanm, cpm or any package manager other than cpan.
You can pass your own diff (git format-patch
is your friend for that) and tell to patch a specific version (the next version should be fixed, no need to try to patch it).
I use it to patch Module::Manifest::Skip which have two bugs fixed in GitHub during a docker image creation to test some code on CI.
CPAN will need the YAML package.
I add a pref into cpandir (~/.cpan/prefs
)
---
match:
distribution: 'INGY/Module-Manifest-Skip-0.23.tar.gz'
depends:
configure_requires:
File::ShareDir: 1.114
patches:
- 'FOOBAR/Module-Manifest-Skip-0.23.patch'
And the patch in CPAN sources (~/.cpan/sources/authors/id/F/FO/FOOBAR
)
diff --git a/lib/Module/Manifest/Skip.pm b/lib/Module/Manifest/Skip.pm
index 434f7ce..27c1ac7 100644
--- a/lib/Module/Manifest/Skip.pm
+++ b/lib/Module/Manifest/Skip.pm
@@ -28,9 +28,6 @@ sub import {
close MS;
exit;
}
- else {
- goto &Moo::import;
- }
}
sub add {
With that CPAN will be able to patch the package on the fly. You can see it during install, it will tell us
# cpan Module::Manifest::Skip
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
Database was generated on Wed, 30 Mar 2022 04:55:39 GMT
Running install for module 'Module::Manifest::Skip'
______________________ D i s t r o P r e f s ______________________
Module-Manifest-Skip.yml[0]
Checksum for /root/.cpan/sources/authors/id/I/IN/INGY/Module-Manifest-Skip-0.23.tar.gz ok
Applying 1 patch:
/root/.cpan/sources/authors/id/F/FO/FOOBAR/Module-Manifest-Skip-0.23.patch
/usr/bin/patch -N -p1
patching file lib/Module/Manifest/Skip.pm
Configuring I/IN/INGY/Module-Manifest-Skip-0.23.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
# ...