chiark / gitweb /
dgit-repos-server: fixes from testing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jan 2014 23:48:35 +0000 (23:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Mar 2014 18:29:03 +0000 (18:29 +0000)
dgit-repos-server [changed mode: 0644->0755]
tests/drs-git-ext
tests/lib

old mode 100644 (file)
new mode 100755 (executable)
index cbbfe1e..2a0bf40
@@ -90,12 +90,12 @@ our $package_re = '[0-9a-z][-+.0-9a-z]+';
 
 our $func;
 our $dgitrepos;
-our $pkg;
+our $package;
 our $suitesfile;
 our $realdestrepo;
 our $destrepo;
 our $workrepo;
-our @keyrings;
+our $keyrings;
 our @lockfhs;
 
 #----- utilities -----
@@ -105,7 +105,7 @@ sub acquirelock ($$) {
     my $fh;
     for (;;) {
        close $fh if $fh;
-       $fh = new IO::File, ">", $lock or die "open $lock: $!";
+       $fh = new IO::File ">", $lock or die "open $lock: $!";
        my $ok = flock $fh, $must ? LOCK_EX : (LOCK_EX|LOCK_NB);
        if (!$ok) {
            return undef unless $must;
@@ -137,29 +137,35 @@ sub reject ($) {
     die "dgit-repos-server: reject: $_[0]\n";
 }
 
+sub runcmd {
+    $!=0; $?=0;
+    my $r = system @_;
+    die "@_ $? $!" if $r;
+}
+
 #----- git-receive-pack -----
 
 sub fixmissing__git_receive_pack () {
-    $destrepo = "$dgitrepos/_tmp/${pkg}_prospective";
+    $destrepo = "$dgitrepos/_tmp/${package}_prospective";
     acquiretree($destrepo, 1);
     my $r = system qw(cp -a --), "$dgitrepos/_template", "$destrepo";
     !$r or die "create new repo failed failed: $r $!";
 }
 
 sub makeworkingclone () {
-    $workrepo = "$dgitrepos/_tmp/${pkg}_incoming$$";
+    $workrepo = "$dgitrepos/_tmp/${package}_incoming$$";
     acquiretree($workrepo, 1);
     runcmd qw(git clone -l -q --mirror), $destrepo, $workrepo;
 }
 
 sub setupstunthook () {
     my $prerecv = "$workrepo/hooks/pre-receive";
-    my $fh = new IO::File, $prerecv, O_WRONLY|O_CREAT|O_TRUNC, 0777
+    my $fh = new IO::File $prerecv, O_WRONLY|O_CREAT|O_TRUNC, 0777
        or die "$prerecv: $!";
     print $fh <<END or die "$prerecv: $!";
 #!/bin/sh
 set -e
-exec $0 --pre-receive-hook $pkg
+exec $0 --pre-receive-hook $package
 END
     close $fh or die "$prerecv: $!";
     $ENV{'DGIT_RPR_WORK'}= $workrepo;
@@ -196,7 +202,7 @@ sub maybeinstallprospective () {
 sub main__git_receive_pack () {
     makeworkingclone();
     setupstunthook();
-    runcmd qw(git receive-pack), $destdir;
+    runcmd qw(git receive-pack), $destrepo;
     maybeinstallprospective();
 }
 
@@ -227,8 +233,8 @@ sub readupdates () {
     }
     STDIN->error and die $!;
 
-    die unless defined $refname;
-    die unless defined $branchname;
+    die unless defined $tagname;
+    die unless defined $suite;
 }
 
 sub parsetag () {
@@ -249,7 +255,7 @@ sub parsetag () {
     $!=0; $_=<T>; defined or die $!;
     m/^($package_re) release (\S+) for (\S+) \[dgit\]$/ or die;
 
-    die unless $1 eq $pkg;
+    die unless $1 eq $package;
     $version = $2;
     die unless $3 eq $suite;
 
@@ -276,8 +282,8 @@ sub checksig_keyring ($) {
 
     my $ok = undef;
 
-    open P, "-|", (qw(gpgv --status-fd=1),
-                  map { '--keyring', $_ }, @keyrings,
+    open P, "-|", (qw(gpgv --status-fd=1 --keyring),
+                  $keyringfile,
                   qw(dgit-tmp/plaintext.asc dgit-tmp/plaintext))
        or die $!;
 
@@ -400,7 +406,7 @@ sub fixmissing__git_upload_pack () {
 }
 
 sub main__git_upload_pack () {
-    runcmd qw(git upload-pack), $destdir;
+    runcmd qw(git upload-pack), $destrepo;
 }
 
 #----- arg parsing and main program -----
@@ -418,7 +424,7 @@ sub parseargsdispatch () {
     if ($ARGV[0] eq '--pre-receive-hook') {
        shift @ARGV;
        @ARGV == 1 or die;
-       $pkg = shift @ARGV;
+       $package = shift @ARGV;
        defined($suitesfile = $ENV{'DGIT_RPR_SUITES'}) or die;
        defined($workrepo = $ENV{'DGIT_RPR_WORK'}) or die;
        defined($destrepo = $ENV{'DGIT_RPR_DEST'}) or die;
@@ -445,9 +451,9 @@ sub parseargsdispatch () {
        $
     }ox 
     or reject "command string not understood";
-    $method = $1;
-    $pkg = $2;
-    $realdestrepo = "$dgitrepos/$pkg.git";
+    my $method = $1;
+    $package = $2;
+    $realdestrepo = "$dgitrepos/$package.git";
 
     my $funcn = $method;
     $funcn =~ y/-/_/;
@@ -467,17 +473,17 @@ sub parseargsdispatch () {
 }
 
 sub unlockall () {
-    while (my $fh = pop $lockfhs) { close $fh; }
+    while (my $fh = pop @lockfhs) { close $fh; }
 }
 
 sub cleanup () {
     unlockall();
     chdir "$dgitrepos/_tmp" or die $!;
-    foreach my $lock (<*.lock>) {
+    foreach my $lf (<*.lock>) {
        my $tree = $lf;
        $tree =~ s/\.lock$//;
        next unless acquiretree($tree, 0);
-       remove $lock or warn $!;
+       remove $lf or warn $!;
        unlockall();
     }
 }
index abb2bc84472c283608247b2a18789f955e7239ed..f7837056511d413a4921d346045ed333eaa6b2f0 100755 (executable)
@@ -10,5 +10,5 @@ ${DGIT_REPOS_SERVER_TEST-dgit-repos-server} \
        $tmp/suites \
        $tmp/dd.gpg,a:$tmp/dm.gpg,m$tmp/dm.txt \
        $troot/git \
-       --sssh
+       --ssh
 : '))))))))))))))))))))))))))))))))))))))))'
index dc0911b8140376775cabf432120889523d7d7868..60abb90945611d440f25f61a8d8682fb8a076746 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -227,9 +227,9 @@ t-git-config () {
 t-drs () {
        export DGIT_TEST_TROOT=$troot
        export DGIT_TEST_TMP=$tmp
      t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext "
      t-git-config dgit-distro.test-dummy.git-check true
      t-git-config dgit-distro.test-dummy.git-create true
t-git-config dgit-distro.test-dummy.git-url "ext::$troot/drs-git-ext %S "
+ t-git-config dgit-distro.test-dummy.git-check true
+ t-git-config dgit-distro.test-dummy.git-create true
 }
 
 t-drs-test () {
@@ -239,4 +239,3 @@ t-drs-test () {
        export ADTTMP=$tmp
        exec "${0///drs-//}" "$@"
 }
-