Commit | Line | Data |
d50cb536 |
1 | #!/usr/bin/perl |
2 | |
3 | print <<'END' if $>; |
4 | NOTE: Since you're not running as root, the installation will su at |
5 | the appropriate time later. You will need to supply the root password |
6 | for the su program. |
7 | |
8 | END |
9 | |
10 | # Gather data. |
11 | |
12 | # JPL_SRC |
13 | |
14 | chop($JPL_SRC = `pwd`); |
15 | print "JPL_SRC = $JPL_SRC\n"; |
16 | |
17 | # JAVA_HOME |
18 | |
19 | foreach $dir ( |
20 | $ENV{JAVA_HOME}, |
21 | "/usr/java", |
22 | "/usr/local/java", |
23 | "/usr/lib/java", |
24 | "/usr/local/lib/java", |
25 | ) { |
26 | $JAVA_HOME = $dir, last if $dir and -d "$dir/bin"; |
27 | } |
28 | die "You must set the \$JAVA_HOME environment variable first.\n" |
29 | unless $JAVA_HOME; |
30 | print "JAVA_HOME = $JAVA_HOME\n"; |
31 | |
32 | # JPL_HOME |
33 | |
34 | ($likelyjpl = $JAVA_HOME) =~ s#(.*)/.*#$1/jpl#; |
35 | |
36 | print <<"END"; |
37 | |
38 | You need to decide which directory JPL files are to be installed in. |
39 | Applications will look in subdirectories of this directory for any JPL |
40 | related files. |
41 | |
42 | You may use the current directory ($JPL_SRC) |
43 | or you may use a directory such as $likelyjpl. |
44 | |
45 | END |
46 | |
47 | $| = 1; |
48 | until (-d $JPL_HOME) { |
49 | print "Install JPL files where: [$JPL_SRC] "; |
50 | chop($JPL_HOME = <STDIN>); |
51 | $JPL_HOME ||= $JPL_SRC; |
52 | unless (-d $JPL_HOME) { |
53 | print "Warning: $JPL_HOME doesn't exist yet!\n\n"; |
54 | print "Do you want to create it? [y] "; |
55 | chop($ans = <STDIN>); |
56 | $ans ||= 'y'; |
57 | next unless $ans =~ /^y/i; |
58 | |
59 | system "mkdir -p $JPL_HOME"; |
60 | if ($> and not -d $JPL_HOME) { |
61 | warn "Couldn't create $JPL_HOME!\nTrying again as root...running su...\n"; |
62 | system "set -x |
63 | su root -c 'mkdir -p $JPL_HOME && chown $> $JPL_HOME && chmod 0755 $JPL_HOME'"; |
64 | warn "Couldn't create $JPL_HOME!\n" unless -d $JPL_HOME; |
65 | } |
66 | } |
67 | } |
68 | print "JPL_HOME = $JPL_HOME\n"; |
69 | |
70 | ######################################################################### |
71 | # Spit out setvars. |
72 | |
73 | print "Writing setvars...\n"; |
74 | |
75 | unlink "$JPL_SRC/setvars"; |
76 | open(SETVARS, ">$JPL_HOME/setvars") or die "Can't create setvars: $!\n"; |
77 | while (<DATA>) { |
78 | s/^JPL_SRC=.*/JPL_SRC='$JPL_SRC'/; |
79 | s/^JAVA_HOME=.*/JAVA_HOME='$JAVA_HOME'/; |
80 | s/^JPL_HOME=.*/JPL_HOME='$JPL_HOME'/; |
81 | print SETVARS $_; |
82 | } |
83 | close SETVARS; |
84 | chmod 0755, "$JPL_HOME/setvars"; |
85 | symlink "$JPL_HOME/setvars", "$JPL_SRC/setvars" if $JPL_HOME ne $JPL_SRC; |
86 | |
87 | ######################################################################### |
88 | # Pretend we're make. |
89 | |
90 | eval `./setvars -perl`; # Take our own medicine. |
91 | |
92 | print "\n\nStarting install...\n"; |
93 | |
94 | system <<'END' and die "Couldn't install JPL\n"; |
95 | set -x |
96 | cd JPL |
97 | perl Makefile.PL |
98 | make clean |
99 | perl Makefile.PL |
100 | make install |
101 | END |
102 | |
103 | print "\nInstalling PerlInterpreter class\n"; |
104 | |
105 | system <<'END' and die "Couldn't install PerlInterpreter\n"; |
106 | set -x |
107 | cd PerlInterpreter |
108 | perl Makefile.PL |
109 | make clean |
110 | perl Makefile.PL |
111 | make install |
112 | END |
113 | |
114 | print "\nInstalling JNI module\n"; |
115 | |
116 | system <<'END' and die "Couldn't install JNI\n"; |
117 | set -x |
118 | cd JNI |
119 | perl Makefile.PL |
120 | make clean |
121 | perl Makefile.PL |
122 | make |
123 | echo 'Attempting to install JNI as root' |
124 | su root -c "make install" |
125 | END |
126 | |
127 | #touch Makefile |
128 | #make -f makefile.jv |
129 | ## These should be executed as root |
130 | #rm -rf /usr/lib/perl5/site_perl/i586-linux/auto/JNI |
131 | #rm -rf /usr/lib/perl5/site_perl/auto/JNI |
132 | #rm -f /usr/lib/perl5/site_perl/JNI.pm |
133 | #make -f makefile.jv install UNINST=1 |
134 | |
135 | print "\nInstalling Sample JPL program\n"; |
136 | |
137 | system <<'END' and die "Couldn't install Sample\n"; |
138 | set -x |
139 | cd Sample |
140 | perl Makefile.PL |
141 | make clean |
142 | perl Makefile.PL |
143 | make install |
144 | END |
145 | |
146 | # Test |
147 | print "\n\nTesting Sample...\n"; |
148 | system <<'END' and die "Couldn't run Sample\n"; |
149 | set -x |
150 | cd Sample |
151 | JPLDEBUG=1 |
152 | export JPLDEBUG |
153 | java Sample |
154 | END |
155 | |
156 | __END__ |
157 | #!/bin/sh |
158 | |
159 | # You can edit this, but your changes will only last until the next |
160 | # time you run install-jpl. |
161 | |
162 | # Where jpl is currently installed |
163 | |
164 | cd `dirname $0` |
165 | JPL_SRC=`pwd` |
166 | |
167 | # Where java is installed |
168 | |
169 | JAVA_HOME=/usr/local/java |
170 | export JAVA_HOME |
171 | |
172 | # Where jpl will be installed |
173 | |
174 | JPL_HOME="$JPL_SRC" |
175 | export JPL_HOME |
176 | |
177 | # Which perl to run |
178 | |
179 | JPLPERL=perl`perl -e "print $]"` |
180 | #JPLPERL=perl5.00404 |
181 | export JPLPERL |
182 | |
183 | # Some derivative variables |
184 | archname=`$JPLPERL -MConfig -e 'print $Config{archname}'` |
185 | archlib=`$JPLPERL -MConfig -e 'print $Config{archlib}'` |
186 | |
187 | CLASSPATH=".:$JPL_HOME/lib${CLASSPATH:+:$CLASSPATH}" |
188 | export CLASSPATH |
189 | |
5cf1d1f1 |
190 | ldlibpthname=`$JPLPERL -MConfig -e 'print $Config{ldlibpthname}'` |
191 | case "$ldlibpthname" in |
192 | '') ldlibpthname=LD_LIBRARY_PATH ;; |
193 | esac |
194 | eval "ldlibpth=\$$ldlibpthname" |
195 | |
196 | $ldlibpthname=".:$JPL_HOME/lib/$archname:$archlib/CORE$ldlibpth" |
197 | export $ldlibpthname |
d50cb536 |
198 | |
199 | PERL5LIB="$JPL_HOME/perl${PERL5LIB:+:$PERL5LIB}" |
200 | export PERL5LIB |
201 | |
202 | # Make sure the right java programs are selected. |
203 | PATH="$JAVA_HOME/bin:$PATH" |
204 | export PATH |
205 | |
206 | case "$1" in |
207 | -perl) |
208 | cat <<END |
209 | \$ENV{PATH} = '$PATH'; |
210 | \$ENV{JAVA_HOME} = '$JAVA_HOME'; |
211 | \$ENV{JPL_HOME} = '$JPL_HOME'; |
212 | \$ENV{JPLPERL} = '$JPLPERL'; |
213 | \$ENV{CLASSPATH} = '$CLASSPATH'; |
5cf1d1f1 |
214 | \$ENV{$ldlibpthname} = '$ldlibpth'; |
d50cb536 |
215 | \$ENV{PERL5LIB} = '$PERL5LIB'; |
216 | END |
217 | ;; |
218 | -sh) |
219 | cat <<END |
5cf1d1f1 |
220 | PATH='$PATH';export PATH;JAVA_HOME='$JAVA_HOME';export JAVA_HOME;JPL_HOME='$JPL_HOME';export JPL_HOME;JPLPERL='$JPLPERL';export JPLPERL;CLASSPATH='$CLASSPATH';export CLASSPATH;$ldlibpthname='$ldlibpth';export $ldlibpthname;PERL5LIB='$PERL5LIB';export PERL5LIB |
d50cb536 |
221 | END |
222 | ;; |
223 | -csh) |
224 | cat <<END |
225 | setenv PATH '$PATH'; |
226 | setenv JAVA_HOME '$JAVA_HOME'; |
227 | setenv JPL_HOME '$JPL_HOME'; |
228 | setenv JPLPERL '$JPLPERL'; |
229 | setenv CLASSPATH '$CLASSPATH'; |
5cf1d1f1 |
230 | setenv $ldlibpthname '$ldlibpth'; |
d50cb536 |
231 | setenv PERL5LIB '$PERL5LIB'; |
232 | END |
233 | ;; |
234 | esac |
235 | |