added the '--subdir' option contributed by Anthony R Iano-Fletcher

This commit is contained in:
Guillaume Morin 2002-01-08 22:04:14 +00:00
parent 5dc4a381c6
commit 5d50efdfba
6 changed files with 51 additions and 6 deletions

View file

@ -9,7 +9,10 @@ current working directory.
Charles Briscoe-Smith <cpbs@debian.org> wrote the fix to prevent
stow -D / stow -R removing initially-empty directories.
Adam Lackorzynski <al10@inf.tu-dresden.de> wrote the fix to prevente
Adam Lackorzynski <al10@inf.tu-dresden.de> wrote the fix which prevents
the generation of wrong links if there are links in the stow directory.
Anthony R Iano-Fletcher <Anthony.Iano-Fletcher@cbel.cit.nih.gov>
contributed the '--subdirs' option.
Stow is currently maintained by Guillaume Morin <gmorin@gnu.org>.

View file

@ -1,3 +1,8 @@
Tue Jan 08 23:00:29 2002 Guillaume Morin <gmorin@gnu.org>
* stow.in: added the '--subdir' option.
* stow.texi,stow.8: documented '--subdir'
Sun Jan 06 12:18:50 2002 Guillaume Morin <gmorin@gnu.org>
* Makefile.am: use EXTRA_DIST to include manpage in distribution

View file

@ -3,7 +3,7 @@ dnl Process this file with Autoconf to produce configure
AC_INIT(stow.in)
PACKAGE=stow
VERSION=1.3.3
VERSION=1.3.3pre4
AM_INIT_AUTOMAKE(stow, $VERSION)
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

9
stow.8
View file

@ -6,7 +6,7 @@ stow \- software package installation manager
.RI [ options ]
.IR package ...
.SH DESCRIPTION
This manual page describes GNU Stow 1.3.3, 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
@ -188,6 +188,13 @@ Set the stow directory to DIR instead of the current directory.
This also has the effect of making the default target directory be
the parent of DIR.
.TP
.I "-s DIRS"
.TP
.I --subdirs=DIRS
Set the subdirectories of the package directory that are to be installed to a
colon delimited list of directories (e.g. bin:man or bin:lib:man). The default
is to install all the subdirectories.
.TP
.I "-t DIR"
.TP
.I --target=DIR

29
stow.in
View file

@ -39,6 +39,7 @@ $ReportHelp = 0;
$Stow = undef;
$Target = undef;
$Restow = 0;
@Subdirs = ();
# FIXME: use Getopt::Long
@ -68,6 +69,15 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} else {
$Target = shift;
}
} elsif ($opt =~ /^s(u(b(d(i(rs?)?)?)?)?)?/i) {
$remainder = $';
if ($remainder =~ /^=/) {
$remainder = $'; # the stuff after the =
} else {
$remainder = shift; # the following argument
}
@Subdirs = split(/:/, $remainder);
warn "remainder='$remainder' Subdirs = (@Subdirs)\n" if ($Verbose > 1);
} elsif ($opt =~ /^verb(o(se?)?)?/i) {
$remainder = $';
if ($remainder =~ /^=(\d+)/) {
@ -105,6 +115,9 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
$Delete = 1;
} elsif ($_ eq 'R') {
$Restow = 1;
} elsif ($_ eq 's') {
@Subdirs = split(/:/, (join('', @opts) || shift));
@opts = ();
} elsif ($_ eq 'V') {
&version();
} else {
@ -147,7 +160,7 @@ if ($Delete || $Restow) {
if (!$Delete || $Restow) {
foreach $Collection (@ARGV) {
warn "Stowing package $Collection...\n" if $Verbose;
&StowContents($Collection, &RelativePath($Target, $Stow));
&StowContents($Collection, &RelativePath($Target, $Stow), @Subdirs);
}
}
@ -323,17 +336,25 @@ sub EmptyTree {
}
sub StowContents {
local($dir, $stow) = @_;
local($dir, $stow, @subdirs) = @_;
local(@contents);
local($content);
warn "Stowing contents of $dir\n" if ($Verbose > 1);
local $text_subdirs = scalar(@subdirs) ? "/{".join(',',@subdirs)."} " : " ";
warn "Stowing contents of $dir in $stow".$text_subdirs."\n" if ($Verbose > 1);
opendir(DIR, &JoinPaths($Stow, $dir))
|| die "$ProgramName: Cannot read directory \"$dir\" ($!)\n";
@contents = readdir(DIR);
closedir(DIR);
foreach $content (@contents) {
next if (($content eq '.') || ($content eq '..'));
if (scalar(@subdirs)) {
warn "Checking $content against (".join(",",@subdirs).")\n" if ($Verbose > 2);
next if (!grep($_ eq $content, @subdirs));
}
if (-d &JoinPaths($Stow, $dir, $content)) {
&StowDir(&JoinPaths($dir, $content), $stow);
} else {
@ -525,6 +546,8 @@ sub usage {
-c, --conflicts Scan for conflicts, implies -n
-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,
--subdirs=DIR:DIR Set subdirs to recurse to DIR:DIR (default is all subdirs)
-v, --verbose[=N] Increase verboseness (levels are 0,1,2,3;
-v or --verbose adds 1; --verbose=N sets level)
-D, --delete Unstow instead of stow

View file

@ -247,6 +247,13 @@ Set the stow directory to @var{dir} instead of the current directory.
This also has the effect of making the default target directory be the
parent of @var{dir}.
@item -s @var{dirs}
@itemx --subdirs=@var{dirs}
Set the subdirectories of the package directory that are to be installed
to a colon delimited list of directories
(e.g. @samp{bin:man} or @samp{bin:lib:man}).
The default is to install all the subdirectories.
@item -t @var{dir}
@itemx --target=@var{dir}
Set the target directory to @var{dir} instead of the parent of the stow