X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=1fdc26c13b0d3a379f8950460df11783665a3521;hb=1e05e9f8e94040b0a763cc9f88c77f83064ebc78;hp=775e03ccd6ac01ee64232a820dee6a343b52ed14;hpb=e1c3f57c5e7dcedbb8df2ea6de3e84436cf375a8;p=dgit.git diff --git a/dgit b/dgit index 775e03cc..1fdc26c1 100755 --- a/dgit +++ b/dgit @@ -78,7 +78,7 @@ our $patches_applied_dirtily = 00; our $tagformat_want; our $tagformat; our $tagformatfn; -our $chase_dsc_distro=1; #xxx configurable +our $chase_dsc_distro=1; our %forceopts = map { $_=>0 } qw(unrepresentable unsupported-source-format @@ -565,6 +565,7 @@ sub cmd_help () { our $td = $ENV{DGIT_TEST_DUMMY_DIR} || "DGIT_TEST_DUMMY_DIR-unset"; our %defcfg = ('dgit.default.distro' => 'debian', + 'dgit.default.old-dsc-distro' => 'debian', 'dgit-suite.*-security.distro' => 'debian-security', 'dgit.default.username' => '', 'dgit.default.archive-query-default-component' => 'main', @@ -664,6 +665,7 @@ sub git_get_config ($) { my ($c) = @_; foreach my $src (@gitcfgsources) { my $l = $gitcfgs{$src}{$c}; + croak "$l $c" if $l && !ref $l; printdebug"C $c ".(defined $l ? join " ", map { messagequote "'$_'" } @$l : "undef")."\n" @@ -679,6 +681,7 @@ sub git_get_config ($) { sub cfg { foreach my $c (@_) { return undef if $c =~ /RETURN-UNDEF/; + printdebug "C? $c\n" if $debuglevel >= 5; my $v = git_get_config($c); return $v if defined $v; my $dv = $defcfg{$c}; @@ -691,7 +694,7 @@ sub cfg { "$us: distro or suite appears not to be (properly) supported"; } -sub access_basedistro () { +sub access_basedistro__noalias () { if (defined $idistro) { return $idistro; } else { @@ -711,6 +714,12 @@ sub access_basedistro () { } } +sub access_basedistro () { + my $noalias = access_basedistro__noalias(); + my $canon = cfg("dgit-distro.$noalias.alias-canon",'RETURN-UNDEF'); + return $canon // $noalias; +} + sub access_nomdistro () { my $base = access_basedistro(); my $r = cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base; @@ -2749,12 +2758,13 @@ sub parse_dsc_field ($$) { if (!defined $f) { progress "$what: NO git hash"; } elsif (($dsc_hash, $dsc_distro, $dsc_hint_tag, $dsc_hint_url) - = $f =~ m/^(\w+) ($distro_re) ($versiontag_re) (\S+)(?:\s|$)/) { + = $f =~ m/^(\w+)\s+($distro_re)\s+($versiontag_re)\s+(\S+)(?:\s|$)/) { progress "$what: specified git info ($dsc_distro)"; $dsc_hint_tag = [ $dsc_hint_tag ]; } elsif ($f =~ m/^\w+\s*$/) { $dsc_hash = $&; - $dsc_distro //= 'debian'; + $dsc_distro //= cfg qw(dgit.default.old-dsc-distro + dgit.default.distro); $dsc_hint_tag = [ debiantags +(getfield $dsc, 'Version'), $dsc_distro ]; progress "$what: specified git hash"; @@ -2769,7 +2779,8 @@ sub resolve_dsc_field_commit ($$) { return unless defined $dsc_hash; my $mapref = - $already_distro eq $dsc_distro || !$chase_dsc_distro + defined $already_mapref && + ($already_distro eq $dsc_distro || !$chase_dsc_distro) ? $already_mapref : undef; my $do_fetch; @@ -2814,8 +2825,12 @@ END return $lrf; }; - if (parse_cfg_bool 'rewrite-map-enable', 'true', - access_cfg('rewrite-map-enable', 'RETURN-UNDEF')) { + my $rewrite_enable = do { + local $idistro = $dsc_distro; + access_cfg('rewrite-map-enable', 'RETURN-UNDEF'); + }; + + if (parse_cfg_bool 'rewrite-map-enable', 'true', $rewrite_enable) { my $lrf = $do_fetch->("rewrite map", $rewritemap) or return; $mapref = $lrf.'/'.$rewritemap; my $rewritemapdata = git_cat_file $mapref.':map'; @@ -6023,11 +6038,15 @@ sub cmd_import_dsc { parse_dscdata(); $package = getfield $dsc, 'Source'; - parse_dsc_field($dsc, "Dgit metadata in .dsc"); - if (defined $dsc_hash - && !forceing [qw(import-dsc-with-dgit-field)]) { + parse_dsc_field($dsc, "Dgit metadata in .dsc") + unless forceing [qw(import-dsc-with-dgit-field)]; + + if (defined $dsc_hash) { progress "dgit: import-dsc of .dsc with Dgit field, using git hash"; + resolve_dsc_field_commit undef, undef; + } + if (defined $dsc_hash) { my @cmd = (qw(sh -ec), "echo $dsc_hash | git cat-file --batch-check"); my $objgot = cmdoutput @cmd; @@ -6264,6 +6283,9 @@ sub parseopts () { } elsif (m/^--no-rm-on-error$/s) { push @ropts, $_; $rmonerror = 0; + } elsif (m/^--no-chase-dsc-distro$/s) { + push @ropts, $_; + $chase_dsc_distro = 0; } elsif (m/^--overwrite$/s) { push @ropts, $_; $overwrite_version = ''; @@ -6309,6 +6331,11 @@ sub parseopts () { # undocumented, for testing push @ropts, $_; $need_split_build_invocation = 1; + } elsif (m/^--config-lookup-explode=(.+)$/s) { + # undocumented, for testing + push @ropts, $_; + $gitcfgs{cmdline}{$1} = 'CONFIG-LOOKUP-EXPLODE'; + # ^ it's supposed to be an array ref } elsif (m/^(--[-0-9a-z]+)(=|$)/ && ($oi = $valopts_long{$1})) { $val = $2 ? $' : undef; #'; $valopt->($oi->{Long});