Index: /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh
===================================================================
--- /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32461)
+++ /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32462)
@@ -1,3 +1,31 @@
-# A basic cascade-make to install the Crypt::LE perl package required for ZeroSSL, used to get an https certificate on Mac
+###################################################
+# A basic cascade-make to install the Crypt::LE perl package required for ZeroSSL, to be used to get an https certificate on Mac
+#
+# Crypt::LE depends on the following packages:
+# - Crypt::OpenSSL::Bignum, which needs openssl/err.h
+#   for which we need to set C_INCLUDE_PATH=$GSDL3SRCHOME/bin/darwin/openssl/include
+#   see https://www.perlmonks.org/?node_id=1181472
+#      "If includes arent in default compiler findable directories, let the user add any extra directories, like he is supposed to
+#       http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html like C_INCLUDE_PATH/LIBRARY_PATH... "
+# - JSON::MaybeXS, which depends on
+#     - JSON::PP
+# - Time::Piece
+# - HTTP::Tiny
+# - Module::Load
+# - Log::Log4perl
+#
+#
+# Compiling AND INSTALLING of all packages takes place in the temporary cpan/tmp folder. A select subset of the compiled/installed
+# products are then copied into their final destinations:
+# - For regular packages, need to put the relevant products (the package folder inside the lib folder) into cpan, maintaining any
+# existing folder structure.
+# - However, for all packages that contain .bundle (mac, or .so for linux) and .xs or .bs bootstrap files, need to put the relevant
+# products (both the "auto" and package folder inside the lib folder) into cpan/perl-<version> (perl-5.18).
+# In this case, both Crypt::OpenSSL and Time::Piece once compiled up require this second treatment.
+#
+# Compiling as well as RUNNING the final Crypt::LE's le.pl executable requires PERL5LIB to have both the cpan and its perl-5.18
+# subdirectory included in env var PERL5LIB.
+#
+###################################################
 
 if [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
@@ -34,5 +62,5 @@
 
 WGET_FLAGS=--no-check-certificate
-TMPDIR=$CPAN_DIR/tmp
+TEMP_DIR=$CPAN_DIR/tmp
 
 OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
@@ -44,13 +72,13 @@
     mv JSON/PP.old JSON/PP
     mv JSON/PP.pm_old JSON/PP.pm
-    rm -rf $TMPDIR
+    rm -rf $TEMP_DIR
     echo "Done cleaning Crypt::LE related packages"
     exit 0
 fi
 
-mkdir -p $TMPDIR
-# We'll download, unpack and compile (Makefile.PL, make and make install) packages into TMPDIR
+mkdir -p $TEMP_DIR
+# We'll download, unpack and compile (Makefile.PL, make and make install) packages into TEMP_DIR
 # before copying the necessary components to their final locations
-cd $TMPDIR
+cd $TEMP_DIR
 
 
@@ -67,13 +95,13 @@
     export C_INCLUDE_PATH=$GSDL3SRCHOME/bin/darwin/openssl/include
     cd $CRYPT_OPENSSL_BIGNUM_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$CRYPT_OPENSSL_BIGNUM
-    make
-    make install
-    #cp -r $TMPDIR/$CRYPT_OPENSSL_BIGNUM/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt/OpenSSL $CPAN_DIR/Crypt/.
-    cp -r $TMPDIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt $CPAN_DIR/perl-5.18/.
-    cp -r $TMPDIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Crypt $CPAN_DIR/perl-5.18/auto/.
+    perl Makefile.PL PREFIX=$TEMP_DIR/$CRYPT_OPENSSL_BIGNUM
+    make
+    make install
+    #cp -r $TEMP_DIR/$CRYPT_OPENSSL_BIGNUM/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt/OpenSSL $CPAN_DIR/Crypt/.
+    cp -r $TEMP_DIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt $CPAN_DIR/perl-5.18/.
+    cp -r $TEMP_DIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Crypt $CPAN_DIR/perl-5.18/auto/.
 
     C_INCLUDE_PATH=
-    cd $TMPDIR
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/Crypt/OpenSSL/Bignum already exists, not installing"
@@ -95,10 +123,10 @@
 
     cd $JSON_PP_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$JSON_PP
-    make
-    make install
-    cp -r $TMPDIR/$JSON_PP/lib/perl5/site_perl/JSON/* JSON $CPAN_DIR/JSON/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$JSON_PP
+    make
+    make install
+    cp -r $TEMP_DIR/$JSON_PP/lib/perl5/site_perl/JSON/* JSON $CPAN_DIR/JSON/.
+
+    cd $TEMP_DIR
 else
     echo "*** The new $CPAN_DIR/JSON/PP.pm already exists, not installing"
@@ -116,10 +144,10 @@
 
     cd $JSON_MAYBEXS_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$JSON_MAYBEXS
-    make
-    make install
-    cp $TMPDIR/$JSON_MAYBEXS/lib/perl5/site_perl/JSON/MaybeXS.pm $CPAN_DIR/JSON/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$JSON_MAYBEXS
+    make
+    make install
+    cp $TEMP_DIR/$JSON_MAYBEXS/lib/perl5/site_perl/JSON/MaybeXS.pm $CPAN_DIR/JSON/.
+
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/JSON/MaybeXS.pm already exists, not installing"
@@ -137,10 +165,10 @@
 
     cd $LOG4PERL_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$LOG4PERL
-    make
-    make install
-    cp -r $TMPDIR/$LOG4PERL/lib/perl5/site_perl/Log $CPAN_DIR/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$LOG4PERL
+    make
+    make install
+    cp -r $TEMP_DIR/$LOG4PERL/lib/perl5/site_perl/Log $CPAN_DIR/.
+
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/Log/Log4Perl already exists, not installing"
@@ -157,11 +185,11 @@
 
     cd $HTTP_TINY_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$HTTP_TINY
-    make
-    make install
-
-    cp -r $TMPDIR/$HTTP_TINY/lib/perl5/site_perl/HTTP/* $CPAN_DIR/HTTP/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$HTTP_TINY
+    make
+    make install
+
+    cp -r $TEMP_DIR/$HTTP_TINY/lib/perl5/site_perl/HTTP/* $CPAN_DIR/HTTP/.
+
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/$HTTP_TINY already exists, not installing"
@@ -179,10 +207,10 @@
 
     cd $MODULE_LOAD_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$MODULE_LOAD
-    make
-    make install
-    cp -r $TMPDIR/$MODULE_LOAD/lib/perl5/site_perl/Module $CPAN_DIR/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$MODULE_LOAD
+    make
+    make install
+    cp -r $TEMP_DIR/$MODULE_LOAD/lib/perl5/site_perl/Module $CPAN_DIR/.
+
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/$MODULE_LOAD already exists, not installing"
@@ -200,13 +228,13 @@
 
     cd $TIME_PIECE_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$TIME_PIECE
-    make
-    make install
-
-    #cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/.
-    cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/perl-5.18
-    cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Time $CPAN_DIR/perl-5.18/auto/.
-
-    cd $TMPDIR
+    perl Makefile.PL PREFIX=$TEMP_DIR/$TIME_PIECE
+    make
+    make install
+
+    #cp -r $TEMP_DIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/.
+    cp -r $TEMP_DIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/perl-5.18
+    cp -r $TEMP_DIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Time $CPAN_DIR/perl-5.18/auto/.
+
+    cd $TEMP_DIR
 else
     echo "*** $CPAN_DIR/$TIME_PIECE already exists, not installing"
@@ -226,11 +254,11 @@
 
     cd $CRYPT_LE_VER
-    perl Makefile.PL PREFIX=$TMPDIR/$CRYPT_LE
-    make
-    make install
-
-    cp -r $TMPDIR/$CRYPT_LE/lib/perl5/site_perl/Crypt/* $CPAN_DIR/Crypt/.
+    perl Makefile.PL PREFIX=$TEMP_DIR/$CRYPT_LE
+    make
+    make install
+
+    cp -r $TEMP_DIR/$CRYPT_LE/lib/perl5/site_perl/Crypt/* $CPAN_DIR/Crypt/.
     # the most important step: we need the le.pl binary
-    cp -r $TMPDIR/$CRYPT_LE/bin $CPAN_DIR/Crypt/LE/.
+    cp -r $TEMP_DIR/$CRYPT_LE/bin $CPAN_DIR/Crypt/LE/.
 
     cd $CPAN_DIR
@@ -248,5 +276,5 @@
     rm -rf tmp
 else
-    echo "   Not deleting the $TMPDIR"
+    echo "   Not deleting the $TEMP_DIR"
 fi
 
