diff options
author | Karl Berry <karl@freefriends.org> | 2007-10-16 20:21:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-10-16 20:21:43 +0000 |
commit | 08f7e8fde76a02f596b9dadce0a7e9acc28bba7f (patch) | |
tree | 2c660b31249d0a196c89538752d49cd7055e51ab | |
parent | b83538b157f381dbacfd8906a1f7377dbbf32dde (diff) |
update updmap
git-svn-id: svn://tug.org/texlive/trunk@5211 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/tlpkg/bin/tlpdb2updmap | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/tlpdb2updmap b/Master/tlpkg/bin/tlpdb2updmap new file mode 100755 index 00000000000..8bdac0d4c5f --- /dev/null +++ b/Master/tlpkg/bin/tlpdb2updmap @@ -0,0 +1,154 @@ +#!/usr/bin/env perl +# $Id: tlpdb2list 5188 2007-10-14 20:32:44Z karl $ +# Copyright 2007 Karl Berry. +# This file is licensed under the GNU General Public License version 2 +# or any later version. +# +# Update the map files in updmap.cfg from tlpdb -- a convenience, since +# the only other way to enable new maps is to do an install. (updmap +# --syncwithtrees disables old maps, but does not enable new.) + +BEGIN { + $^W = 1; + ($mydir = $0) =~ s,/[^/]*$,,; + unshift (@INC, "$mydir/.."); +} + +use strict; + +use TeXLive::TLPOBJ; +use TeXLive::TLPDB; +use Getopt::Long; +use Pod::Usage; +use File::Path; + +our $NEW_UPDMAP_CFG; + +our $mydir; +our $opt_debug = 0; +my $man = 0; +my $help = 0; + +GetOptions("debug!", "help|?" => \$help, "man" => \$man) or pod2usage(2); + +pod2usage(1) if $help; +pod2usage(-exitstatus => 0, -verbose => 2) if $man; + +exit (&main ()); + +sub main +{ + # get the db. + chomp (my $Master = `cd $mydir/../.. && pwd`); # xx TLPDB should default + my $tlpdb_path = "$Master/texlive.tlpdb"; + my $tlpdb = TeXLive::TLPDB->new ("location" => $tlpdb_path); + + # get list of packages. + my %maps; + for my $pkg ($tlpdb->list_packages) { + my $obj = $tlpdb->get_package ($pkg); + die "$0: no TeX Live package named $pkg in $tlpdb_path.\n" if ! $obj; + + # record any maps. + my @executes = $obj->executes; + for (my $e = 0; $e < @executes; $e++) { + my ($action,$value) = split (" ", $executes[$e]); + if ($action =~ /add.*Map/) { + $maps{$action} .= " " if exists $maps{$action}; + $maps{$action} .= $value; + } + } + } + + return &update_updmap_cfg ($Master, %maps); +} + + + +# update updmap.cfg per MAPS. +# +sub update_updmap_cfg +{ + my ($Master, %maps) = @_; + + # read old file. + my $UPDMAP_CFG = "$Master/texmf/web2c/updmap.cfg"; + my @updmap = `cat $UPDMAP_CFG`; + + # find last comment line (which is where the maps start). + my $last_comment; + for ($last_comment = $#updmap; $last_comment >= 0; $last_comment--) { + last if $updmap[$last_comment] =~ /^#/; + } + die "no last comment in $UPDMAP_CFG?!" if $last_comment < 0; + + # write new file. + local *NEW_UPDMAP_CFG; + my $new_updmap_cfg = "$UPDMAP_CFG.new"; # just the filename + $NEW_UPDMAP_CFG = ">$new_updmap_cfg"; # for open + open (NEW_UPDMAP_CFG) || die "open($NEW_UPDMAP_CFG) failed: $!"; + + # first copy everything up to and including the last comment. + for (my $i = 0; $i <= $last_comment; $i++) { + print NEW_UPDMAP_CFG $updmap[$i]; + } + + # add our map lines, preserving alphabetical order. + for my $action (sort keys %maps) { + my @maps = split (/ /, $maps{$action}); + (my $key = $action) =~ s/^add//; # addMap in tlp, Map in updmap.cfg + @maps = map { "$key $_\n" } sort @maps; + print NEW_UPDMAP_CFG @maps; + } + close (NEW_UPDMAP_CFG) || warn "close($NEW_UPDMAP_CFG) failed: $!"; + + # show differences. + print `diff $UPDMAP_CFG $new_updmap_cfg`; + return $?; +} + +__END__ + +=head1 NAME + +tlpdb2updmap - update updmap.cfg from a TeX Live database + +=head1 SYNOPSIS + +tlpdb2updmap [OPTION]... + +=head1 OPTIONS + +The standard options C<-help>, C<-debug>, and C<-man> are accepted. +See the tlpfiles documentation for details. + +=head1 DESCRIPTION + +B<tlpdb2updmap> creates an updated C<updmap.cfg> file in a TL tree with +the C<Map> and C<MixedMap> entries in the TL database. + +C<updmap.cfg> is assumed to be found in +C<Master/texmf/web2c/updmap.cfg>, where C<Master/> is C<../..> of +C<$0>. + +The new file is written to C<updmap.cfg.new> in that same directory, if +there are any changes. A diff is also shown, and the exit status is one. + +Exit status is zero if no differences. + +No repository actions are performed in any case. + +=head1 AUTHORS AND COPYRIGHT + +This script and its documentation were written for the TeX Live +distribution (L<http://tug.org/texlive>) and both are licensed under the +GNU General Public License Version 2 or later. + +=cut + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2: # |