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



On Thu, Jun 26, 2014 at 11:13:28PM +0200, Johannes Schauer wrote:
> Hi,
Hi,
 
[..]
> I was thinking that it would nice if apt would provide an API to retrieve the
> location and properties of Packages and Sources files in /var/lib/apt/lists
>
> If apt had such an interface, then third party applications which make use of
> Packages and Sources files like dose3, ben and botch could directly make use of
> those files and the user would not have to retrieve them from somewhere else.
> 
> `apt-cache dumpavail` doesnt work well here because it prints all available
> binary packages and doesnt allow to select a suite or distribution. It also
> doesnt allow listing source packages.
[..]

Ok, that is certainly doable, attached is a very simple patch that
adds a local filename (abi break). I guess we probably want to return
a struct instead that describes it a bit more. But as David points
out, there are "flat" archives that are really just a Packages file
with mixed architectures so its not always meaningful.

Cheers,
 Michael 

 
> You mentioned creating a mapping between sources.list and files in
> /var/lib/apt/lists. This could be one way to solve this but it would not be the
> only way.
> 
> Here more detail about he use case: a 3rd party application (like botch or
> dose3 or ben) work on Packages and Sources files. If the user now wants to let
> Debian sid amd64 be analyzed by any of these utilities, then they first have to
> require Packages and Sources files for Debian sid amd64. They'd have to do that
> even though apt might already have usable ones in /var/lib/apt/lists.
> Unfortunately, as you already pointed out it is not safe to use anything in
> /var/lib/apt/lists yet. It would be nice if apt could be queried about the
> content of /var/lib/apt/lists so that 3rd party applications can then decide
> whether they can make use of those contents and can thus avoid extra downloads.
> 
> I hope this makes more sense now?
> 
> cheers, josch
> 
> 
> --
> To UNSUBSCRIBE, email to deity-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: https://lists.debian.org/20140626211328.3886.46854@hoothoot
> 
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 18322dc..266a1b7 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -51,6 +51,8 @@ class debStatusIndex : public pkgIndexFile
    bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
+   virtual std::string LocalFileName() const {return File;};
+
    debStatusIndex(std::string File);
    virtual ~debStatusIndex() {};
 };
@@ -87,6 +89,8 @@ class debPackagesIndex : public pkgIndexFile
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
+   virtual std::string LocalFileName() const {return IndexFile("Packages");};
+
    debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
 			bool const &Trusted, std::string const &Arch = "native");
    virtual ~debPackagesIndex() {};
@@ -123,6 +127,8 @@ class debTranslationsIndex : public pkgIndexFile
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
+   virtual std::string LocalFileName() const {return IndexFile(Language);};
+
    debTranslationsIndex(std::string URI,std::string Dist,std::string Section, char const * const Language);
    virtual ~debTranslationsIndex() {};
 };
@@ -160,6 +166,8 @@ class debSourcesIndex : public pkgIndexFile
    virtual bool HasPackages() const {return false;};
    virtual unsigned long Size() const;
    
+   virtual std::string LocalFileName() const {return IndexFile("Sources");};
+
    debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
    virtual ~debSourcesIndex() {};
 };
@@ -190,6 +198,8 @@ class debDebPkgFileIndex : public pkgIndexFile
    // Interface for acquire
    virtual std::string ArchiveURI(std::string /*File*/) const;
 
+   virtual std::string LocalFileName() const {return DebFile;};
+
    debDebPkgFileIndex(std::string DebFile);
    virtual ~debDebPkgFileIndex() {};
 };   
@@ -207,6 +217,7 @@ class debDscFileIndex : public pkgIndexFile
    virtual std::string Describe(bool /*Short*/) const {
       return DscFile;
    };
+   virtual std::string LocalFileName() const {return DscFile;};
 
    debDscFileIndex(std::string &DscFile);
    virtual ~debDscFileIndex() {};
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index 817165f..9a95725 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -95,6 +95,9 @@ class pkgIndexFile
    static std::string LanguageCode();
 
    bool IsTrusted() const { return Trusted; };
+
+   // returns the path of the local file (or "" if its not available)
+   virtual std::string LocalFileName() const {return "";};
    
    pkgIndexFile(bool Trusted): Trusted(Trusted) {};
    virtual ~pkgIndexFile() {};

Reply to: