#885866 libdebian-installer : support of multiple versions in 'Packages' files

#885866#5
Date:
2017-12-30 16:13:44 UTC
From:
To:
Dear Maintainer,

libdebian-installer currently fails when parsing 'Packages' files with
multiple versions of some packages. It results in anna trying to
configure these packages several times and a fatal error.

This error doesn't show up with the patch below applied.

As far as I understand, libdebian-installer parses the stanzas of a 'Packages'
file and store the properties of each package in the fields of a 'package'
structure. The fields are overwritten when a new stanza describes the
same package (say, another version) - the last one wins.

libdebian-installer collects references to these 'package' structures in
two places : a hash table and a slist.
There is only one element of the hash table for each package. But a new stanza
in the 'Packages' file causes a new pointer to be appended to the slist - even
if the package was already seen.

The patch below avoids appending a seen package to the slist.

Regards,
JH Chatenet


diff -Naur a/src/packages_parser.c b/src/packages_parser.c
--- a/src/packages_parser.c
+++ b/src/packages_parser.c
@@ -240,7 +240,9 @@
   di_package *p;
   p = di_packages_get_package_new (parser_data->packages, parser_data->allocator, value->string, value->size);
   p->type = di_package_type_real_package;
-  di_slist_append_chunk (&parser_data->packages->list, p, parser_data->allocator->slist_node_mem_chunk);
+  /* Do not append a new version of a seen package */
+  if (!p->version)
+    di_slist_append_chunk (&parser_data->packages->list, p, parser_data->allocator->slist_node_mem_chunk);
   *data = p;
 }

#885866#12
Date:
2017-12-30 18:44:38 UTC
From:
To:
Hi,

I realized that bug #885866 just submitted is a duplicate
of #562398 and #801161 - and a special case of #345408
and #345419 (and #389430).
Perhaps it should be merged with #562398 and #801161.

The behavior of anna and the underlying cause in libdebian-installer
were described in details in :

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562398#15

and

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562398#20

The purpose of my patch was to avoid a fatal error in anna - I
assumed that policy ("which version of a package to install ?")
would be enforced somewhere else.

Regards,
JH Chatenet