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

[PATCH] Debian: APT Cache file



Debians "Advanced Package Cache" (APT) uses two files
/var/cache/apt/{,src}pkgcache.bin, which contain an index of the data from to
the downloaded Packages, Sources and Releases files.
identify them.

For performance reason the data is architecture dependant and has gone through
10 major versions by now:

10: e8a7b0b2 2014-06-14 increase hashtable size for packages/groups by factor 5
 9: 9005f08e 2013-01-08 [ABI BREAK] adjust pkgCache::State::VerPriority enum, to match reality
 8: f8ae7e8b 2009-06-15 Introduce support for the Enhances field. (Closes: #137583)
 7: 9d06bc80 2007-09-06 dpkg-triggers: Deal properly with new package states.
 6: d242b9e7 2006-09-05 bump cache version to force rebuild so that Breaks dependencies are included.
 5: a52f938b 2005-03-23 Port DDTP to APT 0.6 branch
 4: 6a3da7a6 2001-07-01 Increase the range of the ID type for deps
 3: 204fbdcc 1999-05-23 Multiple different versions support
 2: 578bfd0a 1998-07-02 Base revisions

Because of that getting useful data like the "number of packages" depends on
the major version; I have checked that the data is sane for version 7, 8 and 10
on i386, amd64 and armv6l, but it may be wrong for older/future/other formats
and architectures.

The current format is described in
<https://anonscm.debian.org/cgit/apt/apt.git/tree/apt-pkg/pkgcache.h#n292>

Signed-off-by: Philipp Hahn <hahn@univention.de>
---
Is there an easier solution to check for both little- and big-endian?

$ file /var/cache/apt/*pkgcache.bin
/var/cache/apt/pkgcache.bin:    APT cache data, 64 bit little-endian, version 8.1, 72645 packages, 72655 versions
/var/cache/apt/srcpkgcache.bin: APT cache data, 64 bit little-endian, version 8.1, 72641 packages, 72651 versions

$ file /var/cache/apt/*pkgcache.bin
/var/cache/apt/pkgcache.bin:    APT cache data, little-endian, version 10.6, 67903 packages, 67913 versions
/var/cache/apt/srcpkgcache.bin: APT cache data, little-endian, version 10.6, 67729 packages, 67738 versions

$ file /var/cache/apt/*pkgcache.bin
/var/cache/apt/pkgcache.bin:    APT cache data, 32 bit little-endian, version 8.0, 48491 packages, 48491 versions
/var/cache/apt/srcpkgcache.bin: APT cache data, 32 bit little-endian, version 8.0, 48491 packages, 48491 versions

Philipp
---
 magic/Magdir/deb | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 magic/Magdir/deb

diff --git a/magic/Magdir/deb b/magic/Magdir/deb
new file mode 100644
index 0000000..c6838be
--- /dev/null
+++ b/magic/Magdir/deb
@@ -0,0 +1,41 @@
+# APT Cache file
+# <http://www.fifi.org/doc/libapt-pkg-doc/cache.html/ch2.html>
+# <https://anonscm.debian.org/cgit/apt/apt.git/tree/apt-pkg/pkgcache.h#n292>
+# From: Philipp Hahn <hahn@univention.de>
+0	bequad	0x98FE76DC	APT cache data, 64 bit big-endian
+>8	short	<10	\b, version %d
+>>10	short	x	\b.%d
+>>12	byte	1	\b, dirty
+>>40	quad	x	\b, %lld packages
+>>48	quad	x	\b, %lld versions
+
+0	lequad	0x98FE76DC	APT cache data, 64 bit little-endian
+>8	short	<10	\b, version %d
+>>10	short	x	\b.%d
+>>12	byte	1	\b, dirty
+>>40	quad	x	\b, %lld packages
+>>48	quad	x	\b, %lld versions
+
+0	belong	0x98FE76DC	APT cache data
+>4	byte	>9	\b, big-endian, version %d
+>>5	short	x	\b.%d
+>>6	byte	1	\b, dirty
+>>24	long	x	\b, %d packages
+>>28	long	x	\b, %d versions
+>4	short	<10	\b, 32 bit big-endian, version %d
+>>6	short	x	\b.%d
+>>8	byte	1	\b, dirty
+>>32	long	x	\b, %d packages
+>>36	long	x	\b, %d versions
+
+0	lelong	0x98FE76DC	APT cache data
+>4	byte	>9	\b, little-endian, version %d
+>>5	short	x	\b.%d
+>>6	byte	1	\b, dirty
+>>24	long	x	\b, %d packages
+>>28	long	x	\b, %d versions
+>4	short	<10	\b, 32 bit little-endian, version %d
+>>6	short	x	\b.%d
+>>8	byte	1	\b, dirty
+>>32	long	x	\b, %d packages
+>>36	long	x	\b, %d versions
-- 
2.1.4


Reply to: