diff options
author | Reinhard Kotucha <reinhard.kotucha@web.de> | 2006-12-31 01:09:36 +0000 |
---|---|---|
committer | Reinhard Kotucha <reinhard.kotucha@web.de> | 2006-12-31 01:09:36 +0000 |
commit | 28440aa9ac223b8c38974a5ccd52ae5566913923 (patch) | |
tree | e183b622cea85da495be6624e92ca91fa198657f /Master/bin | |
parent | 48f16fa9021635b9190c84a805b17d08cd2b6eb1 (diff) |
update getnonfreefonts
git-svn-id: svn://tug.org/texlive/trunk@3050 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/bin')
-rwxr-xr-x | Master/bin/alpha-linux/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/hppa-hpux/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/i386-darwin/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/i386-freebsd/getnonfreefonts | 433 | ||||
-rwxr-xr-x | Master/bin/i386-linux/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/i386-solaris/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/mips-irix/getnonfreefonts | 433 | ||||
-rwxr-xr-x | Master/bin/powerpc-aix/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/powerpc-darwin/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/sparc-linux/getnonfreefonts | 45 | ||||
-rwxr-xr-x | Master/bin/sparc-solaris/getnonfreefonts | 433 | ||||
-rw-r--r-- | Master/bin/win32/getnonfreefonts.bat | 93 | ||||
-rwxr-xr-x | Master/bin/x86_64-linux/getnonfreefonts | 45 |
13 files changed, 1117 insertions, 680 deletions
diff --git a/Master/bin/alpha-linux/getnonfreefonts b/Master/bin/alpha-linux/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/alpha-linux/getnonfreefonts +++ b/Master/bin/alpha-linux/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/hppa-hpux/getnonfreefonts b/Master/bin/hppa-hpux/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/hppa-hpux/getnonfreefonts +++ b/Master/bin/hppa-hpux/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/i386-darwin/getnonfreefonts b/Master/bin/i386-darwin/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/i386-darwin/getnonfreefonts +++ b/Master/bin/i386-darwin/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/i386-freebsd/getnonfreefonts b/Master/bin/i386-freebsd/getnonfreefonts index 21dd7a0fff8..969a251b52c 100755 --- a/Master/bin/i386-freebsd/getnonfreefonts +++ b/Master/bin/i386-freebsd/getnonfreefonts @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env perl ## getnonfreefonts -## Copyright 2005 Reinhard Kotucha <reinhard.kotucha@web.de> +## Copyright 2006 Reinhard Kotucha <reinhard.kotucha@web.de> # # This work may be distributed and/or modified under the # conditions of the LaTeX Project Public License, either version 1.3 @@ -11,156 +11,285 @@ # # The current maintainer is Reinhard Kotucha. +my $TL_version='2006'; -# invoke the right shell (code from Thomas Esser): -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - - -URL="${URL-ftp://tug.org/tex/getnonfreefonts/getfont}" - -die () { echo "$1." 1>&2; exit 1; } - -OLDIFS=$IFS -IFS=: -BINDIRS=`echo $PATH` -IFS=$OLDIFS - -for BINDIR in $BINDIRS; do - if test "$BINDIR" != "."; then - for FTP_CLIENT in wget lftp ncftpget curl snarf gftp; do - test -x $BINDIR/$FTP_CLIENT && FTP=$FTP_CLIENT && break - done - fi -done - -test -n "$FTP" || die "No ftp client found" - -export FTP - -case $0 in - *-sys) SYS=true; GETFONT=getfont-sys;; - *) SYS=false; GETFONT=getfont;; -esac -export SYS GETFONT - -ALL=true -RUNSHELL=false - -ARGS_FROM_GETNONFREEFONTS="$@" -export ARGS_FROM_GETNONFREEFONTS - -for ARG in "$@"; do - case $ARG in - -*) - case $ARG in - -shell|--shell) RUNSHELL=true;; - -ftp-client=*|--ftp-client=*) - FTP=`echo "$ARG" | sed 's/.*=//'`;; - -url=*|--url=*) - URL=`echo "$ARG" | sed 's/.*=//'`;; - -h|-help|--help) ALL=false;; - esac;; - *) ALL=false;; - esac -done - -export URL - -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/getnonfreefonts.$$ -(umask 077; mkdir "${tmpdir}") || die "Can't mkdir ${tmpdir}" -trap 'rm -rf ${tmpdir}' 0 1 2 3 7 13 15 - -download () { - echo "Downloading: $1" - case ${FTP} in - wget) wget "$1" || die "$1: Download failed";; - lftp) lftp -c "get $1" || die "$1: Download failed";; - ncftpget) ncftpget "$1" || die "$1: Download failed";; - curl) curl -O "$1" || die "$1: Download failed";; - snarf) snarf "$1" || die "$1: Download failed";; - gftp) gftp -d "$1" || die "$1: Download failed";; - *) die "This can't happen";; - esac +my $getfont_url="ftp://tug.org/tex/getnonfreefonts/getfont$TL_version"; + +use File::Copy; +use Getopt::Long; +$Getopt::Long::autoabbrev=0; + +$opt_lsfonts=0; +$opt_force=0; + +sub usage { + print <<'EOF'; +Usage: + getnonfreefonts[-sys] [-a|--all] [-d|--debug] [-f|--force] + [-l|--lsfonts] [-v|--verbose] [--version] [font1] [font2] ... + + getnonfreefonts installs fonts in $TEXMFHOME. + getnonfreefonts-sys installs fonts in $TEXMFLOCAL. + + Options: + -a|--all Install all fonts. + + -d|--debug Provide additional messages for debugging. + + -f|--force Install fonts even if they are installed already. + + -h|--help Print this message. + + -l|--lsfonts List all fonts available. + + -v|--verbose Be more verbose. + + --version Print version number. + +EOF +; +} + +@ARGS=@ARGV; + +GetOptions + "all|a", + "debug|d", + "force|f", + "help|h", + "lsfonts|l", + "verbose|v", + "version", + "sys"; + +$^W=1 if $opt_debug; + +my $sys=($0=~/-sys$/)? 1:0; +$sys=1 if $opt_sys; + +@allpackages=@ARGV; + +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + +sub message { + my $message=shift; + if ($message=~/^\[/) { + print "$message\n"; + } else { + printf "%-60s", $message; + } +} + + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } } -cd "${tmpdir}" || die "Can't cd ${tmpdir}" - -echo ------------------------------------------------------- -echo "FTP client: ${FTP}" -echo "Temporary dir: ${tmpdir}" -echo "URL: ${URL}" -echo ------------------------------------------------------- - -download ${URL} - -chmod 700 getfont -ln -s getfont getfont-sys -PATH=${tmpdir}:${PATH} -export PATH - -UPDMAP_NEEDED=false - -if ${RUNSHELL}; then - if ${SYS}; then - PS1='[getfont-sys]\$ ' - else - PS1='[getfont]\$ ' - fi - export PS1 - echo ------------------------------------------------------- - echo "FTP client: ${FTP}" - echo "Temporary dir: ${tmpdir}" - echo "URL: ${URL}" - echo "SYS: ${SYS}" - echo "ARGS: ${ARGS_FROM_GETNONFREEFONTS}" - echo ------------------------------------------------------- - echo "Run program \"getfont\" or \"getfont-sys\" for each font you want to install." - echo; echo "Supported fonts are:" - for f in `getfont --lsfonts`; do - echo " $f" - done - echo; echo "Type \"getfont --help\" for more information." - echo "Type \"exit\" to leave this shell."; echo - -# Start the shell. We start a shell even if someone has -# SHELL=/sbin/shutdown in his environment. - - test -z ${SHELL} || SHELL="/bin/sh" - case ${SHELL} in - /bin/bash) /bin/bash;; - /bin/ksh) /bin/ksh;; - /bin/ksh) /bin/ksh;; - *) /bin/sh;; - esac - - echo "Please run \"updmap\" or \"updmap-sys\" now if necessary." -else # no shell - if ${ALL} ; then - for font in `getfont --lsfonts`; do - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} ${font} && UPDMAP_NEEDED=true - done - else - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} && UPDMAP_NEEDED=true - fi - - if ${UPDMAP_NEEDED}; then - if ${SYS}; then - updmap-sys - else - updmap - fi - fi -fi - -cd / -rm -rf "${tmpdir}" - -exit 0 + +sub expand_var { + my $var=shift; + + if (-d "/usr/bin") { + open KPSEWHICH, 'kpsewhich --expand-var=\$' . "$var |"; + } else { + open KPSEWHICH, 'kpsewhich --expand-var=$' . "$var |"; + } + while (<KPSEWHICH>) { + chop; + return $_; + } + close KPSEWHICH; +} + + +# get TMP|TEMP|TMPDIR environment variable + +if ($opt_debug) { + for my $var ("TMP","TEMP","TMPDIR") { + if (defined $ENV{$var}) { + debug_msg "Environment variable $var='$ENV{$var}'"; + } else { + debug_msg "Environment variable $var not set"; + } + } +} + + +if (defined $ENV{'TMP'}) { + $SYSTMP="$ENV{'TMP'}"; +} elsif (defined $ENV{'TEMP'}) { + $SYSTMP="$ENV{'TEMP'}"; +} elsif (defined $ENV{'TMPDIR'}) { + $SYSTMP="$ENV{'TMPDIR'}"; +} else { + $SYSTMP="/tmp"; +} + +debug_msg "Internal variable SYSTMP set to '$SYSTMP'"; + +# Windows usually uses backslashes though forward slashes are probably +# allowed. Perl always needs forward slashes. + +# We convert backslashes to forward slashes if it looks like a Windows +# directory. +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^.:\\/); # c:\abc\def +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; + +sub check_tmpdir{ +die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" + unless (-d "$SYSTMP"); + +die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" + unless (-w "$SYSTMP"); +} + +# Determine INSTALLROOT. + +if ($opt_debug) { + my @path=split ':', $ENV{PATH}; + for my $dir (@path) { + debug_msg "Search for kpsewhich in '$dir'"; + opendir DIR, "$dir"; + my @kpsewichs=grep /^kpsewhich/, readdir DIR; + closedir DIR; + for (@kpsewichs) { + debug_msg "Found $dir/$_" if /^kpsewhich/; + } + } +} + + +if ($sys) { + $INSTALLROOT=expand_var 'TEXMFLOCAL'; +} else { + $INSTALLROOT=expand_var 'TEXMFHOME'; +} + +($sys)? debug_msg "sys=true":debug_msg "sys=false"; + +debug_msg "INSTALLROOT='$INSTALLROOT'"; + +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^.:\\/); # c:\abc\def +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; + +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); + + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { + print <<"ENDUSAGE"; + Directories: + temporary: '$SYSTMP/getfont-<PID>' + install: '$INSTALLROOT' + +ENDUSAGE +check_tmpdir; +check_installroot; +exit 0; +} + +check_tmpdir; +check_installroot; + +my $tmpdir="$SYSTMP/getfont-$$"; +debug_msg "Internal variable tmpdir set to '$tmpdir'"; + +mkdir "$tmpdir" or die "! ERROR: Can't mkdir '$tmpdir'."; +chdir "$tmpdir" or die "! ERROR: Can't cd '$tmpdir'."; + +sub remove_tmpdir { + chdir "$SYSTMP" or die "! ERROR: Can't cd '$SYSTMP'.\n"; + opendir TMPDIR, "$tmpdir" + or print "! ERROR: Can't read directory '$tmpdir'.\n"; + + @alltmps=readdir TMPDIR; + closedir TMPDIR; + + foreach $file (@alltmps) { + next if $file=~/^\./; + unlink "$tmpdir/$file"; + } + rmdir "$tmpdir" or die "! ERROR: Can't remove directory '$tmpdir'.\n"; +} + +# Signal handlers for UNIX, maybe ignored by Windows. + +$SIG{INT} =\&remove_tmpdir; +$SIG{QUIT}=\&remove_tmpdir; +$SIG{BUS} =\&remove_tmpdir; +$SIG{PIPE}=\&remove_tmpdir; +$SIG{TERM}=\&remove_tmpdir; +$SIG{ABRT}=\&remove_tmpdir; +$SIG{SEGV}=\&remove_tmpdir; + +# Download the script from tug.org. + +debug_msg "Running 'wget $getfont_url'"; + +system ('wget', "$getfont_url"); + +# Download the fonts. + +my @getfont=('perl', "./getfont$TL_version", '--getnonfreefonts'); +push @getfont, "--installroot=$INSTALLROOT"; +push @getfont, '--lsfonts' if $opt_lsfonts; +push @getfont, '--force' if $opt_force; +push @getfont, '--debug' if $opt_debug; +push @getfont, '--verbose' if $opt_verbose; +push @getfont, '--sys' if $sys; +push @getfont, '--all' if $opt_all; +push @getfont, @allpackages; + +debug_msg "Running '@getfont'"; + +system @getfont; + +# Evaluate the exit status. It will be 2 if something had been +# installed and in this case we need to run texhash/updmap. + +my $exit_code=$?; +my $exit_status=int($exit_code/256); + +if ($sys) { + debug_msg "Info: Execute updmap-sys if exit status is 2"; +} else { + debug_msg "Info: Execute updmap if exit status is 2"; +} + +debug_msg "Exit status of getfont$TL_version is $exit_status"; + +if ($exit_status==2) { + print "\n"; + system 'texhash', "$INSTALLROOT"; + $updmap_command=($sys)? 'updmap-sys':'updmap'; + @updmap=("$updmap_command"); + push @updmap, '--quiet' unless $opt_verbose; + print "\n"; + message "Updating map files ($updmap_command)..."; + system @updmap; + + message $?? '[failed]':'[done]'; +} + +remove_tmpdir; + +__END__ diff --git a/Master/bin/i386-linux/getnonfreefonts b/Master/bin/i386-linux/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/i386-linux/getnonfreefonts +++ b/Master/bin/i386-linux/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/i386-solaris/getnonfreefonts b/Master/bin/i386-solaris/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/i386-solaris/getnonfreefonts +++ b/Master/bin/i386-solaris/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/mips-irix/getnonfreefonts b/Master/bin/mips-irix/getnonfreefonts index 21dd7a0fff8..969a251b52c 100755 --- a/Master/bin/mips-irix/getnonfreefonts +++ b/Master/bin/mips-irix/getnonfreefonts @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env perl ## getnonfreefonts -## Copyright 2005 Reinhard Kotucha <reinhard.kotucha@web.de> +## Copyright 2006 Reinhard Kotucha <reinhard.kotucha@web.de> # # This work may be distributed and/or modified under the # conditions of the LaTeX Project Public License, either version 1.3 @@ -11,156 +11,285 @@ # # The current maintainer is Reinhard Kotucha. +my $TL_version='2006'; -# invoke the right shell (code from Thomas Esser): -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - - -URL="${URL-ftp://tug.org/tex/getnonfreefonts/getfont}" - -die () { echo "$1." 1>&2; exit 1; } - -OLDIFS=$IFS -IFS=: -BINDIRS=`echo $PATH` -IFS=$OLDIFS - -for BINDIR in $BINDIRS; do - if test "$BINDIR" != "."; then - for FTP_CLIENT in wget lftp ncftpget curl snarf gftp; do - test -x $BINDIR/$FTP_CLIENT && FTP=$FTP_CLIENT && break - done - fi -done - -test -n "$FTP" || die "No ftp client found" - -export FTP - -case $0 in - *-sys) SYS=true; GETFONT=getfont-sys;; - *) SYS=false; GETFONT=getfont;; -esac -export SYS GETFONT - -ALL=true -RUNSHELL=false - -ARGS_FROM_GETNONFREEFONTS="$@" -export ARGS_FROM_GETNONFREEFONTS - -for ARG in "$@"; do - case $ARG in - -*) - case $ARG in - -shell|--shell) RUNSHELL=true;; - -ftp-client=*|--ftp-client=*) - FTP=`echo "$ARG" | sed 's/.*=//'`;; - -url=*|--url=*) - URL=`echo "$ARG" | sed 's/.*=//'`;; - -h|-help|--help) ALL=false;; - esac;; - *) ALL=false;; - esac -done - -export URL - -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/getnonfreefonts.$$ -(umask 077; mkdir "${tmpdir}") || die "Can't mkdir ${tmpdir}" -trap 'rm -rf ${tmpdir}' 0 1 2 3 7 13 15 - -download () { - echo "Downloading: $1" - case ${FTP} in - wget) wget "$1" || die "$1: Download failed";; - lftp) lftp -c "get $1" || die "$1: Download failed";; - ncftpget) ncftpget "$1" || die "$1: Download failed";; - curl) curl -O "$1" || die "$1: Download failed";; - snarf) snarf "$1" || die "$1: Download failed";; - gftp) gftp -d "$1" || die "$1: Download failed";; - *) die "This can't happen";; - esac +my $getfont_url="ftp://tug.org/tex/getnonfreefonts/getfont$TL_version"; + +use File::Copy; +use Getopt::Long; +$Getopt::Long::autoabbrev=0; + +$opt_lsfonts=0; +$opt_force=0; + +sub usage { + print <<'EOF'; +Usage: + getnonfreefonts[-sys] [-a|--all] [-d|--debug] [-f|--force] + [-l|--lsfonts] [-v|--verbose] [--version] [font1] [font2] ... + + getnonfreefonts installs fonts in $TEXMFHOME. + getnonfreefonts-sys installs fonts in $TEXMFLOCAL. + + Options: + -a|--all Install all fonts. + + -d|--debug Provide additional messages for debugging. + + -f|--force Install fonts even if they are installed already. + + -h|--help Print this message. + + -l|--lsfonts List all fonts available. + + -v|--verbose Be more verbose. + + --version Print version number. + +EOF +; +} + +@ARGS=@ARGV; + +GetOptions + "all|a", + "debug|d", + "force|f", + "help|h", + "lsfonts|l", + "verbose|v", + "version", + "sys"; + +$^W=1 if $opt_debug; + +my $sys=($0=~/-sys$/)? 1:0; +$sys=1 if $opt_sys; + +@allpackages=@ARGV; + +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + +sub message { + my $message=shift; + if ($message=~/^\[/) { + print "$message\n"; + } else { + printf "%-60s", $message; + } +} + + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } } -cd "${tmpdir}" || die "Can't cd ${tmpdir}" - -echo ------------------------------------------------------- -echo "FTP client: ${FTP}" -echo "Temporary dir: ${tmpdir}" -echo "URL: ${URL}" -echo ------------------------------------------------------- - -download ${URL} - -chmod 700 getfont -ln -s getfont getfont-sys -PATH=${tmpdir}:${PATH} -export PATH - -UPDMAP_NEEDED=false - -if ${RUNSHELL}; then - if ${SYS}; then - PS1='[getfont-sys]\$ ' - else - PS1='[getfont]\$ ' - fi - export PS1 - echo ------------------------------------------------------- - echo "FTP client: ${FTP}" - echo "Temporary dir: ${tmpdir}" - echo "URL: ${URL}" - echo "SYS: ${SYS}" - echo "ARGS: ${ARGS_FROM_GETNONFREEFONTS}" - echo ------------------------------------------------------- - echo "Run program \"getfont\" or \"getfont-sys\" for each font you want to install." - echo; echo "Supported fonts are:" - for f in `getfont --lsfonts`; do - echo " $f" - done - echo; echo "Type \"getfont --help\" for more information." - echo "Type \"exit\" to leave this shell."; echo - -# Start the shell. We start a shell even if someone has -# SHELL=/sbin/shutdown in his environment. - - test -z ${SHELL} || SHELL="/bin/sh" - case ${SHELL} in - /bin/bash) /bin/bash;; - /bin/ksh) /bin/ksh;; - /bin/ksh) /bin/ksh;; - *) /bin/sh;; - esac - - echo "Please run \"updmap\" or \"updmap-sys\" now if necessary." -else # no shell - if ${ALL} ; then - for font in `getfont --lsfonts`; do - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} ${font} && UPDMAP_NEEDED=true - done - else - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} && UPDMAP_NEEDED=true - fi - - if ${UPDMAP_NEEDED}; then - if ${SYS}; then - updmap-sys - else - updmap - fi - fi -fi - -cd / -rm -rf "${tmpdir}" - -exit 0 + +sub expand_var { + my $var=shift; + + if (-d "/usr/bin") { + open KPSEWHICH, 'kpsewhich --expand-var=\$' . "$var |"; + } else { + open KPSEWHICH, 'kpsewhich --expand-var=$' . "$var |"; + } + while (<KPSEWHICH>) { + chop; + return $_; + } + close KPSEWHICH; +} + + +# get TMP|TEMP|TMPDIR environment variable + +if ($opt_debug) { + for my $var ("TMP","TEMP","TMPDIR") { + if (defined $ENV{$var}) { + debug_msg "Environment variable $var='$ENV{$var}'"; + } else { + debug_msg "Environment variable $var not set"; + } + } +} + + +if (defined $ENV{'TMP'}) { + $SYSTMP="$ENV{'TMP'}"; +} elsif (defined $ENV{'TEMP'}) { + $SYSTMP="$ENV{'TEMP'}"; +} elsif (defined $ENV{'TMPDIR'}) { + $SYSTMP="$ENV{'TMPDIR'}"; +} else { + $SYSTMP="/tmp"; +} + +debug_msg "Internal variable SYSTMP set to '$SYSTMP'"; + +# Windows usually uses backslashes though forward slashes are probably +# allowed. Perl always needs forward slashes. + +# We convert backslashes to forward slashes if it looks like a Windows +# directory. +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^.:\\/); # c:\abc\def +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; + +sub check_tmpdir{ +die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" + unless (-d "$SYSTMP"); + +die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" + unless (-w "$SYSTMP"); +} + +# Determine INSTALLROOT. + +if ($opt_debug) { + my @path=split ':', $ENV{PATH}; + for my $dir (@path) { + debug_msg "Search for kpsewhich in '$dir'"; + opendir DIR, "$dir"; + my @kpsewichs=grep /^kpsewhich/, readdir DIR; + closedir DIR; + for (@kpsewichs) { + debug_msg "Found $dir/$_" if /^kpsewhich/; + } + } +} + + +if ($sys) { + $INSTALLROOT=expand_var 'TEXMFLOCAL'; +} else { + $INSTALLROOT=expand_var 'TEXMFHOME'; +} + +($sys)? debug_msg "sys=true":debug_msg "sys=false"; + +debug_msg "INSTALLROOT='$INSTALLROOT'"; + +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^.:\\/); # c:\abc\def +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; + +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); + + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { + print <<"ENDUSAGE"; + Directories: + temporary: '$SYSTMP/getfont-<PID>' + install: '$INSTALLROOT' + +ENDUSAGE +check_tmpdir; +check_installroot; +exit 0; +} + +check_tmpdir; +check_installroot; + +my $tmpdir="$SYSTMP/getfont-$$"; +debug_msg "Internal variable tmpdir set to '$tmpdir'"; + +mkdir "$tmpdir" or die "! ERROR: Can't mkdir '$tmpdir'."; +chdir "$tmpdir" or die "! ERROR: Can't cd '$tmpdir'."; + +sub remove_tmpdir { + chdir "$SYSTMP" or die "! ERROR: Can't cd '$SYSTMP'.\n"; + opendir TMPDIR, "$tmpdir" + or print "! ERROR: Can't read directory '$tmpdir'.\n"; + + @alltmps=readdir TMPDIR; + closedir TMPDIR; + + foreach $file (@alltmps) { + next if $file=~/^\./; + unlink "$tmpdir/$file"; + } + rmdir "$tmpdir" or die "! ERROR: Can't remove directory '$tmpdir'.\n"; +} + +# Signal handlers for UNIX, maybe ignored by Windows. + +$SIG{INT} =\&remove_tmpdir; +$SIG{QUIT}=\&remove_tmpdir; +$SIG{BUS} =\&remove_tmpdir; +$SIG{PIPE}=\&remove_tmpdir; +$SIG{TERM}=\&remove_tmpdir; +$SIG{ABRT}=\&remove_tmpdir; +$SIG{SEGV}=\&remove_tmpdir; + +# Download the script from tug.org. + +debug_msg "Running 'wget $getfont_url'"; + +system ('wget', "$getfont_url"); + +# Download the fonts. + +my @getfont=('perl', "./getfont$TL_version", '--getnonfreefonts'); +push @getfont, "--installroot=$INSTALLROOT"; +push @getfont, '--lsfonts' if $opt_lsfonts; +push @getfont, '--force' if $opt_force; +push @getfont, '--debug' if $opt_debug; +push @getfont, '--verbose' if $opt_verbose; +push @getfont, '--sys' if $sys; +push @getfont, '--all' if $opt_all; +push @getfont, @allpackages; + +debug_msg "Running '@getfont'"; + +system @getfont; + +# Evaluate the exit status. It will be 2 if something had been +# installed and in this case we need to run texhash/updmap. + +my $exit_code=$?; +my $exit_status=int($exit_code/256); + +if ($sys) { + debug_msg "Info: Execute updmap-sys if exit status is 2"; +} else { + debug_msg "Info: Execute updmap if exit status is 2"; +} + +debug_msg "Exit status of getfont$TL_version is $exit_status"; + +if ($exit_status==2) { + print "\n"; + system 'texhash', "$INSTALLROOT"; + $updmap_command=($sys)? 'updmap-sys':'updmap'; + @updmap=("$updmap_command"); + push @updmap, '--quiet' unless $opt_verbose; + print "\n"; + message "Updating map files ($updmap_command)..."; + system @updmap; + + message $?? '[failed]':'[done]'; +} + +remove_tmpdir; + +__END__ diff --git a/Master/bin/powerpc-aix/getnonfreefonts b/Master/bin/powerpc-aix/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/powerpc-aix/getnonfreefonts +++ b/Master/bin/powerpc-aix/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/powerpc-darwin/getnonfreefonts b/Master/bin/powerpc-darwin/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/powerpc-darwin/getnonfreefonts +++ b/Master/bin/powerpc-darwin/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/sparc-linux/getnonfreefonts b/Master/bin/sparc-linux/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/sparc-linux/getnonfreefonts +++ b/Master/bin/sparc-linux/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; diff --git a/Master/bin/sparc-solaris/getnonfreefonts b/Master/bin/sparc-solaris/getnonfreefonts index 21dd7a0fff8..969a251b52c 100755 --- a/Master/bin/sparc-solaris/getnonfreefonts +++ b/Master/bin/sparc-solaris/getnonfreefonts @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env perl ## getnonfreefonts -## Copyright 2005 Reinhard Kotucha <reinhard.kotucha@web.de> +## Copyright 2006 Reinhard Kotucha <reinhard.kotucha@web.de> # # This work may be distributed and/or modified under the # conditions of the LaTeX Project Public License, either version 1.3 @@ -11,156 +11,285 @@ # # The current maintainer is Reinhard Kotucha. +my $TL_version='2006'; -# invoke the right shell (code from Thomas Esser): -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - - -URL="${URL-ftp://tug.org/tex/getnonfreefonts/getfont}" - -die () { echo "$1." 1>&2; exit 1; } - -OLDIFS=$IFS -IFS=: -BINDIRS=`echo $PATH` -IFS=$OLDIFS - -for BINDIR in $BINDIRS; do - if test "$BINDIR" != "."; then - for FTP_CLIENT in wget lftp ncftpget curl snarf gftp; do - test -x $BINDIR/$FTP_CLIENT && FTP=$FTP_CLIENT && break - done - fi -done - -test -n "$FTP" || die "No ftp client found" - -export FTP - -case $0 in - *-sys) SYS=true; GETFONT=getfont-sys;; - *) SYS=false; GETFONT=getfont;; -esac -export SYS GETFONT - -ALL=true -RUNSHELL=false - -ARGS_FROM_GETNONFREEFONTS="$@" -export ARGS_FROM_GETNONFREEFONTS - -for ARG in "$@"; do - case $ARG in - -*) - case $ARG in - -shell|--shell) RUNSHELL=true;; - -ftp-client=*|--ftp-client=*) - FTP=`echo "$ARG" | sed 's/.*=//'`;; - -url=*|--url=*) - URL=`echo "$ARG" | sed 's/.*=//'`;; - -h|-help|--help) ALL=false;; - esac;; - *) ALL=false;; - esac -done - -export URL - -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/getnonfreefonts.$$ -(umask 077; mkdir "${tmpdir}") || die "Can't mkdir ${tmpdir}" -trap 'rm -rf ${tmpdir}' 0 1 2 3 7 13 15 - -download () { - echo "Downloading: $1" - case ${FTP} in - wget) wget "$1" || die "$1: Download failed";; - lftp) lftp -c "get $1" || die "$1: Download failed";; - ncftpget) ncftpget "$1" || die "$1: Download failed";; - curl) curl -O "$1" || die "$1: Download failed";; - snarf) snarf "$1" || die "$1: Download failed";; - gftp) gftp -d "$1" || die "$1: Download failed";; - *) die "This can't happen";; - esac +my $getfont_url="ftp://tug.org/tex/getnonfreefonts/getfont$TL_version"; + +use File::Copy; +use Getopt::Long; +$Getopt::Long::autoabbrev=0; + +$opt_lsfonts=0; +$opt_force=0; + +sub usage { + print <<'EOF'; +Usage: + getnonfreefonts[-sys] [-a|--all] [-d|--debug] [-f|--force] + [-l|--lsfonts] [-v|--verbose] [--version] [font1] [font2] ... + + getnonfreefonts installs fonts in $TEXMFHOME. + getnonfreefonts-sys installs fonts in $TEXMFLOCAL. + + Options: + -a|--all Install all fonts. + + -d|--debug Provide additional messages for debugging. + + -f|--force Install fonts even if they are installed already. + + -h|--help Print this message. + + -l|--lsfonts List all fonts available. + + -v|--verbose Be more verbose. + + --version Print version number. + +EOF +; +} + +@ARGS=@ARGV; + +GetOptions + "all|a", + "debug|d", + "force|f", + "help|h", + "lsfonts|l", + "verbose|v", + "version", + "sys"; + +$^W=1 if $opt_debug; + +my $sys=($0=~/-sys$/)? 1:0; +$sys=1 if $opt_sys; + +@allpackages=@ARGV; + +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + +sub message { + my $message=shift; + if ($message=~/^\[/) { + print "$message\n"; + } else { + printf "%-60s", $message; + } +} + + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } } -cd "${tmpdir}" || die "Can't cd ${tmpdir}" - -echo ------------------------------------------------------- -echo "FTP client: ${FTP}" -echo "Temporary dir: ${tmpdir}" -echo "URL: ${URL}" -echo ------------------------------------------------------- - -download ${URL} - -chmod 700 getfont -ln -s getfont getfont-sys -PATH=${tmpdir}:${PATH} -export PATH - -UPDMAP_NEEDED=false - -if ${RUNSHELL}; then - if ${SYS}; then - PS1='[getfont-sys]\$ ' - else - PS1='[getfont]\$ ' - fi - export PS1 - echo ------------------------------------------------------- - echo "FTP client: ${FTP}" - echo "Temporary dir: ${tmpdir}" - echo "URL: ${URL}" - echo "SYS: ${SYS}" - echo "ARGS: ${ARGS_FROM_GETNONFREEFONTS}" - echo ------------------------------------------------------- - echo "Run program \"getfont\" or \"getfont-sys\" for each font you want to install." - echo; echo "Supported fonts are:" - for f in `getfont --lsfonts`; do - echo " $f" - done - echo; echo "Type \"getfont --help\" for more information." - echo "Type \"exit\" to leave this shell."; echo - -# Start the shell. We start a shell even if someone has -# SHELL=/sbin/shutdown in his environment. - - test -z ${SHELL} || SHELL="/bin/sh" - case ${SHELL} in - /bin/bash) /bin/bash;; - /bin/ksh) /bin/ksh;; - /bin/ksh) /bin/ksh;; - *) /bin/sh;; - esac - - echo "Please run \"updmap\" or \"updmap-sys\" now if necessary." -else # no shell - if ${ALL} ; then - for font in `getfont --lsfonts`; do - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} ${font} && UPDMAP_NEEDED=true - done - else - ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} && UPDMAP_NEEDED=true - fi - - if ${UPDMAP_NEEDED}; then - if ${SYS}; then - updmap-sys - else - updmap - fi - fi -fi - -cd / -rm -rf "${tmpdir}" - -exit 0 + +sub expand_var { + my $var=shift; + + if (-d "/usr/bin") { + open KPSEWHICH, 'kpsewhich --expand-var=\$' . "$var |"; + } else { + open KPSEWHICH, 'kpsewhich --expand-var=$' . "$var |"; + } + while (<KPSEWHICH>) { + chop; + return $_; + } + close KPSEWHICH; +} + + +# get TMP|TEMP|TMPDIR environment variable + +if ($opt_debug) { + for my $var ("TMP","TEMP","TMPDIR") { + if (defined $ENV{$var}) { + debug_msg "Environment variable $var='$ENV{$var}'"; + } else { + debug_msg "Environment variable $var not set"; + } + } +} + + +if (defined $ENV{'TMP'}) { + $SYSTMP="$ENV{'TMP'}"; +} elsif (defined $ENV{'TEMP'}) { + $SYSTMP="$ENV{'TEMP'}"; +} elsif (defined $ENV{'TMPDIR'}) { + $SYSTMP="$ENV{'TMPDIR'}"; +} else { + $SYSTMP="/tmp"; +} + +debug_msg "Internal variable SYSTMP set to '$SYSTMP'"; + +# Windows usually uses backslashes though forward slashes are probably +# allowed. Perl always needs forward slashes. + +# We convert backslashes to forward slashes if it looks like a Windows +# directory. +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^.:\\/); # c:\abc\def +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; + +sub check_tmpdir{ +die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" + unless (-d "$SYSTMP"); + +die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" + unless (-w "$SYSTMP"); +} + +# Determine INSTALLROOT. + +if ($opt_debug) { + my @path=split ':', $ENV{PATH}; + for my $dir (@path) { + debug_msg "Search for kpsewhich in '$dir'"; + opendir DIR, "$dir"; + my @kpsewichs=grep /^kpsewhich/, readdir DIR; + closedir DIR; + for (@kpsewichs) { + debug_msg "Found $dir/$_" if /^kpsewhich/; + } + } +} + + +if ($sys) { + $INSTALLROOT=expand_var 'TEXMFLOCAL'; +} else { + $INSTALLROOT=expand_var 'TEXMFHOME'; +} + +($sys)? debug_msg "sys=true":debug_msg "sys=false"; + +debug_msg "INSTALLROOT='$INSTALLROOT'"; + +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^.:\\/); # c:\abc\def +$INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; + +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); + + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { + print <<"ENDUSAGE"; + Directories: + temporary: '$SYSTMP/getfont-<PID>' + install: '$INSTALLROOT' + +ENDUSAGE +check_tmpdir; +check_installroot; +exit 0; +} + +check_tmpdir; +check_installroot; + +my $tmpdir="$SYSTMP/getfont-$$"; +debug_msg "Internal variable tmpdir set to '$tmpdir'"; + +mkdir "$tmpdir" or die "! ERROR: Can't mkdir '$tmpdir'."; +chdir "$tmpdir" or die "! ERROR: Can't cd '$tmpdir'."; + +sub remove_tmpdir { + chdir "$SYSTMP" or die "! ERROR: Can't cd '$SYSTMP'.\n"; + opendir TMPDIR, "$tmpdir" + or print "! ERROR: Can't read directory '$tmpdir'.\n"; + + @alltmps=readdir TMPDIR; + closedir TMPDIR; + + foreach $file (@alltmps) { + next if $file=~/^\./; + unlink "$tmpdir/$file"; + } + rmdir "$tmpdir" or die "! ERROR: Can't remove directory '$tmpdir'.\n"; +} + +# Signal handlers for UNIX, maybe ignored by Windows. + +$SIG{INT} =\&remove_tmpdir; +$SIG{QUIT}=\&remove_tmpdir; +$SIG{BUS} =\&remove_tmpdir; +$SIG{PIPE}=\&remove_tmpdir; +$SIG{TERM}=\&remove_tmpdir; +$SIG{ABRT}=\&remove_tmpdir; +$SIG{SEGV}=\&remove_tmpdir; + +# Download the script from tug.org. + +debug_msg "Running 'wget $getfont_url'"; + +system ('wget', "$getfont_url"); + +# Download the fonts. + +my @getfont=('perl', "./getfont$TL_version", '--getnonfreefonts'); +push @getfont, "--installroot=$INSTALLROOT"; +push @getfont, '--lsfonts' if $opt_lsfonts; +push @getfont, '--force' if $opt_force; +push @getfont, '--debug' if $opt_debug; +push @getfont, '--verbose' if $opt_verbose; +push @getfont, '--sys' if $sys; +push @getfont, '--all' if $opt_all; +push @getfont, @allpackages; + +debug_msg "Running '@getfont'"; + +system @getfont; + +# Evaluate the exit status. It will be 2 if something had been +# installed and in this case we need to run texhash/updmap. + +my $exit_code=$?; +my $exit_status=int($exit_code/256); + +if ($sys) { + debug_msg "Info: Execute updmap-sys if exit status is 2"; +} else { + debug_msg "Info: Execute updmap if exit status is 2"; +} + +debug_msg "Exit status of getfont$TL_version is $exit_status"; + +if ($exit_status==2) { + print "\n"; + system 'texhash', "$INSTALLROOT"; + $updmap_command=($sys)? 'updmap-sys':'updmap'; + @updmap=("$updmap_command"); + push @updmap, '--quiet' unless $opt_verbose; + print "\n"; + message "Updating map files ($updmap_command)..."; + system @updmap; + + message $?? '[failed]':'[done]'; +} + +remove_tmpdir; + +__END__ diff --git a/Master/bin/win32/getnonfreefonts.bat b/Master/bin/win32/getnonfreefonts.bat index 351934c96f3..91551f38d28 100644 --- a/Master/bin/win32/getnonfreefonts.bat +++ b/Master/bin/win32/getnonfreefonts.bat @@ -5,7 +5,7 @@ goto endofperl @rem ';
#!/usr/bin/env perl
#line 8
-$^W=1;
+#!/usr/bin/env perl
## getnonfreefonts
## Copyright 2006 Reinhard Kotucha <reinhard.kotucha@web.de>
@@ -57,10 +57,7 @@ EOF ;
}
-unless (@ARGV) {
- usage;
- exit 1;
-}
+@ARGS=@ARGV;
GetOptions
"all|a",
@@ -79,12 +76,22 @@ $sys=1 if $opt_sys; @allpackages=@ARGV;
+print "$TL_version\n" and exit 0 if $opt_version;
+
+if ($opt_help or !@ARGS) {
+ print "\nThis is getnonfreefonts";
+ print '-sys' if ($sys);
+ print ", version $TL_version.\n\n";
+ usage;
+}
+
+
sub message {
my $message=shift;
if ($message=~/^\[/) {
- print "$message\n";
+ print "$message\n";
} else {
- printf "%-60s", $message;
+ printf "%-60s", $message;
}
}
@@ -92,7 +99,7 @@ sub message { sub debug_msg {
my $message=shift;
if ($opt_debug) {
- print STDERR "DEBUG: $message.\n";
+ print STDERR "DEBUG: $message.\n";
}
}
@@ -101,33 +108,30 @@ sub expand_var { my $var=shift;
if (-d "/usr/bin") {
- open KPSEWHICH, 'kpsewhich --expand-var=\$' . "$var |";
+ open KPSEWHICH, 'kpsewhich --expand-var=\$' . "$var |";
} else {
- open KPSEWHICH, 'kpsewhich --expand-var=$' . "$var |";
+ open KPSEWHICH, 'kpsewhich --expand-var=$' . "$var |";
}
while (<KPSEWHICH>) {
- chop;
- return $_;
+ chop;
+ return $_;
}
close KPSEWHICH;
}
-
# get TMP|TEMP|TMPDIR environment variable
if ($opt_debug) {
for my $var ("TMP","TEMP","TMPDIR") {
- if (defined $ENV{$var}) {
- debug_msg "Environment variable $var='$ENV{$var}'";
- } else {
- debug_msg "Environment variable $var not set";
- }
+ if (defined $ENV{$var}) {
+ debug_msg "Environment variable $var='$ENV{$var}'";
+ } else {
+ debug_msg "Environment variable $var not set";
+ }
}
}
-print "$TL_version\n" and exit 0 if $opt_version;
-
if (defined $ENV{'TMP'}) {
$SYSTMP="$ENV{'TMP'}";
@@ -151,25 +155,26 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'";
+sub check_tmpdir{
die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n"
unless (-d "$SYSTMP");
die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n"
unless (-w "$SYSTMP");
-
+}
# Determine INSTALLROOT.
if ($opt_debug) {
my @path=split ':', $ENV{PATH};
for my $dir (@path) {
- debug_msg "Search for kpsewhich in '$dir'";
- opendir DIR, "$dir";
- my @kpsewichs=grep /^kpsewhich/, readdir DIR;
- closedir DIR;
- for (@kpsewichs) {
- debug_msg "Found $dir/$_" if /^kpsewhich/;
- }
+ debug_msg "Search for kpsewhich in '$dir'";
+ opendir DIR, "$dir";
+ my @kpsewichs=grep /^kpsewhich/, readdir DIR;
+ closedir DIR;
+ for (@kpsewichs) {
+ debug_msg "Found $dir/$_" if /^kpsewhich/;
+ }
}
}
@@ -189,28 +194,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'";
-die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n"
- unless (-d "$INSTALLROOT");
-
-die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n"
- unless (-w "$INSTALLROOT");
-
-
-if ($opt_help) {
- print "\nThis is getnonfreefonts";
- print '-sys' if ($sys);
- print ", version $TL_version.\n\n";
+sub check_installroot {
+ die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n"
+ unless (-d "$INSTALLROOT");
- usage;
+ die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n"
+ unless (-w "$INSTALLROOT");
+}
+
+if ($opt_help or !@ARGS) {
print <<"ENDUSAGE";
Directories:
temporary: '$SYSTMP/getfont-<PID>'
install: '$INSTALLROOT'
ENDUSAGE
+check_tmpdir;
+check_installroot;
exit 0;
}
+check_tmpdir;
+check_installroot;
my $tmpdir="$SYSTMP/getfont-$$";
debug_msg "Internal variable tmpdir set to '$tmpdir'";
@@ -221,14 +226,14 @@ chdir "$tmpdir" or die "! ERROR: Can't cd '$tmpdir'."; sub remove_tmpdir {
chdir "$SYSTMP" or die "! ERROR: Can't cd '$SYSTMP'.\n";
opendir TMPDIR, "$tmpdir"
- or print "! ERROR: Can't read directory '$tmpdir'.\n";
+ or print "! ERROR: Can't read directory '$tmpdir'.\n";
@alltmps=readdir TMPDIR;
closedir TMPDIR;
foreach $file (@alltmps) {
- next if $file=~/^\./;
- unlink "$tmpdir/$file";
+ next if $file=~/^\./;
+ unlink "$tmpdir/$file";
}
rmdir "$tmpdir" or die "! ERROR: Can't remove directory '$tmpdir'.\n";
}
@@ -271,7 +276,7 @@ system @getfont; my $exit_code=$?;
my $exit_status=int($exit_code/256);
-if ($sys) {
+if ($sys) {
debug_msg "Info: Execute updmap-sys if exit status is 2";
} else {
debug_msg "Info: Execute updmap if exit status is 2";
diff --git a/Master/bin/x86_64-linux/getnonfreefonts b/Master/bin/x86_64-linux/getnonfreefonts index 41f628becc0..969a251b52c 100755 --- a/Master/bin/x86_64-linux/getnonfreefonts +++ b/Master/bin/x86_64-linux/getnonfreefonts @@ -50,10 +50,7 @@ EOF ; } -unless (@ARGV) { - usage; - exit 1; -} +@ARGS=@ARGV; GetOptions "all|a", @@ -72,6 +69,16 @@ $sys=1 if $opt_sys; @allpackages=@ARGV; +print "$TL_version\n" and exit 0 if $opt_version; + +if ($opt_help or !@ARGS) { + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + usage; +} + + sub message { my $message=shift; if ($message=~/^\[/) { @@ -106,7 +113,6 @@ sub expand_var { } - # get TMP|TEMP|TMPDIR environment variable if ($opt_debug) { @@ -119,8 +125,6 @@ if ($opt_debug) { } } -print "$TL_version\n" and exit 0 if $opt_version; - if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; @@ -144,12 +148,13 @@ $SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; +sub check_tmpdir{ die "! ERROR: The temporary directory '$SYSTMP' doesn't exist.\n" unless (-d "$SYSTMP"); die "! ERROR: The temporary directory '$SYSTMP' is not writable.\n" unless (-w "$SYSTMP"); - +} # Determine INSTALLROOT. @@ -182,28 +187,28 @@ $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def debug_msg "Internal variable INSTALLROOT converted to '$INSTALLROOT'"; -die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" - unless (-d "$INSTALLROOT"); - -die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" - unless (-w "$INSTALLROOT"); - - -if ($opt_help) { - print "\nThis is getnonfreefonts"; - print '-sys' if ($sys); - print ", version $TL_version.\n\n"; +sub check_installroot { + die "! ERROR: The install directory '$INSTALLROOT' doesn't exist.\n" + unless (-d "$INSTALLROOT"); - usage; + die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" + unless (-w "$INSTALLROOT"); +} + +if ($opt_help or !@ARGS) { print <<"ENDUSAGE"; Directories: temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE +check_tmpdir; +check_installroot; exit 0; } +check_tmpdir; +check_installroot; my $tmpdir="$SYSTMP/getfont-$$"; debug_msg "Internal variable tmpdir set to '$tmpdir'"; |