summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2011-09-09 04:12:16 +0000
committerNorbert Preining <preining@logic.at>2011-09-09 04:12:16 +0000
commit427f461ad77c4c41d9b7bbac351660fe31d09908 (patch)
tree06b2de9a1ad6ed45b6d0d195e31c63b4302857c6 /Master
parentd3d956339fe18d53d73e965195951c30c92b3673 (diff)
multi-updmap: again use the function from TLUtils
git-svn-id: svn://tug.org/texlive/trunk@23881 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/dev/multi-updmap.pl169
1 files changed, 23 insertions, 146 deletions
diff --git a/Master/tlpkg/dev/multi-updmap.pl b/Master/tlpkg/dev/multi-updmap.pl
index 9b71119bc3a..3eaf858438e 100644
--- a/Master/tlpkg/dev/multi-updmap.pl
+++ b/Master/tlpkg/dev/multi-updmap.pl
@@ -13,23 +13,34 @@
# Anyone may freely use, modify, and/or distribute this file, without
# limitation.
#
+# TODO
+# - either work on all enable and disable options together, or disallow
+# specifying both!
+# - implement a decent --dry-run
+
+my $TEXMFROOT;
+
+BEGIN {
+ $^W=1;
+ $TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`;
+ if ($?) {
+ print STDERR "updmap: Cannot find TEXMFROOT, aborting!\n";
+ exit 1;
+ }
+ chomp($TEXMFROOT);
+ unshift (@INC, "$TEXMFROOT/tlpkg");
+}
-$^W=1;
-use strict;
my $version = '$Id$';
+
use Getopt::Long qw(:config no_autoabbrev ignore_case_always);
+use strict;
+use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename sort_uniq member);
-my ($TEXMFROOT, $TEXMFMAIN, $TEXMFVAR, $TEXMFCONFIG);
-$TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`;
-if ($?) {
- print STDERR "updmap: Cannot find TEXMFROOT, aborting!\n";
- exit 1;
-}
-chomp($TEXMFROOT);
-chomp($TEXMFMAIN =`kpsewhich --var-value=TEXMFMAIN`);
-chomp($TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`);
-chomp($TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
+chomp(my $TEXMFMAIN =`kpsewhich --var-value=TEXMFMAIN`);
+chomp(my $TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`);
+chomp(my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
my $prg = basename($0);
@@ -155,7 +166,6 @@ sub main {
# TEXMFHOME or TEXMFCONFIG (which is TEXMFSYSCONFIG in the -sys case)
# then use the *top* file (which will be either one of the two),
# if none of the two exists, create a file in TEXMFCONFIG and use it
- chomp(my $TEXMFHOME = `kpsewhich -var-value=TEXMFHOME`);
my $use_top = 0;
for my $f (@used_files) {
if ($f =~ m!($TEXMFHOME|$TEXMFCONFIG)/web2c/updmap.cfg!) {
@@ -1667,139 +1677,6 @@ EOF
exit 0;
}
-#############################################
-#
-# Utilities from TeXLive::TLUtils, we want to be self contained
-#
-sub win32
-{
- if ($^O=~/^MSWin(32|64)$/i) {
- return 1;
- } else {
- return 0;
- }
- # the following needs config.guess, which is quite bad ...
- # return (&platform eq "win32")? 1:0;
-}
-
-sub mkdirhier {
- my ($tree,$mode) = @_;
-
- return if (-d "$tree");
- my $subdir = "";
- # win32 is special as usual: we need to separate //servername/ part
- # from the UNC path, since (! -d //servername/) tests true
- $subdir = $& if ( win32() && ($tree =~ s!^//[^/]+/!!) );
-
- my @dirs = split (/\//, $tree);
- for my $dir (@dirs) {
- $subdir .= "$dir/";
- if (! -d $subdir) {
- if (defined $mode) {
- mkdir ($subdir, $mode)
- || die "$0: mkdir($subdir,$mode) failed, goodbye: $!\n";
- } else {
- mkdir ($subdir) || die "$0: mkdir($subdir) failed, goodbye: $!\n";
- }
- }
- }
-}
-
-sub mktexupd {
- my %files;
- my $mustexist=0;
-
- my $hash={
- "add" => sub {
- foreach my $file (@_) {
- $file =~ s|\\|/|g;
- $files{$file}=1;
- }
- },
- # "reset" => sub {
- # %files=();
- # },
- "mustexist" => sub {
- $mustexist=shift;
- },
- "exec" => sub {
- # check whether files exist
- if ($mustexist) {
- foreach my $file (keys %files) {
- die "File \"$file\" doesn't exist.\n" if (! -f $file);
- }
- }
- my $delim= (&win32)? ';' : ':';
- my $TEXMFDBS;
- chomp($TEXMFDBS=`kpsewhich --show-path="ls-R"`);
-
- my @texmfdbs=split ($delim, "$TEXMFDBS");
- my %dbs;
-
- foreach my $path (keys %files) {
- foreach my $db (@texmfdbs) {
- $db=substr($db, -1) if ($db=~m|/$|); # strip leading /
- if (substr($path, 0, length("$db/")) eq "$db/") {
- # we appended a / because otherwise "texmf" is recognized as a
- # substring of "texmf-dist".
- my $path='./' . substr($path, length("$db/"));
- my ($dir, $file);
- $_=$path;
- ($dir, $file) = m|(.*)/(.*)|;
- $dbs{$db}{$dir}{$file}=1;
- }
- }
- }
- foreach my $db (keys %dbs) {
- if (! -f "$db" || ! -w "$db/ls-R") {
- &mkdirhier ($db);
- }
- open LSR, ">>$db/ls-R";
- foreach my $dir (keys %{$dbs{$db}}) {
- print LSR "\n$dir:\n";
- foreach my $file (keys %{$dbs{$db}{$dir}}) {
- print LSR "$file\n";
- }
- }
- close LSR;
- }
- }
- };
- return $hash;
-}
-
-sub basename {
- my $path=shift;
- if (win32) {
- $path=~s!\\!/!g;
- }
- if ($path=~m!/!) { # basename("foo/bar") -> "bar"
- $path=~m!.*/(.*)!;
- return $1;
- } else { # basename("ignore") -> "ignore"
- return $path;
- }
-}
-
-sub member {
- my $what = shift;
- return scalar grep($_ eq $what, @_);
-}
-
-sub sort_uniq {
- my (@l) = @_;
- my ($e, $f, @r);
- $f = "";
- @l = sort(@l);
- foreach $e (@l) {
- if ($e ne $f) {
- $f = $e;
- push @r, $e;
- }
- }
- return @r;
-}
-
### Local Variables:
### perl-indent-level: 2
### tab-width: 2