From: Ian Jackson Date: Sun, 19 Jan 2014 23:48:35 +0000 (+0000) Subject: dgit-repos-server: fixes from testing X-Git-Tag: debian/0.22~92 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=0c10b5f444e5eb50dcf801a6a3a8aa10b3ad561b dgit-repos-server: fixes from testing --- diff --git a/dgit-repos-server b/dgit-repos-server old mode 100644 new mode 100755 index cbbfe1ea..2a0bf40e --- a/dgit-repos-server +++ b/dgit-repos-server @@ -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 <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; $_=; 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(); } } diff --git a/tests/drs-git-ext b/tests/drs-git-ext index abb2bc84..f7837056 100755 --- a/tests/drs-git-ext +++ b/tests/drs-git-ext @@ -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 : '))))))))))))))))))))))))))))))))))))))))' diff --git a/tests/lib b/tests/lib index dc0911b8..60abb909 100644 --- 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-//}" "$@" } -