diff options
author | Norbert Preining <preining@logic.at> | 2017-07-23 13:31:08 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-07-23 13:31:08 +0000 |
commit | 58f4676b08059aa9e7d04becc006494c0ad0386e (patch) | |
tree | 51d760e90ef37a029dea4e43f952875108378724 | |
parent | 62012ddf76cfb1d21e44055d61bfc80d81c318ac (diff) |
path add: do proper return code handling
git-svn-id: svn://tug.org/texlive/trunk@44872 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/install-tl | 12 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 58 |
2 files changed, 44 insertions, 26 deletions
diff --git a/Master/install-tl b/Master/install-tl index b0941dcbfed..7ce895d60d6 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -1113,7 +1113,7 @@ operations might be disturbed.\n\n"; # on Unix set symlinks # for portable, this option should be unset # it should not be necessary to test separately for portable - do_path_adjustments() if + $errcount += do_path_adjustments() if $vars{'instopt_adjustpath'} and $vars{tlpdbopt_desktop_integration} != 2; # now do the system integration: @@ -1199,17 +1199,21 @@ sub rewrite_tlaunch_ini { } # rewrite_tlaunch_ini sub do_path_adjustments { + my $ret = 0; info ("running path adjustment actions\n"); if (win32()) { TeXLive::TLUtils::w32_add_to_path($vars{'TEXDIR'}.'/bin/win32', $vars{'tlpdbopt_w32_multi_user'}); broadcast_env(); } else { - TeXLive::TLUtils::add_symlinks($vars{'TEXDIR'}, $vars{'this_platform'}, - $vars{'tlpdbopt_sys_bin'}, $vars{'tlpdbopt_sys_man'}, - $vars{'tlpdbopt_sys_info'}); + if (!TeXLive::TLUtils::add_symlinks($vars{'TEXDIR'}, $vars{'this_platform'}, + $vars{'tlpdbopt_sys_bin'}, $vars{'tlpdbopt_sys_man'}, + $vars{'tlpdbopt_sys_info'})) { + $ret = 1; + } } info ("finished with path adjustment actions\n"); + return $ret; } # do_path_adjustments diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index d721baced01..f3767b7889a 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -833,13 +833,13 @@ sub mkdirhier { if (defined $mode) { if (! mkdir ($subdir, $mode)) { $ret = 0; - $reterror = "mkdir($subdir,$mode) failed, goodbye: $!"; + $reterror = "mkdir($subdir,$mode) failed: $!"; last; } } else { if (! mkdir ($subdir)) { $ret = 0; - $reterror = "mkdir($subdir) failed, goodbye: $!"; + $reterror = "mkdir($subdir) failed: $!"; last; } } @@ -1839,7 +1839,11 @@ On Windows it returns undefined. sub add_link_dir_dir { my ($from,$to) = @_; - mkdirhier ($to); + my ($ret, $err) = mkdirhier ($to); + if (!$ret) { + tlwarn("$err\n"); + return 0; + } if (-w $to) { debug ("linking files from $from to $to\n"); chomp (@files = `ls "$from"`); @@ -1894,7 +1898,7 @@ sub remove_link_dir_dir { tlwarn ("not removing $to/$f, not a link or wrong destination!\n"); } } - # trry to remove the destination directory, it might be empty and + # try to remove the destination directory, it might be empty and # we might have write permissions, ignore errors # `rmdir "$to" 2>/dev/null`; return $ret; @@ -1926,7 +1930,7 @@ sub add_remove_symlinks { } else { die ("should not happen, unknown mode $mode in add_remove_symlinks!"); } - + # man my $top_man_dir = "$Master/texmf-dist/doc/man"; debug("$mode symlinks for man pages to $sys_man from $top_man_dir\n"); @@ -1934,25 +1938,35 @@ sub add_remove_symlinks { ; # better to be silent? #info("skipping add of man symlinks, no source directory $top_man_dir\n"); } else { - mkdirhier $sys_man if ($mode eq "add"); - if (-w $sys_man) { - my $foo = `(cd "$top_man_dir" && echo *)`; - my @mans = split (' ', $foo); - chomp (@mans); - foreach my $m (@mans) { - my $mandir = "$top_man_dir/$m"; - next unless -d $mandir; - if ($mode eq "add") { - $errors++ unless add_link_dir_dir($mandir, "$sys_man/$m"); - } else { - $errors++ unless remove_link_dir_dir($mandir, "$sys_man/$m"); + my $man_doable = 1; + if ($mode eq "add") { + my ($ret, $err) = mkdirhier $sys_man; + if (!$ret) { + $man_doable = 0; + tlwarn("$err\n"); + $errors++; + } + } + if ($man_doable) { + if (-w $sys_man) { + my $foo = `(cd "$top_man_dir" && echo *)`; + my @mans = split (' ', $foo); + chomp (@mans); + foreach my $m (@mans) { + my $mandir = "$top_man_dir/$m"; + next unless -d $mandir; + if ($mode eq "add") { + $errors++ unless add_link_dir_dir($mandir, "$sys_man/$m"); + } else { + $errors++ unless remove_link_dir_dir($mandir, "$sys_man/$m"); + } } + #`rmdir "$sys_man" 2>/dev/null` if ($mode eq "remove"); + } else { + tlwarn("man symlink destination ($sys_man) not writable, " + . "cannot $mode symlinks.\n"); + $errors++; } - #`rmdir "$sys_man" 2>/dev/null` if ($mode eq "remove"); - } else { - tlwarn("man symlink destination ($sys_man) not writable," - . "cannot $mode symlinks.\n"); - $errors++; } } |