version 1.8, 2002/08/12 16:20:40
|
version 1.20, 2018/11/01 03:31:21
|
Line 27
|
Line 27
|
|
|
use strict; |
use strict; |
use Fcntl; |
use Fcntl; |
use POSIX qw(tmpnam); |
use File::Temp; |
|
|
if ( scalar(@ARGV) < 2 ) |
if ( scalar(@ARGV) < 2 ) |
{ |
{ |
print (<<USAGE); |
print (<<USAGE); |
Usage: $0 texxml_file_name or |
Usage: $0 texxml_file_name or |
perl $0 -- texxml_file_name |
perl $0 -- texxml_file_name [epssource] [--with-filenames] |
where "texxml_file_name" optionally includes the extension |
where "texxml_file_name" optionally includes the extension |
Output: texxml_file_name.dvi |
Output: texxml_file_name.dvi |
|
|
Line 46 If a second argument is passed, it is us
|
Line 46 If a second argument is passed, it is us
|
|
|
Must be run as somebody with permissions to write temp files and |
Must be run as somebody with permissions to write temp files and |
access /home/httpd/html/adm/help/eps. |
access /home/httpd/html/adm/help/eps. |
|
|
|
If thre is a second argument, it will be used as the path to the |
|
eps files, otherwise "../../loncom/html/adm/help/eps" is used. |
|
|
|
If the optional argument --with-filenames is included then |
|
the filename for each fragment is stuck into the finished file. |
USAGE |
USAGE |
|
|
exit(); |
exit(); |
} |
} |
|
|
my $tmpdir = tmpnam(); |
my $tmpdir = File::Temp::tempdir(); |
my $fileroot = $ARGV[1]; |
my $fileroot = $ARGV[1]; |
|
|
if (substr($fileroot, -7) eq ".texxml") |
if (substr($fileroot, -7) eq ".texxml") |
Line 59 if (substr($fileroot, -7) eq ".texxml")
|
Line 65 if (substr($fileroot, -7) eq ".texxml")
|
$fileroot = substr($fileroot, 0, -7); |
$fileroot = substr($fileroot, 0, -7); |
} |
} |
|
|
if ( -e "$fileroot.pdf" ) |
my $epssource = "../../loncom/html/adm/help/eps"; |
{ |
# override eps source, for build on install |
print "$fileroot already built.\n"; |
if ( $ARGV[2] && $ARGV[2] ne '--with-filenames') { |
exit(); |
$epssource = $ARGV[2]; |
} |
} |
|
|
my $epssource = "/home/httpd/html/adm/help/eps"; |
my $include_filenames=''; |
|
if ( $ARGV[2] eq '--with-filenames' || $ARGV[3] eq '--with-filenames') { |
if ( defined ( $ARGV[2] ) ) # override eps source, for build on install |
$include_filenames='--with-filenames'; |
{ |
|
$epssource = $ARGV[2]; |
|
} |
} |
|
|
my $redir = ">& /dev/null"; # empty this for easier debugging |
#my $redir = ">& /dev/null"; # empty this for easier debugging |
#$redir = ">> /home/jerf/work/loncapa/doc/help/error_log.txt"; |
my $redir = "~/error_log.txt"; |
|
system("rm -f $redir"); |
|
$redir=">> $redir"; |
|
|
mkdir $tmpdir, 0755; |
mkdir $tmpdir, 0755; |
|
|
print "Converting texxml to tex...\n"; |
print "Converting texxml to tex...\n"; |
system ( "perl texxml2latex.pl $fileroot.texxml > $tmpdir/$fileroot.tex" ); |
if (system ( "perl texxml2latex.pl $fileroot.texxml $include_filenames > $tmpdir/$fileroot.tex" )) { |
|
$! = 1; |
|
die "Terminated render because texxml2latex failed; see previous error message."; |
|
}; |
|
|
print "Copying .eps files...\n"; |
print "Copying .eps files...\n"; |
system ( "cp $epssource/* $tmpdir/" ); |
system ( "cp $epssource/* $tmpdir/" ); |
|
|
print "Running Latex...\n"; |
print "Running Latex...\n"; |
system ( "cd $tmpdir; echo | latex $fileroot $redir; echo | latex $fileroot $redir; echo | latex $fileroot\ $redir; " ); |
system ( "cd $tmpdir; echo | latex $fileroot $redir; echo | latex $fileroot $redir; makeindex $fileroot.idx; echo | latex $fileroot\ $redir; " ); |
|
|
print "Running dvips...\n"; |
print "Running dvips...\n"; |
system ( "cd $tmpdir; dvips -f $fileroot.dvi > $fileroot.ps " ); |
system ( "cd $tmpdir; dvips -Ppdf -G0 -f $fileroot.dvi > $fileroot.ps " ); |
|
|
print "Copying ps file...\n"; |
print "Copying ps file...\n"; |
system ( "cp $tmpdir/$fileroot.ps ."); |
system ( "cp $tmpdir/$fileroot.ps ."); |
Line 95 system ( "cp $tmpdir/$fileroot.ps .");
|
Line 104 system ( "cp $tmpdir/$fileroot.ps .");
|
print "Converting to PDF (may take a bit)...\n"; |
print "Converting to PDF (may take a bit)...\n"; |
system ( "ps2pdf $fileroot.ps $fileroot.pdf" ); |
system ( "ps2pdf $fileroot.ps $fileroot.pdf" ); |
|
|
|
print "Rescuing log and tex file for debugging ...\n"; |
|
system ("cp $tmpdir/$fileroot.log ."); |
|
system ("cp $tmpdir/$fileroot.tex ."); |
|
|
print "Clearing temp directory...\n"; |
print "Clearing temp directory...\n"; |
system ( "rm -rf $tmpdir" ); |
system ( "rm -rf $tmpdir" ); |
|
|
Line 104 if ( -e $fileroot . ".ps" )
|
Line 117 if ( -e $fileroot . ".ps" )
|
} |
} |
else |
else |
{ |
{ |
print "Generationr of $fileroot.ps failed.\n"; |
print "Generation of $fileroot.ps failed.\n"; |
} |
} |