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 Charles Briscoe-Smith <cpbs@debian.org> wrote the fix to prevent
stow -D / stow -R removing initially-empty directories. 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. 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>. 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> Sun Jan 06 12:18:50 2002 Guillaume Morin <gmorin@gnu.org>
* Makefile.am: use EXTRA_DIST to include manpage in distribution * 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) AC_INIT(stow.in)
PACKAGE=stow PACKAGE=stow
VERSION=1.3.3 VERSION=1.3.3pre4
AM_INIT_AUTOMAKE(stow, $VERSION) AM_INIT_AUTOMAKE(stow, $VERSION)
AC_SUBST(PACKAGE) AC_SUBST(PACKAGE)
AC_SUBST(VERSION) AC_SUBST(VERSION)

9
stow.8
View file

@ -6,7 +6,7 @@ stow \- software package installation manager
.RI [ options ] .RI [ options ]
.IR package ... .IR package ...
.SH DESCRIPTION .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 installation of software packages. This is not the definitive
documentation for stow; for that, see the info manual. documentation for stow; for that, see the info manual.
.PP .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 This also has the effect of making the default target directory be
the parent of DIR. the parent of DIR.
.TP .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" .I "-t DIR"
.TP .TP
.I --target=DIR .I --target=DIR

29
stow.in
View file

@ -39,6 +39,7 @@ $ReportHelp = 0;
$Stow = undef; $Stow = undef;
$Target = undef; $Target = undef;
$Restow = 0; $Restow = 0;
@Subdirs = ();
# FIXME: use Getopt::Long # FIXME: use Getopt::Long
@ -68,6 +69,15 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
} else { } else {
$Target = shift; $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) { } elsif ($opt =~ /^verb(o(se?)?)?/i) {
$remainder = $'; $remainder = $';
if ($remainder =~ /^=(\d+)/) { if ($remainder =~ /^=(\d+)/) {
@ -105,6 +115,9 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
$Delete = 1; $Delete = 1;
} elsif ($_ eq 'R') { } elsif ($_ eq 'R') {
$Restow = 1; $Restow = 1;
} elsif ($_ eq 's') {
@Subdirs = split(/:/, (join('', @opts) || shift));
@opts = ();
} elsif ($_ eq 'V') { } elsif ($_ eq 'V') {
&version(); &version();
} else { } else {
@ -147,7 +160,7 @@ if ($Delete || $Restow) {
if (!$Delete || $Restow) { if (!$Delete || $Restow) {
foreach $Collection (@ARGV) { foreach $Collection (@ARGV) {
warn "Stowing package $Collection...\n" if $Verbose; 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 { sub StowContents {
local($dir, $stow) = @_; local($dir, $stow, @subdirs) = @_;
local(@contents); local(@contents);
local($content); 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)) opendir(DIR, &JoinPaths($Stow, $dir))
|| die "$ProgramName: Cannot read directory \"$dir\" ($!)\n"; || die "$ProgramName: Cannot read directory \"$dir\" ($!)\n";
@contents = readdir(DIR); @contents = readdir(DIR);
closedir(DIR); closedir(DIR);
foreach $content (@contents) { foreach $content (@contents) {
next if (($content eq '.') || ($content eq '..')); 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)) { if (-d &JoinPaths($Stow, $dir, $content)) {
&StowDir(&JoinPaths($dir, $content), $stow); &StowDir(&JoinPaths($dir, $content), $stow);
} else { } else {
@ -525,6 +546,8 @@ sub usage {
-c, --conflicts Scan for conflicts, implies -n -c, --conflicts Scan for conflicts, implies -n
-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,
--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, --verbose[=N] Increase verboseness (levels are 0,1,2,3;
-v or --verbose adds 1; --verbose=N sets level) -v or --verbose adds 1; --verbose=N sets level)
-D, --delete Unstow instead of stow -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 This also has the effect of making the default target directory be the
parent of @var{dir}. 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} @item -t @var{dir}
@itemx --target=@var{dir} @itemx --target=@var{dir}
Set the target directory to @var{dir} instead of the parent of the stow Set the target directory to @var{dir} instead of the parent of the stow