[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/



Package: apt
Version: 1.0.1
Severity: wishlist

Hi,

some software in Debian works on Packages and Sources files. Instead of
retrieving those from mirrors they could re-use the copies which are
likely present in /var/lib/apt/lists/. But there exists no way to ask
apt which mirror, suite or architecture any of these files belong to,
short of parsing the description string returned by
debPackagesIndex.Describe()

Consider the following code example:

--%<-----------------------------------------------------------------------
#include <apt-pkg/init.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/debindexfile.h>
#include <stdio.h>
#include <string.h>

int main() {
    pkgInitConfig(*_config);
    pkgInitSystem(*_config,_system);
    vector<metaIndex *>::const_iterator I;
    pkgSourceList list;
    list.ReadMainList();
    for (I=list.begin(); I != list.end(); ++I) {
        string diststr = (*I)->GetDist();
        string uristr = (*I)->GetURI();
        std::cout << "dist: " << diststr << " uristr: " << uristr << "\n";
        vector<pkgIndexFile *>::const_iterator J;
        vector<pkgIndexFile *> *indexes = (*I)->GetIndexFiles();
        for (J=indexes->begin(); J != indexes->end(); ++J) {
            if (strcmp((*J)->GetType()->Label, "Debian Package Index") == 0) {
                debPackagesIndex* i = (debPackagesIndex*)(*J);
                std::cout << i->Describe(false) << "\n";
            }
        }
    }
}
-->%-----------------------------------------------------------------------

it will print something like:

dist: jessie uristr: http://ftp.debian.org/debian/
http://ftp.debian.org/debian/ jessie/main amd64 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_jessie_main_binary-amd64_Packages)
http://ftp.debian.org/debian/ jessie/main i386 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_jessie_main_binary-i386_Packages)
dist: sid uristr: http://ftp.debian.org/debian/
http://ftp.debian.org/debian/ sid/main amd64 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_sid_main_binary-amd64_Packages)
http://ftp.debian.org/debian/ sid/main i386 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_sid_main_binary-i386_Packages)
dist: experimental uristr: http://ftp.debian.org/debian/
http://ftp.debian.org/debian/ experimental/main amd64 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_experimental_main_binary-amd64_Packages)
http://ftp.debian.org/debian/ experimental/main i386 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_experimental_main_binary-i386_Packages)


So I can find the distribution and the uri but I cannot find out the
architecture or suite except if I start relying on the Description
string format staying the same which is probably not a good idea.

Having looked at the code, it would probably be easy to add a few more
getter functions which return the individual private members that
Describe() uses to produce the description string?

cheers, josch


Reply to: