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=d5c4d0db84636949b5d42c8cb4dac61f5a14fbc7;hp=5724c93895a72ceb058f427023afbb5b536b2027;hb=66ca07a7e81a379bd745647d239761087c40288c;hpb=6fff08035c6fb48fab8f804d965541f7486b8249 diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian index 5724c938..d5c4d0db 100755 --- a/infra/dgit-repos-policy-debian +++ b/infra/dgit-repos-policy-debian @@ -1,23 +1,5 @@ #!/usr/bin/perl -w # dgit repos policy hook script for Debian -# -# usages: -# dgit-repos-policy-debian DISTRO DGIT-REPOS-DIR ACTION... -# ie. -# dgit-repos-policy-debian ... check-list [...] -# dgit-repos-policy-debian ... check-package PACKAGE [...] -# dgit-repos-policy-debian ... push PACKAGE \ -# VERSION SUITE TAGNAME DELIBERATELIES [...] -# dgit-repos-policy-debian ... push-confirm PACKAGE \ -# VERSION SUITE TAGNAME DELIBERATELIES [...] -# -# cwd for push is a temporary repo where the to-be-pushed objects have -# been received; TAGNAME is the version-based tag -# -# if push requested FRESHREPO, push-confirm happens in said fresh repo -# -# policy hook for a particular package will be invoked only once at -# a time use strict; use POSIX; @@ -31,7 +13,7 @@ our $repos = shift @ARGV // die "need DGIT-REPOS-DIR"; our $action = shift @ARGV // die "need ACTION"; our $publicmode = 02775; -our $policydb = "dbi:SQLite:$repos/policy"; +our $policydb = "dbi:SQLite:$repos/policy.sqlite3"; our $new_upload_propagation_slop = 3600*4 + 100; our $poldbh; @@ -39,6 +21,8 @@ our $pkg; our $pkgdir; our ($pkg_exists,$pkg_secret); +our $stderr; + our ($version,$suite,$tagname); our %deliberately; @@ -78,7 +62,7 @@ our %deliberately; sub poldb_setup () { - $poldbh = DBI->connect($policydb,'','', { + $poldbh ||= DBI->connect($policydb,'','', { RaiseError=>1, PrintError=>1, AutoCommit=>0 }); $poldbh->do("PRAGMA foreign_keys = ON"); @@ -112,10 +96,6 @@ END END } -sub poldb_commit () { - $poldbh->commit; -} - sub apiquery ($) { my ($subpath) = @_; local $/=undef; @@ -344,7 +324,7 @@ END ? "package $ti->{package}" : "any package"; - print STDERR <execute($taintid); my ($ovany) = $overridesanyq->fetchrow_array(); - print STDERR $ovany ? <prepare(<(); + die unless defined $rcode; -my $rcode = $fn->(); -die unless defined $rcode; + eval { $poldbh->commit; }; + last unless length $@; + + die if $sleepy >= 20; + print STDERR "[policy database busy, retrying]\n"; + sleep ++$sleepy; + + $poldbh->rollback; +} -poldb_commit(); +print STDERR $stderr; exit $rcode;