[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-stow] [Patch] Option to exclude files for stow/unstow.
From: |
Cedric Ware |
Subject: |
[Bug-stow] [Patch] Option to exclude files for stow/unstow. |
Date: |
Sun, 9 Jun 2002 16:43:27 +0200 |
User-agent: |
Mutt/1.4i |
Hello,
(Although I did check the archives, I am not subscribed to any
Stow mailing-list; please CC replies to me.)
For some time I have been feeling a need for excluding some files
from being stowed/unstowed (e.g. a 00README file in each package
directory containing some information about where it came from,
how it was compiled and so on).
Here is a patch to Stow 1.3.3 which implements a "-e"/"--exclude"
option to ignore files matching given regular expressions. This
is not very good:
- files under directly symlinked subdirectories are not affected
(i.e. if only one package contains a "foo" subdirectory with an
excluded file, the latter will still appear in the target since
$Target/foo will be a direct symlink);
- the regexps are forced to "^$", as I wouldn't necessarily expect
"-e 00README" to exclude a "_00README.first" file; I don't know
whether it is a good or a bad thing;
- my lack of proficiency at Perl limits me, although it Seems To
Work For Me(tm).
Hope this helps,
Cedric Ware.
diff -urN stow-1.3.3.bak/stow.8 stow-1.3.3/stow.8
--- stow-1.3.3.bak/stow.8 Sat Jan 5 16:06:37 2002
+++ stow-1.3.3/stow.8 Sun Jun 9 15:36:38 2002
@@ -194,6 +194,14 @@
Set the target directory to DIR instead of the parent of the stow
directory.
.TP
+.I "-e RE"
+.TP
+.I --exclude=RE
+Exclude files matching regular expression RE. Several such exclusions
+can be specified with as many `-e' directives. Note that this does
+not affect files under directories that are directly symlinked into
+the target tree.
+.TP
.I -v
.TP
.I --verbose[=N]
diff -urN stow-1.3.3.bak/stow.in stow-1.3.3/stow.in
--- stow-1.3.3.bak/stow.in Sat Jan 5 12:27:01 2002
+++ stow-1.3.3/stow.in Sun Jun 9 15:38:25 2002
@@ -39,6 +39,7 @@
$Stow = undef;
$Target = undef;
$Restow = 0;
address@hidden = ();
# FIXME: use Getopt::Long
@@ -81,6 +82,13 @@
$Restow = 1;
} elsif ($opt =~ /^vers(i(on?)?)?$/i) {
&version();
+ } elsif ($opt =~ /^e(x(c(l(u(de?)?)?)?)?)?/i) {
+ $remainder = $';
+ if ($remainder =~ /^=/) {
+ push(@Exclude, $'); # the stuff after the =
+ } else {
+ push(@Exclude, shift);
+ }
} else {
&usage(($opt =~ /^h(e(lp?)?)?$/) ? undef :
"unknown or ambiguous option: $opt");
@@ -107,6 +115,9 @@
$Restow = 1;
} elsif ($_ eq 'V') {
&version();
+ } elsif ($_ eq 'e') {
+ push(@Exclude, (join('', @opts) || shift));
+ @opts = ();
} else {
&usage(($_ eq 'h') ? undef : "unknown option: $_");
}
@@ -223,8 +234,14 @@
}
@contents = readdir(DIR);
closedir(DIR);
- foreach $content (@contents) {
+ CONTENT: foreach $content (@contents) {
next if (($content eq '.') || ($content eq '..'));
+ foreach $exclude (@Exclude) {
+ if ($content =~ "^$exclude\$") {
+ warn ("OMIT " . &JoinPaths($dir, $content) . "\n") if ($Verbose);
+ next CONTENT;
+ }
+ }
$empty = 0;
if (-l &JoinPaths($Target, $targetdir, $content)) {
($linktarget = readlink(&JoinPaths($Target,
@@ -332,8 +349,14 @@
|| die "$ProgramName: Cannot read directory \"$dir\" ($!)\n";
@contents = readdir(DIR);
closedir(DIR);
- foreach $content (@contents) {
+ CONTENT: foreach $content (@contents) {
next if (($content eq '.') || ($content eq '..'));
+ foreach $exclude (@Exclude) {
+ if ($content =~ "^$exclude\$") {
+ warn ("OMIT " . &JoinPaths($dir, $content) . "\n") if ($Verbose);
+ next CONTENT;
+ }
+ }
if (-d &JoinPaths($Stow, $dir, $content)) {
&StowDir(&JoinPaths($dir, $content), $stow);
} else {
@@ -525,6 +548,7 @@
-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)
+ -e RE, --exclude=RE Exclude files matching regular expression RE
-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
- [Bug-stow] [Patch] Option to exclude files for stow/unstow.,
Cedric Ware <=