[savepoint] rsync tip
authorMatthias Förste <foerste@schlittermann.de>
Fri, 04 Aug 2017 15:44:30 +0200
branchrsync
changeset 45 19639ba80436
parent 44 2552664b674a
[savepoint]
bin/rpi
bin/waitfordeb
--- a/bin/rpi	Thu Apr 19 21:28:37 2012 +0200
+++ b/bin/rpi	Fri Aug 04 15:44:30 2017 +0200
@@ -37,6 +37,13 @@
 my $hostname = hostname_long;
 for (*STDERR, *STDOUT) { select $_; $| = 1; }
 
+my $rci = "$repo/conf/incoming";
+my $i   = parse_incoming($rci)->{$ruleset}->{'IncomingDir'};
+die
+  "Can't find IncomingDir for ruleset [$ruleset] in configuration file: [$rci]\n"
+  unless defined $i;
+my @changes = @ARGV or glob("$i/*.changes");
+
 # see man reprepro
 # used as argument to the -b option of reprepro
 my $repo = "$ENV{HOME}/repo";
@@ -116,28 +123,22 @@
     "There have been errors!"
   ) . '$';
 
-my $rci = "$repo/conf/incoming";
-my $i   = parse_incoming($rci)->{$ruleset}->{'IncomingDir'};
-die
-  "Can't find IncomingDir for ruleset [$ruleset] in configuration file: [$rci]\n"
-  unless defined $i;
-
 # we need to determine uploaders before running reprepro, because it will
 # remove the *.changes files before we are going to parse its output
-my $uploaders = { map { $_ => uploader($_) } glob("$i/*.changes") };
+my $uploaders = { map { $_ => uploader($_) } @changes };
 if ($opt{'run-lintian'}) {
     for my $c (keys %{$uploaders}) {
         sendmails({ $uploaders->{$c} => scalar qx{lintian $c 2>&1} },
             $valid_receivers, $fallback, $hostname,
             "[$hostname] Lintian Report");
+        my $messages =
+        run_command_and_parse_output([@cmd, $c], $uploaders, $important, $unimportant,
+            $log_uncaught, $log_raw);
+        sendmails($messages, $valid_receivers, $fallback, $hostname,
+            "[$hostname] Import Report");
+
     }
 }
-my $messages =
-  run_command_and_parse_output([@cmd], $uploaders, $important, $unimportant,
-    $log_uncaught, $log_raw);
-sendmails($messages, $valid_receivers, $fallback, $hostname,
-    "[$hostname] Import Report");
-
 # determine 'uploader' of changes file; 'uploader' means here: either the
 # signer of the changes file or the changer or the maintainer in that order of
 # preference; the 'changer' means what is extracted from the 'Changed-By' field
--- a/bin/waitfordeb	Thu Apr 19 21:28:37 2012 +0200
+++ b/bin/waitfordeb	Fri Aug 04 15:44:30 2017 +0200
@@ -15,13 +15,13 @@
 $inotify->blocking(0);
 
 my %size;
-my $exit_after;
+my $deadline;
 
 my $ME = basename $0;
 
 sub delay_exit {
     my $fn = shift;
-    $exit_after = time + $to if $size{ basename $fn};
+    $deadline = time + $to if $size{ basename $fn};
 }
 
 sub verify_size {
@@ -36,6 +36,8 @@
 my $nfiles   = 0;
 my $c        = "$incoming/$ARGV[0]";
 
+my @cmd = ("$ENV{HOME}/bin/rpi", $c);
+
 open C, '<', $c or die "Can't open '<$c': $!\n";
 my $skip = 1;
 while (<C>) {
@@ -64,12 +66,41 @@
 do {
 
     $inotify->poll;
-    if (time > $exit_after) {
+    if (time > $deadline) {
         warn "$ME: file upload timed out.\n";
         $done = 1;
     }
 
     $done = 1 unless %size;
-    exec "$ENV{HOME}/bin/rpi" if $done;
+
+    if ($done) {
+        exec @cmd if @cmd;
+        exit;
+    }
 
 } while (sleep 1);
+
+__END__
+
+=head1 NAME
+
+waitfordeb - watch incoming directory for debian package upload completion
+
+=head1 SYNOPSIS
+
+waitfordeb changesfile
+
+waitfordeb -m|--man
+           -h|--help
+
+=head1 DESCRIPTION
+
+In an ideal world every package maintainer would use a tool which reliably
+uploads the changes file as the last file. But sometimes this does not happen
+and reprepro may fail the import. 
+
+=head1 AUTHORS
+
+Matthias Förste L<<foerste@schlittermann.de>>
+
+=cut