summaryrefslogtreecommitdiff
path: root/infra/dgit-repos-policy-debian
diff options
context:
space:
mode:
Diffstat (limited to 'infra/dgit-repos-policy-debian')
-rwxr-xr-xinfra/dgit-repos-policy-debian44
1 files changed, 26 insertions, 18 deletions
diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian
index c84fd7d..d5c4d0d 100755
--- a/infra/dgit-repos-policy-debian
+++ b/infra/dgit-repos-policy-debian
@@ -21,6 +21,8 @@ our $pkg;
our $pkgdir;
our ($pkg_exists,$pkg_secret);
+our $stderr;
+
our ($version,$suite,$tagname);
our %deliberately;
@@ -60,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");
@@ -94,10 +96,6 @@ END
END
}
-sub poldb_commit () {
- $poldbh->commit;
-}
-
sub apiquery ($) {
my ($subpath) = @_;
local $/=undef;
@@ -326,7 +324,7 @@ END
? "package $ti->{package}"
: "any package";
- print STDERR <<END;
+ $stderr .= <<END;
History contains tainted $objtype $objid
Taint recorded$timeshow for $pkginfo
@@ -342,14 +340,14 @@ END
END
$overridesanyq->execute($taintid);
my ($ovany) = $overridesanyq->fetchrow_array();
- print STDERR $ovany ? <<END : <<END;
+ $stderr .= $ovany ? <<END : <<END;
Could be forced using --deliberately. Consult documentation.
END
Uncorrectable error. If confused, consult administrator.
END
$mustreject = 1;
} else {
- print STDERR <<END;
+ $stderr .= <<END;
Forcing due to --deliberately-$ovwhy
END
$untaintq ||= $dbh->prepare(<<END);
@@ -364,30 +362,40 @@ END
}
if ($mustreject) {
- print STDERR <<END;
+ $stderr .= <<END;
Rejecting push due to questionable history.
END
- exit 1;
+ return 1;
}
return 0;
}
-if (defined $pkg) {
- selectpackage;
-}
-
$cmd =~ y/-/_/;
my $fn = ${*::}{"action__$cmd"};
if (!$fn) {
exit 0;
}
-poldb_setup();
+my $sleepy=0;
-my $rcode = $fn->();
-die unless defined $rcode;
+for (;;) {
+ poldb_setup();
+ $stderr = '';
+
+ 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;