X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=infra%2Fdgit-repos-policy-debian;h=a0ac51916027d74e481cad34a47c80a04d2776ae;hp=e665a636566242c95b844c518a3eebaad93870ce;hb=ce56d58f8ba00e77d5ebb5bba91bd187334b427e;hpb=559eacc729c94b9297874ff2c85f44e72648c0a1 diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian index e665a636..a0ac5191 100755 --- a/infra/dgit-repos-policy-debian +++ b/infra/dgit-repos-policy-debian @@ -86,7 +86,9 @@ our %deliberately; sub apiquery ($) { my ($subpath) = @_; local $/=undef; - my $cmd = "$dgitlive/dgit -d$distro \$DGIT_TEST_OPTS"; + my $dgit = "$dgitlive/dgit"; + $dgit = "dgit" if !stat_exists $dgit; + my $cmd = "$dgit -d$distro \$DGIT_TEST_OPTS"; $cmd .= " -".("D" x $debuglevel) if $debuglevel; $cmd .= " archive-api-query $subpath"; printdebug "apiquery $cmd\n"; @@ -104,7 +106,7 @@ sub specific_suite_has_vsn_in_our_history ($) { foreach my $entry (@$in_suite) { my $vsn = $entry->{version}; die "$pkg ?" unless defined $vsn; - my $tagref = "refs/tags/".debiantag $vsn; + my $tagref = "refs/tags/".debiantag $vsn, $distro; printdebug " checking history suite=$suite vsn=$vsn tagref=$tagref\n"; $?=0; my $r = system qw(git show-ref --verify --quiet), $tagref; return 1 if !$r; @@ -279,10 +281,10 @@ sub action_push () { if (deliberately('include-questionable-history')) { return 0; } - die "Package is in NEW and has not been accepted or rejected yet;". + die "\nPackage is in NEW and has not been accepted or rejected yet;". " use a --deliberately option to specify whether you are". " keeping or discarding the previously pushed history. ". - " Please RTFM dgit(1).\n"; + " Please RTFM dgit(1).\n\n"; } sub action_push_confirm () { @@ -452,21 +454,39 @@ if (!$fn) { my $sleepy=0; my $rcode; -for (;;) { - poldb_setup(poldb_path($repos)); - $stderr = ''; +my $db_busy_exception= 'Debian::Dgit::Policy::Debian::DB_BUSY'; - $rcode = $fn->(); - die unless defined $rcode; +my @orgargv = @ARGV; - eval { $poldbh->commit; }; +for (;;) { + @ARGV = @orgargv; + eval { + poldb_setup(poldb_path($repos), sub { + $poldbh->{HandleError} = sub { + return 0 unless $poldbh->err == 5; # SQLITE_BUSY, not in .pm :-( + die bless { }, $db_busy_exception; + }; + + eval ($ENV{'DGIT_RPD_TEST_DBLOOP_HOOK'}//''); + die $@ if length $@; + # used by tests/tests/debpolicy-dbretry + }); + + $stderr = ''; + + $rcode = $fn->(); + die unless defined $rcode; + + $poldbh->commit; + }; last unless length $@; + die $@ unless ref $@ eq $db_busy_exception; die if $sleepy >= 20; - print STDERR "[policy database busy, retrying]\n"; - sleep ++$sleepy; + $sleepy++; + print STDERR "[policy database busy, retrying (${sleepy}s)]\n"; - $poldbh->rollback; + eval { $poldbh->rollback; }; } print STDERR $stderr or die $!;