chiark / gitweb /
dgit-repos-server: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jan 2014 20:45:40 +0000 (20:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Mar 2014 18:29:02 +0000 (18:29 +0000)
dgit-repos-server

index 0cbcf3579aa1ce598dd9a9d7b8792d3931c89e81..51160be419e3941a608c20f382a3f1861fd31acc 100644 (file)
@@ -2,8 +2,8 @@
 # dgit-repos-push-receiver
 #
 # usages:
-#  .../dgit-repos-push-receiver KEYRING-AUTH-SPEC DGIT-REPOS-DIR --ssh
-#  .../dgit-repos-push-receiver KEYRING-AUTH-SPEC DGIT-REPOS-DIR PACKAGE
+#  .../dgit-repos-push-receiver SUITES KEYRING-AUTH-SPEC DGIT-REPOS-DIR --ssh
+#  .../dgit-repos-push-receiver SUITES KEYRING-AUTH-SPEC DGIT-REPOS-DIR PACKAGE
 # internal usage:
 #  .../dgit-repos-push-receiver --pre-receive-hook PACKAGE
 #
@@ -11,6 +11,9 @@
 #
 # Works like git-receive-pack
 #
+# SUITES is the name of a file which lists the permissible suites
+# one per line (#-comments and blank lines ignored)
+#
 # KEYRING-AUTH-SPEC is a :-separated list of
 #   KEYRING.GPG,AUTH-SPEC
 # where AUTH-SPEC is one of
@@ -56,12 +59,29 @@ use strict;
 # (because such a thing causes git-fetch-pack to barf).  So then we
 # do as above, except:
 #  - before starting, we take out our own lock for the destination repo
-#  - we don't make a hardline clone of the destination repo; instead
-#    we make a copy (not a hardlink clone) of _template
-#  - we set up a post-receive hook as well, which does the following:
-#    + check that exactly two refs were updated
-#    + delete the two stunt hooks
-#    + rename the working repo into place as the destination repo
+#  - we create a prospective new destination repo by making a copy
+#    of _template
+#  - we use the prospective new destination repo instead of the
+#    actual new destination repo (since the latter doesn't exist)
+#  - we set up a post-receive hook as well, which
+#    + checks that exactly two refs were updated
+#    + touches a stamp file
+#  - after git-receive-pack exits, we rename the prospective
+#    destination repo into place
+#
+# Cleanup strategy:
+#  - We are crash-only
+#  - Temporary working trees and their locks are cleaned up
+#    opportunistically by a program which tries to take each lock and
+#    if successful deletes both the tree and the lockfile
+#  - Prospective working trees and their locks are cleaned up by
+#    a program which tries to take each lock and if successful
+#    deletes any prospective working tree and the lock (but not
+#    of course any actual tree)
+#  - It is forbidden to _remove_ the lockfile without removing
+#    the corresponding temporary tree, as the lockfile is also
+#    a stampfile whose presence indicates that there may be
+#    cleanup to do
 
 use POSIX;
 use Fcntl qw(:flock);
@@ -318,10 +338,14 @@ sub parseargs () {
        exit 0;
     }
 
-    die unless @ARGV>=2;
+    die unless @ARGV>=3;
+
+    die if $ARGV[0] =~ m/^-/;
+    $suitesfile = shift @ARGV;
 
     die if $ARGV[0] =~ m/^-/;
     $ENV{'DGIT_RPR_KEYRINGS'} = shift @ARGV;
+
     die if $ARGV[0] =~ m/^-/;
     $dgitrepos = shift @ARGV;