summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-12 02:08:53 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-12 16:33:37 +0200
commitb07aeb1a6e24825e534167a737043441e871de9f (patch)
treeb47b5bced3f6352e2cdd6cfa550e351e8cd6ebab /apt-pkg/pkgcache.h
parent8881b11eacd735148d087c8c0f53827cb537b582 (diff)
store Release files data in the Cache
We used to read the Release file for each Packages file and store the data in the PackageFile struct even through potentially many Packages (and Translation-*) files could use the same data. The point of the exercise isn't the duplicated data through. Having the Release files as first-class citizens in the Cache allows us to properly track their state as well as allows us to use the information also for files which aren't in the cache, but where we know to which Release file they belong (Sources are an example for this). This modifies the pkgCache structs, especially the PackagesFile struct which depending on how libapt users access the data in these structs can mean huge breakage or no visible change. As a single data point: aptitude seems to be fine with this. Even if there is breakage it is trivial to fix in a backportable way while avoiding breakage for everyone would be a huge pain for us. Note that not all PackageFile structs have a corresponding ReleaseFile. In particular the dpkg/status file as well as *.deb files have not. As these have only a Archive property need, the Component property takes over this duty and the ReleaseFile remains zero. This is also the reason why it isn't needed nor particularily recommended to change from PackagesFile to ReleaseFile blindly. Sticking with the earlier is usually the better option.
Diffstat (limited to 'apt-pkg/pkgcache.h')
-rw-r--r--apt-pkg/pkgcache.h75
1 files changed, 63 insertions, 12 deletions
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index b4d56611a..696b3b94d 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -133,6 +133,7 @@ class pkgCache /*{{{*/
struct Header;
struct Group;
struct Package;
+ struct ReleaseFile;
struct PackageFile;
struct Version;
struct Description;
@@ -150,6 +151,7 @@ class pkgCache /*{{{*/
class DescIterator;
class DepIterator;
class PrvIterator;
+ class RlsFileIterator;
class PkgFileIterator;
class VerFileIterator;
class DescFileIterator;
@@ -192,9 +194,11 @@ class pkgCache /*{{{*/
enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
enum PkgFFlags {
NotSource=(1<<0), /*!< packages can't be fetched from here, e.g. dpkg/status file */
- NotAutomatic=(1<<1), /*!< archive has a default pin of 1 */
- ButAutomaticUpgrades=(1<<2), /*!< (together with the previous) archive has a default pin of 100 */
- LocalSource=(1<<3), /*!< local sources can't and will not be verified by hashes */
+ LocalSource=(1<<1), /*!< local sources can't and will not be verified by hashes */
+ };
+ enum ReleaseFileFlags {
+ NotAutomatic=(1<<0), /*!< archive has a default pin of 1 */
+ ButAutomaticUpgrades=(1<<1), /*!< (together with the previous) archive has a default pin of 100 */
};
};
@@ -215,6 +219,7 @@ class pkgCache /*{{{*/
Package *PkgP;
VerFile *VerFileP;
DescFile *DescFileP;
+ ReleaseFile *RlsFileP;
PackageFile *PkgFileP;
Version *VerP;
Description *DescP;
@@ -247,6 +252,8 @@ class pkgCache /*{{{*/
inline PkgIterator PkgEnd();
inline PkgFileIterator FileBegin();
inline PkgFileIterator FileEnd();
+ inline RlsFileIterator RlsFileBegin();
+ inline RlsFileIterator RlsFileEnd();
inline bool MultiArchCache() const { return MultiArchEnabled; }
inline char const * NativeArch();
@@ -296,6 +303,7 @@ struct pkgCache::Header
unsigned short HeaderSz;
unsigned short GroupSz;
unsigned short PackageSz;
+ unsigned short ReleaseFileSz;
unsigned short PackageFileSz;
unsigned short VersionSz;
unsigned short DescriptionSz;
@@ -314,6 +322,7 @@ struct pkgCache::Header
map_id_t VersionCount;
map_id_t DescriptionCount;
map_id_t DependsCount;
+ map_fileid_t ReleaseFileCount;
map_fileid_t PackageFileCount;
map_fileid_t VerFileCount;
map_fileid_t DescFileCount;
@@ -324,6 +333,9 @@ struct pkgCache::Header
The PackageFile structures are singly linked lists that represent
all package files that have been merged into the cache. */
map_pointer_t FileList;
+ /** \brief index of the first ReleaseFile structure */
+ map_pointer_t RlsFileList;
+
#if APT_PKG_ABI < 413
APT_DEPRECATED map_pointer_t StringList;
#endif
@@ -482,15 +494,14 @@ struct pkgCache::Package
unsigned long Flags;
};
/*}}}*/
-// Package File structure /*{{{*/
-/** \brief stores information about the files used to generate the cache
+// Release File structure /*{{{*/
+/** \brief stores information about the release files used to generate the cache
- Package files are referenced by Version structures to be able to know
- after the generation still from which Packages file includes this Version
- as we need this information later on e.g. for pinning. */
-struct pkgCache::PackageFile
+ PackageFiles reference ReleaseFiles as we need to keep record of which
+ version belongs to which release e.g. for pinning. */
+struct pkgCache::ReleaseFile
{
- /** \brief physical disk file that this PackageFile represents */
+ /** \brief physical disk file that this ReleaseFile represents */
map_stringitem_t FileName;
/** \brief the release information
@@ -498,13 +509,47 @@ struct pkgCache::PackageFile
release information means. */
map_stringitem_t Archive;
map_stringitem_t Codename;
- map_stringitem_t Component;
map_stringitem_t Version;
map_stringitem_t Origin;
map_stringitem_t Label;
- map_stringitem_t Architecture;
/** \brief The site the index file was fetched from */
map_stringitem_t Site;
+
+ /** \brief Size of the file
+
+ Used together with the modification time as a
+ simple check to ensure that the Packages
+ file has not been altered since Cache generation. */
+ map_filesize_t Size;
+ /** \brief Modification time for the file */
+ time_t mtime;
+
+ /** @TODO document PackageFile::Flags */
+ unsigned long Flags;
+
+ // Linked list
+ /** \brief Link to the next ReleaseFile in the Cache */
+ map_pointer_t NextFile;
+ /** \brief unique sequel ID */
+ should_be_map_fileid_t ID;
+};
+ /*}}}*/
+// Package File structure /*{{{*/
+/** \brief stores information about the files used to generate the cache
+
+ Package files are referenced by Version structures to be able to know
+ after the generation still from which Packages file includes this Version
+ as we need this information later on e.g. for pinning. */
+struct pkgCache::PackageFile
+{
+ /** \brief physical disk file that this PackageFile represents */
+ map_stringitem_t FileName;
+ /** \brief the release information */
+ map_pointer_t Release;
+
+ map_stringitem_t Component;
+ map_stringitem_t Architecture;
+
/** \brief indicates what sort of index file this is
@TODO enumerate at least the possible indexes */
@@ -744,6 +789,11 @@ inline pkgCache::PkgFileIterator pkgCache::FileBegin()
{return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}
inline pkgCache::PkgFileIterator pkgCache::FileEnd()
{return PkgFileIterator(*this,PkgFileP);}
+inline pkgCache::RlsFileIterator pkgCache::RlsFileBegin()
+ {return RlsFileIterator(*this,RlsFileP + HeaderP->RlsFileList);}
+inline pkgCache::RlsFileIterator pkgCache::RlsFileEnd()
+ {return RlsFileIterator(*this,RlsFileP);}
+
// Oh I wish for Real Name Space Support
class pkgCache::Namespace /*{{{*/
@@ -755,6 +805,7 @@ class pkgCache::Namespace /*{{{*/
typedef pkgCache::DescIterator DescIterator;
typedef pkgCache::DepIterator DepIterator;
typedef pkgCache::PrvIterator PrvIterator;
+ typedef pkgCache::RlsFileIterator RlsFileIterator;
typedef pkgCache::PkgFileIterator PkgFileIterator;
typedef pkgCache::VerFileIterator VerFileIterator;
typedef pkgCache::Version Version;