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 /Master/tlpkg | |
parent | 62012ddf76cfb1d21e44055d61bfc80d81c318ac (diff) |
path add: do proper return code handling
git-svn-id: svn://tug.org/texlive/trunk@44872 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 58 |
1 files changed, 36 insertions, 22 deletions
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++; } } |