chiark / gitweb /
dgit-repos-policy-debian: retry on db commit failure
[dgit.git] / infra / dgit-repos-server
index 8a75d0557d49e58700f515aa59e18f6b3dd341de..acff1727541491ace4bfc45ba4e56a63a7e40c84 100755 (executable)
@@ -34,6 +34,8 @@ use strict;
 #  PACKAGE_garbage                  }   (also covers executions of
 #  PACKAGE_garbage-old              }    policy hook script for PACKAGE)
 #  PACKAGE_garbage-tmp              }
+#  policy*                          } (for policy hook script, covered by
+#                                   }  lock only when invoked for a package)
 #
 # leaf locks, held during brief operaton only:
 #
@@ -105,6 +107,35 @@ use strict;
 #    the corresponding temporary tree, as the lockfile is also
 #    a stampfile whose presence indicates that there may be
 #    cleanup to do
+#
+# Policy hook script is invoked like this:
+#   POLICY-HOOK-SCRIPT DISTRO DGIT-REPOS-DIR ACTION...
+# ie.
+#   POLICY-HOOK-SCRIPT ... check-list [...]
+#   POLICY-HOOK-SCRIPT ... check-package PACKAGE [...]
+#   POLICY-HOOK-SCRIPT ... push|push-confirm PACKAGE \
+#         VERSION SUITE TAGNAME DELIBERATELIES [...]
+#
+# Exit status is a bitmask.  Bit weight constants are defined in Dgit.pm.
+#    NOFFCHECK   (2)
+#         suppress dgit-repos-server's fast-forward check ("push" only)
+#    FRESHREPO   (4)
+#         blow away repo right away (ie, as if before push or fetch)
+#         ("check-package" and "push" only)
+# any unexpected bits mean failure, and then known set bits are ignored
+# if no unexpected bits set, operation continues (subject to meaning
+# of any expected bits set).  So, eg, exit 0 means "continue normally"
+# and would be appropriate for an unknown action.
+#
+# cwd for push and push-confirm is a temporary repo where the
+# to-be-pushed objects have been received; TAGNAME is the
+# version-based tag
+#
+# if push requested FRESHREPO, push-confirm happens in said fresh repo
+#
+# policy hook for a particular package will be invoked only once at
+# a time - (see comments about DGIT-REPOS-DIR, above)
+
 
 use POSIX;
 use Fcntl qw(:flock);
@@ -665,9 +696,9 @@ sub checks () {
 
     lockrealtree();
 
-    $policy = policyhook(NOFFCHECK|FRESHREPO, 'push',$package,
-                        $version,$suite,$tagname,
-                        join(",",@delberatelies));
+    my @policy_args = ($package,$version,$suite,$tagname,
+                      join(",",@delberatelies));
+    $policy = policyhook(NOFFCHECK|FRESHREPO, 'push', @policy_args);
 
     checktagnoreplay();
     checksuite();
@@ -696,6 +727,8 @@ sub checks () {
        $destrepo = "${workrepo}_fresh"; # workrepo lock covers
        mkrepo_fromtemplate $destrepo;
     }
+
+    policyhook(0, 'push-confirm', @policy_args);
 }
 
 sub stunthook () {