$NetBSD: patch-bin_updmap,v 1.4 2013/11/17 17:15:43 minskim Exp $

--- bin/updmap.orig	2013-10-07 22:58:25.000000000 +0000
+++ bin/updmap
@@ -3,5 +3,5 @@
 # updmap - maintain map files for outline fonts.
 # (Maintained in TeX Live:Master/texmf-dist/scripts/texlive.)
-# 
+#
 # Copyright 2011, 2012, 2013 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
@@ -24,5 +24,5 @@ my $TEXMFROOT;
 BEGIN {
   $^W=1;
-  $TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`;
+  $TEXMFROOT = `@KPSEWHICH@ -var-value=TEXMFROOT`;
   if ($?) {
     print STDERR "updmap: Cannot find TEXMFROOT, aborting!\n";
@@ -38,5 +38,5 @@ my $version = '$Id: updmap.pl 31853 2013
 use Getopt::Long qw(:config no_autoabbrev ignore_case_always);
 use strict;
-use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename dirname 
+use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename dirname
   sort_uniq member touch);
 
@@ -51,10 +51,10 @@ use TeXLive::TLUtils qw(mkdirhier mktexu
 reset_root_home();
 
-chomp(my $TEXMFDIST = `kpsewhich --var-value=TEXMFDIST`);
-chomp(my $TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`);
-chomp(my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`);
-chomp(my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
-chomp(my $TEXMFSYSCONFIG = `kpsewhich -var-value=TEXMFSYSCONFIG`);
-chomp(my $TEXMFHOME = `kpsewhich -var-value=TEXMFHOME`);
+chomp(my $TEXMFDIST = `@KPSEWHICH@ --var-value=TEXMFDIST`);
+chomp(my $TEXMFVAR = `@KPSEWHICH@ -var-value=TEXMFVAR`);
+chomp(my $TEXMFSYSVAR = `@KPSEWHICH@ -var-value=TEXMFSYSVAR`);
+chomp(my $TEXMFCONFIG = `@KPSEWHICH@ -var-value=TEXMFCONFIG`);
+chomp(my $TEXMFSYSCONFIG = `@KPSEWHICH@ -var-value=TEXMFSYSCONFIG`);
+chomp(my $TEXMFHOME = `@KPSEWHICH@ -var-value=TEXMFHOME`);
 
 # make sure that on windows *everything* is in lower case for comparison
@@ -80,6 +80,6 @@ my @cmdline_options = (
   "sys",
   "listfiles",
-  "cnffile=s@", 
-  "copy", 
+  "cnffile=s@",
+  "copy",
   "disable=s@",
   "dvipdfmoutputdir=s",
@@ -191,5 +191,5 @@ sub main {
     exit 0;
   }
- 
+
   if ($opts{'showoptions'}) {
     for my $o (@{$opts{'showoptions'}}) {
@@ -231,5 +231,5 @@ sub main {
     ($changes_config_file) = @{$opts{'cnffile'}};
   } else {
-    my @all_files = `kpsewhich -all updmap.cfg`;
+    my @all_files = `@KPSEWHICH@ -all updmap.cfg`;
     chomp(@all_files);
     my @used_files;
@@ -241,8 +241,8 @@ sub main {
     my @TEXMFLOCAL;
     if (win32()) {
-      chomp($TEXMFLOCALVAR =`kpsewhich --expand-path=\$TEXMFLOCAL`);
+      chomp($TEXMFLOCALVAR =`@KPSEWHICH@ --expand-path=\$TEXMFLOCAL`);
       @TEXMFLOCAL = map { lc } split(/;/ , $TEXMFLOCALVAR);
     } else {
-      chomp($TEXMFLOCALVAR =`kpsewhich --expand-path='\$TEXMFLOCAL'`);
+      chomp($TEXMFLOCALVAR =`@KPSEWHICH@ --expand-path='\$TEXMFLOCAL'`);
       @TEXMFLOCAL = split /:/ , $TEXMFLOCALVAR;
     }
@@ -280,5 +280,5 @@ sub main {
     # TEXMFLOCAL     $TEXLIVE/texmf-local/web2c/updmap.cfg
     # TEXMFDIST      $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg
-    # 
+    #
     # updmap-sys (root):
     # ==================
@@ -415,5 +415,5 @@ sub main {
 
   if ($cmd && !$opts{'force'} && !$changed) {
-    print "$changes_config_file unchanged.  Map files not recreated.\n" 
+    print "$changes_config_file unchanged.  Map files not recreated.\n"
       if !$opts{'quiet'};
   } else {
@@ -435,5 +435,5 @@ sub main {
       my @missing = read_map_files();
       if (@missing) {
-        print STDERR "\nERROR:  The following map file(s) couldn't be found:\n"; 
+        print STDERR "\nERROR:  The following map file(s) couldn't be found:\n";
         for my $m (@missing) {
           my $orig = $alldata->{'maps'}{$m}{'origin'};
@@ -913,5 +913,5 @@ sub cidx2dvips_old {
       elsif ($_ =~ /^[^ ][^ ]* unicode /) {next;}
       s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Oo][Tt][Ff]/$1/;
-      s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Tt][Tt][FfCc]/$1/; 
+      s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Tt][Tt][FfCc]/$1/;
       s/$/ %/;
       s/^(([^ ]*).*)/$1$2/;
@@ -961,9 +961,9 @@ sub mkMaps {
 
   my ($mode, $mode_origin) = get_cfg('LW35');
-  my ($dvipsPreferOutline, $dvipsPreferOutline_origin) = 
+  my ($dvipsPreferOutline, $dvipsPreferOutline_origin) =
     get_cfg('dvipsPreferOutline');
-  my ($dvipsDownloadBase35, $dvipsDownloadBase35_origin) = 
+  my ($dvipsDownloadBase35, $dvipsDownloadBase35_origin) =
     get_cfg('dvipsDownloadBase35');
-  my ($pdftexDownloadBase14, $pdftexDownloadBase14_origin) = 
+  my ($pdftexDownloadBase14, $pdftexDownloadBase14_origin) =
     get_cfg('pdftexDownloadBase14');
   my ($pxdviUse, $pxdviUse_origin) = get_cfg('pxdviUse');
@@ -1120,5 +1120,5 @@ sub mkMaps {
   push @ps2pk_map, @mixedmaps_fonts;
   push @ps2pk_map, @notmixedmaps_fonts;
-  &writeLines(">$dvipsoutputdir/ps2pk.map", 
+  &writeLines(">$dvipsoutputdir/ps2pk.map",
     normalizeLines(@ps2pk_map));
 
@@ -1127,5 +1127,5 @@ sub mkMaps {
   push @download35_map, "% ps2pk35.map";
   push @download35_map, transLW35($mode, @ps2pk_fonts);
-  &writeLines(">$dvipsoutputdir/download35.map", 
+  &writeLines(">$dvipsoutputdir/download35.map",
     normalizeLines(@download35_map));
 
@@ -1133,8 +1133,8 @@ sub mkMaps {
   push @builtin35_map, "% dvips35.map";
   push @builtin35_map, transLW35($mode, @dvips35_fonts);
-  &writeLines(">$dvipsoutputdir/builtin35.map", 
+  &writeLines(">$dvipsoutputdir/builtin35.map",
     normalizeLines(@builtin35_map));
 
-  my @dftdvips_fonts = 
+  my @dftdvips_fonts =
     (($dvipsDownloadBase35 eq "true") ? @ps2pk_fonts : @dvips35_fonts);
 
@@ -1152,5 +1152,5 @@ sub mkMaps {
   push @psfonts_t1_map, @notmixedmaps_fonts;
   push @psfonts_t1_map, @tmpkanji2;
-  &writeLines(">$dvipsoutputdir/psfonts_t1.map", 
+  &writeLines(">$dvipsoutputdir/psfonts_t1.map",
     normalizeLines(@psfonts_t1_map));
 
@@ -1159,5 +1159,5 @@ sub mkMaps {
   push @psfonts_pk_map, @notmixedmaps_fonts;
   push @psfonts_pk_map, @tmpkanji2;
-  &writeLines(">$dvipsoutputdir/psfonts_pk.map", 
+  &writeLines(">$dvipsoutputdir/psfonts_pk.map",
     normalizeLines(@psfonts_pk_map));
 
@@ -1216,5 +1216,5 @@ sub mkMaps {
     } else {
       print STDERR "$prg: Warning: File $d/$f doesn't exist.\n";
-      print LOG    "Warning: File $d/$f doesn't exist.\n" 
+      print LOG    "Warning: File $d/$f doesn't exist.\n"
         unless $opts{'dry-run'};
     }
@@ -1223,5 +1223,5 @@ sub mkMaps {
   sub check_mismatch {
     my ($mm, $d, $f, $prog) = @_;
-    chomp (my $kpsefound = `kpsewhich --progname=$prog $f`);
+    chomp (my $kpsefound = `@KPSEWHICH@ --progname=$prog $f`);
     if (lc("$d/$f") ne lc($kpsefound)) {
       $mm->{$f} = $kpsefound;
@@ -1332,5 +1332,5 @@ listed below).
 sub locateMap {
   my $map = shift;
-  my $ret = `kpsewhich --format=map $map`;
+  my $ret = `@KPSEWHICH@ --format=map $map`;
   chomp($ret);
   return $ret;
@@ -1376,5 +1376,5 @@ sub processOptions {
   # now continue with normal option handling
 
-  GetOptions(\%opts, @cmdline_options) or 
+  GetOptions(\%opts, @cmdline_options) or
     die "Try \"$prg --help\" for more information.\n";
 }
@@ -1408,5 +1408,5 @@ sub setupOutputDir {
 #   in process_options
 #   (These were the values provided to --setoption.)
-#   
+#
 sub setOptions {
   my (@options) = @_;
@@ -1415,5 +1415,5 @@ sub setOptions {
 
     my ($key,$val) = split (/=/, $o, 2);
-    
+
     die "$prg: unexpected empty key or val for options (@options), goodbye.\n"
       if !$key || !defined($val);
@@ -1497,5 +1497,5 @@ sub disable_map {
     # add a new entry to the top level where we disable it
     # copy over the type from the last entry
-    $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = 
+    $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} =
       $alldata->{'updmap'}{$orig}{'maps'}{$map}{'type'};
     $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled";
@@ -1595,5 +1595,5 @@ sub save_updmap {
 sub check_option {
   my ($opt, $val) = @_;
-  if ((($settings{$opt}{'type'} eq "binary") && 
+  if ((($settings{$opt}{'type'} eq "binary") &&
        $val ne "true" && $val ne "false") ||
       (($settings{$opt}{'type'} eq "string") &&
@@ -1613,10 +1613,10 @@ sub setOption {
 
   die "$prg: Unsupported option $opt." if (!defined($settings{$opt}));
-  die "$0: Invalid value $val for option $opt." 
+  die "$0: Invalid value $val for option $opt."
     if (!check_option($opt, $val));
 
   # silently accept this old option name, just in case.
   return if $opt eq "dvipdfmDownloadBase14";
-  
+
   #print "Setting option $opt to $val...\n" if !$opts{'quiet'};
   my $tc = $alldata->{'changes_config'};
@@ -1766,7 +1766,7 @@ sub normalizeLines {
 # $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'val'} = $val
 # $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'line'} = $i
-# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'type'} 
+# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'type'}
 #            = 'Map'|'MixedMap'|'KanjiMap'|'disabled'
-# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'status'} 
+# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'status'}
 #            = 'enabled'|'disabled'
 # $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'line'} = $i
@@ -1978,5 +1978,5 @@ sub read_map_files {
   }
   @maps = sort_uniq(@maps);
-  my @fullpath = `kpsewhich --format=map @maps`;
+  my @fullpath = `@KPSEWHICH@ --format=map @maps`;
   chomp @fullpath;
   foreach my $map (@maps) {
@@ -1985,5 +1985,5 @@ sub read_map_files {
       $alldata->{'maps'}{$map}{'fullpath'} = $ff;
     } else {
-      # if the map file is not found, then push it onto the list of 
+      # if the map file is not found, then push it onto the list of
       # missing map files, since we know that it is enabled
       push @missing, $map;
@@ -2087,11 +2087,11 @@ sub merge_data {
       # use the font definition only for those fonts where the origin matches
       if ($alldata->{'fonts'}{$f}{'origin'} eq $m) {
-        $alldata->{'merged'}{'allMaps'}{'fonts'}{$f} = 
+        $alldata->{'merged'}{'allMaps'}{'fonts'}{$f} =
           $alldata->{'maps'}{$m}{'fonts'}{$f}
             if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} ne "KanjiMap");
-        $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$f} = 
+        $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$f} =
           $alldata->{'maps'}{$m}{'fonts'}{$f}
             if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map");
-        $alldata->{'merged'}{'KanjiMap'}{'fonts'}{$f} = 
+        $alldata->{'merged'}{'KanjiMap'}{'fonts'}{$f} =
           $alldata->{'maps'}{$m}{'fonts'}{$f}
             if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "KanjiMap");
@@ -2105,5 +2105,5 @@ sub merge_data {
 # $HOME and sudo and updmap-sys horror
 #   some instances of sudo do not reset $HOME to the home of root
-#   as an effect of "sudo updmap" creates root owned files in the home 
+#   as an effect of "sudo updmap" creates root owned files in the home
 #   of a normal user, and "sudo updmap-sys" uses map files and updmap.cfg
 #   files from the directory of a normal user, but creating files
@@ -2133,5 +2133,5 @@ sub reset_root_home {
           # envhome and roothome do agree, nothing to do, that is the good case
         }
-      } else { 
+      } else {
         warning("$prg: home of root not defined, strange!\n");
       }
@@ -2158,5 +2158,5 @@ Usage: $prg     [OPTION] ... [COMMAND]
 
 Update the default font map files used by pdftex, dvips, and dvipdfm(x),
-and optionally pxdvi, as determined by all configuration files updmap.cfg 
+and optionally pxdvi, as determined by all configuration files updmap.cfg
 (the ones returned by running "kpsewhich --all updmap.cfg", but see below).
 
@@ -2174,5 +2174,5 @@ By default, the TeX filename database (l
 
 Options:
-  --cnffile FILE            read FILE for the updmap configuration 
+  --cnffile FILE            read FILE for the updmap configuration
                              (can be given multiple times, in which case
                              all the files are used)
@@ -2261,5 +2261,5 @@ Explanation of trees and files normally 
   layout is used as shipped with TeX Live, the following files are
   read, in the given order.
-  
+
   For updmap-sys:
   TEXMFSYSCONFIG \$TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg
@@ -2276,7 +2276,7 @@ Explanation of trees and files normally 
   TEXMFLOCAL     \$TEXLIVE/texmf-local/web2c/updmap.cfg
   TEXMFDIST      \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg
-  
+
   (where YYYY is the TeX Live release version).
-  
+
   There is one exception to keep upgradability from earlier versions
   of TeX Live: if a file TEXMFLOCAL/web2c/updmap-local.cfg exists
@@ -2299,8 +2299,8 @@ Explanation of trees and files normally 
     kpsewhich --all (equivalently, the one returned by kpsewhich
     updmap.cfg), is used.
-      
+
     2) If neither of the above two are present and changes are made, a
     new config file is created in \$TEXMFCONFIG/web2c/updmap.cfg.
-  
+
   In general, the idea is that if a given config file is not writable, a
   higher-level one can be used.  That way, the distribution's settings
@@ -2321,5 +2321,5 @@ Explanation of trees and files normally 
     or
       \#! MixedMap mapname.map
-    in the higher-priority updmap.cfg file. 
+    in the higher-priority updmap.cfg file.
 
     As an example, suppose you have a copy of MathTime Pro fonts
@@ -2334,5 +2334,5 @@ Explanation of trees and files normally 
   updmap writes the map files for dvips (psfonts.map) and pdftex
   (pdftex.map) to the TEXMFVAR/fonts/map/updmap/{dvips,pdftex}/
-  directories.   
+  directories.
 
   The log file is written to TEXMFVAR/web2c/updmap.log.
