From 0f91727f932956b1c44c248891787722eb85d949 Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Mon, 14 Jun 2010 07:51:31 +0200 Subject: [PATCH] introduce rrr-init; this adds a new dependency File::File::Rule; remove the mention of FFR in rrr-server --- Makefile.PL | 1 + bin/rrr-init | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/rrr-server | 11 ++++--- 3 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 bin/rrr-init diff --git a/Makefile.PL b/Makefile.PL index 6b1ff79..99cd78f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -68,6 +68,7 @@ WriteMakefile 'File::Rsync' => 0, 'Test::More' => 0, 'File::Basename' => 0, + 'File::Find::Rule' => 0, 'File::Path' => 0, 'File::Temp' => 0.21, # removes bogus test on parent directory 'List::MoreUtils' => 0, diff --git a/bin/rrr-init b/bin/rrr-init new file mode 100644 index 0000000..a161c2c --- /dev/null +++ b/bin/rrr-init @@ -0,0 +1,92 @@ +#!/usr/bin/perl -- -*- mode: cperl -*- + +=head1 NAME + +rrr-init - set up RECENT files for a directory tree + +=head1 SYNOPSIS + + rrr-init [options] directory + +=head1 OPTIONS + +=over 8 + +=cut + +my @opt = <<'=back' =~ /B<--(\S+)>/g; + +=item B<--aggregator=s> + +Comma separated list of aggregator specifications, e.g. + + --aggregator=1h,6h,1d,1W,1M,1Q,1Y,Z + +Defaults to C<1h,1d,1M,1Y,Z> + +=item B<--help|h> + +Prints a brief message and exists. + +=item B<--verbose|v+> + +More feedback. + +=back + +=head1 DESCRIPTION + +Walk through a tree and fill all files into initial recentfiles. + +=cut + + +use strict; +use warnings; + +use File::Find::Rule; +use lib "/home/k/sources/rersyncrecent/lib"; +use File::Rsync::Mirror::Recent; +use File::Rsync::Mirror::Recentfile; +use File::Spec; +use Getopt::Long; +use Pod::Usage qw(pod2usage); +use Time::HiRes qw(time); + +our %Opt; +GetOptions(\%Opt, + @opt, + ) or pod2usage(1); + +if ($Opt{help}) { + pod2usage(0); +} + +if (@ARGV != 1) { + pod2usage(1); +} + +my($rootdir) = @ARGV; +my $aggregator_string = $Opt{aggregator} || "1h,1d,1M,1Y,Z"; +my @aggregator = split /\s*,\s*/, $aggregator_string; +my $localroot = File::Spec->rel2abs($rootdir); +my $rf = File::Rsync::Mirror::Recentfile->new + ( + aggregator => \@aggregator, + interval => $aggregator[0], + localroot => $localroot, + verbose => $Opt{verbose}, + ); + +foreach my $file ( map {$_->[1]} sort {$a->[0] <=> $b->[0]} map {[-M $_, $_]} File::Find::Rule->new->file->in($rootdir) ) { + $rf->update(File::Spec->rel2abs($file),"new"); +} + +__END__ + + +# Local Variables: +# mode: cperl +# coding: utf-8 +# cperl-indent-level: 4 +# End: diff --git a/bin/rrr-server b/bin/rrr-server index f4eed3a..581c22d 100644 --- a/bin/rrr-server +++ b/bin/rrr-server @@ -31,17 +31,16 @@ More feedback. After you have setup a tree watch it with inotify and keep it uptodate. Depends on inotify which probably only exists on linux. -=head1 PREREQUISITES +=head1 PREREQUISITE -Linux::Inotify2, File::Find::Rule. +Linux::Inotify2. -They are not declared as prerequisites of the F:R:M:Recent package -because there are so many ways to deal with the serverr side that -rrr-server is not considered essential. +It is not declared as prerequisites of the F:R:M:Recent package +because there are so many ways to use the package so that server side +is considered optional. =cut - use strict; use warnings; -- 2.11.4.GIT