[perltidy] rsync
authorMatthias Förste foerste@schlittermann.de
Thu, 19 Apr 2012 21:10:37 +0200
branchrsync
changeset 42 73cb1d7a1bd8
parent 41 40df28fd3562
child 43 6d4d4ff0796e
[perltidy]
bin/maybe-notify-uploader
bin/rpi
bin/waitfordeb
--- a/bin/maybe-notify-uploader	Thu Apr 19 20:53:29 2012 +0200
+++ b/bin/maybe-notify-uploader	Thu Apr 19 21:10:37 2012 +0200
@@ -4,9 +4,10 @@
 use MIME::EncWords qw(encode_mimewords);
 use POSIX qw(locale_h);
 
-my ($result, $codename, $source, $version, $changes) = @ARGV[0..4];
+my ($result, $codename, $source, $version, $changes) = @ARGV[ 0 .. 4 ];
 
-my ($pat, $fallback, $from) = qw(@schlittermann.de apt@apt.net.schlittermann.de apt@apt.net.schlittermann.de);
+my ($pat, $fallback, $from) =
+  qw(@schlittermann.de apt@apt.net.schlittermann.de apt@apt.net.schlittermann.de);
 my $r;
 
 open C, '<', "$changes" or die "Can't open '<', '$changes': $!\n";
@@ -20,8 +21,8 @@
 
 my $mail = {
 
-    To => $r,
-    From => $from,
+    To      => $r,
+    From    => $from,
     Subject => "$source $version $result in $codename"
 
 };
--- a/bin/rpi	Thu Apr 19 20:53:29 2012 +0200
+++ b/bin/rpi	Thu Apr 19 21:10:37 2012 +0200
@@ -388,7 +388,8 @@
                 $fallback
             ) if $dont_send_to_real_uploader;
 
-            $to = encode_mimewords($to, (Charset => $1)) if setlocale(NULL) =~ /.*\.([^.]+)$/;
+            $to = encode_mimewords($to, (Charset => $1))
+              if setlocale(NULL) =~ /.*\.([^.]+)$/;
 
             sendmail(
                 From    => $from,
--- a/bin/waitfordeb	Thu Apr 19 20:53:29 2012 +0200
+++ b/bin/waitfordeb	Thu Apr 19 21:10:37 2012 +0200
@@ -11,7 +11,7 @@
 my $to = 60;
 
 my $inotify = new Linux::Inotify2
-    or die "unable to create new inotify object: $!";
+  or die "unable to create new inotify object: $!";
 $inotify->blocking(0);
 
 my %size;
@@ -19,18 +19,22 @@
 
 my $ME = basename $0;
 
-sub delay_exit { my $fn = shift; $exit_after = time + $to if $size{basename $fn}; }
-sub verify_size { 
+sub delay_exit {
+    my $fn = shift;
+    $exit_after = time + $to if $size{ basename $fn};
+}
+
+sub verify_size {
     my $fn = shift;
     delay_exit $fn;
     my $bn = basename $fn;
-    my $s = -s $fn;
+    my $s  = -s $fn;
     delete $size{$bn} if defined $s and $s >= $size{$bn};
 }
 
 my $incoming = "$ENV{HOME}/incoming";
-my $nfiles = 0;
-my $c = "$incoming/$ARGV[0]";
+my $nfiles   = 0;
+my $c        = "$incoming/$ARGV[0]";
 
 # first setup a file creation watch on the incoming directory (we cannot set
 # watches on objects that dont exist yet); then *if* a file which is listed in
@@ -44,7 +48,10 @@
     no warnings qw(syntax);
     if (/^files:\s*$/i) { $skip = 0; next; }
     next if $skip;
-    unless (/^ ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ \n]+) *$/) { $skip = 1; next; }
+    unless (/^ ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ \n]+) *$/) {
+        $skip = 1;
+        next;
+    }
     use warnings;
     $size{$5} = $2;
     $nfiles++;
@@ -52,8 +59,12 @@
 close C;
 warn "$ME: no files found in changes file.\n" unless $nfiles;
 
-$inotify->watch($incoming, IN_MODIFY, sub { my $e = shift; delay_exit $e->fullname; } ) or warn "Can't watch: $!";
-$inotify->watch($incoming, IN_CLOSE, sub { my $e = shift; verify_size $e->fullname; } ) or warn "Can't watch: $!";
+$inotify->watch($incoming, IN_MODIFY,
+    sub { my $e = shift; delay_exit $e->fullname; })
+  or warn "Can't watch: $!";
+$inotify->watch($incoming, IN_CLOSE,
+    sub { my $e = shift; verify_size $e->fullname; })
+  or warn "Can't watch: $!";
 
 # do initial check on file in case its upload is already finished
 verify_size "$incoming/$_" for keys %size;