lib/App/SeismicUnixGui/script/post_install_c_compile.pl untested

filter: Statementstmt 0.0% 0 / 73 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 82 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/bin/perl
2  
3 =head1 DOCUMENTATION
4  
5  
6 =head2 SYNOPSIS
7  
8 PERL SCRIPT NAME: post_install_c_compile.pl
9 AUTHOR: Juan Lorenzo
10 DATE: July 11 2022
11  
12 DESCRIPTION
13  
14
15 Help installer compile C and fortran programs
16  
17 =cut
18  
19 =head2 USE
20  
21 =head3 NOTES
22
23 Post-installation files are stored somewhere on the system,
24 e.g., Distribution directory for SeismicUnixGui =
25 /usr/local/lib/x86_64-linux-gnu/perl/5.30.0/auto/
26 App/SeismicUnixGui
27  
28 =head4 Examples
29  
30  
31 =head2 CHANGES and their DATES
32  
33 =cut
34  
35 use Moose;
36 our $VERSION = '0.0.1';
37  
38 use Cwd;
39 use Shell qw(echo find);
40 use File::Basename;
41 use File::Spec;
42  
43 my $C_pathNfile;
44 my $SeismicUnixGui;
45 my $ans = 'n'."\n";
46 my $default_answer = 'y';
47 my $choice = 1;
48 my $repeat = 1;
49 my $bin = 'bin';
50  
51 # search for c libraries
52 my $starting_points = '/home /';
53 my $file = 'run_me_only.sh';
54 my $pathNfile2find = "*c/synseis/$file";
55 my ( $filename, $C_path );
56  
57 print(" Looking for script on the system...\n");
58  
59 my @list = `(find $starting_points -path $pathNfile2find -print 2>/dev/null)`;
60 my $length = scalar @list;
61  
62 print(" Found $length versions of the script:\n");
63 print(" Hint: use one with the \"perl\" in the path name
64 or \"perl5\", for the case of a local installation.
65 But ignore the case(s) with \"blib\" in their name.\n");
66  
67 for ( my $i = 0 ; $i < $length ; $i++ ) {
68  
69 print("Case $i: $list[$i]\n");
70  
71 }
72  
73 while ($ans eq 'n'."\n") {
74
75 print("\nEnter a script name (with Full Path),\n or use the default:$list[0]\n");
76 print("Enter a different name or only Hit Return\n");
77 my $answer = <STDIN>;
78 chomp $answer;
79  
80 if ( length $answer ) {
81
82 $C_pathNfile = $answer;
83
84 }
85 elsif ( !( length $answer ) ) {
86
87 $C_pathNfile = $list[0];
88
89 }
90  
91 print("You chose: $C_pathNfile\n");
92 print("Is that correct? Please answer y or n [$default_answer]\n");
93 $ans = <STDIN>;
94 chomp $ans;
95 }
96  
97 my $path = $C_pathNfile;
98 $path =~ s/$file//;
99 chomp $path;
100 print("path and file: $path$file\n");
101  
102 print("\n\tINSTALLATION OF EXTERNAL C PROGRAMS\n");
103 print("\nC_PATH=$C_pathNfile\n");
104  
105 print "Proceeding to compile\n";
106 chdir "$path";
107 system("sudo bash $file");
108  
109 # Explain ENV settings to user
110 print("\nMake sure you now set the environment variable properly.");
111  
112 ( $filename, $C_path ) = fileparse($C_pathNfile);
113  
114 #print ("Directory:$Fortran_path...\n");
115 my @dirs = File::Spec->splitdir($C_path); # parse directories
116 #print ("@dirs...\n");
117 pop @dirs; # remove top dir
118 pop @dirs; # remove top dir
119 pop @dirs; # remove top dir
120 print ("@dirs...\n");
121 my $SeismicUnixGui_path = File::Spec->catdir(@dirs); # create new path
122 print(
123 "\nFor your system, the environment variable: \$SeismicUnixGui appears to be:\n $SeismicUnixGui_path\n\n"
124 );
125 print("Before running SeismicUnixGui, be sure to add the\n");
126 print("following line to the end of your \".bashrc\" file:\n\n");
127 print("export PATH=\$PATH:$C_path$bin\n\n");
128  
129 print(" End of C-programs Installation\n");
130 print("Hit Enter to leave\n");
131 <STDIN>