summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-01-15 22:55:55 +0000
committerKarl Berry <karl@freefriends.org>2011-01-15 22:55:55 +0000
commitbfd95dc36c55d124a75cedff96e3322a71129880 (patch)
tree86a06c62ff79d0217cdc70265e14b7dbd6cde88b /Master/texmf-dist/scripts
parente97b4a47e8f6cf88d0aae0ea02c25b5671964e7b (diff)
fragmaster 1.4 (16jan11)
git-svn-id: svn://tug.org/texlive/trunk@21083 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/fragmaster/fragmaster.pl50
1 files changed, 29 insertions, 21 deletions
diff --git a/Master/texmf-dist/scripts/fragmaster/fragmaster.pl b/Master/texmf-dist/scripts/fragmaster/fragmaster.pl
index efb4c9aa892..9352086362e 100755
--- a/Master/texmf-dist/scripts/fragmaster/fragmaster.pl
+++ b/Master/texmf-dist/scripts/fragmaster/fragmaster.pl
@@ -1,13 +1,17 @@
#!/usr/bin/perl -w
######################################################################
-# $Id: fragmaster.pl,v 1.3 2006/09/26 08:59:30 tvogel Exp $
#
# fragmaster.pl
+#
# creates EPS and PDF graphics from source EPS and control files
# with \psfrag commands
#
+# Version: 1.4
+#
# Copyright (C) 2004 Tilman Vogel <tilman vogel web de> (dot at dot)
+# Copyright (C) 2011 Agustin Martin <agustin martin hispalinux es> (dot at dot)
+# Add compatibility with Windows texlive.
#
# 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
@@ -65,8 +69,14 @@
#
# Karsten Roemke was inspired for his solution by postings from
# Thomas Wimmer.
+# ----------------------------------------------------------------------------
-chomp($cwd = `pwd`);
+use Cwd;
+use File::Temp qw(tempdir);
+# Seems that File::Path module does not provide this function in texlive perl for Windows
+# use File::Path qw(remove_tree);
+
+$cwd = getcwd;
die "Current path contains whitespace. I am sorry, but LaTeX cannot handle this correctly, move somewhere else. Stopped"
if $cwd =~ /\s/;
@@ -80,10 +90,9 @@ foreach $fm_file (<*_fm>) {
next;
}
-
$dest_eps = "$base.eps";
$dest_pdf = "$base.pdf";
-
+
$do_it = 0;
$do_it = 1
@@ -95,25 +104,23 @@ foreach $fm_file (<*_fm>) {
$oldest_dest = -M $dest_eps;
$oldest_dest = -M $dest_pdf
if -M $dest_pdf > $oldest_dest;
-
+
$youngest_source = -M $fm_file;
$youngest_source = -M $source
if -M $source < $youngest_source;
$do_it = 1
if $oldest_dest > $youngest_source;
}
-
+
if( $do_it ) {
print "$fm_file, $source -> $dest_eps, $dest_pdf\n";
open FMFILE, "<$fm_file"
or die "Cannot read $fm_file!";
- $tempdir = `mktemp -d fm-$base.XXXXXX`
+ $tempdir = tempdir( "fm-$base.XXXXXX", CLEANUP => 1, DIR => $cwd )
or die "Cannot make temporary directory!";
- chomp($tempdir);
-
print "using $tempdir/\n";
open TEXFILE, ">$tempdir/fm.tex"
@@ -140,14 +147,13 @@ foreach $fm_file (<*_fm>) {
push @fmhead, "$_%\n";
}
}
-
+
push @fmfile, " $_%\n";
}
print TEXFILE <<"EOF";
\\documentclass[$fmclassopt]{$fmclass}
\\usepackage{graphicx,psfrag,color}
-\\usepackage{german}
EOF
print TEXFILE
foreach(@fmhead);
@@ -183,7 +189,7 @@ EOF
\usebox{\pict}
\end{document}
EOF
-
+
close TEXFILE;
chdir($tempdir)
@@ -196,8 +202,8 @@ EOF
# the psfrag phantom stuff and to set the BoundingBox wrong
system("dvips -E -P pdf fm.dvi -o fm.ps") / 256 == 0
or die "Cannot dvips!";
-
- chdir("..")
+
+ chdir($cwd)
or die "Cannot chdir back up!";
open PS, "<$tempdir/fm.ps"
@@ -219,17 +225,17 @@ EOF
}
print EPS;
}
-
+
# Not using -E above causes
# papersizes to be included into the PS
# Strip off the specifications.
# Otherwise gv doesn't show the BBox
# and epstopdf won't detect the correct
# PDF media size!
-
+
# while(<PS>) {
# s/^%!PS-Adobe.*/%!PS-Adobe-3.0 EPSF-3.0/;
-
+
# next if /^\%\%DocumentPaperSizes:/;
# if(/^\%\%BeginPaperSize:/) {
# while(<PS>) {
@@ -248,12 +254,14 @@ EOF
system("epstopdf $dest_eps --outfile=$dest_pdf") / 256 == 0
or die "Cannot epstopdf!";
- system("rm -rf $tempdir") / 256 == 0
- or die "Cannot remove $tempdir!";
+ unlink <$tempdir/*>
+ or die "Cannot remove $tempdir! contents\n";
+ rmdir $tempdir
+ or die "Cannot remove $tempdir!\n";
close FMFILE;
-
-
+
+
}
}