summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-03-04 10:03:28 +0000
committerNorbert Preining <preining@logic.at>2009-03-04 10:03:28 +0000
commitbdb51a42ea462e5bb48c8d2dfb0ff10d1db56cd1 (patch)
tree8c7002789d7d15a91d68c0d020f7f8df67b7f41a
parent65a2860236d1425b90f6121a6e5198028a6d752f (diff)
add "postaction on" using TeXLive::PostAction::$package fucntion, use
it for xetex post action code git-svn-id: svn://tug.org/texlive/branches/branch2009-dev@12306 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/TeXLive/PostAction/xetex.pm125
-rw-r--r--Master/tlpkg/TeXLive/TLPSRC.pm10
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm59
-rw-r--r--Master/tlpkg/tlpsrc/xetex.tlpsrc5
4 files changed, 157 insertions, 42 deletions
diff --git a/Master/tlpkg/TeXLive/PostAction/xetex.pm b/Master/tlpkg/TeXLive/PostAction/xetex.pm
new file mode 100644
index 00000000000..be6da183d12
--- /dev/null
+++ b/Master/tlpkg/TeXLive/PostAction/xetex.pm
@@ -0,0 +1,125 @@
+# $Id$
+# TeXLive::PostAction::xetex.pm - post stuff for xetex
+# Copyright 2008, 2009 Norbert Preining
+# This file is licensed under the GNU General Public License version 2
+# or any later version.
+
+package TeXLive::PostAction::xetex;
+
+BEGIN {
+ use Exporter ();
+ use vars qw( @ISA @EXPORT_OK @EXPORT );
+ @ISA = qw(Exporter);
+ @EXPORT_OK = qw(
+ &post_install
+ &post_remove
+ );
+}
+
+use TeXLive::TLUtils qw(win32 mkdirhier copy conv_to_w32_path log debug info
+ touch tlwarn);
+use TeXLive::TLWinGoo;
+use TeXLive::TLConfig;
+
+my $mainmenu = $TeXLive::TLConfig::WindowsMainMenuName;
+
+# xetex
+#
+sub post_install {
+ my ($texdir, $texdirw, $texmfsysvar) = @_;
+ #
+ # bin-installs font-config related stuff
+ #
+ # new version according to Staszek
+ if (!defined($texdir)) {
+ $texdir = `kpsewhich -var-value=SELFAUTOPARENT`;
+ chomp($texdir);
+ $texdirw = $texdir;
+ }
+ if (!defined($texmfsysvar)) {
+ $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`;
+ chomp($texmfsysvar);
+ }
+ if (-r "$texdir/bin/win32/conf/fonts.conf") {
+ # we have installed w32, so put it into texmfsysvar
+ mkdirhier("$texmfsysvar/fonts");
+ TeXLive::TLUtils::rmtree("$texmfsysvar/fonts/conf");
+ TeXLive::TLUtils::rmtree("$texmfsysvar/fonts/cache");
+ my @cpycmd;
+ if (win32()) {
+ push @cpycmd, "xcopy", "/e", "/i", "/q", "/y";
+ } else {
+ push @cpycmd, "cp", "-R";
+ }
+ system(@cpycmd,
+ (win32() ? conv_to_w32_path("$texdir/bin/win32/conf") :
+ "$texdir/bin/win32/conf"),
+ (win32() ? conv_to_w32_path("$texmfsysvar/fonts/conf") :
+ "$texmfsysvar/fonts/conf"));
+ system(@cpycmd,
+ (win32() ? conv_to_w32_path("$texdir/bin/win32/cache") :
+ "$texdir/bin/win32/cache"),
+ (win32() ? conv_to_w32_path("$texmfsysvar/fonts/cache") :
+ "$texmfsysvar/fonts/cache"));
+ if (open(FONTSCONF, "<$texdir/bin/win32/conf/fonts.conf")) {
+ my @lines = <FONTSCONF>;
+ close(FONTSCONF);
+ if (open(FONTSCONF, ">$texmfsysvar/fonts/conf/fonts.conf")) {
+ my $winfontdir;
+ if (win32()) {
+ $winfontdir = $ENV{'SystemRoot'}.'/fonts';
+ $winfontdir =~ s!\\!/!g;
+ #mkdirhier("$texmfsysvar/fonts/cache");
+
+ # fc-cache breaks often on w32 in some strange way
+ # there are claims that touching a font file in $winfontdir
+ # would solve that problem. So lets touch some of them
+ if (opendir (WINFONT, $winfontdir)) {
+ my @dirents = readdir (WINFONT);
+ closedir (WINFONT) || warn "closedir($winfontdir) failed: $!";
+ # do not actually touch anything by now, maybe already the
+ # opendir is enough ...
+
+ # for my $dirent (@dirents) {
+ # if ($dirent =~ m/\.(ttf|otf)$/i) {
+ # touch("$winfontdir/$dirent");
+ # tlwarn("touching $dirent in $winfontdir to make fc-cache work\n");
+ # # one file touched should be enough
+ # last;
+ # }
+ # }
+ }
+ }
+ foreach (@lines) {
+ $_ =~ s!c:/Program Files/texlive/$TeXLive::TLConfig::ReleaseYear!$texdir!;
+ $_ =~ s!c:/windows/fonts!$winfontdir! if win32();
+ # hack around fc-cache problem in from_dvd case:
+ #if (win32() and (uc($texdir) ne uc($texdirw)) and
+ # ($_ =~ m!^<dir>.*texmf-dist.*</dir>!)) { $_ = '<!-- '.$_.' -->'; }
+ print FONTSCONF;
+ }
+ close(FONTSCONF);
+ } else {
+ warn("Cannot open $texmfsysvar/fonts/conf/fonts.conf for writing\n");
+ }
+ } else {
+ warn("Cannot open $texdir/bin/win32/conf/fonts.conf\n");
+ }
+ }
+ # call fc-cache but only when we install on w32!
+ if (win32()) {
+ info("Running fc-cache -v -r\n");
+ log(`fc-cache -v -r 2>&1`);
+ #system("fc-cache","-v", "-r");
+ }
+}
+
+
+1;
+
+### Local Variables:
+### perl-indent-level: 2
+### tab-width: 2
+### indent-tabs-mode: nil
+### End:
+# vim:set tabstop=2 expandtab: #
diff --git a/Master/tlpkg/TeXLive/TLPSRC.pm b/Master/tlpkg/TeXLive/TLPSRC.pm
index 81d5fa82cfe..0032aa28866 100644
--- a/Master/tlpkg/TeXLive/TLPSRC.pm
+++ b/Master/tlpkg/TeXLive/TLPSRC.pm
@@ -791,9 +791,15 @@ On W32 associates the file type I<name> with the command I<cmd>.
On W32 declares files with the extenstion I<.ext> of file type I<name>.
-=item C<postaction code I<arg>>
+=item C<postaction on>
-TODO TODO I don't know how we want to do that
+If a package wants to use this postaction it has to drop a file named
+C<package.pm> into C<tlpkg/TeXLive/PostActions/>. If that is present
+it has to be a proper perl modules, will be loaded with require, and
+the functions C<post_install> and C<post_remove> of that module will
+be called.
+
+TODO Arguments to the functions have to be specified
=back
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 938158710c9..ce64095390d 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -1250,8 +1250,8 @@ sub do_postaction_code {
$ret &&= _do_postaction_filetype($how, $tlpobj, $1);
} elsif ($pa =~ m/\s*fileassoc\s+(.*)\s*$/) {
$ret &&= _do_postaction_fileassoc($how, $tlpobj, $1);
- } elsif ($pa =~ m/\s*code\s+(.*)\s*$/) {
- $ret &&= _do_postaction_code($how, $tlpobj, $1);
+ } elsif ($pa =~ m/\s*on\s*$/) {
+ $ret &&= _do_postaction_code($how, $tlpobj);
} else {
tlwarn("do_postaction_code: don't know how to do $pa\n");
$ret = 0;
@@ -1332,53 +1332,32 @@ sub _do_postaction_filetype {
return 1;
}
sub _do_postaction_code {
- my ($how, $tlpobj, $pa) = @_;
+ my ($how, $tlpobj) = @_;
warn "_do_postaction_code NOT IMPLEMENTED";
- return 1 unless win32();
- my ($errors, %keyval) =
- parse_into_keywords($pa, qw/install remove file/);
-
- if ($errors) {
- tlwarn("parsing the postaction line >>$pa<< did not succeed!\n");
- return 0;
- }
-
- # install can be an arbitrary string
- if (!defined($keyval{'install'})) {
- tlwarn("install of code postaction not given\n");
- return 0;
- }
- my $installsub = $keyval{'install'};
-
- # remove can be an arbitrary string
- if (!defined($keyval{'remove'})) {
- tlwarn("remove of code postaction not given\n");
- return 0;
- }
- my $removesub = $keyval{'remove'};
-
- # file can be an arbitrary string
- if (!defined($keyval{'file'})) {
- tlwarn("file of code postaction not given\n");
+ return 1;
+ my $n = $tlpobj->name;
+ my $reqline = "require TeXLive::PostAction::$n;";
+ eval { $reqline };
+ if ($@) {
+ tlwarn("Cannot load TeXLive::PostAction::$n\n");
+ tlwarn("Post Action for $n disabled!\n";
return 0;
}
- my $file = $keyval{'file'};
-
- # we should require $file, but catch an error if not present,
- # and then evaluate the $installsub and $removesub.
- #
- # It would be nice to think about to make that a bit safer.
- # Already requiring the file can do anything on the whole computer ...
+ # now we load it again and evaluate the post install/remove code
if ($how eq "install") {
- tlwarn("not implemented\n");
- return 0;
+ $reqline .= " TeXLive::PostAction::$n::post_install();";
} elsif ($how eq "remove") {
- tlwarn("not implemented\n");
- return 0;
+ $reqline .= " TeXLive::PostAction::$n::post_remove();";
} else {
tlwarn("Unknown mode $how\n");
return 0;
}
+ eval { $reqline };
+ if ($@) {
+ # loading has worked, so assume that calling the function did not work
+ tlwarn("Cannot run the function TeXLive::PostAction::$n::post_$how\n");
+ return 0;
+ }
return 1;
}
diff --git a/Master/tlpkg/tlpsrc/xetex.tlpsrc b/Master/tlpkg/tlpsrc/xetex.tlpsrc
index 12300476570..2cc3f697e14 100644
--- a/Master/tlpkg/tlpsrc/xetex.tlpsrc
+++ b/Master/tlpkg/tlpsrc/xetex.tlpsrc
@@ -2,6 +2,11 @@ name xetex
category TLCore
#
execute BuildFormat xetex
+#
+# post actions
+postaction on
+runpattern f tlpkg/TeXLive/PostAction/xetex.pm
+#
runpattern f texmf/fmtutil/format.xetex.cnf
#
# these are only needed for darwin only, so