Index: main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh
===================================================================
--- main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32456)
+++ main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh	(revision 32456)
@@ -0,0 +1,230 @@
+# A basic cascade-make to install the Crypt::LE perl package required for ZeroSSL, used to get an https certificate on Mac
+
+if [ "x$GSDL3SRCHOME" = "x" ] ; then
+    echo "GSDL3SRCHOME not set, sourcing gs3-setup.sh"
+    echo ""
+    cd ../../..
+    source ./gs3-setup.sh
+    cd $GSDLHOME/perllib/cpan
+fi
+
+CPAN_DIR=$GSDLHOME/perllib/cpan
+OLD_PERL5LIB=$PERL5LIB
+# 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"
+
+
+WGET_FLAGS=--no-check-certificate
+TMPDIR=$CPAN_DIR/tmp
+
+OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
+
+# if clean was passed in
+if [ "x$1" = "xclean" ] ; 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
+    mv JSON/PP.old JSON/PP
+    mv JSON/PP.pm_old JSON/PP.pm
+    rm -rf $TMPDIR
+    echo "Done cleaning"
+    exit 0
+fi
+
+
+
+mkdir -p $TMPDIR
+
+
+
+
+# We'll download, unpack and compile stuff into TMPDIR
+cd $TMPDIR
+
+
+# First run through the dependencies and then finally Crypt::LE itself
+
+# 1 https://metacpan.org/pod/Crypt::OpenSSL::Bignum
+if [ ! -d "$CPAN_DIR/Crypt/OpenSSL/Bignum" ]; then
+    CRYPT_OPENSSL_BIGNUM=Crypt-OpenSSL-Bignum
+    CRYPT_OPENSSL_BIGNUM_VER=$CRYPT_OPENSSL_BIGNUM-0.09
+    echo "+ Installing $CRYPT_OPENSSL_BIGNUM"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/K/KM/KMX/$CRYPT_OPENSSL_BIGNUM_VER.tar.gz
+    tar -xvzf $CRYPT_OPENSSL_BIGNUM_VER.tar.gz
+    
+    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/.
+    
+    C_INCLUDE_PATH=
+    cd $TMPDIR
+else
+    echo "*** $CPAN_DIR/Crypt/OpenSSL/Bignum already exists, not installing"
+fi
+
+
+# 2a https://metacpan.org/pod/JSON::PP
+# which is the minimum dependency for JSON::MaybeXS
+
+if [ ! -f "$CPAN_DIR/JSON/PP.pm_old" ]; then
+    mv $CPAN_DIR/JSON/PP $CPAN_DIR/JSON/PP.old
+    mv $CPAN_DIR/JSON/PP.pm $CPAN_DIR/JSON/PP.pm_old
+
+    JSON_PP=JSON-PP
+    JSON_PP_VER=$JSON_PP-2.97001
+    echo "+ Installing $JSON_PP"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/$JSON_PP_VER.tar.gz
+    tar -xvzf $JSON_PP_VER.tar.gz
+
+    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
+else
+    echo "*** The new $CPAN_DIR/JSON/PP.pm already exists, not installing"
+fi
+
+
+# 2 https://metacpan.org/pod/JSON::MaybeXS
+
+if [ ! -f "$CPAN_DIR/JSON/MaybeXS.pm" ]; then
+    JSON_MAYBEXS=JSON-MaybeXS
+    JSON_MAYBEXS_VER=$JSON_MAYBEXS-1.004000
+    echo "+ Installing $JSON_MAYBEXS"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/H/HA/HAARG/$JSON_MAYBEXS_VER.tar.gz
+    tar -xvzf $JSON_MAYBEXS_VER.tar.gz
+
+    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
+else
+    echo "*** $CPAN_DIR/JSON/MaybeXS.pm already exists, not installing"
+fi
+
+
+# 3 https://metacpan.org/pod/Log::Log4perl
+
+if [ ! -d "$CPAN_DIR/Log/Log4perl" ]; then
+    LOG4PERL=Log-Log4perl
+    LOG4PERL_VER=$LOG4PERL-1.49
+    echo "+ Installing $LOG4PERL"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/M/MS/MSCHILLI/$LOG4PERL_VER.tar.gz
+    tar -xvzf $LOG4PERL_VER.tar.gz
+
+    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
+else
+    echo "*** $CPAN_DIR/Log/Log4Perl already exists, not installing"
+fi
+
+# 4 https://metacpan.org/pod/HTTP::Tiny
+
+if [ ! -f "$CPAN_DIR/HTTP/Tiny.pm" ]; then
+    HTTP_TINY=HTTP-Tiny
+    HTTP_TINY_VER=$HTTP_TINY-0.076
+    echo "+ Installing $HTTP_TINY"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/$HTTP_TINY_VER.tar.gz
+    tar -xvzf $HTTP_TINY_VER.tar.gz
+
+    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
+else
+    echo "*** $CPAN_DIR/$HTTP_TINY already exists, not installing"
+fi
+
+
+# 5 https://metacpan.org/pod/Module::Load
+
+if [ ! -d "$CPAN_DIR/Module" ]; then
+    MODULE_LOAD=Module-Load
+    MODULE_LOAD_VER=$MODULE_LOAD-0.32
+    echo "+ Installing $MODULE_LOAD"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/B/BI/BINGOS/$MODULE_LOAD_VER.tar.gz
+    tar -xvzf $MODULE_LOAD_VER.tar.gz
+
+    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
+else
+    echo "*** $CPAN_DIR/$MODULE_LOAD already exists, not installing"
+fi
+
+
+# 6 https://metacpan.org/pod/Time::Piece
+
+if [ ! -f "$CPAN_DIR/Time/Piece.pm" ]; then
+    TIME_PIECE=Time-Piece
+    TIME_PIECE_VER=$TIME_PIECE-1.33
+    echo "+ Installing $TIME_PIECE"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/E/ES/ESAYM/$TIME_PIECE_VER.tar.gz
+    tar -xvzf $TIME_PIECE_VER.tar.gz
+
+    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/.
+
+    cd $TMPDIR
+else
+    echo "*** $CPAN_DIR/$TIME_PIECE already exists, not installing"
+fi
+
+
+
+# FINALLY, compile up Crypt::LE
+# https://metacpan.org/pod/Crypt::LE
+
+if [ ! -d "$CPAN_DIR/Crypt/LE" ]; then
+    CRYPT_LE=Crypt-LE
+    CRYPT_LE_VER=$CRYPT_LE-0.31
+    echo "+ FINALLY, Installing $CRYPT_LE"
+    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/L/LE/LEADER/$CRYPT_LE_VER.tar.gz
+    tar -xvzf $CRYPT_LE_VER.tar.gz
+
+    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/.
+    # the most important step: we need the le.pl binary
+    cp -r $TMPDIR/$CRYPT_LE/bin $CPAN_DIR/Crypt/LE/.
+
+    cd $CPAN_DIR
+else
+    echo "*** $CPAN_DIR/$CRYPT_LE already exists, not installing"
+fi
+
+
+# DONE
+# restore env vars
+C_INCLUDE_PATH=$OLD_C_INCLUDE_PATH
+PERL5LIB=$OLD_PERL5LIB
