root/main/trunk/greenstone2/perllib/cpan/compile-zerossl.sh @ 32461

Revision 32461, 7.9 KB (checked in by ak19, 8 months ago)

1. Changes to get le.pl to finally work: the bootstrap files of the dynamic/native packages Crypt::OpenSSL::Bignum and Time::Piece need to be in cpan/perl-5.18 and its auto subfolder (the .bs and .bundle files for mac need to be present in their correct locations). 2. The final step to get le.pl to work, pointed out by Dr Bainbridge, is to include not just cpan but also cpan/perl-5.18 in PERL5LIB

  • Property svn:executable set to *
Line 
1# A basic cascade-make to install the Crypt::LE perl package required for ZeroSSL, used to get an https certificate on Mac
2
3if [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
4    echo "Usage: $0 [--clean|--keep|--help|-h]"
5    echo "  Run without flags to compile and remove unnecessary stuff at the end."
6    echo "  Run with --keep to retain the cpan/tmp subdir at compilation's end."
7    echo "  Run with --clean to remove all traces of compilation completely so you can recompile from scratch"
8    echo "  Run with --help/-h to see this Usage statement again"
9    exit 0
10fi
11
12if [ "x$GSDL3SRCHOME" = "x" ] ; then
13    echo "GSDL3SRCHOME not set, sourcing gs3-setup.sh"
14    echo ""
15    cd ../../..
16    source ./gs3-setup.sh
17    cd $GSDLHOME/perllib/cpan
18fi
19
20echo ""
21echo "**************************"
22
23CPAN_DIR=$GSDLHOME/perllib/cpan
24OLD_PERL5LIB=$PERL5LIB
25
26# make the dirs cpan/perl-5.18 and its subdir auto if they don't already exist
27mkdir -p $CPAN_DIR/perl-5.18/auto
28
29# dependencies are not found if PERL5LIB is simply set to cpan. PERL5LIB Needs to specifically be exported
30export PERL5LIB=$CPAN_DIR:$CPAN_DIR/perl-5.18:$PERL5LIB
31
32#echo "**** PERL5LIB is $PERL5LIB"
33
34
35WGET_FLAGS=--no-check-certificate
36TMPDIR=$CPAN_DIR/tmp
37
38OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
39
40# if clean was passed in
41if [ "x$1" = "x--clean" ] ; then
42    cd $CPAN_DIR
43    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
44    mv JSON/PP.old JSON/PP
45    mv JSON/PP.pm_old JSON/PP.pm
46    rm -rf $TMPDIR
47    echo "Done cleaning Crypt::LE related packages"
48    exit 0
49fi
50
51mkdir -p $TMPDIR
52# We'll download, unpack and compile (Makefile.PL, make and make install) packages into TMPDIR
53# before copying the necessary components to their final locations
54cd $TMPDIR
55
56
57# First run through the dependencies and then finally Crypt::LE itself
58
59# 1 https://metacpan.org/pod/Crypt::OpenSSL::Bignum
60if [ ! -d "$CPAN_DIR/perl-5.18/Crypt/OpenSSL/Bignum" ]; then
61    CRYPT_OPENSSL_BIGNUM=Crypt-OpenSSL-Bignum
62    CRYPT_OPENSSL_BIGNUM_VER=$CRYPT_OPENSSL_BIGNUM-0.09
63    echo "+ Installing $CRYPT_OPENSSL_BIGNUM"
64    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/K/KM/KMX/$CRYPT_OPENSSL_BIGNUM_VER.tar.gz
65    tar -xvzf $CRYPT_OPENSSL_BIGNUM_VER.tar.gz
66   
67    export C_INCLUDE_PATH=$GSDL3SRCHOME/bin/darwin/openssl/include
68    cd $CRYPT_OPENSSL_BIGNUM_VER
69    perl Makefile.PL PREFIX=$TMPDIR/$CRYPT_OPENSSL_BIGNUM
70    make
71    make install
72    #cp -r $TMPDIR/$CRYPT_OPENSSL_BIGNUM/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt/OpenSSL $CPAN_DIR/Crypt/.
73    cp -r $TMPDIR/Crypt-OpenSSL-Bignum/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Crypt $CPAN_DIR/perl-5.18/.
74    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/.
75
76    C_INCLUDE_PATH=
77    cd $TMPDIR
78else
79    echo "*** $CPAN_DIR/Crypt/OpenSSL/Bignum already exists, not installing"
80fi
81
82
83# 2a https://metacpan.org/pod/JSON::PP
84# which is the minimum dependency for JSON::MaybeXS
85
86if [ ! -f "$CPAN_DIR/JSON/PP.pm_old" ]; then
87    mv $CPAN_DIR/JSON/PP $CPAN_DIR/JSON/PP.old
88    mv $CPAN_DIR/JSON/PP.pm $CPAN_DIR/JSON/PP.pm_old
89
90    JSON_PP=JSON-PP
91    JSON_PP_VER=$JSON_PP-2.97001
92    echo "+ Installing $JSON_PP"
93    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/$JSON_PP_VER.tar.gz
94    tar -xvzf $JSON_PP_VER.tar.gz
95
96    cd $JSON_PP_VER
97    perl Makefile.PL PREFIX=$TMPDIR/$JSON_PP
98    make
99    make install
100    cp -r $TMPDIR/$JSON_PP/lib/perl5/site_perl/JSON/* JSON $CPAN_DIR/JSON/.
101
102    cd $TMPDIR
103else
104    echo "*** The new $CPAN_DIR/JSON/PP.pm already exists, not installing"
105fi
106
107
108# 2 https://metacpan.org/pod/JSON::MaybeXS
109
110if [ ! -f "$CPAN_DIR/JSON/MaybeXS.pm" ]; then
111    JSON_MAYBEXS=JSON-MaybeXS
112    JSON_MAYBEXS_VER=$JSON_MAYBEXS-1.004000
113    echo "+ Installing $JSON_MAYBEXS"
114    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/H/HA/HAARG/$JSON_MAYBEXS_VER.tar.gz
115    tar -xvzf $JSON_MAYBEXS_VER.tar.gz
116
117    cd $JSON_MAYBEXS_VER
118    perl Makefile.PL PREFIX=$TMPDIR/$JSON_MAYBEXS
119    make
120    make install
121    cp $TMPDIR/$JSON_MAYBEXS/lib/perl5/site_perl/JSON/MaybeXS.pm $CPAN_DIR/JSON/.
122
123    cd $TMPDIR
124else
125    echo "*** $CPAN_DIR/JSON/MaybeXS.pm already exists, not installing"
126fi
127
128
129# 3 https://metacpan.org/pod/Log::Log4perl
130
131if [ ! -d "$CPAN_DIR/Log/Log4perl" ]; then
132    LOG4PERL=Log-Log4perl
133    LOG4PERL_VER=$LOG4PERL-1.49
134    echo "+ Installing $LOG4PERL"
135    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/M/MS/MSCHILLI/$LOG4PERL_VER.tar.gz
136    tar -xvzf $LOG4PERL_VER.tar.gz
137
138    cd $LOG4PERL_VER
139    perl Makefile.PL PREFIX=$TMPDIR/$LOG4PERL
140    make
141    make install
142    cp -r $TMPDIR/$LOG4PERL/lib/perl5/site_perl/Log $CPAN_DIR/.
143
144    cd $TMPDIR
145else
146    echo "*** $CPAN_DIR/Log/Log4Perl already exists, not installing"
147fi
148
149# 4 https://metacpan.org/pod/HTTP::Tiny
150
151if [ ! -f "$CPAN_DIR/HTTP/Tiny.pm" ]; then
152    HTTP_TINY=HTTP-Tiny
153    HTTP_TINY_VER=$HTTP_TINY-0.076
154    echo "+ Installing $HTTP_TINY"
155    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/$HTTP_TINY_VER.tar.gz
156    tar -xvzf $HTTP_TINY_VER.tar.gz
157
158    cd $HTTP_TINY_VER
159    perl Makefile.PL PREFIX=$TMPDIR/$HTTP_TINY
160    make
161    make install
162
163    cp -r $TMPDIR/$HTTP_TINY/lib/perl5/site_perl/HTTP/* $CPAN_DIR/HTTP/.
164
165    cd $TMPDIR
166else
167    echo "*** $CPAN_DIR/$HTTP_TINY already exists, not installing"
168fi
169
170
171# 5 https://metacpan.org/pod/Module::Load
172
173if [ ! -d "$CPAN_DIR/Module" ]; then
174    MODULE_LOAD=Module-Load
175    MODULE_LOAD_VER=$MODULE_LOAD-0.32
176    echo "+ Installing $MODULE_LOAD"
177    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/B/BI/BINGOS/$MODULE_LOAD_VER.tar.gz
178    tar -xvzf $MODULE_LOAD_VER.tar.gz
179
180    cd $MODULE_LOAD_VER
181    perl Makefile.PL PREFIX=$TMPDIR/$MODULE_LOAD
182    make
183    make install
184    cp -r $TMPDIR/$MODULE_LOAD/lib/perl5/site_perl/Module $CPAN_DIR/.
185
186    cd $TMPDIR
187else
188    echo "*** $CPAN_DIR/$MODULE_LOAD already exists, not installing"
189fi
190
191
192# 6 https://metacpan.org/pod/Time::Piece
193
194if [ ! -f "$CPAN_DIR/perl-5.18/Time/Piece.pm" ]; then
195    TIME_PIECE=Time-Piece
196    TIME_PIECE_VER=$TIME_PIECE-1.33
197    echo "+ Installing $TIME_PIECE"
198    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/E/ES/ESAYM/$TIME_PIECE_VER.tar.gz
199    tar -xvzf $TIME_PIECE_VER.tar.gz
200
201    cd $TIME_PIECE_VER
202    perl Makefile.PL PREFIX=$TMPDIR/$TIME_PIECE
203    make
204    make install
205
206    #cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/.
207    cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/Time $CPAN_DIR/perl-5.18
208    cp -r $TMPDIR/$TIME_PIECE/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/Time $CPAN_DIR/perl-5.18/auto/.
209
210    cd $TMPDIR
211else
212    echo "*** $CPAN_DIR/$TIME_PIECE already exists, not installing"
213fi
214
215
216
217# FINALLY, compile up Crypt::LE
218# https://metacpan.org/pod/Crypt::LE
219
220if [ ! -d "$CPAN_DIR/Crypt/LE" ]; then
221    CRYPT_LE=Crypt-LE
222    CRYPT_LE_VER=$CRYPT_LE-0.31
223    echo "+ FINALLY, Installing $CRYPT_LE"
224    wget $WGET_FLAGS https://cpan.metacpan.org/authors/id/L/LE/LEADER/$CRYPT_LE_VER.tar.gz
225    tar -xvzf $CRYPT_LE_VER.tar.gz
226
227    cd $CRYPT_LE_VER
228    perl Makefile.PL PREFIX=$TMPDIR/$CRYPT_LE
229    make
230    make install
231
232    cp -r $TMPDIR/$CRYPT_LE/lib/perl5/site_perl/Crypt/* $CPAN_DIR/Crypt/.
233    # the most important step: we need the le.pl binary
234    cp -r $TMPDIR/$CRYPT_LE/bin $CPAN_DIR/Crypt/LE/.
235
236    cd $CPAN_DIR
237else
238    echo "*** $CPAN_DIR/$CRYPT_LE already exists, not installing"
239fi
240
241
242# DONE
243
244echo "*****************************"
245echo "*** Done compiling Crypt::LE."
246if [ "x$1" != "x--keep" ] ; then
247    echo "    Will now delete tmp subdir"
248    rm -rf tmp
249else
250    echo "   Not deleting the $TMPDIR"
251fi
252
253# restore env vars
254C_INCLUDE_PATH=$OLD_C_INCLUDE_PATH
255PERL5LIB=$OLD_PERL5LIB
256
257export PERL5LIB=$CPAN_DIR:$CPAN_DIR/perl-5.18:$PERL5LIB
258
259echo "Restored environment and updated PERL5LIB to $PERL5LIB necessary to run Crypt::LE."
260echo "You can now run $CPAN_DIR/Crypt/LE/bin/le.pl"
Note: See TracBrowser for help on using the browser.