I looked a bit into the problem in version 0.22.7 and found the following via 
perl -d:

In line 198, the directory /var/lib/apt/lists (the content of $list_dir)  is 
searched for files _ending_ with "Packages" (note the dollar sign after 
Packages):
> files = map { $list_dir . $_} grep /Packages$/, readdir(DIR);

So none of the compression formats which can be used by setting apt.conf' 
GzipIndexes option (ending with at least "Packages.gz" and "Packages.lz4", but 
probably more) are supported by apt-show-versions. You can of course change 
this line and remove the dollar sign after Packages, but this won't do it 
because of the following.

In line 564 (in function parse_file), the Package file is parsed. 
Unfortunately, 
this is done by reading it as a normal text file line by line (see line 566), 
which cannot work with compressed files, even if the above fix has been 
applied. 

You could try to decompress, depending on the file extension, with a suitable 
perl library, but all I found in Debian for lz4 (my itch and in the future 
probably most people's itch) by a quick search was a library which would 
decompress the whole file at once, so you would first need to load the whole 
file 
and then decompress it. As the file can be several megabytes large, this is not 
the best approach, although it would be doable.

Alternatively, you could depend on all packages like liblz4-tool and read the 
file through a pipe. This would be possible, but this would install some 
packages, which would not be used at all (because you would have to depend on 
every compression format supported by apt, even if not currently used).

After having a look on apt-show-versions, I think that its approach is flawed. 
apt already provides tools to read the database, which are performance-
optimized (at least in the most recent versions) and support all compression 
formats. Maybe I am overlooking something, but in my opinion, apt-show-
versions should be changed from reading the packages files and maintaining its 
own cache to parsing apt-cache's output. That said, I am not going to provide 
a patch for that, as I just switched with my main apt-show-versions use-case 
to apt.

So instead of
> apt-show-versions -a $PACKAGENAME
I switched to use
> apt policy $PACKAGENAME.

Although I like apt-show-versions' output more, this way the query is so much 
faster. Additionally, I can activate options like GzipIndexes accelerating apt 
also for other use-cases  without getting problems. And after purging apt-
show-versions, I do not get these any longer:
> Error: No information about packages! (Maybe no deb entries?)
> E: Problem executing scripts APT::Update::Post-Invoke-Success 'test -x 
/usr/bin/apt-show-versions || exit 0 ; apt-show-versions -i'
> E: Sub-process returned an error code

Kind regards
Patrick

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to