File: install-test

package info (click to toggle)
latex2html 98.1-pre2-b6-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,880 kB
  • ctags: 2,808
  • sloc: perl: 34,603; makefile: 690; sh: 107
file content (397 lines) | stat: -rwxr-xr-x 12,131 bytes parent folder | download
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
#!/usr/bin/perl

# $Id: install-test,v 1.16 1998/06/21 17:28:12 MRO Exp $
# LaTeX2HTML Version 98.1 : install-test

$dd = '/';  # directory delimiter;

# This perl script substitutes the variable $LATEX2HTMLDIR in the main
# latex2html script with the actual path to the latex2html distribution 
# files. It then tests for the availability of the external support programs.

# To do the installation manually:
# (1) Edit the file latex2html.config to set the correct pathnames where 
#     necessary
# (2) Put the path to the latex2html source files in the variable 
#     $LATEX2HTMLDIR in the main latex2html script 
#     OR
#     set an environment variable LATEX2HTMLDIR to point to the latex2html 
#     source files.
 
# Added for Debian
if ($ENV{'LATEX2HTMLDIR'}) { $LATEX2HTMLDIR = $ENV{'LATEX2HTMLDIR'}; }

# 
use lib '/usr/lib/latex2html/';
use AnyDBM_File;
use Override qw($DEBUG getpwuid link setenv getenv symlink rename
		getcwd syswait find_executable
		substitute_var_val $LATEX2HTMLDIR $TEMPDIR
		make_directory_absolute unlink $dd $envkey $image_pre);


print<<"#EOM";

This is install-test for LaTeX2HTML V98.1
=========================================

#EOM
;




# first, assure this
open(TMP,">TEST.TMP") ||
    die "I need a writeable directory: open TEST.TMP failed: $!\n";
close TMP;
unlink "TEST.TMP";

if (! $ENV{'LATEX2HTMLDIR'}){
# Read /etc/latex2html.config to get the value of $LATEX2HTML
 open(TMP,"</etc/latex2html.config") ||
    die "Cannot open /etc/latex2html.config!\n";
while (<TMP>) {
    if (/^\s*\$LATEX2HTMLDIR\s*=(.*)$/) {
	$LATEX2HTMLDIR = eval($1);
	last;
    }
}
close TMP;
}

if ($LATEX2HTMLDIR eq "/user" || !$LATEX2HTMLDIR) {
    print <<"#EOM";
\$LATEX2HTMLDIR of latex2html.config is not set up, we can do this now.
\$LATEX2HTMLDIR will be used to host the release of LaTeX2HTML you unpacked
and is defined at the top of latex2html.config.
Before we continue, make sure that everything of LaTeX2HTML is there and that
you are *in* that directory.

Note: the latex2html script itself need not reside here, you can place it
elsewhere (e.g. in /usr/local/bin ) after install-test completes successfully.
#EOM
;

#    local($pwd) = `pwd`; chop $pwd;
    local($pwd) = &getcwd();
    print "\nWhat is the LaTeX2HTML directory?\n [$pwd]: ";
    $_ = <STDIN>; chop;
    if (/(\S+)/) {
	$LATEX2HTMLDIR = $1;
    }
    else {
	$LATEX2HTMLDIR = $pwd;
        $LATEX2HTMLDIR =~ s/\\/${dd}/g;
    }
    print "\$LATEX2HTMLDIR will be \"$LATEX2HTMLDIR\"\n";

    print "changing LaTeX2HTML directory in latex2html.config was " .
	(&substitute_dir_var(0,"latex2html.config") ? "" : "not ") .
	    "successful.\n";
}


# Require contents of latex2html.config.
&read_config_file;


# Substitute the variable $LATEX2HTMLDIR
print STDERR "\nMain script installation was... ";
print STDERR (&substitute_dir_var(-1,"latex2html") ? "" : "not ")
	. "successful.\n";

if (&find_executable('kpsewhich')) {
#    &substitute_var_val("latex2html.config", Web2C, 1);
    &substitute_var_val("latex2html.config"
	, "^\\\s*\\\$Web2C\\\s*=.*\$", "\$Web2C = 1;");
    print "Web2C found, using it\n";
}

if ($^O =~ MSWin32) {
    print "Specific Win32 configuration...\n";
#    &substitute_var_val("latex2html.config", NOFORK, 1)
    &substitute_var_val("latex2html.config"
	, "^\\\s*\\\$NOFORK\\\s*=.*\$", "\$NOFORK = 1;")
	|| print "\$NOFORK not found\n";
# These are perl scripts and under Win32 ;
# ... so  perl  must be called explicitly
    &substitute_var_val("latex2html.config", "^\\\$PSTOIMG\\\s*=.*\$",
                       "\$PSTOIMG = \"perl \$LATEX2HTMLDIR${dd}pstoimg\"; ");
    &substitute_var_val("latex2html.config", "^\\\$TEXEXPAND\\\s*=.*\$",
                       "\$TEXEXPAND = \"perl \$LATEX2HTMLDIR${dd}texexpand\"; ");
}

print "Testing availability of external programs...\n";
&test_external_programs;


sub read_config_file {
    &deal_with_forward_references;
    require("latex2html.config") if
	((-f "latex2html.config") ||
	 die "Could not find file latex2html.config\n");
}

# Changes lines of the form:
# $LATEX2HTMLDIR = <SOMETHING> 
# to
# $LATEX2HTMLDIR = <current value of $LATEX2HTMLDIR> 
# Running this on a Debian system means that latex2html.config and
# latex2html are in different locations. We hack that in here.
sub substitute_dir_var {
  local($SUCCESS, $file) = @_;

  # Added for Debian.
  my $filename = "$LATEX2HTMLDIR${dd}$file";
  if ($file =~ m/^latex2html.config$/o) {
    $filename = "/etc/latex2html.config" unless $ENV{'LATEX2HTMLDIR'};
  }
  if ($file =~ m/^latex2html$/o) {
    $filename = "/usr/bin/latex2html" unless $ENV{'LATEX2HTMLDIR'};
  }
  if ( (-f "$filename") ||
       die "\nCannot find $filename\nPlease check the value of \$LATEX2HTMLDIR in latex2html.config\n") {
    rename("$filename","$filename.bak") || die "Cannot rename $filename: $!";
    open(IN, "<$filename.bak")  || die "Cannot open $filename.bak: $!";
    open(OUT, ">$filename")        || die "Cannot open $filename: $!";
    chmod(0755, "$filename")    if -x "$filename.bak";
    
    while (<IN>) {
      #	    s/\$LATEX2HTMLDIR\s*=.*$/
      #		do {$SUCCESS = 1;
      #		    "\$LATEX2HTMLDIR='$LATEX2HTMLDIR';"
      s/^\s*(\$LATEX2HTMLDIR\s*=|use lib ).*$/
	do {$SUCCESS += 1; print STDERR $SUCCESS." ";
	    (($1 =~ m|use lib|)? "use lib \"$LATEX2HTMLDIR\";"
	     : "\$LATEX2HTMLDIR='$LATEX2HTMLDIR';")
	      . " # Inserted by installation script"}/eg;
      print OUT;
    }
    close IN;
    close OUT;
  }
  print STDERR "...";
  $SUCCESS;
}

sub ask_n {
  my $answer;
  print @_,"? [No] ";
  $answer=<STDIN>;
  return ( $answer =~ /^\s*[yY].*/ );
}

sub ask_y {
  my $answer;
  print @_,"? [Yes] ";
  $answer=<STDIN>;
  return ( $answer !~ /^\s*[Nn].*/ );
}
 

sub deal_with_forward_references {
    foreach ("ignore_commands", "process_commands_in_tex") {
	eval "sub $_ {}"}
}

sub test_external_programs {
    local ($nolatex2html, $version, $revision, $nopic, $nojust, $tmp) = (0,0);
    # Perl
    $ver = $] * 1.0;
    $vers = sprintf("%4.3f", $ver);
    if ($ver < 5.000) {
	print "\n*** ERROR: You are using Perl version $vers\n".
	    "\nThis may cause problems." .
		"Please upgrade to version 5 at patch level 3 or higher\n";}
    elsif ($ver < 5.003) {print "Perl version $vers is OK for most things. \n"
	    ."However upgrading to v5.003 or later is advisable.\n"}
    else {print "Perl version $vers is OK. \n"}

#    $nolatex2html = &look_for($TEXEXPAND, "exec", "texexpand");
    $nolatex2html = &look_for($TEXEXPAND, "perl", "texexpand");
    if ($nolatex2html) {
	print "\n*** ERROR: Will not be able to run latex2html: ".
	    "Cannot find texexpand.\n"}
    else {
	print STDERR "Setting up texexpand script...";
	print STDERR (&substitute_dir_var(0,"texexpand") ? "succeeded\n" : "\n*failed*\n");
    }
#           if ($nolatex2html = &look_for($TEXEXPAND, "perl", "texexpand"));

    print "Checking for availability of DBM or NDBM (Unix DataBase Management)...\n";
    if ((! eval 'dbmopen(%array, "DBM.tst",0755)') && $@) {
        print "*** ERROR: $@ \nYou will not be able to use latex2html.\n";
    } else {
#JCL: we do not need to write sth into it, if Perl lacks DBM we
# detected it with dbmopen before...
	dbmclose(%array);
	print "DBM was found.\n";
    }
    unlink ('DBM.tst.dir', 'DBM.tst.pag');

    print "Checking if globbing works... ";
    open(TMP,">TEST1.TMP"); close TMP;
    open(TMP,">TEST2.TMP"); close TMP;
    local(@list) = (<TEST*.TMP>);
    if ($#list == 1) {
	print "globbing is ok.\n";
    }
    else {
	print "globbing failed.\n";
	print "LaTeX2HTML will *not* work.\n";
	print "checking what's wrong...\n";
	# Perl uses full_csh to perform globbing, this may change of course
	local($csh) = eval('require "Config.pm"; &Config::FETCH("","full_csh")');
	if ($csh) {
	    print "your csh is $csh\n";
	    if (! -f $csh) {
		print "$csh does not exist!\n";
		print "Find the csh or tcsh on your system and link it to $csh.\n";
		die "Then restart install-test.\n";
	    }
	    elsif (! -x $csh) {
		die "$csh is not executable!\n";
	    }
	    else {
		print "$csh exists and is executable... I can't help here.\n";
		print "Maybe you should continue and check LaTeX2HTML by translating the manual.\n";
		print "Continue?\n";
		<STDIN>;
	    }
	}
	else {
	    print "I can't help with that Perl version.\n";
	    print "You need more detailed advise on what went wrong here.\n";
	    print "Continue?\n";
	    <STDIN>;
	}
    }
    unlink("TEST1.TMP","TEST2.TMP");

    $version=undef;
    $_ = &get_first_line_of_stderr("$DVIPS -f DUMMY");
    s/dvips(k|\(k\))?\s*([\d\.]+)/$version = $2;/eo;
    $patch = $version;
    if ($patch && ($patch < 5.516)) {
	$nopic = 1;
	print "\n*** Warning: You are using DVIPS $version.".
	    "\nThis may cause problems when generating inlined images" .
		"\nif your DVIPS does not support the command line options".
		    "\n-S, -i and -o".
			"\nSee the manual for more details.\n";}
    elsif (! $patch) {
        print "Warning:  I was not able to find DVIPS. ".
	    "\nPlease make sure that your version of DVIPS".
		"\nsupports the command line options -S, -i and -o.".
		    "\nVersion 5.516 or higher is OK.".
			"\nI was unable to verify your version.\n";}
    else {
	print "DVIPS version $version is OK.\n"
    }

    $nopic = &look_for($PSTOIMG,"perl", "pstoimg");

# Substitute the variable $LATEX2HTMLDIR in pstoimg
    if (!$nopic) {
	print "Setting up pstoimg script...";
	print (&substitute_dir_var(-1,"pstoimg") ? "succeeded\n" : "\n*failed*\n");
	print "Setting up configure-pstoimg script...";
	print (&substitute_dir_var(0,"configure-pstoimg") ? "succeeded\n" : "\n*failed*\n");
    }

    $tmp = &look_for($LATEX, "util", $LATEX);
    $nopic = $tmp unless $nopic;

    print "Warning: May not be able to convert equations, figures, tables ".
	"\nand unknown environments to inlined images.\n" if $nopic;

    print "Warning: Will not be able to deal with some style files.\n"
	if &look_for($LATEX2HTMLSTYLES, "dir", "Styles directory");

    print "\nMain set-up done.\n";

    unless ($nopic) {
	print "You may complete this set-up by configuring pstoimg now...proceed?\n";
	<STDIN>;
	require "configure-pstoimg";
    }
}

sub look_for {
    local($what,$type, $name) = @_;
    local($fail,$_);
    if (($type eq "exec") && (! -x $what)) {
	print "Making $what executable...\n";
	chmod 0755, $what;
	if (! -x $what) {
	    $fail = "Error: Could not make $what executable.\n";
	}
    }
    elsif ($type eq "perl") {
       if (! ($what =~ m"^perl\s+([\w:\\/-]*)")) {
           if (! -f $what) {
               $fail = "Error: Could not find $what perl script.\n";
           }
           else {
               $what = "perl $what";
           }
       }
       elsif (! -f $1) {
           $fail = "Error: Could not find $1 perl script.\n";
       }
    }
    elsif (($type eq "util") && (! -f $what)) {
	print "Looking for $name...\n";
#	$_ = `sh -c "type  $what"`;
#	chop;
#	if ((/no /) || (/not found/) || (/^\s*$/)) {
#	    $fail = "Warning: $name was * NOT * found.\n";}
        if ($^O =~ MSWin32) {
            $what = &find_executable($what);
        } else {
            $_ = `sh -c "type  $what"`;
            chop;
            if ((/no /) || (/not found/) || (/^\s*$/)) {
                $fail = "Warning: $name was * NOT * found.\n";
            } else {
               $what = $_;
            }
        }
    }
    elsif (($type eq "dir") && (! -d $what)) {
	$fail = "Error: directory $name was * NOT * found.\n";
    }
    ($fail ? print $fail : print "$name was found.\n");
    $fail;
}	

# Page 164 of the Camel book.     
sub get_first_line_of_stderr {
    local($prog) = @_[0];
    open(SO, ">&STDOUT");
    open(SE, ">&STDERR");

    open(STDOUT, ">${dd}tmp${dd}foo$$");
    open(STDOUT, ">${TEMPDIR}${dd}foo$$");
    open(STDERR,">&STDOUT");

    select(STDERR); $| = 1;
    select(STDOUT); $| = 1;

    `$prog`;

    close(STDOUT);
    close(STDERR);

    open(STDOUT, ">&SO");
    open(STDERR, ">&SE");

    open(FOO,"<${dd}tmp${dd}foo$$");
    open(FOO,"<${TEMPDIR}${dd}foo$$");
    $_ = <FOO> ;
    close(FOO);
    $_;
}