Importing Mail::SpamAssassin into Baserock

This guide demonstrates the use of the cpan importer's module injection feature, which allows imports of locally modified sources. We use the import tool to attempt an import of Mail::SpamAssassin, which at the time of writing fails due to a bug in its Makefile.PL. We fix the bug locally and import the module from our fixed source.

/src/import# baserock-import cpan Mail::SpamAssassin --log=importlog

Distribution `Mail-SpamAssassin' provides module `Mail::SpamAssassin', importing `Mail-SpamAssassin-master'...

08/24/15 07:46:56 UTC: Import of cpan Mail-SpamAssassin started
Not updating existing Git checkouts or existing definitions
Mail-SpamAssassin: calling cpan.to_lorry to generate lorry
Lorrying https://cpan.metacpan.org/authors/id/K/KM/KMCGRAIL/SpamAssassin/Mail-SpamAssassin-3.4.1.tar.gz
Mail-SpamAssassin master: using checkouts/cpan_Mail-SpamAssassin-tarball ref master (commit 93853b29e538c00335017b6cb16bec3f057f4e19)
Mail-SpamAssassin master: calling cpan.find_deps to calculate dependencies
cpan.find_deps failed with code 255: perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
carton exited with error: 2 at /src/import/baserockimport/exts/cpan.find_deps line 66.

Errors encountered, not generating a stratum morphology.
See the README files for guidance.
08/24/15 07:47:04 UTC: Import of cpan Mail-SpamAssassin ended (took 7 seconds)
Errors encountered during import
        Mail-SpamAssassin-master

The initial import fails, an examination of Mail::SpamAssassin's Makefile.PL shows that the Makefile.PL will exit early if it finds it has missing dependencies. Because the Makefile.PL exits early it doesn't generate the metadata the import tool uses to obtain the module's dependencies.

Note: if your import in fact succeeded then you already have some of this module's dependencies installed.

For the purposes of the import we can fix the Makefile.PL by commenting out the line that causes it to exit early.

/src/import# cd checkouts/cpan_Mail-SpamAssassin-tarball/
/src/import/checkouts/cpan_Mail-SpamAssassin-tarball# sed -i 's/exit 0/#&/' Makefile.PL
/src/import/checkouts/cpan_Mail-SpamAssassin-tarball# git diff
diff --git a/Makefile.PL b/Makefile.PL
index 33ca2af..e5c31c6 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -311,7 +311,7 @@ if (Mail::SpamAssassin::Util::DependencyInfo::long_diagnostics() != 0) {
# missing required module?  die!
# bug 5908: http://cpantest.grango.org/wiki/CPANAuthorNotes says
# we should exit with a status of 0, but without creating Makefile
-  exit 0;
+  #exit 0;
}

foreach my $file (@FILES_THAT_MUST_EXIST) {

Commit the change,

/src/import/checkouts/cpan_Mail-SpamAssassin-tarball# git commit -a -m "don't exit early"

Rerun the import, the import tool will inject our local copy of Mail::SpamAssassin into a local minicpan repository, when the import tool searches for a module it first searches the minicpan repository, if the module cannot be found in the minicpan repository then the tool will search CPAN.

/src/import# baserock-import cpan Mail::SpamAssassin --log=importlog

Distribution `Mail-SpamAssassin' provides module `Mail::SpamAssassin', importing `Mail-SpamAssassin-master'...

08/24/15 08:11:51 UTC: Import of cpan Mail-SpamAssassin started
Not updating existing Git checkouts or existing definitions
Mail-SpamAssassin: calling cpan.to_lorry to generate lorry
Lorrying https://cpan.metacpan.org/authors/id/K/KM/KMCGRAIL/SpamAssassin/Mail-SpamAssassin-3.4.1.tar.gz
Mail-SpamAssassin master: using checkouts/cpan_Mail-SpamAssassin-tarball ref master (commit 286d435e5fd70a6338fe91c2bb939c88585d5efc)
Mail-SpamAssassin master: calling cpan.find_deps to calculate dependencies
Digest-HMAC: calling cpan.to_lorry to generate lorry
Lorrying http://cpan.metacpan.org/authors/id/G/GA/GAAS/Digest-HMAC-1.03.tar.gz
Digest-HMAC 1.03: using checkouts/cpan_Digest-HMAC-tarball ref Digest-HMAC-1.03 (commit 0dea3d4b861713341920248fee3fdd8d3886e5fd)
Digest-HMAC 1.03: calling cpan.find_deps to calculate dependencies
...
Generating stratum morph for Mail-SpamAssassin
08/24/15 08:13:17 UTC: Import of cpan Mail-SpamAssassin ended (took 85 seconds)