summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2009-04-20 22:41:10 +0000
committerJay Freeman <saurik@saurik.com>2009-04-20 22:41:10 +0000
commite37ba76c1a089f2ee7d35985e3cd9574d9215131 (patch)
tree9130712d082875fc75b641e5d42677c34534515d
parent296d17953cb8108e0959231dfa109d158b7665e2 (diff)
Numerous fundamental performance improvements for APT.
git-svn-id: http://svn.telesphoreo.org/trunk@593 514c082c-b64e-11dc-b46d-3d985efe055d
-rw-r--r--data/apt/_metadata/conflicts2
-rw-r--r--data/apt/cfnetwork.diff2
-rw-r--r--data/apt/display.diff95
-rw-r--r--data/apt/find.diff37
-rw-r--r--data/apt/finddesc.diff59
-rw-r--r--data/apt/hashtable.diff61
-rw-r--r--data/apt/intl.diff12
-rw-r--r--data/apt/longdesc.diff17
-rw-r--r--data/apt/make.sh1
-rw-r--r--data/apt/mmap.diff198
-rw-r--r--data/apt/printf.diff12
-rw-r--r--data/apt/public.diff15
-rw-r--r--data/apt/tag.diff280
-rw-r--r--data/apt/textdomain.diff72
14 files changed, 789 insertions, 74 deletions
diff --git a/data/apt/_metadata/conflicts b/data/apt/_metadata/conflicts
index 26617d002..fa15e31d4 100644
--- a/data/apt/_metadata/conflicts
+++ b/data/apt/_metadata/conflicts
@@ -1 +1 @@
-cydia (<< 1.0.2821-1)
+cydia (<< 1.0.2843-1)
diff --git a/data/apt/cfnetwork.diff b/data/apt/cfnetwork.diff
index 1639ab7c7..7da0635a0 100644
--- a/data/apt/cfnetwork.diff
+++ b/data/apt/cfnetwork.diff
@@ -267,7 +267,7 @@ diff -ru apt-0.7.20.2/methods/http.cc apt-0.7.20.2+iPhone/methods/http.cc
+ if (UniqueID_ != NULL)
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Unique-ID"), UniqueID_);
+
-+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.534"));
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.592"));
+
+ CFReadStreamRef rs = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, hm);
+ CFRelease(hm);
diff --git a/data/apt/display.diff b/data/apt/display.diff
new file mode 100644
index 000000000..2e8fdb375
--- /dev/null
+++ b/data/apt/display.diff
@@ -0,0 +1,95 @@
+diff -ru apt-0.7.20.2/apt-pkg/cacheiterators.h apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h
+--- apt-0.7.20.2/apt-pkg/cacheiterators.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h 2009-04-20 16:50:43.000000000 +0000
+@@ -71,6 +71,7 @@
+ inline pkgCache *Cache() {return Owner;};
+
+ inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
++ inline const char *Display() const {return Pkg->Display == 0?0:Owner->StrP + Pkg->Display;};
+ inline const char *Section() const {return Pkg->Section == 0?0:Owner->StrP + Pkg->Section;};
+ inline bool Purge() const {return Pkg->CurrentState == pkgCache::State::Purge ||
+ (Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotInstalled);};
+@@ -123,6 +124,7 @@
+ inline pkgCache *Cache() {return Owner;};
+
+ inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner->StrP + Ver->VerStr;};
++ inline const char *Display() const {return Ver->Display == 0?0:Owner->StrP + Ver->Display;};
+ inline const char *Section() const {return Ver->Section == 0?0:Owner->StrP + Ver->Section;};
+ inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
+ inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
+diff -ru apt-0.7.20.2/apt-pkg/deb/deblistparser.cc apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.20.2/apt-pkg/deb/deblistparser.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc 2009-04-20 17:02:43.000000000 +0000
+@@ -75,6 +75,10 @@
+ /* */
+ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
+ {
++ Ver->Display = UniqFindTagWrite("Name");
++ if (Ver->Display == 0)
++ Ver->Display = UniqFindTagWrite("Maemo-Display-Name");
++
+ // Parse the section
+ Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
+@@ -169,6 +169,10 @@
+ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
+ pkgCache::VerIterator Ver)
+ {
++ if (Pkg->Display == 0)
++ Pkg->Display = UniqFindTagWrite("Name");
++ if (Pkg->Display == 0)
++ Pkg->Display = UniqFindTagWrite("Maemo-Display-Name");
+ if (Pkg->Section == 0)
+ Pkg->Section = UniqFindTagWrite("Section");
+ if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.cc apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.cc 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc 2009-04-20 17:26:22.000000000 +0000
+@@ -51,6 +51,17 @@
+ return Section.FindS("Package");
+ }
+ /*}}}*/
++// RecordParser::Display - Return the package display name /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++string debRecordParser::Display()
++{
++ string display(Section.FindS("Name"));
++ if (display.empty())
++ display = Section.FindS("Maemo-Display-Name");
++ return display;
++}
++ /*}}}*/
+ // RecordParser::Homepage - Return the package homepage /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.h apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.h 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h 2009-04-20 17:20:31.000000000 +0000
+@@ -39,6 +39,7 @@
+ virtual string ShortDesc();
+ virtual string LongDesc();
+ virtual string Name();
++ virtual string Display();
+ virtual string Homepage();
+
+ virtual void GetRec(const char *&Start,const char *&Stop);
+diff -ru apt-0.7.20.2/apt-pkg/pkgcache.h apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.20.2/apt-pkg/pkgcache.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h 2009-04-20 16:49:55.000000000 +0000
+@@ -200,6 +200,7 @@
+ {
+ // Pointers
+ map_ptrloc Name; // Stringtable
++ map_ptrloc Display; // Stringtable
+ map_ptrloc VersionList; // Version
+ map_ptrloc CurrentVer; // Version
+ map_ptrloc Section; // StringTable (StringItem)
+@@ -259,6 +272,7 @@
+ struct pkgCache::Version
+ {
+ map_ptrloc VerStr; // Stringtable
++ map_ptrloc Display; // Stringtable
+ map_ptrloc Section; // StringTable (StringItem)
+ map_ptrloc Arch; // StringTable
+
diff --git a/data/apt/find.diff b/data/apt/find.diff
new file mode 100644
index 000000000..56eb1e2ab
--- /dev/null
+++ b/data/apt/find.diff
@@ -0,0 +1,37 @@
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.cc apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc 2009-04-19 03:41:21.000000000 +0000
+@@ -170,3 +170,11 @@
+ Section.GetSection(Start,Stop);
+ }
+ /*}}}*/
++// RecordParser::Find - Locate a tag /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++bool debRecordParser::Find(const char *Tag,const char *&Start, const char *&End)
++{
++ return Section.Find(Tag,Start,End);
++}
++ /*}}}*/
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.h apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h 2009-04-19 03:46:48.000000000 +0000
+@@ -47,6 +47,7 @@
+ virtual string Homepage();
+
+ virtual void GetRec(const char *&Start,const char *&Stop);
++ virtual bool Find(const char *Tag,const char *&Start, const char *&End);
+
+ debRecordParser(string FileName,pkgCache &Cache);
+ };
+diff -ru apt-0.7.20.2/apt-pkg/pkgrecords.h apt-0.7.20.2+iPhone/apt-pkg/pkgrecords.h
+--- apt-0.7.20.2/apt-pkg/pkgrecords.h 2009-04-18 23:19:45.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgrecords.h 2009-04-19 03:39:04.000000000 +0000
+@@ -70,6 +70,7 @@
+
+ // The record in binary form
+ virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
++ virtual bool Find(const char *Tag,const char *&Start, const char *&End) {Start = End = 0; return false;};
+
+ virtual ~Parser() {};
+ };
diff --git a/data/apt/finddesc.diff b/data/apt/finddesc.diff
new file mode 100644
index 000000000..15bba37e2
--- /dev/null
+++ b/data/apt/finddesc.diff
@@ -0,0 +1,59 @@
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.cc apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.cc 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc 2009-04-20 17:26:22.000000000 +0000
+@@ -124,6 +134,29 @@
+ return orig;
+ }
+ /*}}}*/
++// RecordParser::ShortDesc - Return a 1 line description /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++bool debRecordParser::ShortDesc(const char *&Start,const char *&End)
++{
++ if (!LongDesc(Start,End))
++ return false;
++ const char *Line = (const char *) memchr(Start, '\n', End - Start);
++ if (Line != NULL)
++ End = Line;
++ return true;
++}
++ /*}}}*/
++// RecordParser::LongDesc - Return a longer description /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++bool debRecordParser::LongDesc(const char *&Start,const char *&End)
++{
++ if (!Section.Find("Description",Start,End))
++ return Section.Find(("Description-" + pkgIndexFile::LanguageCode()).c_str(),Start,End);
++ return true;
++}
++ /*}}}*/
+
+ static const char *SourceVerSeparators = " ()";
+
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.h apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.h 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h 2009-04-20 17:20:31.000000000 +0000
+@@ -39,6 +39,9 @@
+ virtual string SourcePkg();
+ virtual string SourceVer();
+
++ virtual bool ShortDesc(const char *&Start,const char *&End);
++ virtual bool LongDesc(const char *&Start,const char *&End);
++
+ // These are some general stats about the package
+ virtual string Maintainer();
+ virtual string ShortDesc();
+diff -ru apt-0.7.20.2/apt-pkg/pkgrecords.h apt-0.7.20.2+iPhone/apt-pkg/pkgrecords.h
+--- apt-0.7.20.2/apt-pkg/pkgrecords.h 2009-04-20 19:56:46.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgrecords.h 2009-04-20 19:55:58.000000000 +0000
+@@ -61,6 +61,9 @@
+ virtual string SourcePkg() {return string();};
+ virtual string SourceVer() {return string();};
+
++ virtual bool ShortDesc(const char *&Start,const char *&End) {return false;}
++ virtual bool LongDesc(const char *&Start,const char *&End) {return false;}
++
+ // These are some general stats about the package
+ virtual string Maintainer() {return string();};
+ virtual string ShortDesc() {return string();};
diff --git a/data/apt/hashtable.diff b/data/apt/hashtable.diff
new file mode 100644
index 000000000..fe5c046c8
--- /dev/null
+++ b/data/apt/hashtable.diff
@@ -0,0 +1,61 @@
+diff -ru apt-0.7.20.2/apt-pkg/tagfile.cc apt-0.7.20.2+iPhone/apt-pkg/tagfile.cc
+--- apt-0.7.20.2/apt-pkg/tagfile.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/tagfile.cc 2009-04-19 02:42:49.000000000 +0000
+@@ -220,7 +220,10 @@
+ if (isspace(Stop[0]) == 0)
+ {
+ Indexes[TagCount++] = Stop - Section;
+- AlphaIndexes[AlphaHash(Stop,End)] = TagCount;
++ unsigned long hash(AlphaHash(Stop, End));
++ while (AlphaIndexes[hash] != 0)
++ hash = (hash + 1) % (sizeof(AlphaIndexes) / sizeof(AlphaIndexes[0]));
++ AlphaIndexes[hash] = TagCount;
+ }
+
+ Stop = (const char *)memchr(Stop,'\n',End - Stop);
+@@ -258,14 +261,16 @@
+ bool pkgTagSection::Find(const char *Tag,unsigned &Pos) const
+ {
+ unsigned int Length = strlen(Tag);
+- unsigned int I = AlphaIndexes[AlphaHash(Tag)];
+- if (I == 0)
+- return false;
+- I--;
++ unsigned int J = AlphaHash(Tag);
+
+- for (unsigned int Counter = 0; Counter != TagCount; Counter++,
+- I = (I+1)%TagCount)
++ for (unsigned int Counter = 0; Counter != TagCount; Counter++,
++ J = (J+1)%(sizeof(AlphaIndexes)/sizeof(AlphaIndexes[0])))
+ {
++ unsigned int I = AlphaIndexes[J];
++ if (I == 0)
++ return false;
++ I--;
++
+ const char *St;
+ St = Section + Indexes[I];
+ if (strncasecmp(Tag,St,Length) != 0)
+@@ -291,14 +296,16 @@
+ const char *&End) const
+ {
+ unsigned int Length = strlen(Tag);
+- unsigned int I = AlphaIndexes[AlphaHash(Tag)];
+- if (I == 0)
+- return false;
+- I--;
++ unsigned int J = AlphaHash(Tag);
+
+- for (unsigned int Counter = 0; Counter != TagCount; Counter++,
+- I = (I+1)%TagCount)
++ for (unsigned int Counter = 0; Counter != TagCount; Counter++,
++ J = (J+1)%(sizeof(AlphaIndexes)/sizeof(AlphaIndexes[0])))
+ {
++ unsigned int I = AlphaIndexes[J];
++ if (I == 0)
++ return false;
++ I--;
++
+ const char *St;
+ St = Section + Indexes[I];
+ if (strncasecmp(Tag,St,Length) != 0)
diff --git a/data/apt/intl.diff b/data/apt/intl.diff
new file mode 100644
index 000000000..f2f35eb6d
--- /dev/null
+++ b/data/apt/intl.diff
@@ -0,0 +1,12 @@
+diff -ru apt-0.7.20.2/apt-inst/makefile apt-0.7.20.2+iPhone/apt-inst/makefile
+--- apt-0.7.20.2/apt-inst/makefile 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-inst/makefile 2009-04-16 01:54:17.000000000 +0000
+@@ -14,7 +14,7 @@
+ LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
+ MAJOR=1.1
+ MINOR=0
+-SLIBS=$(PTHREADLIB) -lapt-pkg
++SLIBS=$(PTHREADLIB) -lapt-pkg $(INTLLIBS)
+ APT_DOMAIN:=libapt-inst$(MAJOR)
+
+ # Source code for the contributed non-core things
diff --git a/data/apt/longdesc.diff b/data/apt/longdesc.diff
new file mode 100644
index 000000000..d2cd4bbbe
--- /dev/null
+++ b/data/apt/longdesc.diff
@@ -0,0 +1,17 @@
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.cc apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.cc 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc 2009-04-20 17:26:22.000000000 +0000
+@@ -111,10 +122,9 @@
+ string orig, dest;
+ char *codeset = nl_langinfo(CODESET);
+
+- if (!Section.FindS("Description").empty())
+- orig = Section.FindS("Description").c_str();
+- else
+- orig = Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str()).c_str();
++ orig = Section.FindS("Description");
++ if (orig.empty())
++ orig = Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str());
+
+ if (strcmp(codeset,"UTF-8") != 0) {
+ UTF8ToCodeset(codeset, orig, &dest);
diff --git a/data/apt/make.sh b/data/apt/make.sh
index 48647de72..fbfc6a7a2 100644
--- a/data/apt/make.sh
+++ b/data/apt/make.sh
@@ -7,6 +7,7 @@ pkg: mkdir -p /etc/apt/sources.list.d
pkg: mkdir -p /var/cache/apt/archives/partial
pkg: mkdir -p /var/lib/apt/lists/partial
pkg: mkdir -p /var/lib/apt/periodic
+pkg: mkdir -p /var/log/apt
pkg: mkdir -p /usr/bin /usr/lib/apt
pkg: cp -a bin/apt-* /usr/bin
diff --git a/data/apt/mmap.diff b/data/apt/mmap.diff
new file mode 100644
index 000000000..0184c380c
--- /dev/null
+++ b/data/apt/mmap.diff
@@ -0,0 +1,198 @@
+diff -ru apt-0.7.20.2/apt-pkg/tagfile.cc apt-0.7.20.2+iPhone/apt-pkg/tagfile.cc
+--- apt-0.7.20.2/apt-pkg/tagfile.cc 2009-04-19 02:42:49.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/tagfile.cc 2009-04-19 03:28:33.000000000 +0000
+@@ -28,11 +28,11 @@
+ // ---------------------------------------------------------------------
+ /* */
+ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
+- Fd(*pFd),
+- Size(Size)
++ Fd(*pFd)
+ {
+- if (Fd.IsOpen() == false)
++ if (Fd.IsOpen() == false || Fd.Size() == 0)
+ {
++ Map = NULL;
+ Buffer = 0;
+ Start = End = Buffer = 0;
+ Done = true;
+@@ -40,7 +40,8 @@
+ return;
+ }
+
+- Buffer = new char[Size];
++ Map = new MMap(*pFd, MMap::ReadOnly);
++ Buffer = reinterpret_cast<char *>(Map->Data());
+ Start = End = Buffer;
+ Done = false;
+ iOffset = 0;
+@@ -52,36 +53,9 @@
+ /* */
+ pkgTagFile::~pkgTagFile()
+ {
+- delete [] Buffer;
++ delete Map;
+ }
+ /*}}}*/
+-// TagFile::Resize - Resize the internal buffer /*{{{*/
+-// ---------------------------------------------------------------------
+-/* Resize the internal buffer (double it in size). Fail if a maximum size
+- * size is reached.
+- */
+-bool pkgTagFile::Resize()
+-{
+- char *tmp;
+- unsigned long EndSize = End - Start;
+-
+- // fail is the buffer grows too big
+- if(Size > 1024*1024+1)
+- return false;
+-
+- // get new buffer and use it
+- tmp = new char[2*Size];
+- memcpy(tmp, Buffer, Size);
+- Size = Size*2;
+- delete [] Buffer;
+- Buffer = tmp;
+-
+- // update the start/end pointers to the new buffer
+- Start = Buffer;
+- End = Start + EndSize;
+- return true;
+-}
+-
+ // TagFile::Step - Advance to the next section /*{{{*/
+ // ---------------------------------------------------------------------
+ /* If the Section Scanner fails we refill the buffer and try again.
+@@ -90,15 +64,11 @@
+ */
+ bool pkgTagFile::Step(pkgTagSection &Tag)
+ {
+- while (Tag.Scan(Start,End - Start) == false)
++ if (Tag.Scan(Start,End - Start) == false)
+ {
+- if (Fill() == false)
+- return false;
+-
+- if(Tag.Scan(Start,End - Start))
+- break;
+-
+- if (Resize() == false)
++ if (Start == End)
++ return false;
++ else
+ return _error->Error(_("Unable to parse package file %s (1)"),
+ Fd.Name().c_str());
+ }
+@@ -115,41 +85,11 @@
+ then fills the rest from the file */
+ bool pkgTagFile::Fill()
+ {
+- unsigned long EndSize = End - Start;
+- unsigned long Actual = 0;
+-
+- memmove(Buffer,Start,EndSize);
+- Start = Buffer;
+- End = Buffer + EndSize;
+-
+- if (Done == false)
+- {
+- // See if only a bit of the file is left
+- if (Fd.Read(End,Size - (End - Buffer),&Actual) == false)
+- return false;
+- if (Actual != Size - (End - Buffer))
+- Done = true;
+- End += Actual;
+- }
+-
+- if (Done == true)
+- {
+- if (EndSize <= 3 && Actual == 0)
+- return false;
+- if (Size - (End - Buffer) < 4)
+- return true;
+-
+- // Append a double new line if one does not exist
+- unsigned int LineCount = 0;
+- for (const char *E = End - 1; E - End < 6 && (*E == '\n' || *E == '\r'); E--)
+- if (*E == '\n')
+- LineCount++;
+- for (; LineCount < 2; LineCount++)
+- *End++ = '\n';
+-
+- return true;
+- }
+-
++ unsigned int Size(Map->Size());
++ End = Buffer + Size;
++ if (iOffset >= Size)
++ return false;
++ Start = Buffer + iOffset;
+ return true;
+ }
+ /*}}}*/
+@@ -171,20 +111,11 @@
+ // Reposition and reload..
+ iOffset = Offset;
+ Done = false;
+- if (Fd.Seek(Offset) == false)
+- return false;
+ End = Start = Buffer;
+
+ if (Fill() == false)
+ return false;
+
+- if (Tag.Scan(Start,End - Start) == true)
+- return true;
+-
+- // This appends a double new line (for the real eof handling)
+- if (Fill() == false)
+- return false;
+-
+ if (Tag.Scan(Start,End - Start) == false)
+ return _error->Error(_("Unable to parse package file %s (2)"),Fd.Name().c_str());
+
+@@ -228,14 +161,16 @@
+
+ Stop = (const char *)memchr(Stop,'\n',End - Stop);
+
+- if (Stop == 0)
+- return false;
++ if (Stop == 0) {
++ Stop = End;
++ goto end;
++ }
+
+ for (; Stop+1 < End && Stop[1] == '\r'; Stop++);
+
+ // Double newline marks the end of the record
+- if (Stop+1 < End && Stop[1] == '\n')
+- {
++ if (Stop+1 == End || Stop[1] == '\n')
++ end: {
+ Indexes[TagCount] = Stop - Section;
+ for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++);
+ return true;
+diff -ru apt-0.7.20.2/apt-pkg/tagfile.h apt-0.7.20.2+iPhone/apt-pkg/tagfile.h
+--- apt-0.7.20.2/apt-pkg/tagfile.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/tagfile.h 2009-04-19 03:04:07.000000000 +0000
+@@ -21,6 +21,7 @@
+ #define PKGLIB_TAGFILE_H
+
+
++#include <apt-pkg/mmap.h>
+ #include <apt-pkg/fileutl.h>
+ #include <stdio.h>
+
+@@ -71,10 +72,9 @@
+ char *End;
+ bool Done;
+ unsigned long iOffset;
+- unsigned long Size;
++ MMap *Map;
+
+ bool Fill();
+- bool Resize();
+
+ public:
+
diff --git a/data/apt/printf.diff b/data/apt/printf.diff
new file mode 100644
index 000000000..847758bf2
--- /dev/null
+++ b/data/apt/printf.diff
@@ -0,0 +1,12 @@
+diff -ru apt-0.7.20.2/ftparchive/writer.cc apt-0.7.20.2+iPhone/ftparchive/writer.cc
+--- apt-0.7.20.2/ftparchive/writer.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/ftparchive/writer.cc 2009-04-20 17:53:48.000000000 +0000
+@@ -629,7 +629,7 @@
+
+ // Add the dsc to the files hash list
+ char Files[1000];
+- snprintf(Files,sizeof(Files),"\n %s %lu %s\n %s",
++ snprintf(Files,sizeof(Files),"\n %s %llu %s\n %s",
+ string(MD5.Result()).c_str(),St.st_size,
+ flNotDir(FileName).c_str(),
+ Tags.FindS("Files").c_str());
diff --git a/data/apt/public.diff b/data/apt/public.diff
new file mode 100644
index 000000000..04e5051f8
--- /dev/null
+++ b/data/apt/public.diff
@@ -0,0 +1,15 @@
+diff -ru apt-0.7.20.2/apt-pkg/deb/debindexfile.h apt-0.7.20.2+iPhone/apt-pkg/deb/debindexfile.h
+--- apt-0.7.20.2/apt-pkg/deb/debindexfile.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debindexfile.h 2009-04-19 04:12:51.000000000 +0000
+@@ -49,9 +49,10 @@
+
+ string Info(const char *Type) const;
+ string IndexFile(const char *Type) const;
+- string IndexURI(const char *Type) const;
+
+ public:
++
++ string IndexURI(const char *Type) const;
+
+ virtual const Type *GetType() const;
+
diff --git a/data/apt/tag.diff b/data/apt/tag.diff
new file mode 100644
index 000000000..b315e2e50
--- /dev/null
+++ b/data/apt/tag.diff
@@ -0,0 +1,280 @@
+diff -ru apt-0.7.20.2/apt-pkg/cacheiterators.h apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h
+--- apt-0.7.20.2/apt-pkg/cacheiterators.h 2009-04-20 16:50:43.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h 2009-04-20 18:27:20.000000000 +0000
+@@ -79,6 +79,7 @@
+ inline VerIterator CurrentVer() const;
+ inline DepIterator RevDependsList() const;
+ inline PrvIterator ProvidesList() const;
++ inline TagIterator TagList() const;
+ inline unsigned long Index() const {return Pkg - Owner->PkgP;};
+ OkState State() const;
+
+@@ -148,6 +150,48 @@
+ };
+ };
+
++// Tag Iterator
++class pkgCache::TagIterator
++{
++ Tag *Tg;
++ pkgCache *Owner;
++
++ void _dummy();
++
++ public:
++
++ // Iteration
++ void operator ++(int) {if (Tg != Owner->TagP) Tg = Owner->TagP + Tg->NextTag;};
++ inline void operator ++() {operator ++(0);};
++ inline bool end() const {return Tg == Owner->TagP?true:false;};
++ inline void operator =(const TagIterator &B) {Tg = B.Tg; Owner = B.Owner;};
++
++ // Comparison
++ inline bool operator ==(const TagIterator &B) const {return Tg == B.Tg;};
++ inline bool operator !=(const TagIterator &B) const {return Tg != B.Tg;};
++ int CompareTag(const TagIterator &B) const;
++
++ // Accessors
++ inline Tag *operator ->() {return Tg;};
++ inline Tag const *operator ->() const {return Tg;};
++ inline Tag &operator *() {return *Tg;};
++ inline Tag const &operator *() const {return *Tg;};
++ inline operator Tag *() {return Tg == Owner->TagP?0:Tg;};
++ inline operator Tag const *() const {return Tg == Owner->TagP?0:Tg;};
++ inline pkgCache *Cache() {return Owner;};
++
++ inline const char *Name() const {return Owner->StrP + Tg->Name;};
++ inline unsigned long Index() const {return Tg - Owner->TagP;};
++
++ inline TagIterator() : Tg(0), Owner(0) {};
++ inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Tg(Trg),
++ Owner(&Owner)
++ {
++ if (Tg == 0)
++ Tg = Owner.TagP;
++ };
++};
++
+ // Description Iterator
+ class pkgCache::DescIterator
+ {
+@@ -423,6 +467,8 @@
+ {return DepIterator(*Owner,Owner->DepP + Pkg->RevDepends,Pkg);};
+ inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
+ {return PrvIterator(*Owner,Owner->ProvideP + Pkg->ProvidesList,Pkg);};
++inline pkgCache::TagIterator pkgCache::PkgIterator::TagList() const
++ {return TagIterator(*Owner,Owner->TagP + Pkg->TagList);};
+ inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
+ {return DescIterator(*Owner,Owner->DescP + Ver->DescriptionList);};
+ inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
+diff -ru apt-0.7.20.2/apt-pkg/deb/deblistparser.cc apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.20.2/apt-pkg/deb/deblistparser.cc 2009-04-20 17:02:43.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc 2009-04-20 19:27:47.000000000 +0000
+@@ -185,6 +189,11 @@
+
+ if (ParseStatus(Pkg,Ver) == false)
+ return false;
++
++ if (Pkg->TagList == 0)
++ if (ParseTag(Pkg) == false)
++ return false;
++
+ return true;
+ }
+ /*}}}*/
+@@ -570,6 +579,46 @@
+ return true;
+ }
+ /*}}}*/
++// ListParser::ParseTag - Parse the tag list /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++bool debListParser::ParseTag(pkgCache::PkgIterator Pkg)
++{
++ const char *Start;
++ const char *Stop;
++ if (Section.Find("Tag",Start,Stop) == false)
++ return true;
++
++ while (1) {
++ while (1) {
++ if (Start == Stop)
++ return true;
++ if (Stop[-1] != ' ' && Stop[-1] != '\t')
++ break;
++ --Stop;
++ }
++
++ const char *Begin = Stop - 1;
++ while (Begin != Start && Begin[-1] != ' ' && Begin[-1] != ',')
++ --Begin;
++
++ if (NewTag(Pkg, Begin, Stop - Begin) == false)
++ return false;
++
++ while (1) {
++ if (Begin == Start)
++ return true;
++ if (Begin[-1] == ',')
++ break;
++ --Begin;
++ }
++
++ Stop = Begin - 1;
++ }
++
++ return true;
++}
++ /*}}}*/
+ // ListParser::GrabWord - Matches a word and returns /*{{{*/
+ // ---------------------------------------------------------------------
+ /* Looks for a word in a list of words - for ParseStatus */
+diff -ru apt-0.7.20.2/apt-pkg/deb/deblistparser.h apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.h
+--- apt-0.7.20.2/apt-pkg/deb/deblistparser.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.h 2009-04-20 18:29:09.000000000 +0000
+@@ -38,6 +38,7 @@
+ bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
+ unsigned int Type);
+ bool ParseProvides(pkgCache::VerIterator Ver);
++ bool ParseTag(pkgCache::PkgIterator Pkg);
+ static bool GrabWord(string Word,WordList *List,unsigned char &Out);
+
+ public:
+diff -ru apt-0.7.20.2/apt-pkg/pkgcache.cc apt-0.7.20.2+iPhone/apt-pkg/pkgcache.cc
+--- apt-0.7.20.2/apt-pkg/pkgcache.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcache.cc 2009-04-20 19:10:52.000000000 +0000
+@@ -124,6 +124,7 @@
+ VerP = (Version *)Map.Data();
+ DescP = (Description *)Map.Data();
+ ProvideP = (Provides *)Map.Data();
++ TagP = (Tag *)Map.Data();
+ DepP = (Dependency *)Map.Data();
+ StringItemP = (StringItem *)Map.Data();
+ StrP = (char *)Map.Data();
+diff -ru apt-0.7.20.2/apt-pkg/pkgcachegen.cc apt-0.7.20.2+iPhone/apt-pkg/pkgcachegen.cc
+--- apt-0.7.20.2/apt-pkg/pkgcachegen.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcachegen.cc 2009-04-20 19:28:52.000000000 +0000
+@@ -570,6 +570,32 @@
+ return true;
+ }
+ /*}}}*/
++// ListParser::NewTag - Create a Tag element /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++bool pkgCacheGenerator::ListParser::NewTag(pkgCache::PkgIterator Pkg,
++ const char *NameStart,
++ unsigned int NameSize)
++{
++ pkgCache &Cache = Owner->Cache;
++
++ // Get a structure
++ unsigned long Tagg = Owner->Map.Allocate(sizeof(pkgCache::Tag));
++ if (Tagg == 0)
++ return false;
++ Cache.HeaderP->TagCount++;
++
++ // Fill it in
++ pkgCache::TagIterator Tg(Cache,Cache.TagP + Tagg);
++ Tg->Name = WriteString(NameStart,NameSize);
++ if (Tg->Name == 0)
++ return false;
++ Tg->NextTag = Pkg->TagList;
++ Pkg->TagList = Tg.Index();
++
++ return true;
++}
++ /*}}}*/
+ // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
+ // ---------------------------------------------------------------------
+ /* This is used to select which file is to be associated with all newly
+diff -ru apt-0.7.20.2/apt-pkg/pkgcachegen.h apt-0.7.20.2+iPhone/apt-pkg/pkgcachegen.h
+--- apt-0.7.20.2/apt-pkg/pkgcachegen.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcachegen.h 2009-04-20 18:47:57.000000000 +0000
+@@ -101,6 +101,7 @@
+ unsigned int Type);
+ bool NewProvides(pkgCache::VerIterator Ver,const string &Package,
+ const string &Version);
++ bool NewTag(pkgCache::PkgIterator Pkg,const char *NameStart,unsigned int NameSize);
+
+ public:
+
+diff -ru apt-0.7.20.2/apt-pkg/pkgcache.h apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.20.2/apt-pkg/pkgcache.h 2009-04-20 16:49:55.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h 2009-04-20 18:26:48.000000000 +0000
+@@ -41,6 +41,7 @@
+ struct StringItem;
+ struct VerFile;
+ struct DescFile;
++ struct Tag;
+
+ // Iterators
+ class PkgIterator;
+@@ -51,6 +52,7 @@
+ class PkgFileIterator;
+ class VerFileIterator;
+ class DescFileIterator;
++ class TagIterator;
+ friend class PkgIterator;
+ friend class VerIterator;
+ friend class DescInterator;
+@@ -59,6 +61,7 @@
+ friend class PkgFileIterator;
+ friend class VerFileIterator;
+ friend class DescFileIterator;
++ friend class TagIterator;
+
+ class Namespace;
+
+@@ -109,6 +112,7 @@
+ DescFile *DescFileP;
+ PackageFile *PkgFileP;
+ Version *VerP;
++ Tag *TagP;
+ Description *DescP;
+ Provides *ProvideP;
+ Dependency *DepP;
+@@ -161,6 +165,7 @@
+ unsigned short PackageSz;
+ unsigned short PackageFileSz;
+ unsigned short VersionSz;
++ unsigned short TagSz;
+ unsigned short DescriptionSz;
+ unsigned short DependencySz;
+ unsigned short ProvidesSz;
+@@ -170,6 +175,7 @@
+ // Structure counts
+ unsigned long PackageCount;
+ unsigned long VersionCount;
++ unsigned long TagCount;
+ unsigned long DescriptionCount;
+ unsigned long DependsCount;
+ unsigned long PackageFileCount;
+@@ -209,6 +215,7 @@
+ map_ptrloc NextPackage; // Package
+ map_ptrloc RevDepends; // Dependency
+ map_ptrloc ProvidesList; // Provides
++ map_ptrloc TagList; // Tag
+
+ // Install/Remove/Purge etc
+ unsigned char SelectedState; // What
+@@ -248,6 +255,12 @@
+ unsigned short Size;
+ };
+
++struct pkgCache::Tag
++{
++ map_ptrloc Name; // Stringtable
++ map_ptrloc NextTag; // Tag
++};
++
+ struct pkgCache::DescFile
+ {
+ map_ptrloc File; // PackageFile
+@@ -340,6 +354,7 @@
+
+ typedef pkgCache::PkgIterator PkgIterator;
+ typedef pkgCache::VerIterator VerIterator;
++ typedef pkgCache::TagIterator TagIterator;
+ typedef pkgCache::DescIterator DescIterator;
+ typedef pkgCache::DepIterator DepIterator;
+ typedef pkgCache::PrvIterator PrvIterator;
diff --git a/data/apt/textdomain.diff b/data/apt/textdomain.diff
deleted file mode 100644
index 6ef3853e5..000000000
--- a/data/apt/textdomain.diff
+++ /dev/null
@@ -1,72 +0,0 @@
-diff -ru apt-0.7.20.2/cmdline/apt-cache.cc apt-0.7.20.2+iPhone/cmdline/apt-cache.cc
---- apt-0.7.20.2/cmdline/apt-cache.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-cache.cc 2009-04-14 16:10:02.000000000 +0000
-@@ -1810,7 +1810,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
-diff -ru apt-0.7.20.2/cmdline/apt-cdrom.cc apt-0.7.20.2+iPhone/cmdline/apt-cdrom.cc
---- apt-0.7.20.2/cmdline/apt-cdrom.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-cdrom.cc 2009-04-14 16:10:02.000000000 +0000
-@@ -188,7 +188,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
-diff -ru apt-0.7.20.2/cmdline/apt-config.cc apt-0.7.20.2+iPhone/cmdline/apt-config.cc
---- apt-0.7.20.2/cmdline/apt-config.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-config.cc 2009-04-14 16:10:02.000000000 +0000
-@@ -103,7 +103,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
-diff -ru apt-0.7.20.2/cmdline/apt-extracttemplates.cc apt-0.7.20.2+iPhone/cmdline/apt-extracttemplates.cc
---- apt-0.7.20.2/cmdline/apt-extracttemplates.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-extracttemplates.cc 2009-04-14 16:10:02.000000000 +0000
-@@ -361,7 +361,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
-diff -ru apt-0.7.20.2/cmdline/apt-get.cc apt-0.7.20.2+iPhone/cmdline/apt-get.cc
---- apt-0.7.20.2/cmdline/apt-get.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-get.cc 2009-04-15 19:38:48.000000000 +0000
-@@ -2758,7 +2759,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
-diff -ru apt-0.7.20.2/cmdline/apt-sortpkgs.cc apt-0.7.20.2+iPhone/cmdline/apt-sortpkgs.cc
---- apt-0.7.20.2/cmdline/apt-sortpkgs.cc 2009-02-07 15:09:35.000000000 +0000
-+++ apt-0.7.20.2+iPhone/cmdline/apt-sortpkgs.cc 2009-04-14 16:10:02.000000000 +0000
-@@ -174,7 +174,7 @@
-
- // Set up gettext support
- setlocale(LC_ALL,"");
-- textdomain(PACKAGE);
-+ //textdomain(PACKAGE);
-
- // Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);