-
Notifications
You must be signed in to change notification settings - Fork 49
/
install.pl
executable file
·848 lines (689 loc) · 22 KB
/
install.pl
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
#!/usr/bin/perl
# miRDeep2 install perl script
# Copyright (C) 2009 - 2012, 2014 - 2017, 2019 Sebastian Mackowiak
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
use strict;
use warnings;
print STDERR "\n
###############################################################################################
# Last update: Aug 27, 2024
# This is the miRDeep2 installer
# It is tested under a bash and zsh shell
# It will try to download all necessary third-party tools and install them.
# To run this installer you need to have mirdeep2.0.0.8 or later
#
###############################################################################################
";
my $dir=`pwd 2>&1`;
chomp $dir;
if(not $ENV{PERL5LIB}){$ENV{PERL5LIB}="$dir/lib/perl5";}
if($ENV{PERL5LIB} !~ /$dir\/lib\/perl5/){
$ENV{PERL5LIB}.=":$dir/lib/perl5";
}
my $time =time;
my $new='no';
$new = $ARGV[0] if($ARGV[0]);
my $shell=$ENV{'SHELL'};
my $shellconf='.bashrc';
if($shell =~ /zsh/){
if(-f "$ENV{'HOME'}/.zshenv"){
$shellconf='.zshenv';
}elsif(-f "$ENV{'HOME'}/.zshrc"){
$shellconf='.zshrc';
}else{
die "Could not determine file for setting environment variables\n";
}
}
if($new !~ /no/){
print STDERR "making backup of .bashrc,$shellconf and .cshrc and removing all entries of mirdeep in those files\n";
rem_mirdeep(".bashrc");
rem_mirdeep("$shellconf");
rem_mirdeep(".cshrc");
}
my $grep;
$grep=`which grep`;
if(not $grep){
$grep=`which ggrep`;
}
if(not $grep){
die "No grep found on system\n";
}
chomp $grep;
my $gcc=`gcc --version 2>&1`;
if($gcc !~ /(GCC)/i and $gcc !~ /clang/i){
print STDERR "\nError:\n\tno gcc compiler installed. Please install a gcc compiler\n";
my $r=`uname -s`;
chomp $r;
if($r !~ /Linux/i){
print STDERR "==> If you are using MacOS then you probably need to install Xcode with commandline-tools from the appstore!\n\n";
}
exit;
}else{
if($gcc =~ /^gcc\s*\S*\s*(\d+\S+)\s*/){
print STDERR "gcc version: $1 already installed, nothing to do ...\n";
}
if($gcc =~ /clang/){
print STDERR "clang installed already installed, nothing to do ...\n";
}
}
my %progs;
$progs{bowtie}=0;
$progs{RNAfold}=0;
$progs{randfold}=0;
$progs{zlib}=0;
$progs{pdf}=0;
$progs{ttf}=0;
my $wget=`wget 2>&1`;
my $curl=`which curl`;
my $dtool='';
my $dopt='';
if($wget =~ /URL/i){
$dtool ="wget";
}elsif($curl){
$dtool ="curl -L"; ## forces curl to follow redirections
$dopt=" -O";
}else{
die "No commandline download tool found on your system. Please install wget or curl on your machine\n";
}
if(not -d 'bin'){
#creating bin directory which will also contain other executables in the end\n";
my $ret=system("cp -r src bin");
if(not $ret){
print STDERR "bin directory created successful\n";
}else{
die "Could not create binary directory\n";
}
}
my $err;
my $dfile='';
##only attach to config file if not yet existing
my $in=`$grep "$dir/bin" ~/.bashrc`;
## set install dir
my $install_bin_dir="$dir/bin";
foreach my $e(@ARGV){
if($e =~ /install-dir=(.+)/){
$install_bin_dir=$1;
}
}
if($install_bin_dir ne "$dir/bin"){
## check if it is writable and existent
if(not -d $install_bin_dir){
print STDERR "The given installation directory by argument install-dir is not existent\nexecutable files will be put into $dir/bin instead\n";
$install_bin_dir="$dir/bin";
}else{
chdir $install_bin_dir;
my $ret=system("touch mirdeep_test_file");
if(not $ret){
system("rm mirdeep_test_file");
}else{
print STDERR "The given installation directory by argument install-dir is either not existent or not writeable\nexectable files will be put into $dir/bin instead\n";
$install_bin_dir="$dir/bin";
}
chdir "$dir";
}
}
## check if we have the install path in our files
$in=`$grep "$install_bin_dir" ~/$shellconf`;
if(not $in){
my $ret=`$grep $install_bin_dir ~/$shellconf |$grep PATH`;
if(not $ret){
`echo 'export PATH=\$PATH:$install_bin_dir' >> ~/$shellconf`;
}
}
## add this temporarily to make perl installation possible on some systems
print STDERR "Checking environment variables ...\n";
my $g=`$grep PERL_MB_OPT ~/$shellconf \|$grep install_base `;
if($g){
}else{
print STDERR "adding variables PERL_MB_OPT,PERL_MM_OPT,PERL5LIB to $shellconf\n";
`echo >> ~/$shellconf`;
`echo 'PERL_MB_OPT=\"--install_base $ENV{'HOME'}/perl5\";export PERL_MB_OPT' >> ~/$shellconf`;
`echo 'PERL_MM_OPT=\"INSTALL_BASE=$ENV{'HOME'}/perl5\";export PERL_MM_OPT' >> ~/$shellconf`;
$g=`grep $dir/lib/perl5 ~/$shellconf`;
if(not $g){
$g=`grep PERL5LIB ~/$shellconf`;
if(not $g){
`echo 'export PERL5LIB=$dir/lib/perl5' >> ~/$shellconf`;
}else{
`echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/$shellconf`;
}
}
`echo >> ~/$shellconf`;
print STDERR "please run the install.pl script again in a new terminal window or just type
source ~/$shellconf
perl install.pl
so that the new environment variables are visible to the install.pl script\n";
exit;
}
$g=`$grep $dir/lib/perl5 ~/$shellconf`;
if(not $g){
$g=`grep PERL5LIB ~/$shellconf`;
if(not $g){
`echo 'export PERL5LIB=$dir/lib/perl5' >> ~/$shellconf`;
}else{
`echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/$shellconf`;
}
`echo >> ~/$shellconf`;
print STDERR "please run the install.pl script again in a new terminal window or just type
source ~/$shellconf
perl install.pl
so that the new environment variables are visible to the install.pl script\n";
exit;
}
my $in2;
if(-f "~/.cshrc"){
$in2=`$grep "$install_bin_dir" ~/.cshrc`;
if(not $in2){
`echo 'setenv PATH \$PATH:$install_bin_dir' >> ~/.cshrc`;
}
}
my $binnew=1;
if(not -d "essentials"){
`mkdir essentials`;
}else{
$binnew=0;
}
chdir("essentials");
my $a=`uname -a`;
my $bowtie;
my $bowtie_version="1.1.1";
if($dtool =~ /curl/){
`$dtool https://sourceforge.net/projects/bowtie-bio/files/bowtie/ > to_del`;
}else{
`$dtool https://sourceforge.net/projects/bowtie-bio/files/bowtie/ -O to_del`;
}
open IN,"to_del" or die "No bowtie_file_info file found\n";
while(<IN>){
if(/projects\/bowtie-bio\/files\/bowtie\/(\d\.\d+\.*\d*)\//){
$bowtie_version=$1;
last;
}
}
close IN;
$bowtie_version="1.1.1"; #we force this version, cause 1.2 needs the TBB lib installed
my $bv=$bowtie_version;
if($bv =~ /(\d\.\d)\.0/){
$bv=$1;
}
my $ret=checkBIN("bowtie","Usage");
if($ret == 0){
print STDERR "bowtie already installed, nothing to do ...\n";
$progs{bowtie} = 1;
}else{
if(not -d "bowtie-$bowtie_version"){
## this needed to be added cause the authors removed the 0 in the version number for the filename
print STDERR "Downloading bowtie $bowtie_version binaries\n\n";
if($a =~ /Darwin/i){ ## download mac version
$bowtie = "bowtie-$bv-macos-x86_64.zip";
}elsif($a =~ /x86_64/i){
$bowtie = "bowtie-$bv-linux-x86_64.zip";
}else{
$bowtie = "bowtie-$bv-src.zip";
}
if(not -f $bowtie){
if(check("http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie")){
$err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie $dopt");
if($err){
die "\nError:\n\t$bowtie could not be downloaded\n\n\n";
}
}elsif(check("http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/old/$bowtie_version/$bowtie")){
$err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/old/$bowtie_version/$bowtie $dopt");
if($err){
die "\nError:\n\t$bowtie could not be downloaded\n\n\n";
}
}elsif(check("https://sourceforge.net/projects/bowtie-bio/files/bowtie/$bowtie_version/$bowtie",$bowtie)){
if(not -f $bowtie){
$err=system("$dtool https://sourceforge.net/projects/bowtie-bio/files/bowtie/$bowtie_version/$bowtie $dopt");
}else{
$err=0;
}
if($err){
die "\nError:\n\t$bowtie could not be downloaded\n\n\n";
}
}else{
die "\nError:\n\t$bowtie not found on server http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/ \n\n\n";
}
}
if(not -f "$bowtie"){
die "$bowtie download failed \nPlease try to download bowtie manually from here http://bowtie-bio.sourceforge.net/index.shtml";
}
print STDERR "Installing bowtie binaries\n\n";
$err=system("unzip -u $bowtie 1>> install.log 2>>install_error.log");
if($err){
die "unzip $bowtie was not successful\n";
}
}
chdir "$install_bin_dir";
buildgood("$dir/essentials/bowtie-$bv/bowtie","bowtie");
if(not -f "bowtie"){
system("ln -s $dir/essentials/bowtie-$bv/bowtie* .");
}
chdir "$dir/essentials/";
}
$ret = checkBIN("RNAfold -h","usage");
if($ret == 0){
print STDERR "RNAfold already installed, nothing to do ...\n";
$progs{RNAfold}=1;
}else{
if(not -d "ViennaRNA-1.8.4"){
$dfile="ViennaRNA-1.8.4.tar.gz";
if(not -f $dfile){
print STDERR "Downloading Vienna package now\n\n";
my $ptc="https://www.tbi.univie.ac.at/RNA/download/sourcecode/1_8_x/ViennaRNA-1.8.4.tar.gz";
# if(check("http://www.tbi.univie.ac.at/RNA/packages/source/ViennaRNA-1.8.4.tar.gz")){ # address changed
if(check($ptc,$dfile)){
if(not -f $dfile){
$err=system("$dtool $ptc $dopt");
}else{
$err=0;
}
if($err){
die "Download of Vienna package not successful\n\n";
}
}else{
die "Vienna package not found at http://www.tbi.univie.ac.at/RNA/packages/source/ViennaRNA-1.8.4.tar.gz
Please try to download the Vienna package from here http://www.tbi.univie.ac.at/RNA/RNAfold.html
\n";
}
}
if(not -f "ViennaRNA-1.8.4.tar.gz"){
die "Vienna package download failed\n";
}
}
if(not -f "ViennaRNA-1.8.4/Progs/RNAfold"){
print STDERR "Installing Vienna package now \n\n";
`tar xzf ViennaRNA-1.8.4.tar.gz`;
chdir("ViennaRNA-1.8.4/");
`./configure --prefix=$dir/essentials/ViennaRNA-1.8.4/install_dir --without-perl --without-forester --without-kinfold`;
if(not -d "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin/"){
`mkdir -p $dir/essentials/ViennaRNA-1.8.4/install_dir/bin/`;
}
chdir("lib");
my $PATCH="$dir/patch_files";
my @PF=qw(fold cofold subopt treedist);
for my $i(@PF){
`cp $i.c $i.c.orig`;
`cp $PATCH/${i}_patch.c $i.c`;
}
chdir "../H";
my $i='part_func';
`cp $i.h $i.h.orig`;
`cp $PATCH/${i}_patch.h $i.h`;
chdir "../lib";
print STDERR "compiling libRNA.a\n";
`make libRNA.a 2>> ../install_error.log`;
my $ok=1;
if(not -f "libRNA.a"){
$ok=0;
}
chdir "..";
chdir 'Progs';
print STDERR "compiling RNAfold\n";
`make RNAfold 2>> ../install_error.log`;
if(not -f "RNAfold"){
$ok=0;
}
chdir "..";
if($ok){
`ln -s $dir/essentials/ViennaRNA-1.8.4/Progs/RNAfold $dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold`;
$ok =0 if(not -f "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold");
}
if(not $ok){
print STDERR "building only RNAfold program failed, trying a full Vienna package install\n";
`make 1>> ../install.log 2>> ../install_error.log`;
`make install 1>> ../install.log 2>> ../install_error.log`;
}else{
print STDERR "building RNAfold tool done\n";
}
buildgood("$dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold","RNAfold");
chdir("..");
chdir "$install_bin_dir";
if(not -f "RNAfold"){
system("ln -s $dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold .");
}
chdir "$dir/essentials/"
}
}
#$in = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.bashrc`;
#if(not $in){
# print STDERR "Vienna package path has been added to \$PATH variable\n";
# `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.bashrc`;
#}
#$in = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/$shellconf`;
#if(not $in){
# print STDERR "Vienna package path has been added to \$PATH variable\n";
# `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/$shellconf`;
#}
#$in2 = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.cshrc`;
#if(not $in2){
#`echo 'setenv PATH \$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.cshrc`;
#}
$ret = checkBIN("randfold","let7");
#my $randf = `randfold -h`;
#if($randf =~ /no\s*randfold/i){ ## this should work
if($ret == 0){
print STDERR "randfold\t\t\t\t\t already installed, nothing to do ...\n";
$progs{randfold}=1;
}else{
$dfile="squid-1.9g.tar.gz";
if(not -f $dfile){
print STDERR "Downloading SQUID library now\n\n";
`$dtool http://eddylab.org/software/squid/squid.tar.gz $dopt`;
`mv squid.tar.gz $dfile`;
}
if(not -f $dfile){
system("cp ../squid-1.9g.tar.gz squid-1.9g.tar.gz");
}
if(not -f "squid-1.9g.tar.gz"){
die "squid could not be downloaded\n Please try to download the library from here http://selab.janelia.org/software.html";
}
if(not -d "squid-1.9g" and -f "squid-1.9g.tar.gz"){
print STDERR "Extracting squid and configuring it now\n\n";
`mkdir squid-1.9g`;
`tar xzf squid-1.9g.tar.gz -C squid-1.9g`;
my $a=`ls squid-1.9g`;
chomp $a;
`mv squid-1.9g/$a/* squid-1.9g/`;
`rm -rf squid-1.9g/$a`;
chdir("squid-1.9g");
`./configure 1>>../install.log 2>>../install_error.log`;
`make CFLAGS="\$CFLAGS -Wno-implicit-function-declaration" 1>>../install.log 2>>install_error.log`;
buildgood("$dir/essentials/squid-1.9g/libsquid.a");
chdir("..");
}
$dfile="randfold-2.0.tar.gz";
if(not -f $dfile ){
print STDERR "Downloading randfold now\n\n";
`$dtool http://bioinformatics.psb.ugent.be/supplementary_data/erbon/nov2003/downloads/randfold-2.0.tar.gz $dopt`;
}
if(not -f "randfold-2.0.tar.gz"){
die "randfold could not be downloaded\nPlease try to download randfold from here http://bioinformatics.psb.ugent.be/software/details/Randfold\n";
}
if(not -d "randfold-2.0" and -f "randfold-2.0.tar.gz"){
print STDERR "Installing randfold now\n\n";
`tar xzf randfold-2.0.tar.gz`;
chdir("randfold-2.0");
open IN,"<Makefile" or die "File Makefile not found\n\n";
open OUT,">Makefile_new" or die "Makefile_new could not be created\n\n";
while(<IN>){
if(/INCLUDE=-I\.\s*/i){
print OUT "INCLUDE=-I. -I$dir/essentials/squid-1.9g -L$dir/essentials/squid-1.9g/\n";
}else{
print OUT;
}
}
close IN;
close OUT;
## added so we can make it run on MacOSX as well.
open IN,"<fold.c" or die "File fold.c not found\n";
open OUT,">fold.c.new" or die "Cannot generate file fold.c.new\n";
while(<IN>){
if(/^inline\s+(int\s+LoopEnergy.+$)/i){
print OUT "$1";
}elsif(/^inline\s+(int\s+HairpinE.+$)/i){
print OUT "$1";
}else{
print OUT;
}
}
close OUT;
`mv fold.c fold.c.orig`;
`mv fold.c.new fold.c`;
`mv Makefile Makefile.orig`;
`mv Makefile_new Makefile`;
`make CFLAGS="\$CFLAGS -Wno-implicit-function-declaration" 1>>../install.log 2>>../install_error.log`;
buildgood("$dir/essentials/randfold-2.0/randfold","randfold");
chdir("..");
}
# $in = `$grep "$dir/essentials/randfold-2.0:*" ~/.bashrc`;
# if(not $in){
# print STDERR "Randfold path has been added to \$PATH variable\n";
# `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/.bashrc`;
# }
# $in = `$grep "$dir/essentials/randfold-2.0:*" ~/$shellconf`;
# if(not $in){
# print STDERR "Randfold path has been added to \$PATH variable\n";
# `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/$shellconf`;
#}
# $in2 = `$grep "$dir/essentials/randfold-2.0:*" ~/.cshrc`;
# if($in2){
#`echo 'setenv PATH \$PATH:$dir/essentials/randfold-2.0' >> ~/.cshrc`;
# }
chdir "$install_bin_dir";
if(not -f "randfold"){
system("ln -s $dir/essentials/randfold-2.0/randfold .");
}
chdir "$dir/essentials/"
}
##check for zlib perl
my $zlib=`perl -e 'use Compress::Zlib;' 2>&1`;
if(not $zlib){
print STDERR "Compress::Zlib\t\t\t\t\t already installed, nothing to do ...\n";
$progs{zlib}=1;
}else{
die "please install Compress::Zlib by using CPAN before you proceed\n";
}
#my $pdfapi=`perl -e 'use PDF::API2;' 2>&1`;
$ret = checkBIN("perl -e \'use Font::TTF; print \"installed\";\'","installed");
if($ret == 0){
print STDERR "Font::TTf already installed, nothing to do ...\n";
$progs{ttf}=1;
}else{
my $version='';
if( -f "CHECKSUMS"){ unlink "CHECKSUMS";}
`$dtool http://www.cpan.org/authors/id/M/MH/MHOSKEN/CHECKSUMS $dopt`;
open IN,"CHECKSUMS" or die "File checksums not found\n";
while(<IN>){
if(/((Font-TTF-\d.+).tar.gz)/){
$dfile=$1;
$version=$2;
}
}
close IN;
if(not -f $dfile){
print STDERR "Downloading Font::TTF now\n\n";
`$dtool http://www.cpan.org/authors/id/M/MH/MHOSKEN/$dfile $dopt`;
}
if(not -f $dfile){
die "Download of Font::TTF failed\n\n";
}
print STDERR "Installing Font-TTF now\n\n";
`tar xzf $dfile`;
chdir("$version");
`perl Makefile.PL INSTALL_BASE=$ENV{'HOME'}/perl5 LIB=$dir/lib/perl5`;
`make 1>>../install.log 2>>../install_error.log`;
`mv Makefile Makefile.orig`;
open IN,"Makefile.orig" or die "No Makefile found\n";
open OUT,">Makefile" or die "No Makefile found\n";
while(my $cl= <IN>){
if($cl =~ /^INSTALL_BASE\s=/){
print OUT "INSTALL_BASE = $dir\n";
}else{
print OUT $cl;
}
}
close IN;
`make install 1>>../install.log 2>>..install_error.log`;
$ret = checkBIN("perl -e \'use Font::TTF; print \"installed\";\'","installed");
if($ret == 0){
print STDERR "Font::TTF installation successful \n";
$progs{ttf}=1;
}
chdir("..");
}
$ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed");
if($ret == 0){
print STDERR "PDF::API2 already installed, nothing to do ...\n";
$progs{pdf}=1;
}else{
my $version='';
if( -f "CHECKSUMS"){ unlink "CHECKSUMS";}
`$dtool http://www.cpan.org/authors/id/S/SS/SSIMMS/CHECKSUMS $dopt`;
open IN,"CHECKSUMS" or die "File checksums not found\n";
while(<IN>){
if(/((PDF-API2-\d.+).tar.gz)/){
$dfile=$1;
$version=$2;
}
}
close IN;
if(not -f $dfile){
print STDERR "Downloading PDF-API2 now\n\n";
`$dtool http://ftp-stud.hs-esslingen.de/pub/Mirrors/CPAN/authors/id/S/SS/SSIMMS/$dfile $dopt`;
}
if(not -f $dfile){
die "Download of PDF-API2 failed\n\n";
}
print STDERR "Installing PDF-API2 now\n\n";
`tar xzf $dfile`;
chdir("$version");
`perl Makefile.PL INSTALL_BASE=$ENV{'HOME'}/perl5 LIB=$dir/lib/perl5`;
`make 1>>../install.log 2>>..install_error.log`;
`mv Makefile Makefile.orig`;
open IN,"Makefile.orig" or die "No Makefile found\n";
open OUT,">Makefile" or die "No Makefile found\n";
while(my $cl= <IN>){
if($cl =~ /^INSTALL_BASE\s=/){
print OUT "INSTALL_BASE = $dir\n";
}else{
print OUT $cl;
}
}
close IN;
`make install 1>>../install.log 2>>..install_error.log`;
$ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed");
if($ret == 0){
print STDERR "PDF::API2 installation successful\n";
$progs{pdf}=1;
}
chdir("..");
}
my $sum=0;
for my $k (keys %progs){
$sum+=$progs{$k};
print STDERR "\n\n$k was/is not installed properly\n\n" if(not $progs{$k} and $binnew==0);
}
if($sum == 6){
print STDERR "\n\nInstallation successful\n\n\n\n\n\n";
print STDERR "To check if everything works fine you can now change to the
tutorial_dir and type 'bash run_tut.sh' to make a test run\n\n";
chdir $dir;
open EF,">install_successful" or die "Could not create file install_successful\n
In case that all tools are running properly then please create this empty file manually
in your mirdeep2 installation folder. Otherwise the other tools will not run.
";
close EF;
}else{
print STDERR "\n\nPlease run the install.pl script again to check if
everything is properly installed.
";
}
exit;
sub rem_mirdeep{
my ($file)=@_;
if(-f "$ENV{'HOME'}/$file"){
`cp ~/$file ~/${file}_$time`;
print STDERR "~/$file backup is ~/${file}_$time\n";
`mv ~/$file ~/$file.bak`;
open OUT,">$ENV{'HOME'}/$file" or die "Cannot create file $ENV{'HOME'}/$file\n";
open IN,"$ENV{'HOME'}/$file.bak";
my @line;
my $tmp;
while(<IN>){
$tmp="";
if(/mirdeep/){
@line = split(/:/);
foreach(@line){
if(/mirdeep/){}else{
$tmp.="$_";
}
}
if($file !~ /.cshrc/){
if($tmp !~ /PATH=\$PATH$/ and $tmp !~ /PERL5LIB=\$PERL5LIB\s*$/){
print OUT "$tmp\n";
}
}else{
if($tmp !~ /PATH \$PATH$/ and $tmp !~ /PERL5LIB \$PERL5LIB\s*$/){
print OUT "$tmp\n";
}
}
}else{
print OUT;
}
}
}else{
print "file $ENV{'HOME'}/$file.bak not found\n";
}
}
sub checkBIN{
my ($a,$b) = @_;
my $e = system("$a> tmp 2>tmp2");
open IN,"<tmp";
my $found =1;
while(<IN>){
if(/$b/i){
$found =0;
}
}
close IN;
if($found){
open IN,"<tmp2";
while(<IN>){
if(/$b/i){
$found =0;
}
}
}
close IN;
return $found;
}
sub check{
my ($url,$file) = @_;
my $out='';
if($dtool =~ /wget/){
$out=`wget --spider -v $url 2>&1`;
}elsif($dtool =~ /curl/){
$out=`curl --head $url |head -n1`;
if($out =~ /NOT/i){
$out='broken';
}
if($url =~ /https/){
`curl $url > $file`;
if(-s "$file" < 1000){
$out='broken';
`rm -f $file`;
}else{
$out=0;
}
}
}else{
die "No download tool found\nplease install wget or curl\n";
}
if($out =~ /broken/i){
return 0;
}else{
return 1;
}
}
sub buildgood{
if(-f $_[0]){
print STDERR "Building of $_[0] successful\n";
$progs{$_[1]}=1 if($_[1]);
}else{
die "Building of $_[0] not successful\nPlease have a look at the install.log and install_error.log in
the essentials directory
";
}
}