Index: /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh
===================================================================
--- /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32478)
+++ /main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32479)
@@ -21,8 +21,8 @@
 # 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).
+# products (both the "auto" and package folder inside the lib folder) into cpan/perl-<version> ($PERL_FOLDER, e.g. "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
+# Compiling as well as RUNNING the final Crypt::LE's le.pl executable requires PERL5LIB to have both the cpan and its $PERL_FOLDER
 # subdirectory included in env var PERL5LIB.
 #
@@ -52,9 +52,12 @@
 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
+# PERL_FOLDER is something like "$PERL_FOLDER" (even if the full version number is 5.18.2)
+PERL_FOLDER=`perl -e 'print "perl-5.".substr($],3,2);'`
+
+# make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
+mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
 
 # dependencies are not found if PERL5LIB is simply set to cpan. PERL5LIB Needs to specifically be exported
-export PERL5LIB=$CPAN_DIR:$CPAN_DIR/perl-5.18:$PERL5LIB
+export PERL5LIB=$CPAN_DIR:$CPAN_DIR/$PERL_FOLDER:$PERL5LIB
 
 #echo "**** PERL5LIB is $PERL5LIB"
@@ -62,5 +65,9 @@
 
 WGET_FLAGS=--no-check-certificate
-TEMP_DIR=$CPAN_DIR/tmp
+# folder where we'll put the downloaded files, the compile products and the temporary install products
+# after everything is installed there, we copy just the relevant installed files to their final locations
+# then the tmp file gets deleted
+TEMP_DIR=$CPAN_DIR/tmp-crypt-le
+
 
 OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
@@ -69,5 +76,5 @@
 if [ "x$1" = "x--clean" ] ; then
     cd $CPAN_DIR
-    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
+    rm -rf $PERL_FOLDER/Crypt $PERL_FOLDER/Time $PERL_FOLDER/auto/Crypt $PERL_FOLDER/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
@@ -86,5 +93,5 @@
 
 # 1 https://metacpan.org/pod/Crypt::OpenSSL::Bignum
-if [ ! -d "$CPAN_DIR/perl-5.18/Crypt/OpenSSL/Bignum" ]; then
+if [ ! -d "$CPAN_DIR/$PERL_FOLDER/Crypt/OpenSSL/Bignum" ]; then
     CRYPT_OPENSSL_BIGNUM=Crypt-OpenSSL-Bignum
     CRYPT_OPENSSL_BIGNUM_VER=$CRYPT_OPENSSL_BIGNUM-0.09
@@ -99,6 +106,6 @@
     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/.
+    cp -r $TEMP_DIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt $CPAN_DIR/$PERL_FOLDER/.
+    cp -r $TEMP_DIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Crypt $CPAN_DIR/$PERL_FOLDER/auto/.
 
     C_INCLUDE_PATH=
@@ -220,5 +227,5 @@
 # 6 https://metacpan.org/pod/Time::Piece
 
-if [ ! -f "$CPAN_DIR/perl-5.18/Time/Piece.pm" ]; then
+if [ ! -f "$CPAN_DIR/$PERL_FOLDER/Time/Piece.pm" ]; then
     TIME_PIECE=Time-Piece
     TIME_PIECE_VER=$TIME_PIECE-1.33
@@ -233,6 +240,6 @@
 
     #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/.
+    cp -r $TEMP_DIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/$PERL_FOLDER
+    cp -r $TEMP_DIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Time $CPAN_DIR/$PERL_FOLDER/auto/.
 
     cd $TEMP_DIR
@@ -283,6 +290,8 @@
 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"
+# for this export line to work, would need to source ./compile-zerossl.sh
+#export PERL5LIB=$CPAN_DIR:$CPAN_DIR/$PERL_FOLDER:$PERL5LIB
+
+echo "Restored environment"
+echo "You can now run $CPAN_DIR/Crypt/LE/bin/le.pl after exporting PERL5LIB to contain both cpan and cpan/$PERL_FOLDER. Do:"
+echo "   export PERL5LIB=$CPAN_DIR:$CPAN_DIR/$PERL_FOLDER:$PERL5LIB"
