[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#752702: apt: please add a way to to retrieve the location of Packages/Sources files in /var/lib/apt/lists/



Hi,

Quoting Julian Andres Klode (2014-06-25 22:40:40)
> Now I understand what you mean. I thought you meant the location of the files
> on disk. Do you mean the location on the mirror instead?  Stuff like
> architecture, etc. is exported in the cache in pkgCache::PackageFile.

All of it. The location on disk, the arch, the suite, the mirror url, the
component...

Ideal would be a query interface like: give me the binary package file on disk
for debian sid, main, amd64. But the other way round would probably be much
easier to implement: extend the existing interface to provide this information
for all files in the main list.

Back to the code snippet I posted:

01    for (I=list.begin(); I != list.end(); ++I) {
02        string diststr = (*I)->GetDist();
03        string uristr = (*I)->GetURI();
04        std::cout << "dist: " << diststr << " uristr: " << uristr << "\n";
05        vector<pkgIndexFile *>::const_iterator J;
06        vector<pkgIndexFile *> *indexes = (*I)->GetIndexFiles();
07        for (J=indexes->begin(); J != indexes->end(); ++J) {
08            if (strcmp((*J)->GetType()->Label, "Debian Package Index") == 0) {
09                debPackagesIndex* i = (debPackagesIndex*)(*J);
10                std::cout << i->Describe(false) << "\n";
11            }
12        }
13    }

the distribution and uristring can already be accessed (see lines 2 and 3) but
I do not see a way to get the architecture, the suite, or the exact filename
for example even though you say it's possible through pkgCache::PackageFile. If
yes - how?

The function debPackagesIndex->Describe() gives information about architecture,
suite and filename but that information is encoded in a string which I do not
think is safe to parse as it cannot be guaranteed that its format will stay the
same in the future, as it is meant for human consumption, no?

So what I'm looking for are functions like debPackagesIndex->getArch(),
debPackagesIndex->getSuite() and debPackagesIndex->getFilename(). Having these
functions is what I want to make this bugreport about.

Some minor things are, that I apparently have to forcefully cast the
pkgIndexFile to a debPackagesIndex in line 9 based on a string comparison in
line 8. There does not seem to be a better way to determine the type of a
pkgIndexFile object than to call GetType() and do a string comparison. It would
be better to have an enum or similar for this, no?

cheers, josch


Reply to: