bug-stow
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-stow] add absolute softlinks.


From: Todd Denniston
Subject: [Bug-stow] add absolute softlinks.
Date: Thu, 30 Oct 2003 14:20:26 -0500

from looking at the archives, this seems the appropriate mail group to send
patches to, sorry if I'm wrong.

Because of the way we use nfs bin directories, I found I needed to have stow
create absolute links instead of relative. 

The following patch allows the user to select absolute links, and updates the
documentation to reflect this.  As is documented there is only one minor
problem, which I can live with, if the target has been created with absolute
the user must specify absolute when deleting or restowing.

BTW I think you might want to try `grep "1\.3\." *` in a cvs checked out stow
directory and see if you need to update the version in some places...I noted
some inconsistencies.

P.S. are you going to do another 'release' any time soon
http://savannah.gnu.org/projects/stow shows the last one at 01/07/2002? 
also the subversions.gnu.org:/cvsroot/stow repository does not look like you
(or anyone) has updated it since 2002-12-10, is this the correct repo to be
working from? I noted that Alfred M. Szmidt's patch from 2003-06-14 has not
made it in yet.



-- 
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane) 
Harnessing the Power of Technology for the Warfighter
Index: stow.8
===================================================================
RCS file: /cvsroot/stow/stow/stow.8,v
retrieving revision 1.7
diff -u -r1.7 stow.8
--- stow.8      26 Jan 2002 15:21:11 -0000      1.7
+++ stow.8      30 Oct 2003 18:39:33 -0000
@@ -6,7 +6,7 @@
 .RI [ options ]
 .IR package ...
 .SH DESCRIPTION
-This manual page describes GNU Stow 1.3.4, a program for managing the
+This manual page describes GNU Stow 1.3.4?, a program for managing the
 installation of software packages. This is not the definitive
 documentation for stow; for that, see the info manual.
 .PP
@@ -144,7 +144,7 @@
 .IR / .
 The target of a relative symlink is
 computed starting from the symlink's own directory. Stow only creates
-relative symlinks.
+relative symlinks by default.
 .SH OPTIONS
 The stow directory is assumed to be the value of the 'STOW_DIR' environment 
 variable or if unset the current directory, and the
@@ -174,6 +174,15 @@
 .B would
 take place.
 .TP
+.I -a
+.TP
+.I --absolute
+Use absolute symlinks instead of relative symlinks. Note that 
+if the absolute option is used in the stowing, 
+it 
+.B must 
+also be on the stow command line when deleting or restowing.
+.TP
 .I -c
 .TP
 .I --conflicts
@@ -421,6 +430,15 @@
 .I .stow
 search the next time it encounters a
 tree-folding symlink.
+.IP *
+When deleting packages (see ``Deleting packages'') which have been 
+installed with the ''absolute'' option, the ``absolute'' option must be 
+used with the delete command.  If the ``absolute'' option is not used in 
+deleting links created with the ``absolute'' option, unexpected links 
+will be created and the target directory links will no longer be 
+recognized as stow controlled.  The links can be repaired by hand by 
+re-linking them with out the ``..'' sections on the front.
+
 .SH AUTHOR
 This man page was constructed by Charles Briscoe-Smith from
 parts of Stow's info manual. That manual contained the following
Index: stow.in
===================================================================
RCS file: /cvsroot/stow/stow/stow.in,v
retrieving revision 1.15
diff -u -r1.15 stow.in
--- stow.in     2 Dec 2002 00:16:03 -0000       1.15
+++ stow.in     30 Oct 2003 18:39:34 -0000
@@ -41,6 +41,7 @@
 $Restow = 0;
 $Force = 0;
 @Subdirs = ();
+$AbsoluteLinks = 0;
 
 use Getopt::Long;
 Getopt::Long::Configure ("gnu_getopt");
@@ -58,6 +59,7 @@
   'R|restow' => \$Restow,
   'V|version' => sub { my($arg, $val) = @_; &version() if ( $val ); },
   'h|help' => sub { my($arg, $val) = @_; &usage(undef) if ($val); },
+  'a|bsolute' => sub { $AbsoluteLinks = 1; },
 ) or usage(undef);
 
 &usage("No packages named") unless @ARGV;
@@ -87,13 +89,28 @@
 
 if ($Delete || $Restow) {
   @Collections = @ARGV;
-  &Unstow('', &RelativePath($Target, $Stow));
+  ##need to devise a test...if current links dont have .. as first
+  ##member go absolute.?? should it set absolute in a restow condition??(prob 
not).
+  if ($AbsoluteLinks eq 0) {
+    &Unstow('', &RelativePath($Target, $Stow));
+  }else{
+    &Unstow('', $Stow);
+  }
 }
 
 if (!$Delete || $Restow) {
   foreach $Collection (@ARGV) {
     warn "Stowing package $Collection...\n" if $Verbose;
-    &StowContents($Collection, &RelativePath($Target, $Stow), @Subdirs);
+    if ($AbsoluteLinks eq 0) {
+      warn "calling StowContents with RelativePath $Target & $Stow\n" if 
($Verbose > 2);
+      &StowContents($Collection, &RelativePath($Target, $Stow), @Subdirs);
+    }else{
+      warn "calling StowContents with Absolute paths to $Stow\n" if ($Verbose 
> 2);
+      #until a test is devised for delete to figure out absolute was used, the
+      #user should be warned.
+      warn "You'll need to remember to use 'absolute' when delete-ing or 
restow-ing.\n" if (1 == 1);
+      &StowContents($Collection, $Stow, @Subdirs);
+    }
   }
 }
 
@@ -289,6 +306,7 @@
     }
 
     if (-d &JoinPaths($Stow, $dir, $content)) {
+      warn "calling StowDir for $dir $content & $stow\n" if ($Verbose > 2);
       &StowDir(&JoinPaths($dir, $content), $stow);
     } else {
       &StowNondir(&JoinPaths($dir, $content), $stow);
@@ -302,6 +320,7 @@
   local($collection) = shift(@dir);
   local($subdir) = join('/', @dir);
   local($linktarget, $stowsubdir);
+  local($tadstowstart, @tadstow);
 
   warn "Stowing directory $dir\n" if ($Verbose > 1);
   if (-l &JoinPaths($Target, $subdir)) {
@@ -326,9 +345,18 @@
       if (-d &JoinPaths($Stow, $stowsubdir)) {
        &DoUnlink(&JoinPaths($Target, $subdir));
        &DoMkdir(&JoinPaths($Target, $subdir));
-       &StowContents($stowsubdir, &JoinPaths('..', $stow));
-       &StowContents($dir, &JoinPaths('..', $stow));
+       warn "StowDir  linktarget($linktarget) 
stowsubdir($stowsubdir)\nTarget($Target) subdir($subdir)\nstow($stow)\n" if 
($Verbose > 2);
+       @tadstow == split(/\/+/, $stow);
+       $tadstowstart = shift(@tadstow);
+       if($tadstowstart eq '..') {
+         &StowContents($stowsubdir, &JoinPaths('..', $stow));
+         &StowContents($dir, &JoinPaths('..', $stow));
+       }else{
+         &StowContents($stowsubdir, $stow);
+         &StowContents($dir, $stow);
+       }
       } else {
+       warn "conflict 2" if ($Verbose > 2);
        (&Conflict($dir, $subdir), return);
       }
     } else {
@@ -338,11 +366,19 @@
     }
   } elsif (-e &JoinPaths($Target, $subdir)) {
     if (-d &JoinPaths($Target, $subdir)) {
-      &StowContents($dir, &JoinPaths('..', $stow));
+       @tadstow == split(/\/+/, $stow);
+       $tadstowstart = shift(@tadstow);
+       if($tadstowstart eq '..') {
+         &StowContents($dir, &JoinPaths('..', $stow));
+       }else{
+         &StowContents($dir, $stow);
+       }
     } else {
+       warn "conflict 3" if ($Verbose > 2);
       &Conflict($dir, $subdir);
     }
   } else {
+    warn "making link for $stow $dir\n" if ($Verbose > 2);
     &DoLink(&JoinPaths($stow, $dir),
            &JoinPaths($Target, $subdir));
   }
@@ -445,21 +481,55 @@
   local($x);
   local(@d) = split(/\/+/, $Stow);
 
-  while (@path) {
-    $x = shift(@path);
-    if ($x eq '..') {
-      # ignore if /, since /.. is /
-      pop(@x) if scalar(@x) > 1;
-    } elsif ($x ne '.') {
-      push(@x, $x);
+  warn "FindStowMember  ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
+
+  $x = shift(@path);
+  local(@path) = split(/\/+/, $path);
+  warn "FindStowMember1 ($x) (@path)\n" if ($Verbose > 2);
+  if($x eq '..') {
+    warn "FindStowMember1.10($x) (@x)\n" if ($Verbose > 2);
+    #beforetad
+    while (@path) {
+      $x = shift(@path);
+      if ($x eq '..') {
+       warn "FindStowMember1.15($x) (@x)\n" if ($Verbose > 2);
+       # ignore if /, since /.. is /
+       pop(@x) if scalar(@x) > 1;
+      } elsif ($x ne '.') {
+       warn "FindStowMember1.17($x) (@x)\n" if ($Verbose > 2);
+       push(@x, $x);
+      }
     }
+    #beforetad
+  } else {
+    warn "FindStowMember1.20($x) (@x)\n" if ($Verbose > 2);
+    @x='';#blank @x
+    shift(@x);#now remove the blank.
+    warn "FindStowMember1.20($x) (@x)\n" if ($Verbose > 2);
+    while (@path) {
+      $x = shift(@path);
+      if ($x eq '..') {
+       warn "FindStowMember1.25($x) (@x)\n" if ($Verbose > 2);
+       # ignore if /, since /.. is /
+       pop(@x) if scalar(@x) > 1;
+      } elsif ($x ne '.') {
+       warn "FindStowMember1.27 ($x) (@x)\n" if ($Verbose > 2);
+       push(@x, $x);
+      }
+    }    
   }
+
+  warn "FindStowMember2 ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
   while (@x && @d) {
+    warn "FindStowMemberA ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
     if (($x = shift(@x)) ne shift(@d)) {
+      warn "FindStowMemberB ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
       return '';
     }
   }
+  warn "FindStowMember3 ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
   return '' if @d;
+  warn "FindStowMember4 ($start) ($path) \n(@x) (@path)\n ($x) (@d) \n" if 
($Verbose > 2);
   join('/', @x);
 }
 
@@ -482,6 +552,7 @@
   print "Usage: $ProgramName [OPTION ...] PACKAGE ...\n";
   print <<EOT;
   -n, --no              Do not actually make changes
+  -a, --absolute        Use the full path instead of relative symlinks
   -c, --conflicts       Scan for conflicts, implies -n
   -i, --ignore          Ignore conflicts.
   -f, --force           Try to override conflicts.
Index: stow.texi
===================================================================
RCS file: /cvsroot/stow/stow/stow.texi,v
retrieving revision 1.7
diff -u -r1.7 stow.texi
--- stow.texi   26 Jan 2002 15:21:11 -0000      1.7
+++ stow.texi   30 Oct 2003 18:39:34 -0000
@@ -204,7 +204,9 @@
 starting from @file{/}.  A relative symlink names a relative path; that
 is, one not starting from @file{/}.  The target of a relative symlink is
 computed starting from the symlink's own directory.  Stow only
-creates relative symlinks.
+creates relative symlinks by default use the @dfn{absolute} option to
+use absolute symlinks. Note that if the @dfn{absolute} option is used in 
+creation, it must also be on the command line when deleting or restowing.
 
 @node Invoking Stow, Installing packages, Terminology, Top
 @chapter Invoking Stow
@@ -235,6 +237,12 @@
 place (@pxref{Conflicts}); but it won't fail to report conflicts that
 @emph{would} take place.
 
address@hidden -a
address@hidden --absolute
+Use absolute symlinks instead of relative symlinks. Note that 
+if the @dfn{absolute} option is used in the stowing, 
+it must also be on the stow command line when deleting or restowing.
+
 @item -c
 @itemx --conflicts
 Do not exit immediately when a conflict is encountered.  This option
@@ -404,6 +412,9 @@
 removing the directory, then linking the directory back to the surviving
 package.
 
+Note that if the absolute option was used in the original stow command it 
+must be used in the delete command to have expected results @pxref{Known bugs}.
+
 @node Caveats, Bootstrapping, Deleting packages, Top
 @chapter Caveats
 
@@ -799,6 +810,15 @@
 path contains a @file{.stow} file.  If it finds one, it can ``learn''
 about the cooperating stow directory to short-circuit the @file{.stow}
 search the next time it encounters a tree-folding symlink.
+
address@hidden
+When deleting packages (@pxref{Deleting packages}) which have been 
+installed with the @dfn{absolute} option, the @dfn{absolute} option must be 
+used with the delete command.  If the @dfn{absolute} option is not used in 
+deleting links created with the @dfn{absolute} option, unexpected links 
+will be created and the target directory links will no longer be 
+recognized as stow controlled.  The links can be repaired by hand by 
+re-linking them with out the @dfn{..} sections on the front.
 @end itemize
 
 @node GNU General Public License, Index, Known bugs, Top

reply via email to

[Prev in Thread] Current Thread [Next in Thread]