Index: /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh
===================================================================
--- /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32460)
+++ /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32461)
@@ -1,3 +1,12 @@
 # A basic cascade-make to install the Crypt::LE perl package required for ZeroSSL, used to get an https certificate on Mac
+
+if [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
+    echo "Usage: $0 [--clean|--keep|--help|-h]"
+    echo "  Run without flags to compile and remove unnecessary stuff at the end."
+    echo "  Run with --keep to retain the cpan/tmp subdir at compilation's end." 
+    echo "  Run with --clean to remove all traces of compilation completely so you can recompile from scratch"
+    echo "  Run with --help/-h to see this Usage statement again"
+    exit 0
+fi
 
 if [ "x$GSDL3SRCHOME" = "x" ] ; then
@@ -9,10 +18,17 @@
 fi
 
+echo ""
+echo "**************************"
+
 CPAN_DIR=$GSDLHOME/perllib/cpan
 OLD_PERL5LIB=$PERL5LIB
+
+# make the dirs cpan/perl-5.18 and its subdir auto if they don't already exist
+mkdir -p $CPAN_DIR/perl-5.18/auto
+
 # dependencies are not found if PERL5LIB is simply set to cpan. PERL5LIB Needs to specifically be exported
-export PERL5LIB=$CPAN_DIR
-
-echo "**** PERL5LIB is $PERL5LIB"
+export PERL5LIB=$CPAN_DIR:$CPAN_DIR/perl-5.18:$PERL5LIB
+
+#echo "**** PERL5LIB is $PERL5LIB"
 
 
@@ -23,22 +39,17 @@
 
 # if clean was passed in
-if [ "x$1" = "xclean" ] ; then
+if [ "x$1" = "x--clean" ] ; then
     cd $CPAN_DIR
-    rm -rf Crypt/OpenSSL Log JSON/MaybeXS.pm Log Time Module JSON/PP.pm JSON/PP Crypt/LE Crypt/LE.pm
+    rm -rf perl-5.18/Crypt perl-5.18/Time perl-5.18/auto/Crypt perl-5.18/auto/Time Log JSON/MaybeXS.pm Log Module JSON/PP.pm JSON/PP Crypt/LE Crypt/LE.pm
     mv JSON/PP.old JSON/PP
     mv JSON/PP.pm_old JSON/PP.pm
     rm -rf $TMPDIR
-    echo "Done cleaning"
+    echo "Done cleaning Crypt::LE related packages"
     exit 0
 fi
 
-
-
 mkdir -p $TMPDIR
-
-
-
-
-# We'll download, unpack and compile stuff into TMPDIR
+# We'll download, unpack and compile (Makefile.PL, make and make install) packages into TMPDIR
+# before copying the necessary components to their final locations
 cd $TMPDIR
 
@@ -47,5 +58,5 @@
 
 # 1 https://metacpan.org/pod/Crypt::OpenSSL::Bignum
-if [ ! -d "$CPAN_DIR/Crypt/OpenSSL/Bignum" ]; then
+if [ ! -d "$CPAN_DIR/perl-5.18/Crypt/OpenSSL/Bignum" ]; then
     CRYPT_OPENSSL_BIGNUM=Crypt-OpenSSL-Bignum
     CRYPT_OPENSSL_BIGNUM_VER=$CRYPT_OPENSSL_BIGNUM-0.09
@@ -59,6 +70,8 @@
     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/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/.
+
     C_INCLUDE_PATH=
     cd $TMPDIR
@@ -179,5 +192,5 @@
 # 6 https://metacpan.org/pod/Time::Piece
 
-if [ ! -f "$CPAN_DIR/Time/Piece.pm" ]; then
+if [ ! -f "$CPAN_DIR/perl-5.18/Time/Piece.pm" ]; then
     TIME_PIECE=Time-Piece
     TIME_PIECE_VER=$TIME_PIECE-1.33
@@ -191,5 +204,7 @@
     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/.
+    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
@@ -226,5 +241,20 @@
 
 # DONE
+
+echo "*****************************"
+echo "*** Done compiling Crypt::LE."
+if [ "x$1" != "x--keep" ] ; then
+    echo "    Will now delete tmp subdir"
+    rm -rf tmp
+else
+    echo "   Not deleting the $TMPDIR"
+fi
+
 # restore env vars
 C_INCLUDE_PATH=$OLD_C_INCLUDE_PATH
 PERL5LIB=$OLD_PERL5LIB
+
+export PERL5LIB=$CPAN_DIR:$CPAN_DIR/perl-5.18:$PERL5LIB
+
+echo "Restored environment and updated PERL5LIB to $PERL5LIB necessary to run Crypt::LE."
+echo "You can now run $CPAN_DIR/Crypt/LE/bin/le.pl"
