Bug#904678: dpkg-reconfigure apt-file ought to give me sources contents
Ian Jackson:
> Package: apt-file
> Version: 3.1.4
> Severity: wishlist
>
> Ansgar has just told me about Contents-sources.gz. Wow! But this has
> apparently existed for years and I never knew. This bug report is
> about the fact that it is rather harder to use than would be ideal.
Thanks for reporting this bug. :)
> The README.md.gz says
>
> - The "-a" option cannot be used with "source" or "udeb-$ARCH".
> Please use the new "--index-names" option. Remember to
> configure APT to download the extra Contents files.
>
> This is enough of a hint to find some things, I guess, but it would be
> nice if:
> [...]
> > Thanks,
> Ian.
>
I can appreciate those suggestions from a user perspective. However,
from a maintainer perspective, I do not want all the trouble and issues
of having to maintain maintscripts, debconf prompts, etc.
But we can certainly improve the situation despite of that. As I
understand you, the primary key issue is finding the index names. What
do you think of a "list-indices" command a la:
"""
$ apt-file list-indices
+-----------------+-----------------------------+
| Index Name (-I) | DefaultEnabled (Apt config) |
+-----------------+-----------------------------+
| deb | <unset> |
| udeb | false |
| deb-legacy | <unset> |
| dsc | false |
+-----------------+-----------------------------+
"""
(See attached patch for a prototype)
Do you think that would have solved your issue?
Thanks,
~Niels
diff --git a/apt-file b/apt-file
index a7b71fa..f8d08be 100755
--- a/apt-file
+++ b/apt-file
@@ -401,6 +401,57 @@ sub grep_package($) {
print_winners $ret, 0;
}
+sub list_indices {
+ my $iter = AptPkg::Config::Iter->new($_config);
+
+ my @indices;
+ my @headers = (
+ {
+ header => 'Index Name (-I)',
+ key => 'name'
+ },
+ {
+ header => 'DefaultEnabled (Apt config)',
+ key => 'default-enabled',
+ },
+ );
+ my @len = map { length($_->{header}) } @headers;
+ while (defined(my $key = $iter->next)) {
+ my ($type, $index_name) = @_;
+ next if $key !~ m/^Acquire::IndexTargets::(deb|deb-src)::Contents-([^: \t]+)$/;
+ ($type, $index_name) = ($1, $2);
+ my $index = {
+ 'name' => $index_name,
+ 'type' => $type,
+ 'key' => $key,
+ 'default-enabled' => ($_config->{"${key}::DefaultEnabled"} // '<unset>'),
+ };
+ for my $i (0..$#headers) {
+ my $header = $headers[$i];
+ my $value = $index->{$header->{'key'}};
+ $len[$i] = length($value) if length($value) > $len[$i];
+ }
+ push(@indices, $index);
+ }
+
+ my $row_delimit = sprintf("+-%s-+", join('-+-', map { '-' x $len[$_] } (0..$#headers)));
+
+ printf("%s\n", $row_delimit);
+ printf("| %s |\n", join(' | ', map { sprintf("%-*s", $len[$_], $headers[$_]{'header'}) }
+ (0..$#headers)));
+ printf("%s\n", $row_delimit);
+ for my $index (@indices) {
+ my $name = $index->{'name'};
+ my $type = $index->{'type'};
+ my $key = $index->{'key'};
+ my $enabled = $_config->{"${key}::DefaultEnabled"} // '<unset>';
+ printf("| %s |\n", join(' | ', map {
+ sprintf("%-*s", $len[$_], $index->{$headers[$_]{'key'}})
+ } (0..$#headers)));
+ }
+ printf("%s\n", $row_delimit);
+}
+
sub print_help {
my $err_code = shift || 0;
@@ -451,6 +502,7 @@ Action:
update Fetch Contents files from apt-sources.
search|find <pattern> Search files in packages
list|show <pattern> List files in packages
+ list-indices List indices configured in APT.
EOF
exit $err_code;
}
@@ -665,6 +717,7 @@ sub main {
find => \&grep_file,
list => \&grep_package,
show => \&grep_package,
+ 'list-indices' => \&list_indices,
};
if ($Conf->{help}) {
Reply to: