chiark / gitweb /
dgit-repos-policy-debian: Fix mode calculation
[dgit.git] / infra / dgit-repos-policy-debian
index 3353d42dd1998324442fc6f5a1ac26e4ca15b106..ce98cd72e46bfa104cf57182037dfb09d8f8a51b 100755 (executable)
@@ -23,7 +23,7 @@ our $dgitlive = shift @ARGV // die "need DGIT-LIVE-DIR";
 our $action = shift @ARGV // die "need ACTION";
 
 our $publicmode = 02775;
-our $new_upload_propagation_slop = 3600*4 + 100;
+our $new_upload_propagation_slop = 3600*4 + 100;# fixme config;
 
 our $poldbh;
 our $pkg;
@@ -83,7 +83,7 @@ our %deliberately;
 sub apiquery ($) {
     my ($subpath) = @_;
     local $/=undef;
-    my $cmd = "$dgitlive/dgit -d $distro \$DGIT_TEST_OPTS";
+    my $cmd = "$dgitlive/dgit -d$distro \$DGIT_TEST_OPTS";
     $cmd .= " -".("D" x $debuglevel) if $debuglevel;
     $cmd .= " archive-api-query $subpath";
     printdebug "apiquery $cmd\n";
@@ -199,7 +199,7 @@ sub add_taint_by_tag ($$) {
              " removed from NEW (ie, rejected) (or never arrived)");
 }
 
-sub action__check_package () {
+sub action_check_package () {
     getpackage();
     return 0 unless $pkg_exists;
     return 0 unless $pkg_secret;
@@ -259,8 +259,8 @@ sub action_push () {
 
 sub action_push_confirm () {
     getpackage();
-    die unless @ARGV;
-    my $freshrepo = shift @ARGV;
+    die unless @ARGV >= 5;
+    my $freshrepo = $ARGV[4];
 
     my $initq = $poldbh->prepare(<<END);
         SELECT taint_id, gitobjid FROM taints t
@@ -376,7 +376,10 @@ END
            my $oldmode = ((stat _)[2]);
            my $oldwrites = $oldmode & 0222;
            # remove r and x bits which have corresponding w bits clear
-           my $newmode = $oldmode & ($oldwrites << 1) & ($oldwrites > 1);
+           my $newmode = $oldmode &
+               (~0555 | ($oldwrites << 1) | ($oldwrites >> 1));
+           printdebug sprintf "chmod %#o (was %#o) %s\n",
+               $newmode, $oldmode, $freshrepo;
            chmod $newmode, $freshrepo or die $!;
        }
     }