11 my $DEFAULT_TARGET = '/usr/local/';
13 our $Wanted = \&bad_links;
16 our $Target = $DEFAULT_TARGET;
18 # put the main loop into a block so that tests can load this as a module
24 #check_stow($Target, $Wanted);
30 'b|badlinks' => sub { $Wanted = \&bad_links },
31 'a|aliens' => sub { $Wanted = \&aliens },
32 'l|list' => sub { $Wanted = \&list },
33 't|target=s' => \$Target,
40 USAGE: chkstow [options]
43 -t DIR, --target=DIR Set the target directory to DIR
44 (default is $DEFAULT_TARGET)
45 -b, --badlinks Report symlinks that point to non-existent files
46 -a, --aliens Report non-symlinks in the target directory
47 -l, --list List packages in the target directory
49 --badlinks is the default mode.
55 #my ($Target, $Wanted) = @_;
59 preprocess => \&skip_dirs,
62 find(\%options, $Target);
64 if ($Wanted == \&list) {
66 delete $Package{'..'};
69 print map "$_\n", sort(keys %Package);
76 # skip stow source and unstowed targets
77 if (-e ".stow" || -e ".notstowed" ) {
78 warn "skipping $File::Find::dir\n";
86 # checking for files that do not link to anything
88 -l && !-e && print "Bogus link: $File::Find::name\n";
91 # checking for files that are not owned by stow
93 !-l && !-d && print "Unstowed file: $File::Find::name\n";
96 # just list the packages in the the target directory
97 # FIXME: what if the stow dir is not called 'stow'?
101 s{\A(?:\.\./)+stow/}{}g;
107 1; # Hey, it's a module!
111 # cperl-indent-level: 4