chiark / gitweb /
dgit-repos-server etc.: Rework argument & distros-dir passing (no overall functional...
[dgit.git] / infra / dgit-repos-server
index f391b08776ada836a2720a7c6b429141178bdd85..93f6481e35a1a2a605adcb6f7a82bd615bd1a7e8 100755 (executable)
@@ -2,8 +2,13 @@
 # dgit-repos-server
 #
 # usages:
 # dgit-repos-server
 #
 # usages:
-#  .../dgit-repos-server DISTRO SUITES KEYRING-AUTH-SPEC \
-#      DGIT-REPOS-DIR POLICY-HOOK-SCRIPT --ssh
+#   dgit-repos-server DISTRO DISTRO-DIR AUTH-SPEC [<settings>] --ssh
+#   dgit-repos-server DISTRO DISTRO-DIR AUTH-SPEC [<settings>] --cron
+# settings
+#   --repos=GIT-REPOS-DIR      default DISTRO-DIR/repos/
+#   --suites=SUITES-FILE       default DISTRO-DIR/suites
+#   --policy-hook=POLICY-HOOK  default DISTRO-DIR/policy-hook
+# (DISTRO-DIR is not used other than as default)
 # internal usage:
 #  .../dgit-repos-server --pre-receive-hook PACKAGE
 #
 # internal usage:
 #  .../dgit-repos-server --pre-receive-hook PACKAGE
 #
@@ -14,7 +19,7 @@
 # SUITES is the name of a file which lists the permissible suites
 # one per line (#-comments and blank lines ignored)
 #
 # 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
+# AUTH-SPEC is a :-separated list of
 #   KEYRING.GPG,AUTH-SPEC
 # where AUTH-SPEC is one of
 #   a
 #   KEYRING.GPG,AUTH-SPEC
 # where AUTH-SPEC is one of
 #   a
@@ -135,6 +140,11 @@ use strict;
 #
 # policy hook for a particular package will be invoked only once at
 # a time - (see comments about DGIT-REPOS-DIR, above)
 #
 # policy hook for a particular package will be invoked only once at
 # a time - (see comments about DGIT-REPOS-DIR, above)
+#
+# 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.
 
 
 use POSIX;
 
 
 use POSIX;
@@ -776,6 +786,17 @@ sub argval () {
     return $v;
 }
 
     return $v;
 }
 
+our %indistrodir = (
+    # keys are used for DGIT_DRS_XXX too
+    'repos' => \$dgitrepos,
+    'suites' => \$suitesfile,
+    'policy-hook' => \$policyhook,
+    );
+
+our @hookenvs = qw(distro suitesfile policyhook keyrings dgitrepos);
+
+# workrepo and destrepo handled ad-hoc
+
 sub parseargsdispatch () {
     die unless @ARGV;
 
 sub parseargsdispatch () {
     die unless @ARGV;
 
@@ -792,12 +813,9 @@ sub parseargsdispatch () {
        shift @ARGV;
        @ARGV == 1 or die;
        $package = shift @ARGV;
        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;
+       ${ $main::{$_} } = $ENV{"DGIT_DRS_\U$_"} foreach @hookenvs;
        defined($workrepo = $ENV{'DGIT_DRS_WORK'}) or die;
        defined($destrepo = $ENV{'DGIT_DRS_DEST'}) 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();
        open STDOUT, ">&STDERR" or die $!;
        eval {
            stunthook();
@@ -809,11 +827,20 @@ sub parseargsdispatch () {
        exit 0;
     }
 
        exit 0;
     }
 
-    $ENV{'DGIT_DRS_DISTRO'} = $distro = argval();
-    $ENV{'DGIT_DRS_SUITES'} = argval();
-    $ENV{'DGIT_DRS_KEYRINGS'} = argval();
-    $dgitrepos = argval();
-    $ENV{'DGIT_DRS_POLICYHOOK'} = $policyhook = argval();
+    $distro = $ENV{'DGIT_DRS_DISTRO'}     = argval();
+    my $distrodir                         = argval();
+    $keyrings = $ENV{'DGIT_DRS_KEYRINGS'} = argval();
+
+    foreach my $dk (keys %indistrodir) {
+       ${ $indistrodir{$dk} } = "$distrodir/$dk";
+    }
+
+    while (@ARGV && $ARGV[0] =~ m/^--([-0-9a-z]+)=/ && $indistrodir{$1}) {
+       ${ $indistrodir{$1} } = $'; #';
+       shift @ARGV;
+    }
+
+    $ENV{"DGIT_DRS_\U$_"} = ${ $main::{$_} } foreach @hookenvs;
 
     die unless @ARGV==1 && $ARGV[0] eq '--ssh';
 
 
     die unless @ARGV==1 && $ARGV[0] eq '--ssh';