equal
deleted
inserted
replaced
13 my $inotify = new Linux::Inotify2 |
13 my $inotify = new Linux::Inotify2 |
14 or die "unable to create new inotify object: $!"; |
14 or die "unable to create new inotify object: $!"; |
15 $inotify->blocking(0); |
15 $inotify->blocking(0); |
16 |
16 |
17 my %size; |
17 my %size; |
18 my $exit_after; |
18 my $deadline; |
19 |
19 |
20 my $ME = basename $0; |
20 my $ME = basename $0; |
21 |
21 |
22 sub delay_exit { |
22 sub delay_exit { |
23 my $fn = shift; |
23 my $fn = shift; |
24 $exit_after = time + $to if $size{ basename $fn}; |
24 $deadline = time + $to if $size{ basename $fn}; |
25 } |
25 } |
26 |
26 |
27 sub verify_size { |
27 sub verify_size { |
28 my $fn = shift; |
28 my $fn = shift; |
29 delay_exit $fn; |
29 delay_exit $fn; |
33 } |
33 } |
34 |
34 |
35 my $incoming = "$ENV{HOME}/incoming"; |
35 my $incoming = "$ENV{HOME}/incoming"; |
36 my $nfiles = 0; |
36 my $nfiles = 0; |
37 my $c = "$incoming/$ARGV[0]"; |
37 my $c = "$incoming/$ARGV[0]"; |
|
38 |
|
39 my @cmd = ("$ENV{HOME}/bin/rpi", $c); |
38 |
40 |
39 open C, '<', $c or die "Can't open '<$c': $!\n"; |
41 open C, '<', $c or die "Can't open '<$c': $!\n"; |
40 my $skip = 1; |
42 my $skip = 1; |
41 while (<C>) { |
43 while (<C>) { |
42 no warnings qw(syntax); |
44 no warnings qw(syntax); |
62 |
64 |
63 my $done = 0; |
65 my $done = 0; |
64 do { |
66 do { |
65 |
67 |
66 $inotify->poll; |
68 $inotify->poll; |
67 if (time > $exit_after) { |
69 if (time > $deadline) { |
68 warn "$ME: file upload timed out.\n"; |
70 warn "$ME: file upload timed out.\n"; |
69 $done = 1; |
71 $done = 1; |
70 } |
72 } |
71 |
73 |
72 $done = 1 unless %size; |
74 $done = 1 unless %size; |
73 exec "$ENV{HOME}/bin/rpi" if $done; |
75 |
|
76 if ($done) { |
|
77 exec @cmd if @cmd; |
|
78 exit; |
|
79 } |
74 |
80 |
75 } while (sleep 1); |
81 } while (sleep 1); |
|
82 |
|
83 __END__ |
|
84 |
|
85 =head1 NAME |
|
86 |
|
87 waitfordeb - watch incoming directory for debian package upload completion |
|
88 |
|
89 =head1 SYNOPSIS |
|
90 |
|
91 waitfordeb changesfile |
|
92 |
|
93 waitfordeb -m|--man |
|
94 -h|--help |
|
95 |
|
96 =head1 DESCRIPTION |
|
97 |
|
98 In an ideal world every package maintainer would use a tool which reliably |
|
99 uploads the changes file as the last file. But sometimes this does not happen |
|
100 and reprepro may fail the import. |
|
101 |
|
102 =head1 AUTHORS |
|
103 |
|
104 Matthias Förste L<<foerste@schlittermann.de>> |
|
105 |
|
106 =cut |