# HG changeset patch # User Matthias Förste foerste@schlittermann.de # Date 1335432775 -7200 # Node ID 0ed7846bef6face260e53095429093a81c6bd791 # Parent 5bb3d096ca223a6074777b36a10f12deaf5bea32 replaced Build.PL with simple Makefile for easier deb package creation diff -r 5bb3d096ca22 -r 0ed7846bef6f Build.PL --- a/Build.PL Thu Apr 26 10:42:50 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -# 'script_files' requires 0.18 -use Module::Build 0.18; -my $build = Module::Build->new( - module_name => 'IUS::wgndMkStruct', - create_license => 1, - license => 'gpl3', - requires => { - 'Getopt::Long' => 0, - 'Pod::Usage' => 0, - 'Linux::Inotify2' => 0 - }, - script_files => ['wgnd-mkstruct'], - dist_version_from => 'wgnd-mkstruct' -); -$build->create_build_script; diff -r 5bb3d096ca22 -r 0ed7846bef6f MANIFEST.SKIP --- a/MANIFEST.SKIP Thu Apr 26 10:42:50 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -# Avoid mercurial version control files. -\B\.hg\b -\B\.hgignore\b - -#!start included /usr/share/perl/5.10/ExtUtils/MANIFEST.SKIP -# Avoid version control files. -\bRCS\b -\bCVS\b -\bSCCS\b -,v$ -\B\.svn\b -\B\.git\b -\B\.gitignore\b -\b_darcs\b - -# Avoid Makemaker generated and utility files. -\bMANIFEST\.bak -\bMakefile$ -\bblib/ -\bMakeMaker-\d -\bpm_to_blib\.ts$ -\bpm_to_blib$ -\bblibdirs\.ts$ # 6.18 through 6.25 generated this - -# Avoid Module::Build generated and utility files. -\bBuild$ -\b_build/ - -# Avoid temp and backup files. -~$ -\.old$ -\#$ -\b\.# -\.bak$ - -# Avoid Devel::Cover files. -\bcover_db\b -#!end included /usr/share/perl/5.10/ExtUtils/MANIFEST.SKIP - - -# Avoid Module::Build generated and utility files. -\bBuild$ -\bBuild.bat$ -\b_build -\bBuild.COM$ -\bBUILD.COM$ -\bbuild.com$ -\bIUS-WiegandMkStruct-[\d\.\_]+ diff -r 5bb3d096ca22 -r 0ed7846bef6f Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Apr 26 11:32:55 2012 +0200 @@ -0,0 +1,17 @@ +DESTDIR = + +prefix = /usr/local +sbindir = $(prefix)/sbin +scripts = wgnd-mkstruct + +%: %.pl + cp -a $< $@ + +all: $(scripts) + +install: all + install -m 0755 -d $(DESTDIR)$(sbindir) + install -m 0755 wgnd-mkstruct $(DESTDIR)$(sbindir) + +clean: + -rm -f $(scripts) diff -r 5bb3d096ca22 -r 0ed7846bef6f wgnd-mkstruct --- a/wgnd-mkstruct Thu Apr 26 10:42:50 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2012 Matthias Förste -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Matthias Förste - -=encoding utf8 -=cut - -use strict; -use warnings; - -my $VERSION = '0.1'; -my $ME = $0; -use Getopt::Long; -use Pod::Usage; -use Linux::Inotify2; -# File::Rsync in squeeze does not support --xattrs yet -#use File::Rsync; - -my $map = 'wgnd-mkstruct.map.pl'; - -sub trace { print @_ if $ENV{DEBUG}; } - -GetOptions( - "map=s" => \$map, - "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) }, - "m|man" => sub { - pod2usage( - -verbose => 2, - -exitval => 0, - -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1] - ); - }, -) or pod2usage(); - -our $source; -use lib ('.', $ENV{HOME}, '/etc'); -require $map; - -my $inotify = new Linux::Inotify2 - or die "Can't create new inotify object: $!"; -my @rsync = qw(/usr/bin/rsync -ihv -aAX); - -for (keys %{$source}) { - - # add watchers - $inotify->watch ("$_", IN_CREATE, sub { - - my $pid = fork; - - if (not defined $pid) { - warn "Can't fork: $!\n"; - } elsif ($pid == 0) { - my $e = shift; - my $name = $e->fullname; - print "$name was created\n" if $e->IN_CREATE; - print "$name is no longer mounted\n" if $e->IN_UNMOUNT; - print "$name is gone\n" if $e->IN_IGNORED; - print "events for $name have been lost\n" if $e->IN_Q_OVERFLOW; - exec @rsync, $source->{$e->{w}->{name}}, $name; - warn "Can't exec: $!\n"; - } - - }) or die "Can't add watch: $!\n"; -} - -while (1) { - - $inotify->poll; - while (-1 != (my $pid = wait)) { - my $e = $? >> 8; - print "${ME}[$pid]: exit $e\n"; - } - -} - - -__END__ - -=pod - -=head1 NAME - -wgnd-mkstruct - instantiate a directory structure template - -=head1 SYNOPSIS - -wgnd-mkstruct [--map filename] - -wgnd-mkstruct -m|--man - -h|--help - -=head1 DESCRIPTION - -wgnd-mkstruct watches some directories for newly created subdirectories and -synchronises these from a given template directory. - -=head1 OPTIONS - -=over - -=item B<--map> I - -Name of a file containing mappings between templates and directories. Defaults -to F. - -=back - -=head1 FILES - -=over - -=item F - -default for B<--map> - -=back - -=head1 AUTHOR - -Matthias Förste - -=cut diff -r 5bb3d096ca22 -r 0ed7846bef6f wgnd-mkstruct.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wgnd-mkstruct.pl Thu Apr 26 11:32:55 2012 +0200 @@ -0,0 +1,137 @@ +#!/usr/bin/perl + +# Copyright (C) 2012 Matthias Förste +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Matthias Förste + +=encoding utf8 +=cut + +use strict; +use warnings; + +my $VERSION = '0.1'; +my $ME = $0; +use Getopt::Long; +use Pod::Usage; +use Linux::Inotify2; +# File::Rsync in squeeze does not support --xattrs yet +#use File::Rsync; + +my $map = 'wgnd-mkstruct.map.pl'; + +sub trace { print @_ if $ENV{DEBUG}; } + +GetOptions( + "map=s" => \$map, + "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) }, + "m|man" => sub { + pod2usage( + -verbose => 2, + -exitval => 0, + -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1] + ); + }, +) or pod2usage(); + +our $source; +use lib ('.', $ENV{HOME}, '/etc'); +require $map; + +my $inotify = new Linux::Inotify2 + or die "Can't create new inotify object: $!"; +my @rsync = qw(/usr/bin/rsync -ihv -aAX); + +for (keys %{$source}) { + + # add watchers + $inotify->watch ("$_", IN_CREATE, sub { + + my $pid = fork; + + if (not defined $pid) { + warn "Can't fork: $!\n"; + } elsif ($pid == 0) { + my $e = shift; + my $name = $e->fullname; + print "$name was created\n" if $e->IN_CREATE; + print "$name is no longer mounted\n" if $e->IN_UNMOUNT; + print "$name is gone\n" if $e->IN_IGNORED; + print "events for $name have been lost\n" if $e->IN_Q_OVERFLOW; + exec @rsync, $source->{$e->{w}->{name}}, $name; + warn "Can't exec: $!\n"; + } + + }) or die "Can't add watch: $!\n"; +} + +while (1) { + + $inotify->poll; + while (-1 != (my $pid = wait)) { + my $e = $? >> 8; + print "${ME}[$pid]: exit $e\n"; + } + +} + + +__END__ + +=pod + +=head1 NAME + +wgnd-mkstruct - instantiate a directory structure template + +=head1 SYNOPSIS + +wgnd-mkstruct [--map filename] + +wgnd-mkstruct -m|--man + -h|--help + +=head1 DESCRIPTION + +wgnd-mkstruct watches some directories for newly created subdirectories and +synchronises these from a given template directory. + +=head1 OPTIONS + +=over + +=item B<--map> I + +Name of a file containing mappings between templates and directories. Defaults +to F. + +=back + +=head1 FILES + +=over + +=item F + +default for B<--map> + +=back + +=head1 AUTHOR + +Matthias Förste + +=cut