chiark / gitweb /
Introduce policy-hook script into dgit-ssh-dispatch and dgit-repos-server, but do...
[dgit.git] / infra / dgit-repos-server
index c70bc27fd13b8a7d50ea3d25dba2bd9a7588f3ef..c20eb68f54bbca1f5dde6dfbc14ae9f12d44950a 100755 (executable)
@@ -2,7 +2,8 @@
 # dgit-repos-server
 #
 # usages:
-#  .../dgit-repos-server SUITES KEYRING-AUTH-SPEC DGIT-REPOS-DIR --ssh
+#  .../dgit-repos-server DISTRO SUITES KEYRING-AUTH-SPEC \
+#      DGIT-REPOS-DIR POLICY-HOOK-SCRIPT --ssh
 # internal usage:
 #  .../dgit-repos-server --pre-receive-hook PACKAGE
 #
@@ -94,12 +95,15 @@ our $func;
 our $dgitrepos;
 our $package;
 our $suitesfile;
+our $policyhook;
 our $realdestrepo;
 our $destrepo;
 our $workrepo;
 our $keyrings;
 our @lockfhs;
 our $debug='';
+our @deliberatelies;
+our $policy;
 
 #----- utilities -----
 
@@ -331,6 +335,20 @@ sub parsetag () {
     for (;;) {
        print PT or die $!;
        $!=0; $_=<T>; defined or die "missing signature? $!";
+       if (m/^\[dgit ([^"].*)\]$/) { # [dgit "something"] is for future
+           $_ = $1." ";
+           for (;;) {
+               if (s/^distro\=(\S+) //) {
+                   die "$1 != $distro" unless $1 eq $distro;
+               } elsif (s/^(--deliberately-$package_re) //) {
+                   push @deliberatelies, $1;
+               } elsif (s/^[-+.=0-9a-z]\S* //) {
+               } else {
+                   die "unknown dgit info in tag";
+               }
+           }
+           next;
+       }
        last if m/^-----BEGIN PGP/;
     }
     for (;;) {
@@ -463,7 +481,7 @@ sub tagh1 ($) {
 
 sub checks () {
     debug "checks";
-    checksuite();
+
     tagh1('type') eq 'commit' or reject "tag refers to wrong kind of object";
     tagh1('object') eq $commit or reject "tag refers to wrong commit";
     tagh1('tag') eq $tagname or reject "tag name in tag is wrong";
@@ -474,6 +492,8 @@ sub checks () {
     debug "translated version $v";
     $tagname eq "debian/$v" or die;
 
+    checksuite();
+
     # check that our ref is being fast-forwarded
     debug "oldcommit $oldcommit";
     if ($oldcommit =~ m/[^0]/) {
@@ -549,10 +569,12 @@ sub parseargsdispatch () {
        shift @ARGV;
        @ARGV == 1 or die;
        $package = shift @ARGV;
+       defined($distro = $ENV{'DGIT_DRS_DISTRO'}) or die;
        defined($suitesfile = $ENV{'DGIT_DRS_SUITES'}) or die;
        defined($workrepo = $ENV{'DGIT_DRS_WORK'}) or die;
        defined($destrepo = $ENV{'DGIT_DRS_DEST'}) or die;
        defined($keyrings = $ENV{'DGIT_DRS_KEYRINGS'}) or die $!;
+       defined($policyhook = $ENV{'DGIT_DRS_POLICYHOOK'}) or die $!;
        open STDOUT, ">&STDERR" or die $!;
        eval {
            stunthook();
@@ -564,9 +586,11 @@ sub parseargsdispatch () {
        exit 0;
     }
 
+    $ENV{'DGIT_DRS_DISTRO'} = argval();
     $ENV{'DGIT_DRS_SUITES'} = argval();
     $ENV{'DGIT_DRS_KEYRINGS'} = argval();
     $dgitrepos = argval();
+    $ENV{'DGIT_DRS_POLICYHOOK'} = $policyhook = argval();
 
     die unless @ARGV==1 && $ARGV[0] eq '--ssh';