chiark / gitweb /
Infra: dgit-ssh-dispatch: Formatting fix (nfc)
[dgit.git] / infra / dgit-repos-policy-debian
index 9c2153df5e9e487ee2293ac3364066765ff4ba1f..a770c55ec07d40e5858c2c782c41934a6ecab8f1 100755 (executable)
@@ -219,15 +219,16 @@ sub check_package () {
     my $age = time -  $mtime;
     printdebug "check_package age=$age\n";
 
-    return 0 if $age < $new_upload_propagation_slop;
-
-    return 0 if new_has_vsn_in_our_history();
-
     if (good_suite_has_vsn_in_our_history) {
        chmod $publicmode, "." or die $!;
+       $pkg_secret = 0;
        return 0;
     }
 
+    return 0 if $age < $new_upload_propagation_slop;
+
+    return 0 if new_has_vsn_in_our_history();
+
     printdebug "check_package secret, deleted, tainting\n";
 
     git_for_each_ref('refs/tags', sub {
@@ -260,6 +261,8 @@ sub action_push () {
     getpackage();
     getpushinfo();
 
+    check_package(); # might make package public, or might add taints
+
     return 0 unless $pkg_exists;
     return 0 unless $pkg_secret;
 
@@ -449,21 +452,38 @@ if (!$fn) {
 my $sleepy=0;
 my $rcode;
 
+my $db_busy_exception= 'Debian::Dgit::Policy::Debian::DB_BUSY';
+
+my @orgargv = @ARGV;
+
 for (;;) {
-    poldb_setup(poldb_path($repos));
-    $stderr = '';
+    @ARGV = @orgargv;
+    eval {
+       poldb_setup(poldb_path($repos));
+       $stderr = '';
+
+       eval ($ENV{'DGIT_DRS_RPD_TEST_DBLOOP_HOOK'}//'');
+       die $@ if length $@;
+       # used by tests/tests/debpolicy-dbretry
+
+       $poldbh->{HandleError} = sub {
+           return 0 unless $poldbh->err == 5; # SQLITE_BUSY, not in .pm :-(
+           die bless { }, $db_busy_exception;
+       };
 
-    $rcode = $fn->();
-    die unless defined $rcode;
+       $rcode = $fn->();
+       die unless defined $rcode;
 
-    eval { $poldbh->commit; };
+       $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 $!;