From 8dc465a4eb4bf7045c6cffa9cd50e217f3337589 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 5 Sep 2019 12:59:16 +0100 Subject: [PATCH] dgit: Use distro-info-data to resolve unknown suites to distros Closes: #931212 Signed-off-by: Ian Jackson --- debian/control | 5 +++-- dgit | 17 +++++++++++++++++ dgit.1 | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 3e82d8d8..3edda13d 100644 --- a/debian/control +++ b/debian/control @@ -15,8 +15,9 @@ Depends: perl, libdpkg-perl, git-core, devscripts, dpkg-dev, coreutils (>= 8.23-1~), libdigest-sha-perl, dput, curl, apt, libjson-perl, ca-certificates, - libtext-iconv-perl, libtext-glob-perl, libwww-curl-perl -Recommends: ssh-client + libtext-iconv-perl, libtext-glob-perl, libwww-curl-perl, + libtext-csv-perl +Recommends: ssh-client, distro-info-data Suggests: sbuild | pbuilder | cowbuilder Architecture: all Description: git interoperability with the Debian archive diff --git a/dgit b/dgit index fde8d615..962bca1a 100755 --- a/dgit +++ b/dgit @@ -46,6 +46,7 @@ use Digest::SHA; use Digest::MD5; use List::MoreUtils qw(pairwise); use Text::Glob qw(match_glob); +use Text::CSV; use Fcntl qw(:DEFAULT :flock); use Carp; @@ -867,6 +868,22 @@ sub access_basedistro__noalias () { return $kl->{$k}; } } + foreach my $csvf () { + my $csv_distro = + $csvf =~ m{/(\w+)\.csv$} ? $1 : do { + printdebug "skipping $csvf\n"; + next; + }; + my $csv = Text::CSV->new({ binary => 1, auto_diag => 2 }) or die; + my $fh = new IO::File $csvf, "<:encoding(utf8)" + or die "open $csvf: $!"; + while (my $cols = $csv->getline($fh)) { + next unless $cols->[2] eq $isuite; + return $csv_distro; + } + die "$csvf $!" if $fh->error; + close $fh; + } return cfg("dgit.default.distro"); } } diff --git a/dgit.1 b/dgit.1 index 29825c2c..93b8ed68 100644 --- a/dgit.1 +++ b/dgit.1 @@ -1359,6 +1359,10 @@ may be a glob pattern. .TP .BI dgit.default.distro " distro" The default distro for an unknown suite. + +This is only used if no +.BI /usr/share/distro-info/ somedistro .csv +mentions the specified suite. .TP .BI dgit.default.default-suite " suite" The default suite (eg for clone). -- 2.30.2