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

Revision 32462, 9.5 KB (checked in by ak19, 11 months ago)

File comments and renaming TMPDIR to TEMP_DIR, since the former is a C env var name also used when compiling perl.

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