added the '--ignore' and '--force' options

This commit is contained in:
Gaël Roualland 2002-01-09 01:25:55 +00:00
parent 5d50efdfba
commit 185531cc01
5 changed files with 64 additions and 20 deletions

View file

@ -1,3 +1,9 @@
Wed Jan 9 02:20:15 2002 Gaël Roualland <gael.roualland@iname.com>
* stow.in: added the '--ignore' and '--force' options.
* stow.texi,stow.8: documented '--ignore' and '--force'.
* TODO: removed reference to '--ignore' like feature.
Tue Jan 08 23:00:29 2002 Guillaume Morin <gmorin@gnu.org> Tue Jan 08 23:00:29 2002 Guillaume Morin <gmorin@gnu.org>
* stow.in: added the '--subdir' option. * stow.in: added the '--subdir' option.

5
TODO
View file

@ -4,11 +4,6 @@
* Fix empty-dir problem (see "Known bugs" in the manual) * Fix empty-dir problem (see "Known bugs" in the manual)
* Continue after conflicts.
When detecting a conflict, affected subparts of the Stow traversal can
be skipped while continuing with other subparts.
* Traverse links in the target tree? * Traverse links in the target tree?
From e-mail with meyering@na-net.ornl.gov: From e-mail with meyering@na-net.ornl.gov:

14
stow.8
View file

@ -181,6 +181,20 @@ option implies `-n', and is used to search for all conflicts that
might arise from an actual Stow operation. As with `-n', however, might arise from an actual Stow operation. As with `-n', however,
false conflicts might be reported (see ``Conflicts'' in the info manual). false conflicts might be reported (see ``Conflicts'' in the info manual).
.TP .TP
.I -i
.TP
.I --ignore
Do not exit immediatly when a conflict is encountered, but continue
processing the package.
.TP
.I -f
.TP
.I --force
Try to override conflicts by removing conflicting links. This will
only remove links to other packages in the stow directory. Other
links or files will not be removed (it will be similar to `-i' in
that case).
.TP
.I "-d DIR" .I "-d DIR"
.TP .TP
.I --dir=DIR .I --dir=DIR

31
stow.in
View file

@ -39,6 +39,7 @@ $ReportHelp = 0;
$Stow = undef; $Stow = undef;
$Target = undef; $Target = undef;
$Restow = 0; $Restow = 0;
$Force = 0;
@Subdirs = (); @Subdirs = ();
@ -55,6 +56,11 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} elsif ($opt =~ /^c(o(n(f(l(i(c(ts?)?)?)?)?)?)?)?$/i) { } elsif ($opt =~ /^c(o(n(f(l(i(c(ts?)?)?)?)?)?)?)?$/i) {
$Conflicts = 1; $Conflicts = 1;
$NotReally = 1; $NotReally = 1;
} elsif ($opt =~ /^i(g(n(o(r(e?)?)?)?)?)$/i) {
$Conflicts = 1;
} elsif ($opt =~ /^f(o(r(c(e?)?)?)?)$/i) {
$Force = 1;
$Conflicts = 1;
} elsif ($opt =~ /^dir?/i) { } elsif ($opt =~ /^dir?/i) {
$remainder = $'; $remainder = $';
if ($remainder =~ /^=/) { if ($remainder =~ /^=/) {
@ -103,6 +109,11 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} elsif ($_ eq 'c') { } elsif ($_ eq 'c') {
$Conflicts = 1; $Conflicts = 1;
$NotReally = 1; $NotReally = 1;
} elsif ($_ eq 'i') {
$Conflicts = 1;
} elsif ($_ eq 'f') {
$Force = 1;
$Conflicts = 1;
} elsif ($_ eq 'd') { } elsif ($_ eq 'd') {
$Stow = (join('', @opts) || shift); $Stow = (join('', @opts) || shift);
@opts = (); @opts = ();
@ -434,24 +445,28 @@ sub StowNondir {
$linktarget)) $linktarget))
|| (&Conflict($file, $subfile), return); || (&Conflict($file, $subfile), return);
if (-e &JoinPaths($Stow, $stowsubfile)) { if (-e &JoinPaths($Stow, $stowsubfile)) {
(&Conflict($file, $subfile), return) if ($stowsubfile eq $file) {
unless ($stowsubfile eq $file);
warn sprintf("%s already points to %s\n", warn sprintf("%s already points to %s\n",
&JoinPaths($Target, $subfile), &JoinPaths($Target, $subfile),
&JoinPaths($Stow, $file)) &JoinPaths($Stow, $file))
if ($Verbose > 2); if ($Verbose > 2);
return;
} else { } else {
&DoUnlink(&JoinPaths($Target, $subfile)); &Conflict($file, $subfile);
&DoLink(&JoinPaths($stow, $file), return unless $Force;
&JoinPaths($Target, $subfile)); warn "OVERRIDING link to ". &JoinPaths($Stow, $stowsubfile) . "\n"
if $Verbose;
} }
}
&DoUnlink(&JoinPaths($Target, $subfile));
} elsif (-e &JoinPaths($Target, $subfile)) { } elsif (-e &JoinPaths($Target, $subfile)) {
&Conflict($file, $subfile); &Conflict($file, $subfile);
} else { return;
}
&DoLink(&JoinPaths($stow, $file), &DoLink(&JoinPaths($stow, $file),
&JoinPaths($Target, $subfile)); &JoinPaths($Target, $subfile));
} }
}
sub DoUnlink { sub DoUnlink {
local($file) = @_; local($file) = @_;
@ -544,6 +559,8 @@ sub usage {
print <<EOT; print <<EOT;
-n, --no Do not actually make changes -n, --no Do not actually make changes
-c, --conflicts Scan for conflicts, implies -n -c, --conflicts Scan for conflicts, implies -n
-i, --ignore Ignore conflicts.
-f, --force Try to override conflicts.
-d DIR, --dir=DIR Set stow dir to DIR (default is current dir) -d DIR, --dir=DIR Set stow dir to DIR (default is current dir)
-t DIR, --target=DIR Set target to DIR (default is parent of stow dir) -t DIR, --target=DIR Set target to DIR (default is parent of stow dir)
-s DIR:DIR, -s DIR:DIR,

View file

@ -241,6 +241,18 @@ implies @samp{-n}, and is used to search for all conflicts that might
arise from an actual Stow operation. As with @samp{-n}, however, arise from an actual Stow operation. As with @samp{-n}, however,
false conflicts might be reported (@pxref{Conflicts}). false conflicts might be reported (@pxref{Conflicts}).
@item -i
@itemx --ignore
Do not exit immediatly when a conflict is encountered, but continue
processing the package.
@item -f
@itemx --force
Try to override conflicts by removing conflicting links. This will
only remove links to other packages in the stow directory. Other
links or files will not be removed (it will be similar to @samp{-i} in
that case).
@item -d @var{dir} @item -d @var{dir}
@itemx --dir=@var{dir} @itemx --dir=@var{dir}
Set the stow directory to @var{dir} instead of the current directory. Set the stow directory to @var{dir} instead of the current directory.
@ -697,8 +709,8 @@ where Stow needs it to, then no conflict has occurred. (Thus it
is harmless to install a package that has already been installed.) is harmless to install a package that has already been installed.)
A conflict causes Stow to exit immediately and print a warning A conflict causes Stow to exit immediately and print a warning
(unless @samp{-c} is given), even if that means aborting an installation (unless @samp{-c}, @samp{-i} or @samp{-f} are given), even if that means
in mid-package. aborting an installation in mid-package.
@cindex false conflict @cindex false conflict
When running Stow with the @samp{-n} or @samp{-c} options, no actual When running Stow with the @samp{-n} or @samp{-c} options, no actual