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>
* stow.in: added the '--subdir' option.

5
TODO
View file

@ -4,11 +4,6 @@
* 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?
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,
false conflicts might be reported (see ``Conflicts'' in the info manual).
.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"
.TP
.I --dir=DIR

31
stow.in
View file

@ -39,6 +39,7 @@ $ReportHelp = 0;
$Stow = undef;
$Target = undef;
$Restow = 0;
$Force = 0;
@Subdirs = ();
@ -55,6 +56,11 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} elsif ($opt =~ /^c(o(n(f(l(i(c(ts?)?)?)?)?)?)?)?$/i) {
$Conflicts = 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) {
$remainder = $';
if ($remainder =~ /^=/) {
@ -103,6 +109,11 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} elsif ($_ eq 'c') {
$Conflicts = 1;
$NotReally = 1;
} elsif ($_ eq 'i') {
$Conflicts = 1;
} elsif ($_ eq 'f') {
$Force = 1;
$Conflicts = 1;
} elsif ($_ eq 'd') {
$Stow = (join('', @opts) || shift);
@opts = ();
@ -434,23 +445,27 @@ sub StowNondir {
$linktarget))
|| (&Conflict($file, $subfile), return);
if (-e &JoinPaths($Stow, $stowsubfile)) {
(&Conflict($file, $subfile), return)
unless ($stowsubfile eq $file);
if ($stowsubfile eq $file) {
warn sprintf("%s already points to %s\n",
&JoinPaths($Target, $subfile),
&JoinPaths($Stow, $file))
if ($Verbose > 2);
return;
} else {
&DoUnlink(&JoinPaths($Target, $subfile));
&DoLink(&JoinPaths($stow, $file),
&JoinPaths($Target, $subfile));
&Conflict($file, $subfile);
return unless $Force;
warn "OVERRIDING link to ". &JoinPaths($Stow, $stowsubfile) . "\n"
if $Verbose;
}
}
&DoUnlink(&JoinPaths($Target, $subfile));
} elsif (-e &JoinPaths($Target, $subfile)) {
&Conflict($file, $subfile);
} else {
return;
}
&DoLink(&JoinPaths($stow, $file),
&JoinPaths($Target, $subfile));
}
}
sub DoUnlink {
@ -544,6 +559,8 @@ sub usage {
print <<EOT;
-n, --no Do not actually make changes
-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)
-t DIR, --target=DIR Set target to DIR (default is parent of stow 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,
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}
@itemx --dir=@var{dir}
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.)
A conflict causes Stow to exit immediately and print a warning
(unless @samp{-c} is given), even if that means aborting an installation
in mid-package.
(unless @samp{-c}, @samp{-i} or @samp{-f} are given), even if that means
aborting an installation in mid-package.
@cindex false conflict
When running Stow with the @samp{-n} or @samp{-c} options, no actual