texlive[44872] Master: path add: do proper return code handling

commits+preining at tug.org commits+preining at tug.org
Sun Jul 23 15:31:08 CEST 2017


Revision: 44872
          http://tug.org/svn/texlive?view=revision&revision=44872
Author:   preining
Date:     2017-07-23 15:31:08 +0200 (Sun, 23 Jul 2017)
Log Message:
-----------
path add: do proper return code handling

Modified Paths:
--------------
    trunk/Master/install-tl
    trunk/Master/tlpkg/TeXLive/TLUtils.pm

Modified: trunk/Master/install-tl
===================================================================
--- trunk/Master/install-tl	2017-07-23 13:31:00 UTC (rev 44871)
+++ trunk/Master/install-tl	2017-07-23 13:31:08 UTC (rev 44872)
@@ -1113,7 +1113,7 @@
   # 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,6 +1199,7 @@
 } # 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',
@@ -1205,11 +1206,14 @@
       $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
 
 

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2017-07-23 13:31:00 UTC (rev 44871)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2017-07-23 13:31:08 UTC (rev 44872)
@@ -833,13 +833,13 @@
         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 @@
 
 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 @@
         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 @@
   } 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 @@
     ; # 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++;
     }
   }
   



More information about the tex-live-commits mailing list