forked from hepcat72/CFF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.tcsh
executable file
·535 lines (449 loc) · 15 KB
/
install.tcsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
#!/bin/tcsh
#CFF easy-install script
#install.tcsh
#Version: 2.0
#See README for advanced install instructions
#USAGE 1: install.tcsh <USEARCH>
#USAGE 2: install.tcsh <USEARCH> <MUSCLE>
#
# Where "<USEARCH>" and "<MUSCLE>" can be:
# 1. A download URL of a gzipped tarball or executable
# 2. A tarball or executable
# 3. "skip" or "ignore"
#
#Examples:
# install.tcsh http://drive5.com/cgi-bin/upload3.py?license=0000000000000000000
# install.tcsh usearch7.0.1090_i86osx32
# install.tcsh usearch muscle3.8.31_i86darwin64.tar
# install.tcsh skip http://www.drive5.com/muscle/downloads3.8.31/muscle3.8.31_i86linux64.tar.gz
#
#usearch and muscle are third-party applications not maintained by CFF.
#The muscle executable is directly downloadable for anyone.
#To get usearch, you must visit this site and agree to the terms:
#
# http://www.drive5.com/usearch/download.html
setenv MYARGV "$argv dummy"
setenv USEARCHPARAM `echo "$MYARGV" | cut -f 1 -d " "`
setenv MUSCLEPARAM `echo "$MYARGV" | cut -f 2 -d " "`
setenv LIBOPT "-l$HOME/perl5"
setenv ROOTINSTALL 0
setenv ROOTOPT ''
setenv ROOTNOSKIP ''
setenv INSTALLLIBS 'App::cpanminus local::lib'
setenv BASHENV "$HOME/.bashrc"
setenv TCSHENV "$HOME/.cshrc"
#Make sure that MUSCLEPARAM isn't a duplicate of USEARCHPARAM
if ( "$MUSCLEPARAM" == "dummy" ) then
setenv MUSCLEPARAM ''
endif
##
## Error-check the number of supplied parameters
##
if ( "$USEARCHPARAM" == '' ) then
echo 'ERROR 1: The first parameter (a usearch download URL, usearch tarball, usearch executable or the value "skip") is a required parameter. Please go to http://www.drive5.com and obtain a usearch download URL. (E.g. ./install http://drive5.com/cgi-bin/upload3.py?license=0000000000000000000)'
exit 1
endif
##
## Make sure the user is executing this script from the CFF directory
##
setenv CWD `pwd`
setenv INCFFDIR `perl -e 'if($ARGV[0] =~ m%/CFF[^/]*/?$%){print("1\n")}else{print("0\n")}' $CWD`
if ( ! $INCFFDIR ) then
echo "ERROR 2: Must execute this script from inside the CFF directory. (Do not remove 'CFF' from the name of the directory either or you won't be able to run the install script.)"
exit 2
endif
##
## Prepare for either a system- or local-level install
##
#setenv CPANMEXE ''
#If we are running as root
if ( `id -u` == "0" ) then
setenv ROOTINSTALL 1
setenv ROOTOPT '--sudo'
setenv LIBOPT ''
setenv ROOTNOSKIP '--no-skip-installed'
#setenv INSTALL_BASE /usr/local
which cpanm >& /dev/null
if ( $status ) then
#We're installing cpanm temporarily here:
setenv PATH "$HOME/perl5/bin:$PATH"
rehash
endif
#setenv CPANMEXE `which cpanm | grep -v -i "not found"`
#echo "PATH3: $PATH"
echo
echo '## Installing at system level'
echo
else
setenv INSTALLLIBS "$INSTALLLIBS local::lib"
endif
##
## See if we're on Mac OS X so that we can ensure the developer tools are installed
##
which xcode-select >>& logfile
if ( ! $status ) then
#We're on Mac OS X
#Now let's see if they have the developer tools installed
xcode-select -p >>& logfile
if ( $status ) then
echo
echo Developer tools not installed.
xcode-select --install >>& logfile
echo A window will appear in a moment to walk you through the XCode installation.
echo -n 'Hit return when XCode installation is complete: '
echo $<
#Now make sure they succeeded with the xcode install
xcode-select -p >>& logfile
if ( $status ) then
echo "ERROR 3: Apple Developer Tools install failed"
echo "Installation failed"
exit 3
endif
endif
endif
##
## Determine if cpanminus and local::lib (if we're using it) are already installed
##
perl -e 'use App::cpanminus' >& /dev/null
setenv CPANMBAD $status
perl -e 'use local::lib' >& /dev/null
setenv LLIBBAD $status
setenv CPME `which cpanm | grep -v -i "not found"`
if ( $status || "$CPME" == '' ) setenv CPANMBAD 1
if ( $CPANMBAD || $LLIBBAD ) then
echo
echo '## Installing cpanminus'
echo
echo "curl -L https://cpanmin.us | perl - $ROOTOPT $LIBOPT $INSTALLLIBS"
curl -L https://cpanmin.us | perl - $ROOTOPT $LIBOPT $INSTALLLIBS
if ( $status ) then
curl -L https://git.io/cpanm | perl - $ROOTOPT $LIBOPT $INSTALLLIBS
if ( $status ) then
echo "ERROR 4: Install of $INSTALLLIBS encountered an error"
echo "Installation failed"
exit 4
endif
endif
endif
##
## Set up the environment
##
if ( "$ROOTINSTALL" == "0" ) then
echo
echo '## Setting up environment'
echo
#bash
echo 'export MANPATH=$MANPATH'":$HOME/perl5/man" >> $BASHENV
perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=--shelltype,bourne >> $BASHENV
#csh
echo 'if ! $?MANPATH setenv MANPATH "";' >> $TCSHENV
echo 'if "${MANPATH}" != "" setenv MANPATH "${MANPATH}:${HOME}/perl5/man";' >> $TCSHENV
echo 'if "${MANPATH}" == "" setenv MANPATH "${HOME}/perl5/man";' >> $TCSHENV
perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=--shelltype,csh >> $TCSHENV
#This sets up the environment for this script
eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,csh`
if ( $status ) then
echo "ERROR 5: local::lib environment setup failed"
echo "Installation failed"
exit 5
endif
#make sure cpanm is in the PATH
if ( `which cpanm | grep -v -i "not found"` == "" ) then
setenv CPANMPATH `perl -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,csh | grep INSTALL_BASE | cut -d = -f 2 | cut -d ':' -f 1 | cut -d '"' -f 1 | perl -pne 'chomp;$_ .= "/bin";'`
if ( "$CPANMPATH" != '' ) then
setenv PATH "${PATH}:$CPANMPATH"
rehash
endif
endif
else
#We'll assume that /usr/local is set up properly in their environment
if ( ! $LLIBBAD ) then
#This sets up the environment for this script
eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,csh,--deactivate-all`
if ( $status ) then
echo "ERROR 6: Setting up environment failed"
echo "Installation failed"
exit 6
endif
endif
#If local::lib is installed, deactivate it
setenv CPANMPATH `which cpanm | grep -v -i "not found"`
if ( "$CPANMPATH" == "" ) then
#cpanminus, when installed by the user can be detected by root, but root doesn't
#always have the path to the cpanm executable, so we will attempt to grab it here:
setenv CPANMPATH `perl -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,csh | grep INSTALL_BASE | cut -d = -f 2 | cut -d ':' -f 1 | cut -d '"' -f 1 | perl -pne 'chomp;$_ .= "/bin";'`
if ( "$CPANMPATH" != '' ) then
echo "Adding cpanm's PATH [$CPANMPATH] to the PATH"
setenv PATH "${PATH}:$CPANMPATH"
rehash
else
echo "WARNING: Unable to determine cpanm PATH"
endif
else
echo "DEBUG: cpanm's PATH [$CPANMPATH] is in your PATH [$PATH]. Yay!"
endif
endif
#Sometimes (maybe just on virtual machines) you have
#to rehash to find new executables in your path
rehash
which cpanm >>& logfile
if ( $status ) then
#Last ditch effort - maybe it's in /usr/local/bin and the root account doesn't have it in its path for whatever reason
which /usr/local/bin/cpanm
if ( ! $status ) then
setenv PATH /usr/local/bin:$PATH
rehash
which cpanm
if ( $status ) then
echo "ERROR 7: cpanm not found in PATH: $PATH"
echo "Installation failed"
exit 7
endif
else
echo "ERROR 8: cpanm not found in PATH: $PATH"
echo "Installation failed"
exit 8
endif
endif
@ plmoderrs = ( 0 );
setenv MODLIST ""
foreach MODULENAME ( "Getopt::Long" "File::Glob" "IPC::Open3" "IO::Select" "IO::Pipe::Producer" "Sys::Info" "Sys::MemInfo" "File::Which" "Math::Random" )
setenv MODULEFILE `perl -e '$ARGV[0] =~ s%::%/%g;print("$ARGV[0].pm")' $MODULENAME`
echo
echo "## Installing $MODULENAME"
echo
if ( "$ROOTINSTALL" == "1" ) then
setenv ISLOCAL `perl -e 'if(exists($ENV{PERL_LOCAL_LIB_ROOT}) == 0){print("0\n")}my $p = quotemeta($ENV{PERL_LOCAL_LIB_ROOT});print(($INC{$ARGV[0]} =~ /^$p/ ? 0 : 1),"\n")' $MODULEFILE`
if ( "$ISLOCAL" == "1" ) then
echo "cpanm $ROOTOPT $ROOTNOSKIP $MODULENAME"
cpanm $ROOTOPT $ROOTNOSKIP $MODULENAME
else
echo "cpanm $ROOTOPT $MODULENAME"
cpanm $ROOTOPT $MODULENAME
endif
else
echo "cpanm $MODULENAME"
cpanm $MODULENAME
endif
perl -M$MODULENAME -e 'if(exists($INC{$ARGV[0]}) == 0 || $INC{$ARGV[0]} eq ""){exit(1)}' $MODULEFILE
if ( $status ) then
echo
echo "## Error installing $MODULENAME. Trying to force."
echo
echo "cpanm $ROOTOPT $ROOTNOSKIP --force $MODULENAME"
cpanm $ROOTOPT $ROOTNOSKIP --force $MODULENAME
if ( $status ) then
echo "Installation incomplete"
@ plmoderrs = ( ${plmoderrs} + 1 );
setenv MODLIST "$MODLIST $MODULENAME"
endif
else
echo -n "$MODULENAME is installed in "
perl -M$MODULENAME -e 'print $INC{$ARGV[0]}' $MODULEFILE
echo
endif
end
echo
echo '## Checking installed perl modules'
echo
perl -e 'use Getopt::Long;use File::Glob;use IPC::Open3;use IO::Select;use IO::Pipe::Producer;use Sys::Info;use Sys::MemInfo;use File::Which;use Math::Random'
if ( $status ) then
#Last ditch effort - source the user's environment file.
if ( -e $HOME/.cshrc ) then
source $HOME/.cshrc
endif
perl -e 'use Getopt::Long;use File::Glob;use IPC::Open3;use IO::Select;use IO::Pipe::Producer;use Sys::Info;use Sys::MemInfo;use File::Which;use Math::Random'
if ( $status ) then
echo "ERROR 9: Test of dependent perl modules failed."
echo " The following "${plmoderrs}" perl modules were not installed."
echo " $MODLIST"
echo "Installation incomplete"
exit 9
else
echo "WARNING: Had to source your $HOME/.cshrc file to use the installed perl modules."
endif
else
echo "Perl modules look good."
echo
endif
##
## Install muscle
##
if ( "$MUSCLEPARAM" != "skip" && "$MUSCLEPARAM" != "ignore" ) then
echo
echo '## Installing muscle'
echo
./install_muscle.tcsh "$MUSCLEPARAM"
if ( $status ) then
echo 'ERROR 10: muscle installation failed. Not found in PATH ['"$PATH"']. Please run the following commands, replacing "<muscle3.8.31_i86darwin64.tar.gz>" and "<muscle3.8.31_i86darwin64>" with the path to your muscle download and executable (without the ".tar/gz" extension)'
echo
echo ' tar -xvf <muscle3.8.31_i86darwin64.tar.gz>'
echo ' chmod 755 <muscle3.8.31_i86darwin64>'
echo ' mkdir '"$HOME/bin"
echo ' PATH=$PATH:'"$HOME/bin"
echo ' mv <muscle3.8.31_i86darwin64> $HOME/bin/'
echo ' cd $HOME/bin/'
echo ' ln -s <muscle3.8.31_i86darwin64> muscle'
echo
echo "Installation incomplete"
exit 10
endif
echo
echo '## Checking muscle installation'
echo
#Sometimes (maybe just on virtual machines) you have to rehash to find new executables in your path
rehash
which muscle >>& logfile
if ( $status && "$ROOTINSTALL" == "0" ) then
#Assume that the executable is in the current directory
setenv PATH "${PATH}:"`pwd`
rehash
endif
which muscle
if ( $status ) then
echo 'ERROR 11: muscle check failed. Not found in PATH ['"$PATH"']. Please run the following commands, replacing "<muscle3.8.31_i86darwin64.tar.gz>" and "<muscle3.8.31_i86darwin64>" with the path to your muscle download and executable (without the ".tar/gz" extension)'
which muscle >>& logfile
echo "PATH: $PATH" >>& logfile
ls /usr/local/bin >>& logfile
echo
echo ' tar -xvf <muscle3.8.31_i86darwin64.tar.gz>'
echo ' chmod 755 <muscle3.8.31_i86darwin64>'
echo ' mkdir '"$HOME/bin"
echo ' PATH=$PATH:'"$HOME/bin"
echo ' mv <muscle3.8.31_i86darwin64> $HOME/bin/'
echo ' cd $HOME/bin/'
echo ' ln -s <muscle3.8.31_i86darwin64> muscle'
echo
echo "Installation incomplete"
exit 11
endif
else
echo 'Skipping muscle config/install.'
endif
##
## Install usearch
##
if ( "$USEARCHPARAM" != "skip" && "$USEARCHPARAM" != "ignore" ) then
echo
echo '## Installing usearch'
echo
./install_usearch.tcsh "$USEARCHPARAM"
if ( $status ) then
echo 'ERROR 12: usearch installation failed. Not found in PATH ['"$PATH"']. Please run the following commands, replacing "<usearch7.0.1090_i86osx32>" with the path to your usearch executable'
echo
echo ' chmod 755 <usearch7.0.1090_i86osx32>'
echo ' mkdir '"$HOME/bin"
echo ' PATH=$PATH:'"$HOME/bin"
echo ' mv <usearch7.0.1090_i86osx32> $HOME/bin/'
echo ' cd $HOME/bin/'
echo ' ln -s <usearch7.0.1090_i86osx32> muscle'
echo
echo "Installation incomplete"
exit 12
endif
echo
echo '## Checking usearch installation'
echo
#Sometimes (maybe just on virtual machines) you have to rehash to find new executables in your path
rehash
which usearch >>& logfile
if ( $status && "$ROOTINSTALL" == "0" ) then
#Assume that the executable is in the current directory
setenv PATH "${PATH}:"`pwd`
rehash
endif
which usearch
if ( $status ) then
echo 'ERROR 13: usearch check failed. Not found in PATH ['"$PATH"']. Please run the following commands, replacing "<usearch7.0.1090_i86osx32>" with the path to your usearch executable'
echo
echo ' chmod 755 <usearch7.0.1090_i86osx32>'
echo ' mkdir '"$HOME/bin"
echo ' PATH=$PATH:'"$HOME/bin"
echo ' mv <usearch7.0.1090_i86osx32> $HOME/bin/'
echo ' cd $HOME/bin/'
echo ' ln -s <usearch7.0.1090_i86osx32> usearch'
echo
echo "Installation incomplete"
exit 13
endif
else
echo 'Skipping usearch config/install.'
endif
##
## Install CFF
##
echo
echo '## Configuring CFF'
echo
perl Makefile.PL
if ( $status ) then
echo "ERROR 14: `perl Makefile.PL` failed."
echo "Installation incomplete"
exit 14
endif
echo
echo '## Compiling CFF'
echo
make
if ( $status ) then
echo "ERROR 15: `make` failed."
echo "Installation incomplete"
exit 15
endif
echo
echo '## Installing CFF'
echo
make install
if ( $status ) then
echo "ERROR 16: 'make install' failed."
echo "Installation incomplete"
exit 16
endif
##
## Test the installation
##
echo
echo '## Testing CFF installation'
echo
#Run the tests in the test directory
cd test
./run_test.tcsh
setenv FAILURE $status
cd ..
if ( $FAILURE ) then
echo "ERROR 17: CFF test failed."
echo "Installation incomplete"
exit 17
else
##
## Clean up
##
#Clean up files owned by root from the user's directory
if ( "$ROOTINSTALL" == "1" ) then
make clean >& /dev/null
\rm -f Makefile.old muscle* usearch* logfile
setenv AFILE "$HOME/perl5"
setenv OWNER `ls -ld $AFILE | awk '{print $3}'`
if ( "$OWNER" == "root" ) then
\rmdir $AFILE >& /dev/null
endif
setenv AFILE "$HOME/.cpanm"
setenv OWNER `ls -ld $AFILE | awk '{print $3}'`
if ( "$OWNER" == "root" ) then
\rm -rf $AFILE
endif
#This should actually be fixed in the run_test script
setenv AFILE "samples/run_all_qiime_tax_commands.sh"
setenv OWNER `ls -ld $AFILE | awk '{print $3}'`
if ( "$OWNER" == "root" ) then
\rm -f $AFILE
endif
endif
echo
echo "## CFF installation successful"
echo
echo "To start using CFF, please open a new terminal window or run:"
echo " for bash: '. $BASHENV'"
echo " for tcsh: 'source $TCSHENV'"
exit 0
endif