X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=9dadc8cce98274eb96944e60b01df5d26a491a95;hp=ac394f0648a2adb5c2e8aa1bb1a45fead3996656;hb=ada48ca013e77d7e821d326db40bc1a59ba639ea;hpb=0e6a55238ffdee98d5b23c70fe4105c41ea28f34 diff --git a/dgit b/dgit index ac394f06..9dadc8cc 100755 --- a/dgit +++ b/dgit @@ -18,7 +18,9 @@ # along with this program. If not, see . use strict; -$SIG{__WARN__} = sub { die $_[0]; }; + +use Debian::Dgit; +setup_sigwarn(); use IO::Handle; use Data::Dumper; @@ -446,8 +448,9 @@ our %defcfg = ('dgit.default.distro' => 'debian', 'dgit-distro.debian.archive-query' => 'ftpmasterapi:', 'dgit-distro.debian.git-check' => 'url', 'dgit-distro.debian.git-check-suffix' => '/info/refs', + 'dgit-distro.debian.new-private-pushers' => 't', 'dgit-distro.debian/push.git-url' => '', - 'dgit-distro.debian/push.git-host' => 'dgit-git.debian.net', + 'dgit-distro.debian/push.git-host' => 'push.dgit.debian.org', 'dgit-distro.debian/push.git-user-force' => 'dgit', 'dgit-distro.debian/push.git-proto' => 'git+ssh://', 'dgit-distro.debian/push.git-path' => '/dgit/debian/repos', @@ -463,15 +466,8 @@ our %defcfg = ('dgit.default.distro' => 'debian', # 'dgit-distro.debian.archive-query-tls-curl-args', # '--ca-path=/etc/ssl/ca-debian', # ^ this is a workaround but works (only) on DSA-administered machines - 'dgit-distro.debian.diverts.alioth' => '/alioth', 'dgit-distro.debian.git-url' => 'https://git.dgit.debian.org', 'dgit-distro.debian.git-url-suffix' => '', - 'dgit-distro.debian/push.diverts.alioth' => '/alioth', - 'dgit-distro.debian/alioth.git-host' => 'git.debian.org', - 'dgit-distro.debian/alioth.git-user-force' => '', - 'dgit-distro.debian/alioth.git-proto' => 'git+ssh://', - 'dgit-distro.debian/alioth.git-path' => '/git/dgit-repos/repos', - 'dgit-distro.debian/alioth.git-create' => 'ssh-cmd', 'dgit-distro.debian.upload-host' => 'ftp-master', # for dput 'dgit-distro.debian.mirror' => 'http://ftp.debian.org/debian/', 'dgit-distro.debian.backports-quirk' => '(squeeze)-backports*', @@ -554,10 +550,45 @@ sub access_quirk () { return ('none',undef); } -our $access_pushing = 0; +our $access_forpush; + +sub parse_cfg_bool ($$$) { + my ($what,$def,$v) = @_; + $v //= $def; + return + $v =~ m/^[ty1]/ ? 1 : + $v =~ m/^[fn0]/ ? 0 : + badcfg "$what needs t (true, y, 1) or f (false, n, 0) not \`$v'"; +} + +sub access_forpush_config () { + my $d = access_basedistro(); + + return 1 if + $new_package && + parse_cfg_bool('new-private-pushers', 0, + cfg("dgit-distro.$d.new-private-pushers", + 'RETURN-UNDEF')); + + my $v = cfg("dgit-distro.$d.readonly", 'RETURN-UNDEF'); + $v //= 'a'; + return + $v =~ m/^[ty1]/ ? 0 : # force readonly, forpush = 0 + $v =~ m/^[fn0]/ ? 1 : # force nonreadonly, forpush = 1 + $v =~ m/^[a]/ ? '' : # auto, forpush = '' + badcfg "readonly needs t (true, y, 1) or f (false, n, 0) or a (auto)"; +} + +sub access_forpush () { + $access_forpush //= access_forpush_config(); + return $access_forpush; +} sub pushing () { - $access_pushing = 1; + die "$access_forpush ?" if ($access_forpush // 1) ne 1; + badcfg "pushing but distro is configured readonly" + if access_forpush_config() eq '0'; + $access_forpush = 1; } sub access_distros () { @@ -575,7 +606,7 @@ sub access_distros () { unshift @l, $instead_distro; @l = grep { defined } @l; - if ($access_pushing) { + if (access_forpush()) { @l = map { ("$_/push", $_) } @l; } @l; @@ -652,7 +683,7 @@ sub access_giturl (;$) { my ($optional) = @_; my $url = access_cfg('git-url','RETURN-UNDEF'); my $suffix; - if (!defined $url) { + if (!length $url) { my $proto = access_cfg('git-proto', 'RETURN-UNDEF'); return undef unless defined $proto; $url = @@ -1823,12 +1854,6 @@ sub dopush ($) { failedcmd @diffcmd; } } -#fetch from alioth -#do fast forward check and maybe fake merge -# if (!is_fast_fwd(mainbranch -# runcmd @git, qw(fetch -p ), "$alioth_git/$package.git", -# map { lref($_).":".rref($_) } -# (uploadbranch()); my $head = git_rev_parse('HEAD'); if (!$changesfile) { my $multi = "$buildproductsdir/". @@ -3050,6 +3075,7 @@ my $cmd = shift @ARGV; $cmd =~ y/-/_/; if (!defined $quilt_mode) { + local $access_forpush; $quilt_mode = cfg('dgit.force.quilt-mode', 'RETURN-UNDEF') // access_cfg('quilt-mode', 'RETURN-UNDEF') // 'linear';