chiark / gitweb /
Introduce policy-hook script into dgit-ssh-dispatch and dgit-repos-server, but do...
[dgit.git] / infra / dgit-repos-server
index 7c447d288050856a281c51feb7fabe8770f68c6f..c20eb68f54bbca1f5dde6dfbc14ae9f12d44950a 100755 (executable)
@@ -2,7 +2,8 @@
 # dgit-repos-server
 #
 # usages:
-#  .../dgit-repos-server DISTRO 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 -----
 
@@ -336,7 +340,9 @@ sub parsetag () {
            for (;;) {
                if (s/^distro\=(\S+) //) {
                    die "$1 != $distro" unless $1 eq $distro;
-               } elsif (s/^[-+.=0-9a-z]+ //) {
+               } elsif (s/^(--deliberately-$package_re) //) {
+                   push @deliberatelies, $1;
+               } elsif (s/^[-+.=0-9a-z]\S* //) {
                } else {
                    die "unknown dgit info in tag";
                }
@@ -475,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";
@@ -486,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]/) {
@@ -566,6 +574,7 @@ sub parseargsdispatch () {
        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();
@@ -581,6 +590,7 @@ sub parseargsdispatch () {
     $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';