chiark / gitweb /
Implement cron mode for dgit-repos-server and corresponding code in dgit-repos-policy...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 May 2015 16:46:31 +0000 (17:46 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 10:54:08 +0000 (11:54 +0100)
infra/dgit-repos-policy-debian
infra/dgit-repos-server

index 41a5551faa005c591dfb0fed62467b9387e88dff..3c7c006bc6c8b0edd271b5b0fb6c512cc8be9b33 100755 (executable)
@@ -373,6 +373,21 @@ END
     return 0;
 }
 
     return 0;
 }
 
+sub action_check_list () {
+    opendir L, "$repos" or die "$repos $!";
+    while (defined (my $dent = readdir L)) {
+       next unless $dent =~ m/^($package_re)\.git$/;
+       $pkg = $1;
+       statpackage();
+       next unless $pkg_exists;
+       next unless $pkg_secret;
+       print "$pkg\n" or die $!;
+    }
+    closedir L or die $!;
+    close STDOUT or die $!;
+    return 0;
+}
+
 $action =~ y/-/_/;
 my $fn = ${*::}{"action_$action"};
 if (!$fn) {
 $action =~ y/-/_/;
 my $fn = ${*::}{"action_$action"};
 if (!$fn) {
index 2be40c57c94cc50ebd8233fe0e0f23c8e4c4c9d1..f6ac5072d8849a1e3de83b60bffa67088b610ae6 100755 (executable)
@@ -25,6 +25,7 @@
 # where AUTH-SPEC is one of
 #   a
 #   mDM.TXT
 # where AUTH-SPEC is one of
 #   a
 #   mDM.TXT
+# (With --cron AUTH-SPEC is not used and may be the empty string.)
 
 use strict;
 $SIG{__WARN__} = sub { die $_[0]; };
 
 use strict;
 $SIG{__WARN__} = sub { die $_[0]; };
@@ -154,8 +155,9 @@ $SIG{__WARN__} = sub { die $_[0]; };
 #
 # check-list and check-package are invoked via the --cron option.
 # First, without any locking, check-list is called.  It should produce
 #
 # check-list and check-package are invoked via the --cron option.
 # First, without any locking, check-list is called.  It should produce
-# a list of package names.  Then check-package will be invoked for
-# each named package, in each case after taking an appropriate lock.
+# a list of package names (one per line).  Then check-package will be
+# invoked for each named package, in each case after taking an
+# appropriate lock.
 #
 # If policy hook wants to run dgit (or something else in the dgit
 # package), it should use DGIT-LIVE-DIR/dgit (etc.)
 #
 # If policy hook wants to run dgit (or something else in the dgit
 # package), it should use DGIT-LIVE-DIR/dgit (etc.)
@@ -164,6 +166,7 @@ $SIG{__WARN__} = sub { die $_[0]; };
 use POSIX;
 use Fcntl qw(:flock);
 use File::Path qw(rmtree);
 use POSIX;
 use Fcntl qw(:flock);
 use File::Path qw(rmtree);
+use File::Temp qw(tempfile);
 
 use Debian::Dgit qw(:DEFAULT :policyflags);
 
 
 use Debian::Dgit qw(:DEFAULT :policyflags);
 
@@ -864,6 +867,27 @@ sub mode_ssh () {
     &$mainfunc;
 }
 
     &$mainfunc;
 }
 
+sub mode_cron () {
+    die if @ARGV;
+
+    my $listfh = tempfile();
+    open STDOUT, ">&", $listfh or die $!;
+    policyhook(0,'check-list');
+    open STDOUT, ">&STDERR" or die $!;
+
+    seek $listfh, 0, 0 or die $!;
+    while (<$listfh>) {
+       chomp or die;
+       next if m/^\s*\#/;
+       next unless m/\S/;
+       die unless m/^($package_re)$/;
+       
+       $package = $1;
+       policy_checkpackage();
+    }
+    die $! if $listfh->error;
+}    
+
 sub parseargsdispatch () {
     die unless @ARGV;
 
 sub parseargsdispatch () {
     die unless @ARGV;