diff options
author | Reinhard Kotucha <reinhard.kotucha@web.de> | 2006-12-01 00:30:38 +0000 |
---|---|---|
committer | Reinhard Kotucha <reinhard.kotucha@web.de> | 2006-12-01 00:30:38 +0000 |
commit | e7ebe52239446fc14659c9f283c5a0bf570cdf04 (patch) | |
tree | 373ae585296dce3a1b12b6fe5ad3e14390b4c9bf /Build | |
parent | 3294fccfff998be5fdc8edcc0daaea241c2bfe51 (diff) |
update getnonfreefonts.
git-svn-id: svn://tug.org/texlive/trunk@2567 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/texlive/getnonfreefonts | 122 |
1 files changed, 100 insertions, 22 deletions
diff --git a/Build/source/texk/texlive/getnonfreefonts b/Build/source/texk/texlive/getnonfreefonts index 4072a0917fe..4e71eeeaa69 100644 --- a/Build/source/texk/texlive/getnonfreefonts +++ b/Build/source/texk/texlive/getnonfreefonts @@ -13,7 +13,7 @@ my $TL_version='2006'; -my $getfont_url="ftp://tug.org/tex/getnonfreefonts/getfont2006"; +my $getfont_url="ftp://tug.org/tex/getnonfreefonts/getfont$TL_version"; use File::Copy; use Getopt::Long; @@ -34,6 +34,8 @@ Usage: 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. @@ -76,6 +78,15 @@ sub message { } } + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } +} + + sub expand_var { my $var=shift; @@ -91,49 +102,93 @@ sub expand_var { close KPSEWHICH; } -if ($sys) { - $INSTALLROOT=expand_var 'TEXMFLOCAL'; -} else { - $INSTALLROOT=expand_var 'TEXMFHOME'; -} + # 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'}"; + $SYSTMP="$ENV{'TMP'}"; } elsif (defined $ENV{'TEMP'}) { - $systmp="$ENV{'TEMP'}"; + $SYSTMP="$ENV{'TEMP'}"; } elsif (defined $ENV{'TMPDIR'}) { - $systmp="$ENV{'SYSTMP'}"; + $SYSTMP="$ENV{'SYSTMP'}"; } else { - $systmp="/tmp"; + $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 +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^.:\\/); # c:\abc\def +$SYSTMP=~s/\\/\//g if ($SYSTMP=~/^\\\\/); # \\abc\def + +debug_msg "Internal variable SYSTMP converted to '$SYSTMP'"; + +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'; +} -die "! ERROR: The directory '$systmp' doesn't exist.\n" - unless (-d "$systmp"); +($sys)? debug_msg "sys=true":debug_msg "sys=false"; -die "! ERROR: The directory '$systmp' is not writable.\n" - unless (-w "$systmp"); +debug_msg "INSTALLROOT='$INSTALLROOT'"; $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^.:\\/); # c:\abc\def $INSTALLROOT=~s/\\/\//g if ($INSTALLROOT=~/^\\\\/); # \\abc\def -die "! ERROR: The directory '$INSTALLROOT' is not writable.\n" +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) { usage; print <<"ENDUSAGE"; Directories: - temporary: '$systmp/getfont-<PID>' + temporary: '$SYSTMP/getfont-<PID>' install: '$INSTALLROOT' ENDUSAGE @@ -141,12 +196,14 @@ exit 0; } -my $tmpdir="$systmp/getfont-$$"; +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"; + chdir "$SYSTMP" or die "! ERROR: Can't cd '$SYSTMP'.\n"; opendir TMPDIR, "$tmpdir" or print "! ERROR: Can't read directory '$tmpdir'.\n"; @@ -170,21 +227,41 @@ $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"; @@ -192,7 +269,8 @@ if ($exit_status==2) { $updmap_command=($sys)? 'updmap-sys':'updmap'; @updmap=("$updmap_command"); push @updmap, '--quiet' unless $opt_verbose; - message "\nUpdating map files ($updmap_command)..."; + print "\n"; + message "Updating map files ($updmap_command)..."; system @updmap; message $?? '[failed]':'[done]'; |