From ee72c8e218febb4e5e2395951e36cd91b36aabcd Mon Sep 17 00:00:00 2001 From: Reinhard Kotucha Date: Wed, 6 Dec 2006 00:44:25 +0000 Subject: Bug fixed. git-svn-id: svn://tug.org/texlive/trunk@2597 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/texlive/getnonfreefonts | 19 ++-- Build/source/texk/texlive/getnonfreefonts.man | 11 +++ Master/bin/win32/getnonfreefonts-sys.bat | 136 +++++++++++++++++++++----- Master/bin/win32/getnonfreefonts.bat | 136 +++++++++++++++++++++----- 4 files changed, 246 insertions(+), 56 deletions(-) diff --git a/Build/source/texk/texlive/getnonfreefonts b/Build/source/texk/texlive/getnonfreefonts index 4e71eeeaa69..f91af05f4f5 100644 --- a/Build/source/texk/texlive/getnonfreefonts +++ b/Build/source/texk/texlive/getnonfreefonts @@ -34,7 +34,7 @@ Usage: Options: -a|--all Install all fonts. - -d|--debug Provide additional messages for debugging.. + -d|--debug Provide additional messages for debugging. -f|--force Install fonts even if they are installed already. @@ -60,6 +60,7 @@ GetOptions "help|h", "lsfonts|l", "verbose|v", + "version", "sys"; $^W=1 if $opt_debug; @@ -116,13 +117,15 @@ if ($opt_debug) { } } +print "$TL_version\n" and exit 0 if $opt_version; + if (defined $ENV{'TMP'}) { $SYSTMP="$ENV{'TMP'}"; } elsif (defined $ENV{'TEMP'}) { $SYSTMP="$ENV{'TEMP'}"; } elsif (defined $ENV{'TMPDIR'}) { - $SYSTMP="$ENV{'SYSTMP'}"; + $SYSTMP="$ENV{'TMPDIR'}"; } else { $SYSTMP="/tmp"; } @@ -159,9 +162,9 @@ if ($opt_debug) { debug_msg "Found $dir/$_" if /^kpsewhich/; } } - } + if ($sys) { $INSTALLROOT=expand_var 'TEXMFLOCAL'; } else { @@ -185,9 +188,13 @@ die "! ERROR: The install directory '$INSTALLROOT' is not writable.\n" if ($opt_help) { - usage; - print <<"ENDUSAGE"; - Directories: + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + + usage; + print <<"ENDUSAGE"; + Directories: temporary: '$SYSTMP/getfont-' install: '$INSTALLROOT' diff --git a/Build/source/texk/texlive/getnonfreefonts.man b/Build/source/texk/texlive/getnonfreefonts.man index ea039466572..0c2da752fbf 100644 --- a/Build/source/texk/texlive/getnonfreefonts.man +++ b/Build/source/texk/texlive/getnonfreefonts.man @@ -56,6 +56,12 @@ to get a list of supported fonts. .rg Install all fonts. +.TP +.BR "-d" , " --debug" +.rg +Provide additional messages for debugging. These messages are sent to +STDERR. + .TP .BR "-f" , " --force" .rg @@ -90,6 +96,11 @@ option it behaves exactly like .rg Be more verbose. This option is only needed for debugging. +.TP +.BR "--version" +.rg +Print version number. + .SH ENVIRONMENT One of the environment variables .BR "TMP" , " TEMP" , diff --git a/Master/bin/win32/getnonfreefonts-sys.bat b/Master/bin/win32/getnonfreefonts-sys.bat index 269f3d5cba6..3ad7e362a4d 100755 --- a/Master/bin/win32/getnonfreefonts-sys.bat +++ b/Master/bin/win32/getnonfreefonts-sys.bat @@ -20,7 +20,7 @@ $^W=1; 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; @@ -41,6 +41,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. @@ -65,6 +67,7 @@ GetOptions "help|h", "lsfonts|l", "verbose|v", + "version", "sys"; $^W=1 if $opt_debug; @@ -83,6 +86,15 @@ sub message { } } + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } +} + + sub expand_var { my $var=shift; @@ -98,49 +110,99 @@ 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"; + } + } +} + +print "$TL_version\n" and exit 0 if $opt_version; + + 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{'TMPDIR'}"; } 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 directory '$systmp' doesn't exist.\n" - unless (-d "$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/; + } + } +} -die "! ERROR: The directory '$systmp' is not writable.\n" - unless (-w "$systmp"); + +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 -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-' + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + + usage; + print <<"ENDUSAGE"; + Directories: + temporary: '$SYSTMP/getfont-' install: '$INSTALLROOT' ENDUSAGE @@ -148,12 +210,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"; @@ -177,21 +241,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"; @@ -199,7 +283,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]'; @@ -208,4 +293,5 @@ if ($exit_status==2) { remove_tmpdir; __END__ + :endofperl diff --git a/Master/bin/win32/getnonfreefonts.bat b/Master/bin/win32/getnonfreefonts.bat index 269f3d5cba6..3ad7e362a4d 100755 --- a/Master/bin/win32/getnonfreefonts.bat +++ b/Master/bin/win32/getnonfreefonts.bat @@ -20,7 +20,7 @@ $^W=1; 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; @@ -41,6 +41,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. @@ -65,6 +67,7 @@ GetOptions "help|h", "lsfonts|l", "verbose|v", + "version", "sys"; $^W=1 if $opt_debug; @@ -83,6 +86,15 @@ sub message { } } + +sub debug_msg { + my $message=shift; + if ($opt_debug) { + print STDERR "DEBUG: $message.\n"; + } +} + + sub expand_var { my $var=shift; @@ -98,49 +110,99 @@ 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"; + } + } +} + +print "$TL_version\n" and exit 0 if $opt_version; + + 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{'TMPDIR'}"; } 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 directory '$systmp' doesn't exist.\n" - unless (-d "$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/; + } + } +} -die "! ERROR: The directory '$systmp' is not writable.\n" - unless (-w "$systmp"); + +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 -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-' + print "\nThis is getnonfreefonts"; + print '-sys' if ($sys); + print ", version $TL_version.\n\n"; + + usage; + print <<"ENDUSAGE"; + Directories: + temporary: '$SYSTMP/getfont-' install: '$INSTALLROOT' ENDUSAGE @@ -148,12 +210,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"; @@ -177,21 +241,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"; @@ -199,7 +283,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]'; @@ -208,4 +293,5 @@ if ($exit_status==2) { remove_tmpdir; __END__ + :endofperl -- cgit v1.2.3