summaryrefslogtreecommitdiff
path: root/data/_apt7
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2018-12-07 13:01:05 -1000
committerSam Bingner <sam@bingner.com>2018-12-07 13:01:05 -1000
commitdabe8669a56fca398da9a7dd117eb74f874cddc0 (patch)
tree1e9f41f484e72a02652b600498a7b09aee62b7e6 /data/_apt7
parentbae6eae573376ebc0e942e88c4f6eaea9b0f1574 (diff)
Update to use libapt instead of apt7-lib for apt1.4+ and add apt-rdepends
Diffstat (limited to 'data/_apt7')
l---------data/_apt7/_metadata/lz4.dep1
l---------data/_apt7/_metadata/maintainer2
-rw-r--r--data/_apt7/_metadata/version2
-rw-r--r--data/_apt7/abi-4.8.diff315
-rw-r--r--data/_apt7/apt-get.diff20
-rw-r--r--data/_apt7/apt-nito.tgzbin38054572 -> 0 bytes
-rw-r--r--data/_apt7/apt_0.7.25.3.tar.gzbin0 -> 2646727 bytes
-rw-r--r--data/_apt7/aptbug545699.args1
-rw-r--r--data/_apt7/aptbug545699.diff71
-rw-r--r--data/_apt7/architecture.diff13
-rw-r--r--data/_apt7/cache-limit.diff21
-rw-r--r--data/_apt7/cfnetwork.diff703
-rw-r--r--data/_apt7/cftype.diff11
-rw-r--r--data/_apt7/date-errors.diff12
-rw-r--r--data/_apt7/deblistparser.diff27
-rw-r--r--data/_apt7/deprecated.diff13
-rw-r--r--data/_apt7/display.diff125
-rw-r--r--data/_apt7/find.diff37
-rw-r--r--data/_apt7/finddesc.diff59
-rw-r--r--data/_apt7/hashtable.diff61
-rw-r--r--data/_apt7/iconv.diff23
-rw-r--r--data/_apt7/insensitive.diff12
-rw-r--r--data/_apt7/intl.diff12
-rw-r--r--data/_apt7/longdesc.diff17
-rw-r--r--data/_apt7/make.sh36
-rw-r--r--data/_apt7/map_anon.diff17
-rw-r--r--data/_apt7/memrchr.c161
-rw-r--r--data/_apt7/memrchr.diff195
-rw-r--r--data/_apt7/mmap.diff199
-rw-r--r--data/_apt7/parallel.diff33
-rw-r--r--data/_apt7/port.diff216
-rw-r--r--data/_apt7/printf.diff12
-rw-r--r--data/_apt7/public.diff15
-rw-r--r--data/_apt7/reinstreq.diff21
-rw-r--r--data/_apt7/sandbox-errors.diff10
-rw-r--r--data/_apt7/sha1.diff12
-rw-r--r--data/_apt7/strdupa.diff80
-rw-r--r--data/_apt7/tag.diff280
-rw-r--r--data/_apt7/timestamp.diff (renamed from data/_apt7/_metadata/in.1443.00)0
-rw-r--r--data/_apt7/tolerance.diff24
-rw-r--r--data/_apt7/tornado.diff719
-rw-r--r--data/_apt7/torque.diff147
-rw-r--r--data/_apt7/turbulence.diff64
43 files changed, 3730 insertions, 69 deletions
diff --git a/data/_apt7/_metadata/lz4.dep b/data/_apt7/_metadata/lz4.dep
deleted file mode 120000
index bccb2875c..000000000
--- a/data/_apt7/_metadata/lz4.dep
+++ /dev/null
@@ -1 +0,0 @@
-../../lz4 \ No newline at end of file
diff --git a/data/_apt7/_metadata/maintainer b/data/_apt7/_metadata/maintainer
index 573d7ebef..0fa66e077 120000
--- a/data/_apt7/_metadata/maintainer
+++ b/data/_apt7/_metadata/maintainer
@@ -1 +1 @@
-../../../people/sbingner \ No newline at end of file
+../../../people/saurik \ No newline at end of file
diff --git a/data/_apt7/_metadata/version b/data/_apt7/_metadata/version
index b2e46d185..61c4e572d 100644
--- a/data/_apt7/_metadata/version
+++ b/data/_apt7/_metadata/version
@@ -1 +1 @@
-1.4.8
+0.7.25.3
diff --git a/data/_apt7/abi-4.8.diff b/data/_apt7/abi-4.8.diff
new file mode 100644
index 000000000..e2f2de96e
--- /dev/null
+++ b/data/_apt7/abi-4.8.diff
@@ -0,0 +1,315 @@
+diff -ru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-22 18:42:49.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-22 19:48:19.000000000 +0000
+@@ -698,8 +698,6 @@
+ FileI->Version = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Origin",Start,Stop) == true)
+ FileI->Origin = WriteUniqString(Start,Stop - Start);
+- if (Section.Find("Codename",Start,Stop) == true)
+- FileI->Codename = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Label",Start,Stop) == true)
+ FileI->Label = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Architecture",Start,Stop) == true)
+diff -ru apt-0.7.25.3/apt-pkg/depcache.cc apt-0.7.25.3+iPhone/apt-pkg/depcache.cc
+--- apt-0.7.25.3/apt-pkg/depcache.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/depcache.cc 2010-02-22 19:38:27.000000000 +0000
+@@ -80,6 +80,9 @@
+ // DepCache::pkgDepCache - Constructors /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
++static bool DebugMarker;
++static bool DebugAutoInstall;
++
+ pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) :
+ group_level(0), Cache(pCache), PkgState(0), DepState(0)
+ {
+diff -ru apt-0.7.25.3/apt-pkg/depcache.h apt-0.7.25.3+iPhone/apt-pkg/depcache.h
+--- apt-0.7.25.3/apt-pkg/depcache.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/depcache.h 2010-02-22 19:38:14.000000000 +0000
+@@ -295,9 +295,6 @@
+ unsigned long iPolicyBrokenCount;
+ unsigned long iBadCount;
+
+- bool DebugMarker;
+- bool DebugAutoInstall;
+-
+ Policy *delLocalPolicy; // For memory clean up..
+ Policy *LocalPolicy;
+
+@@ -420,7 +417,7 @@
+ * \param Depth recursive deep of this Marker call
+ * \param FromUser was the install requested by the user?
+ */
+- virtual bool IsInstallOk(const PkgIterator &Pkg,bool AutoInst = true,
++ bool IsInstallOk(const PkgIterator &Pkg,bool AutoInst = true,
+ unsigned long Depth = 0, bool FromUser = true);
+
+ /** \return \b true if it's OK for MarkDelete to remove
+@@ -439,7 +436,7 @@
+ * \param Depth recursive deep of this Marker call
+ * \param FromUser was the remove requested by the user?
+ */
+- virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false,
++ bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false,
+ unsigned long Depth = 0, bool FromUser = true);
+
+ // This is for debuging
+diff -ru apt-0.7.25.3/apt-pkg/pkgcache.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc
+--- apt-0.7.25.3/apt-pkg/pkgcache.cc 2010-02-22 18:42:49.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc 2010-02-22 19:49:45.000000000 +0000
+@@ -49,7 +49,7 @@
+
+ /* Whenever the structures change the major version should be bumped,
+ whenever the generator changes the minor version should be bumped. */
+- MajorVersion = 8;
++ MajorVersion = 7;
+ MinorVersion = 0;
+ Dirty = false;
+
+@@ -658,8 +658,6 @@
+ Res = Res + (Res.empty() == true?"o=":",o=") + Origin();
+ if (Archive() != 0)
+ Res = Res + (Res.empty() == true?"a=":",a=") + Archive();
+- if (Codename() != 0)
+- Res = Res + (Res.empty() == true?"n=":",n=") + Codename();
+ if (Label() != 0)
+ Res = Res + (Res.empty() == true?"l=":",l=") + Label();
+ if (Component() != 0)
+diff -ru apt-0.7.25.3/apt-pkg/pkgcache.h apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.25.3/apt-pkg/pkgcache.h 2010-02-22 18:42:49.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h 2010-02-22 19:46:08.000000000 +0000
+@@ -222,16 +222,15 @@
+ unsigned char InstState; // Flags
+ unsigned char CurrentState; // State
+
+- unsigned int ID;
++ unsigned short ID;
+ unsigned long Flags;
+ };
+- /*}}}*/
+-struct pkgCache::PackageFile /*{{{*/
++
++struct pkgCache::PackageFile
+ {
+ // Names
+ map_ptrloc FileName; // Stringtable
+ map_ptrloc Archive; // Stringtable
+- map_ptrloc Codename; // Stringtable
+ map_ptrloc Component; // Stringtable
+ map_ptrloc Version; // Stringtable
+ map_ptrloc Origin; // Stringtable
+@@ -244,7 +243,7 @@
+
+ // Linked list
+ map_ptrloc NextFile; // PackageFile
+- unsigned int ID;
++ unsigned short ID;
+ time_t mtime; // Modification time for the file
+ };
+ /*}}}*/
+@@ -288,7 +287,7 @@
+ map_ptrloc Size; // These are the .deb size
+ map_ptrloc InstalledSize;
+ unsigned short Hash;
+- unsigned int ID;
++ unsigned short ID;
+ unsigned char Priority;
+ };
+ /*}}}*/
+@@ -305,7 +304,7 @@
+ map_ptrloc NextDesc; // Description
+ map_ptrloc ParentPkg; // Package
+
+- unsigned int ID;
++ unsigned short ID;
+ };
+ /*}}}*/
+ struct pkgCache::Dependency /*{{{*/
+diff -ru apt-0.7.25.3/apt-pkg/tagfile.h apt-0.7.25.3+iPhone/apt-pkg/tagfile.h
+--- apt-0.7.25.3/apt-pkg/tagfile.h 2010-02-22 18:42:49.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/tagfile.h 2010-02-22 19:41:05.000000000 +0000
+@@ -28,6 +28,7 @@
+ class pkgTagSection
+ {
+ const char *Section;
++ const char *Stop;
+
+ // We have a limit of 256 tags per section.
+ unsigned int Indexes[256];
+@@ -35,9 +36,6 @@
+
+ unsigned int TagCount;
+
+- protected:
+- const char *Stop;
+-
+ public:
+
+ inline bool operator ==(const pkgTagSection &rhs) {return Section == rhs.Section;};
+@@ -52,7 +50,7 @@
+ bool Scan(const char *Start,unsigned long MaxLength);
+ inline unsigned long size() const {return Stop - Section;};
+ void Trim();
+- virtual void TrimRecord(bool BeforeRecord, const char* &End);
++ void TrimRecord(bool BeforeRecord, const char* &End);
+
+ inline unsigned int Count() const {return TagCount;};
+ inline void Get(const char *&Start,const char *&Stop,unsigned int I) const
+diff -ru apt-0.7.25.3/apt-pkg/versionmatch.cc apt-0.7.25.3+iPhone/apt-pkg/versionmatch.cc
+--- apt-0.7.25.3/apt-pkg/versionmatch.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/versionmatch.cc 2010-02-22 19:51:20.000000000 +0000
+@@ -63,7 +63,7 @@
+ if (isdigit(Data[0]))
+ RelVerStr = Data;
+ else
+- RelRelease = Data;
++ RelArchive = Data;
+
+ if (RelVerStr.length() > 0 && RelVerStr.end()[-1] == '*')
+ {
+@@ -94,8 +94,6 @@
+ RelOrigin = Fragments[J]+2;
+ else if (stringcasecmp(Fragments[J],Fragments[J]+2,"a=") == 0)
+ RelArchive = Fragments[J]+2;
+- else if (stringcasecmp(Fragments[J],Fragments[J]+2,"n=") == 0)
+- RelCodename = Fragments[J]+2;
+ else if (stringcasecmp(Fragments[J],Fragments[J]+2,"l=") == 0)
+ RelLabel = Fragments[J]+2;
+ else if (stringcasecmp(Fragments[J],Fragments[J]+2,"c=") == 0)
+@@ -177,7 +175,6 @@
+
+ if (RelVerStr.empty() == true && RelOrigin.empty() == true &&
+ RelArchive.empty() == true && RelLabel.empty() == true &&
+- RelRelease.empty() == true && RelCodename.empty() == true &&
+ RelComponent.empty() == true)
+ return false;
+
+@@ -193,16 +190,6 @@
+ if (File->Archive == 0 ||
+ stringcasecmp(RelArchive,File.Archive()) != 0)
+ return false;
+- if (RelCodename.empty() == false)
+- if (File->Codename == 0 ||
+- stringcasecmp(RelCodename,File.Codename()) != 0)
+- return false;
+- if (RelRelease.empty() == false)
+- if ((File->Archive == 0 ||
+- stringcasecmp(RelRelease,File.Archive()) != 0) &&
+- (File->Codename == 0 ||
+- stringcasecmp(RelRelease,File.Codename()) != 0))
+- return false;
+ if (RelLabel.empty() == false)
+ if (File->Label == 0 ||
+ stringcasecmp(RelLabel,File.Label()) != 0)
+diff -ru apt-0.7.25.3/apt-pkg/versionmatch.h apt-0.7.25.3+iPhone/apt-pkg/versionmatch.h
+--- apt-0.7.25.3/apt-pkg/versionmatch.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/versionmatch.h 2010-02-22 19:50:32.000000000 +0000
+@@ -50,8 +50,6 @@
+ string RelVerStr;
+ bool RelVerPrefixMatch;
+ string RelOrigin;
+- string RelRelease;
+- string RelCodename;
+ string RelArchive;
+ string RelLabel;
+ string RelComponent;
+diff -ru apt-0.7.25.3/cmdline/apt-get.cc apt-0.7.25.3+iPhone/cmdline/apt-get.cc
+--- apt-0.7.25.3/cmdline/apt-get.cc 2010-02-22 18:42:49.000000000 +0000
++++ apt-0.7.25.3+iPhone/cmdline/apt-get.cc 2010-02-22 19:51:54.000000000 +0000
+@@ -1296,8 +1296,7 @@
+
+ // or we match against a release
+ if(VerTag.empty() == false ||
+- (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) ||
+- (VF.File().Codename() != 0 && VF.File().Codename() == DefRel))
++ (VF.File().Archive() != 0 && VF.File().Archive() == DefRel))
+ {
+ pkgRecords::Parser &Parse = Recs.Lookup(VF);
+ Src = Parse.SourcePkg();
+diff -ru apt-0.7.25.3/apt-pkg/depcache.cc apt-0.7.25.3+iPhone/apt-pkg/depcache.cc
+--- apt-0.7.25.3/apt-pkg/depcache.cc 2010-02-22 19:38:27.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/depcache.cc 2010-02-22 20:02:41.000000000 +0000
+@@ -774,6 +774,10 @@
+ // DepCache::MarkDelete - Put the package in the delete state /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
++void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool Purge) {
++ MarkDelete(Pkg, Purge, 0);
++}
++
+ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge,
+ unsigned long Depth, bool FromUser)
+ {
+diff -ru apt-0.7.25.3/apt-pkg/depcache.h apt-0.7.25.3+iPhone/apt-pkg/depcache.h
+--- apt-0.7.25.3/apt-pkg/depcache.h 2010-02-22 19:38:14.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/depcache.h 2010-02-22 20:02:47.000000000 +0000
+@@ -388,10 +388,13 @@
+ /** \name State Manipulators
+ */
+ // @{
+- void MarkKeep(PkgIterator const &Pkg, bool Soft = false,
+- bool FromUser = true, unsigned long Depth = 0);
++ void MarkKeep(PkgIterator const &Pkg, bool Soft = false,
++ bool FromUser = true);
++ void MarkKeep(PkgIterator const &Pkg, bool Soft,
++ bool FromUser, unsigned long Depth);
+- void MarkDelete(PkgIterator const &Pkg, bool Purge = false,
+- unsigned long Depth = 0, bool FromUser = true);
++ void MarkDelete(PkgIterator const &Pkg,bool Purge = false);
++ void MarkDelete(PkgIterator const &Pkg, bool Purge,
++ unsigned long Depth, bool FromUser = true);
+ void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
+ unsigned long Depth = 0, bool FromUser = true,
+ bool ForceImportantDeps = false);
+diff -ru apt-0.7.25.3/apt-pkg/cacheiterators.h apt-0.7.25.3+iPhone/apt-pkg/cacheiterators.h
+--- apt-0.7.25.3/apt-pkg/cacheiterators.h 2010-02-22 20:06:07.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/cacheiterators.h 2010-02-22 20:07:13.000000000 +0000
+@@ -387,7 +387,6 @@
+ inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
+ inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
+ inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
+- inline const char *Codename() const {return File->Codename ==0?0:Owner->StrP + File->Codename;};
+ inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
+ inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
+ inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
+diff -ru apt-0.7.25.3/apt-pkg/tagfile.h apt-0.7.25.3+iPhone/apt-pkg/tagfile.h
+--- apt-0.7.25.3/apt-pkg/tagfile.h 2010-02-22 20:06:07.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/tagfile.h 2010-02-22 20:09:55.000000000 +0000
+@@ -28,8 +28,11 @@
+ class pkgTagSection
+ {
+ const char *Section;
++
++ protected:
+ const char *Stop;
+
++ private:
+ // We have a limit of 256 tags per section.
+ unsigned int Indexes[256];
+ unsigned int AlphaIndexes[0x100];
+diff -ru apt-0.7.25.3/apt-pkg/init.h apt-0.7.25.3+iPhone/apt-pkg/init.h
+--- apt-0.7.25.3/apt-pkg/init.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/init.h 2010-02-22 20:34:49.000000000 +0000
+@@ -22,7 +22,7 @@
+ // Non-ABI-Breaks should only increase RELEASE number.
+ // See also buildlib/libversion.mak
+ #define APT_PKG_MAJOR 4
+-#define APT_PKG_MINOR 8
++#define APT_PKG_MINOR 6
+ #define APT_PKG_RELEASE 0
+
+ extern const char *pkgVersion;
+diff -ru apt-0.7.25.3/apt-pkg/depcache.cc apt-0.7.25.3+iPhone/apt-pkg/depcache.cc
+--- apt-0.7.25.3/apt-pkg/depcache.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/depcache.cc 2010-02-22 20:44:23.000000000 +0000
+@@ -707,6 +707,10 @@
+ // DepCache::MarkKeep - Put the package in the keep state /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
++void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser) {
++ MarkKeep(Pkg, Soft, FromUser, 0);
++}
++
+ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser,
+ unsigned long Depth)
+ {
diff --git a/data/_apt7/apt-get.diff b/data/_apt7/apt-get.diff
new file mode 100644
index 000000000..6d5bacac9
--- /dev/null
+++ b/data/_apt7/apt-get.diff
@@ -0,0 +1,20 @@
+diff -ur apt-0.7.25.3/cmdline/apt-get.cc apt-0.7.25.3+iPhone/cmdline/apt-get.cc
+--- apt-0.7.25.3/cmdline/apt-get.cc 2018-12-03 13:17:35.000000000 -1000
++++ apt-0.7.25.3+iPhone/cmdline/apt-get.cc 2018-12-03 13:20:54.000000000 -1000
+@@ -1844,12 +1844,12 @@
+ if ((*Cache)[I].Install() == false)
+ continue;
+
+- const char **J;
+- for (J = CmdL.FileList + 1; *J != 0; J++)
+- if (strcmp(*J,I.Name()) == 0)
++ const char **K;
++ for (K = CmdL.FileList + 1; *K != 0; K++)
++ if (strcmp(*K,I.Name()) == 0)
+ break;
+
+- if (*J == 0) {
++ if (*K == 0) {
+ List += string(I.Name()) + " ";
+ VersionsList += string(Cache[I].CandVersion) + "\n";
+ }
diff --git a/data/_apt7/apt-nito.tgz b/data/_apt7/apt-nito.tgz
deleted file mode 100644
index 8ebac625c..000000000
--- a/data/_apt7/apt-nito.tgz
+++ /dev/null
Binary files differ
diff --git a/data/_apt7/apt_0.7.25.3.tar.gz b/data/_apt7/apt_0.7.25.3.tar.gz
new file mode 100644
index 000000000..72b140be8
--- /dev/null
+++ b/data/_apt7/apt_0.7.25.3.tar.gz
Binary files differ
diff --git a/data/_apt7/aptbug545699.args b/data/_apt7/aptbug545699.args
new file mode 100644
index 000000000..4dd9cbd34
--- /dev/null
+++ b/data/_apt7/aptbug545699.args
@@ -0,0 +1 @@
+-p0
diff --git a/data/_apt7/aptbug545699.diff b/data/_apt7/aptbug545699.diff
new file mode 100644
index 000000000..336241f9b
--- /dev/null
+++ b/data/_apt7/aptbug545699.diff
@@ -0,0 +1,71 @@
+=== modified file 'apt-pkg/acquire-item.cc'
+--- apt-pkg/acquire-item.cc 2009-08-28 19:07:55 +0000
++++ apt-pkg/acquire-item.cc 2009-09-08 12:50:05 +0000
+@@ -274,7 +274,7 @@
+ if(last_space != string::npos)
+ Description.erase(last_space, Description.size()-last_space);
+ new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
+- ExpectedHash, available_patches);
++ ExpectedHash, ServerSha1, available_patches);
+ Complete = false;
+ Status = StatDone;
+ Dequeue();
+@@ -342,9 +342,10 @@
+ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
+ string URI,string URIDesc,string ShortDesc,
+ HashString ExpectedHash,
++ string ServerSha1,
+ vector<DiffInfo> diffs)
+ : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash),
+- available_patches(diffs)
++ available_patches(diffs), ServerSha1(ServerSha1)
+ {
+
+ DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+@@ -430,6 +431,13 @@
+ std::clog << "QueueNextDiff: "
+ << FinalFile << " (" << local_sha1 << ")"<<std::endl;
+
++ // final file reached before all patches are applied
++ if(local_sha1 == ServerSha1)
++ {
++ Finish(true);
++ return true;
++ }
++
+ // remove all patches until the next matching patch is found
+ // this requires the Index file to be ordered
+ for(vector<DiffInfo>::iterator I=available_patches.begin();
+@@ -527,7 +535,7 @@
+ // see if there is more to download
+ if(available_patches.size() > 0) {
+ new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
+- ExpectedHash, available_patches);
++ ExpectedHash, ServerSha1, available_patches);
+ return Finish();
+ } else
+ return Finish(true);
+
+=== modified file 'apt-pkg/acquire-item.h'
+--- apt-pkg/acquire-item.h 2009-08-11 22:52:26 +0000
++++ apt-pkg/acquire-item.h 2009-09-08 12:30:11 +0000
+@@ -422,6 +422,10 @@
+ * off the front?
+ */
+ vector<DiffInfo> available_patches;
++
++ /** Stop applying patches when reaching that sha1 */
++ string ServerSha1;
++
+ /** The current status of this patch. */
+ enum DiffState
+ {
+@@ -475,6 +479,7 @@
+ */
+ pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc,
+ string ShortDesc, HashString ExpectedHash,
++ string ServerSha1,
+ vector<DiffInfo> diffs=vector<DiffInfo>());
+ };
+ /*}}}*/
+
diff --git a/data/_apt7/architecture.diff b/data/_apt7/architecture.diff
new file mode 100644
index 000000000..65533f6a6
--- /dev/null
+++ b/data/_apt7/architecture.diff
@@ -0,0 +1,13 @@
+diff -ru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2011-05-27 05:46:33.000000000 +0000
+@@ -605,6 +605,9 @@
+ if (stringcmp(Start,Stop,"all") == 0)
+ return true;
+
++ if (stringcmp(Start,Stop,"cydia") == 0)
++ return true;
++
+ iOffset = Tags.Offset();
+ }
+ return false;
diff --git a/data/_apt7/cache-limit.diff b/data/_apt7/cache-limit.diff
new file mode 100644
index 000000000..01db636be
--- /dev/null
+++ b/data/_apt7/cache-limit.diff
@@ -0,0 +1,21 @@
+diff -ru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc
+--- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2014-06-13 09:34:25.000000000 +0000
+@@ -827,7 +827,7 @@
+ MMap **OutMap,bool AllowMem)
+ {
+ bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
+- unsigned long const MapSize = _config->FindI("APT::Cache-Limit",24*1024*1024);
++ unsigned long const MapSize = _config->FindI("APT::Cache-Limit",128*1024*1024);
+
+ vector<pkgIndexFile *> Files;
+ for (vector<metaIndex *>::const_iterator i = List.begin();
+@@ -992,7 +992,7 @@
+ /* */
+ bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+ {
+- unsigned long MapSize = _config->FindI("APT::Cache-Limit",20*1024*1024);
++ unsigned long MapSize = _config->FindI("APT::Cache-Limit",128*1024*1024);
+ vector<pkgIndexFile *> Files;
+ unsigned long EndOfSource = Files.size();
+ if (_system->AddStatusFiles(Files) == false)
diff --git a/data/_apt7/cfnetwork.diff b/data/_apt7/cfnetwork.diff
new file mode 100644
index 000000000..f6d609521
--- /dev/null
+++ b/data/_apt7/cfnetwork.diff
@@ -0,0 +1,703 @@
+diff -ru apt-0.7.25.3/methods/http.cc apt-0.7.25.3+iPhone/methods/http.cc
+--- apt-0.7.25.3/methods/http.cc 2010-02-01 19:44:41.000000000 +0000
++++ apt-0.7.25.3+iPhone/methods/http.cc 2010-02-22 20:20:42.000000000 +0000
+@@ -31,6 +31,7 @@
+ #include <apt-pkg/hashes.h>
+ #include <apt-pkg/netrc.h>
+
++#include <sys/sysctl.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ #include <utime.h>
+@@ -41,11 +42,20 @@
+ #include <string.h>
+ #include <iostream>
+ #include <map>
++#include <set>
+ #include <apti18n.h>
+
+
+ // Internet stuff
+ #include <netdb.h>
++#include <arpa/inet.h>
++
++#include <dlfcn.h>
++#include <lockdown.h>
++#include <CoreFoundation/CoreFoundation.h>
++#include <CoreServices/CoreServices.h>
++#include <CFNetwork/CFNetwork.h>
++#include <SystemConfiguration/SystemConfiguration.h>
+
+ #include "config.h"
+ #include "connect.h"
+@@ -54,6 +62,51 @@
+ /*}}}*/
+ using namespace std;
+
++CFStringRef Firmware_;
++const char *Machine_;
++CFStringRef UniqueID_;
++
++void CfrsError(const char *name, CFReadStreamRef rs) {
++ CFStreamError se = CFReadStreamGetError(rs);
++
++ if (se.domain == kCFStreamErrorDomainCustom) {
++ } else if (se.domain == kCFStreamErrorDomainPOSIX) {
++ _error->Error("POSIX: %s", strerror(se.error));
++ } else if (se.domain == kCFStreamErrorDomainMacOSStatus) {
++ _error->Error("MacOSStatus: %ld", se.error);
++ } else if (se.domain == kCFStreamErrorDomainNetDB) {
++ _error->Error("NetDB: %s %s", name, gai_strerror(se.error));
++ } else if (se.domain == kCFStreamErrorDomainMach) {
++ _error->Error("Mach: %ld", se.error);
++ } else if (se.domain == kCFStreamErrorDomainHTTP) {
++ switch (se.error) {
++ case kCFStreamErrorHTTPParseFailure:
++ _error->Error("Parse failure");
++ break;
++
++ case kCFStreamErrorHTTPRedirectionLoop:
++ _error->Error("Redirection loop");
++ break;
++
++ case kCFStreamErrorHTTPBadURL:
++ _error->Error("Bad URL");
++ break;
++
++ default:
++ _error->Error("Unknown HTTP error: %ld", se.error);
++ break;
++ }
++ } else if (se.domain == kCFStreamErrorDomainSOCKS) {
++ _error->Error("SOCKS: %ld", se.error);
++ } else if (se.domain == kCFStreamErrorDomainSystemConfiguration) {
++ _error->Error("SystemConfiguration: %ld", se.error);
++ } else if (se.domain == kCFStreamErrorDomainSSL) {
++ _error->Error("SSL: %ld", se.error);
++ } else {
++ _error->Error("Domain #%ld: %ld", se.domain, se.error);
++ }
++}
++
+ string HttpMethod::FailFile;
+ int HttpMethod::FailFd = -1;
+ time_t HttpMethod::FailTime = 0;
+@@ -646,6 +699,51 @@
+ }
+ /*}}}*/
+
++static const CFOptionFlags kNetworkEvents =
++ kCFStreamEventOpenCompleted |
++ kCFStreamEventHasBytesAvailable |
++ kCFStreamEventEndEncountered |
++ kCFStreamEventErrorOccurred |
++0;
++
++static void CFReadStreamCallback(CFReadStreamRef stream, CFStreamEventType event, void *arg) {
++ switch (event) {
++ case kCFStreamEventOpenCompleted:
++ break;
++
++ case kCFStreamEventHasBytesAvailable:
++ case kCFStreamEventEndEncountered:
++ *reinterpret_cast<int *>(arg) = 1;
++ CFRunLoopStop(CFRunLoopGetCurrent());
++ break;
++
++ case kCFStreamEventErrorOccurred:
++ *reinterpret_cast<int *>(arg) = -1;
++ CFRunLoopStop(CFRunLoopGetCurrent());
++ break;
++ }
++}
++
++/* http://lists.apple.com/archives/Macnetworkprog/2006/Apr/msg00014.html */
++int CFReadStreamOpen(CFReadStreamRef stream, double timeout) {
++ CFStreamClientContext context;
++ int value(0);
++
++ memset(&context, 0, sizeof(context));
++ context.info = &value;
++
++ if (CFReadStreamSetClient(stream, kNetworkEvents, CFReadStreamCallback, &context)) {
++ CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
++ if (CFReadStreamOpen(stream))
++ CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeout, false);
++ else
++ value = -1;
++ CFReadStreamSetClient(stream, kCFStreamEventNone, NULL, NULL);
++ }
++
++ return value;
++}
++
+ // HttpMethod::SendReq - Send the HTTP request /*{{{*/
+ // ---------------------------------------------------------------------
+ /* This places the http request in the outbound buffer */
+@@ -1088,6 +1186,8 @@
+ signal(SIGINT,SigTerm);
+
+ Server = 0;
++
++ std::set<std::string> cached;
+
+ int FailCounter = 0;
+ while (1)
+@@ -1107,214 +1207,314 @@
+
+ if (Queue == 0)
+ continue;
+-
+- // Connect to the server
+- if (Server == 0 || Server->Comp(Queue->Uri) == false)
+- {
+- delete Server;
+- Server = new ServerState(Queue->Uri,this);
+- }
+- /* If the server has explicitly said this is the last connection
+- then we pre-emptively shut down the pipeline and tear down
+- the connection. This will speed up HTTP/1.0 servers a tad
+- since we don't have to wait for the close sequence to
+- complete */
+- if (Server->Persistent == false)
+- Server->Close();
+-
+- // Reset the pipeline
+- if (Server->ServerFd == -1)
+- QueueBack = Queue;
+-
+- // Connnect to the host
+- if (Server->Open() == false)
+- {
+- Fail(true);
+- delete Server;
+- Server = 0;
+- continue;
++
++ CFStringEncoding se = kCFStringEncodingUTF8;
++
++ char *url = strdup(Queue->Uri.c_str());
++ url:
++ URI uri = std::string(url);
++ std::string hs = uri.Host;
++
++ if (cached.find(hs) != cached.end()) {
++ _error->Error("Cached Failure");
++ Fail(true);
++ free(url);
++ FailCounter = 0;
++ continue;
++ }
++
++ std::string urs = uri;
++
++ for (;;) {
++ size_t bad = urs.find_first_of("+");
++ if (bad == std::string::npos)
++ break;
++ // XXX: generalize
++ urs = urs.substr(0, bad) + "%2b" + urs.substr(bad + 1);
+ }
+
+- // Fill the pipeline.
+- Fetch(0);
+-
+- // Fetch the next URL header data from the server.
+- switch (Server->RunHeaders())
+- {
+- case 0:
+- break;
+-
+- // The header data is bad
+- case 2:
+- {
+- _error->Error(_("Bad header data"));
+- Fail(true);
+- RotateDNS();
+- continue;
+- }
+-
+- // The server closed a connection during the header get..
+- default:
+- case 1:
+- {
+- FailCounter++;
+- _error->Discard();
+- Server->Close();
+- Server->Pipeline = false;
+-
+- if (FailCounter >= 2)
+- {
+- Fail(_("Connection failed"),true);
+- FailCounter = 0;
+- }
+-
+- RotateDNS();
+- continue;
+- }
+- };
++ CFStringRef sr = CFStringCreateWithCString(kCFAllocatorDefault, urs.c_str(), se);
++ CFURLRef ur = CFURLCreateWithString(kCFAllocatorDefault, sr, NULL);
++ CFRelease(sr);
++ CFHTTPMessageRef hm = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), ur, kCFHTTPVersion1_1);
++ CFRelease(ur);
++
++ struct stat SBuf;
++ if (stat(Queue->DestFile.c_str(), &SBuf) >= 0 && SBuf.st_size > 0) {
++ sr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("bytes=%li-"), (long) SBuf.st_size - 1);
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Range"), sr);
++ CFRelease(sr);
++
++ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se);
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Range"), sr);
++ CFRelease(sr);
++
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Cache-Control"), CFSTR("no-cache"));
++ } else if (Queue->LastModified != 0) {
++ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(Queue->LastModified).c_str(), se);
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Modified-Since"), sr);
++ CFRelease(sr);
++
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Cache-Control"), CFSTR("no-cache"));
++ } else
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Cache-Control"), CFSTR("max-age=0"));
++
++ if (Firmware_ != NULL)
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Firmware"), Firmware_);
++
++ sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se);
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr);
++ CFRelease(sr);
++
++ if (UniqueID_ != NULL)
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Unique-ID"), UniqueID_);
++
++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.592"));
++
++ CFReadStreamRef rs = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, hm);
++ CFRelease(hm);
++
++#define _kCFStreamPropertyReadTimeout CFSTR("_kCFStreamPropertyReadTimeout")
++#define _kCFStreamPropertyWriteTimeout CFSTR("_kCFStreamPropertyWriteTimeout")
++#define _kCFStreamPropertySocketImmediateBufferTimeOut CFSTR("_kCFStreamPropertySocketImmediateBufferTimeOut")
++
++ /*SInt32 to(TimeOut);
++ CFNumberRef nm(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &to));*/
++ double to(TimeOut);
++ CFNumberRef nm(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &to));
++
++ CFReadStreamSetProperty(rs, _kCFStreamPropertyReadTimeout, nm);
++ CFReadStreamSetProperty(rs, _kCFStreamPropertyWriteTimeout, nm);
++ CFReadStreamSetProperty(rs, _kCFStreamPropertySocketImmediateBufferTimeOut, nm);
++ CFRelease(nm);
++
++ CFDictionaryRef dr = SCDynamicStoreCopyProxies(NULL);
++ CFReadStreamSetProperty(rs, kCFStreamPropertyHTTPProxy, dr);
++ CFRelease(dr);
++
++ //CFReadStreamSetProperty(rs, kCFStreamPropertyHTTPShouldAutoredirect, kCFBooleanTrue);
++ CFReadStreamSetProperty(rs, kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue);
+
+- // Decide what to do.
+ FetchResult Res;
++ CFIndex rd;
++ UInt32 sc;
++
++ uint8_t data[10240];
++ size_t offset = 0;
++
++ Status("Connecting to %s", hs.c_str());
++
++ switch (CFReadStreamOpen(rs, to)) {
++ case -1:
++ CfrsError("Open", rs);
++ goto fail;
++
++ case 0:
++ _error->Error("Host Unreachable");
++ cached.insert(hs);
++ goto fail;
++
++ case 1:
++ /* success */
++ break;
++
++ fail:
++ Fail(true);
++ goto done;
++ }
++
++ rd = CFReadStreamRead(rs, data, sizeof(data));
++
++ if (rd == -1) {
++ CfrsError(uri.Host.c_str(), rs);
++ cached.insert(hs);
++ Fail(true);
++ goto done;
++ }
++
+ Res.Filename = Queue->DestFile;
+- switch (DealWithHeaders(Res,Server))
+- {
+- // Ok, the file is Open
+- case 0:
+- {
+- URIStart(Res);
+
+- // Run the data
+- bool Result = Server->RunData();
++ hm = (CFHTTPMessageRef) CFReadStreamCopyProperty(rs, kCFStreamPropertyHTTPResponseHeader);
++ sc = CFHTTPMessageGetResponseStatusCode(hm);
++
++ if (sc == 301 || sc == 302) {
++ sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Location"));
++ if (sr == NULL) {
++ Fail();
++ goto done_;
++ } else {
++ size_t ln = CFStringGetLength(sr) + 1;
++ free(url);
++ url = static_cast<char *>(malloc(ln));
++
++ if (!CFStringGetCString(sr, url, ln, se)) {
++ Fail();
++ goto done_;
++ }
++
++ CFRelease(sr);
++ goto url;
++ }
++ }
++
++ sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Content-Range"));
++ if (sr != NULL) {
++ size_t ln = CFStringGetLength(sr) + 1;
++ char cr[ln];
++
++ if (!CFStringGetCString(sr, cr, ln, se)) {
++ Fail();
++ goto done_;
++ }
++
++ CFRelease(sr);
++
++ if (sscanf(cr, "bytes %lu-%*u/%lu", &offset, &Res.Size) != 2) {
++ _error->Error(_("The HTTP server sent an invalid Content-Range header"));
++ Fail();
++ goto done_;
++ }
++
++ if (offset > Res.Size) {
++ _error->Error(_("This HTTP server has broken range support"));
++ Fail();
++ goto done_;
++ }
++ } else {
++ sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Content-Length"));
++ if (sr != NULL) {
++ Res.Size = CFStringGetIntValue(sr);
++ CFRelease(sr);
++ }
++ }
++
++ time(&Res.LastModified);
++
++ sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Last-Modified"));
++ if (sr != NULL) {
++ size_t ln = CFStringGetLength(sr) + 1;
++ char cr[ln];
++
++ if (!CFStringGetCString(sr, cr, ln, se)) {
++ Fail();
++ goto done_;
++ }
++
++ CFRelease(sr);
++
++ if (!StrToTime(cr, Res.LastModified)) {
++ _error->Error(_("Unknown date format"));
++ Fail();
++ goto done_;
++ }
++ }
++
++ if (sc < 200 || sc >= 300 && sc != 304) {
++ sr = CFHTTPMessageCopyResponseStatusLine(hm);
+
+- /* If the server is sending back sizeless responses then fill in
+- the size now */
++ size_t ln = CFStringGetLength(sr) + 1;
++ char cr[ln];
++
++ if (!CFStringGetCString(sr, cr, ln, se)) {
++ Fail();
++ goto done;
++ }
++
++ CFRelease(sr);
++
++ _error->Error("%s", cr);
++
++ Fail();
++ goto done_;
++ }
++
++ CFRelease(hm);
++
++ if (sc == 304) {
++ unlink(Queue->DestFile.c_str());
++ Res.IMSHit = true;
++ Res.LastModified = Queue->LastModified;
++ URIDone(Res);
++ } else {
++ Hashes hash;
++
++ File = new FileFd(Queue->DestFile, FileFd::WriteAny);
++ if (_error->PendingError() == true) {
++ delete File;
++ File = NULL;
++ Fail();
++ goto done;
++ }
++
++ FailFile = Queue->DestFile;
++ FailFile.c_str(); // Make sure we dont do a malloc in the signal handler
++ FailFd = File->Fd();
++ FailTime = Res.LastModified;
++
++ Res.ResumePoint = offset;
++ ftruncate(File->Fd(), offset);
++
++ if (offset != 0) {
++ lseek(File->Fd(), 0, SEEK_SET);
++ if (!hash.AddFD(File->Fd(), offset)) {
++ _error->Errno("read", _("Problem hashing file"));
++ delete File;
++ File = NULL;
++ Fail();
++ goto done;
++ }
++ }
++
++ lseek(File->Fd(), 0, SEEK_END);
++
++ URIStart(Res);
++
++ read: if (rd == -1) {
++ CfrsError("rd", rs);
++ Fail(true);
++ } else if (rd == 0) {
+ if (Res.Size == 0)
+ Res.Size = File->Size();
+-
+- // Close the file, destroy the FD object and timestamp it
+- FailFd = -1;
+- delete File;
+- File = 0;
+-
+- // Timestamp
++
+ struct utimbuf UBuf;
+ time(&UBuf.actime);
+- UBuf.actime = Server->Date;
+- UBuf.modtime = Server->Date;
+- utime(Queue->DestFile.c_str(),&UBuf);
++ UBuf.actime = Res.LastModified;
++ UBuf.modtime = Res.LastModified;
++ utime(Queue->DestFile.c_str(), &UBuf);
+
+- // Send status to APT
+- if (Result == true)
+- {
+- Res.TakeHashes(*Server->In.Hash);
+- URIDone(Res);
+- }
+- else
+- {
+- if (Server->ServerFd == -1)
+- {
+- FailCounter++;
+- _error->Discard();
+- Server->Close();
+-
+- if (FailCounter >= 2)
+- {
+- Fail(_("Connection failed"),true);
+- FailCounter = 0;
+- }
+-
+- QueueBack = Queue;
+- }
+- else
+- Fail(true);
+- }
+- break;
+- }
+-
+- // IMS hit
+- case 1:
+- {
++ Res.TakeHashes(hash);
+ URIDone(Res);
+- break;
+- }
+-
+- // Hard server error, not found or something
+- case 3:
+- {
+- Fail();
+- break;
+- }
+-
+- // Hard internal error, kill the connection and fail
+- case 5:
+- {
+- delete File;
+- File = 0;
++ } else {
++ hash.Add(data, rd);
+
+- Fail();
+- RotateDNS();
+- Server->Close();
+- break;
+- }
++ uint8_t *dt = data;
++ while (rd != 0) {
++ int sz = write(File->Fd(), dt, rd);
++
++ if (sz == -1) {
++ delete File;
++ File = NULL;
++ Fail();
++ goto done;
++ }
+
+- // We need to flush the data, the header is like a 404 w/ error text
+- case 4:
+- {
+- Fail();
+-
+- // Send to content to dev/null
+- File = new FileFd("/dev/null",FileFd::WriteExists);
+- Server->RunData();
+- delete File;
+- File = 0;
+- break;
+- }
+-
+- // Try again with a new URL
+- case 6:
+- {
+- // Clear rest of response if there is content
+- if (Server->HaveContent)
+- {
+- File = new FileFd("/dev/null",FileFd::WriteExists);
+- Server->RunData();
+- delete File;
+- File = 0;
++ dt += sz;
++ rd -= sz;
+ }
+
+- /* Detect redirect loops. No more redirects are allowed
+- after the same URI is seen twice in a queue item. */
+- StringVector &R = Redirected[Queue->DestFile];
+- bool StopRedirects = false;
+- if (R.size() == 0)
+- R.push_back(Queue->Uri);
+- else if (R[0] == "STOP" || R.size() > 10)
+- StopRedirects = true;
+- else
+- {
+- for (StringVectorIterator I = R.begin(); I != R.end(); I++)
+- if (Queue->Uri == *I)
+- {
+- R[0] = "STOP";
+- break;
+- }
+-
+- R.push_back(Queue->Uri);
+- }
+-
+- if (StopRedirects == false)
+- Redirect(NextURI);
+- else
+- Fail();
+-
+- break;
++ rd = CFReadStreamRead(rs, data, sizeof(data));
++ goto read;
+ }
+-
+- default:
+- Fail(_("Internal error"));
+- break;
+ }
+-
++
++ goto done;
++ done_:
++ CFRelease(hm);
++ done:
++ CFReadStreamClose(rs);
++ CFRelease(rs);
++ free(url);
++
+ FailCounter = 0;
+ }
+
+@@ -1330,6 +1530,41 @@
+ signal(SIGPIPE, SIG_IGN);
+
+ HttpMethod Mth;
++
++ size_t size;
++ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
++ char *machine = new char[size];
++ sysctlbyname("hw.machine", machine, &size, NULL, 0);
++ Machine_ = machine;
++
++ const char *path = "/System/Library/CoreServices/SystemVersion.plist";
++ CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (uint8_t *) path, strlen(path), false);
++
++ CFPropertyListRef plist; {
++ CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
++ CFReadStreamOpen(stream);
++ plist = CFPropertyListCreateFromStream(kCFAllocatorDefault, stream, 0, kCFPropertyListImmutable, NULL, NULL);
++ CFReadStreamClose(stream);
++ }
++
++ CFRelease(url);
++
++ if (plist != NULL) {
++ Firmware_ = (CFStringRef) CFRetain(CFDictionaryGetValue((CFDictionaryRef) plist, CFSTR("ProductVersion")));
++ CFRelease(plist);
++ }
++
++ if (UniqueID_ == NULL)
++ if (void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY))
++ if (CFStringRef (*$MGCopyAnswer)(CFStringRef) = (CFStringRef (*)(CFStringRef)) dlsym(libMobileGestalt, "MGCopyAnswer"))
++ UniqueID_ = $MGCopyAnswer(CFSTR("UniqueDeviceID"));
++
++ if (UniqueID_ == NULL)
++ if (void *lockdown = lockdown_connect()) {
++ UniqueID_ = (CFStringRef)lockdown_copy_value(lockdown, NULL, kLockdownUniqueDeviceIDKey);
++ lockdown_disconnect(lockdown);
++ }
++
+ return Mth.Loop();
+ }
+
+diff -ru apt-0.7.25.3/methods/makefile apt-0.7.25.3+iPhone/methods/makefile
+--- apt-0.7.25.3/methods/makefile 2010-02-01 19:44:41.000000000 +0000
++++ apt-0.7.25.3+iPhone/methods/makefile 2010-02-22 20:14:29.000000000 +0000
+@@ -46,7 +46,7 @@
+
+ # The http method
+ PROGRAM=http
+-SLIBS = -lapt-pkg $(SOCKETLIBS) $(INTLLIBS)
++SLIBS = -lapt-pkg $(SOCKETLIBS) $(INTLLIBS) -framework CoreFoundation -framework CFNetwork -framework SystemConfiguration -framework IOKit -llockdown
+ LIB_MAKES = apt-pkg/makefile
+ SOURCE = http.cc rfc2553emu.cc connect.cc
+ include $(PROGRAM_H)
diff --git a/data/_apt7/cftype.diff b/data/_apt7/cftype.diff
deleted file mode 100644
index 2c21cba39..000000000
--- a/data/_apt7/cftype.diff
+++ /dev/null
@@ -1,11 +0,0 @@
---- apt/methods/http.cc 2018-07-30 21:45:07.000000000 -1000
-+++ apt+iPhone/methods/http.cc 2018-07-30 23:55:04.000000000 -1000
-@@ -603,7 +603,7 @@
-
- if (UniqueID_ == NULL)
- if (void *lockdown = lockdown_connect()) {
-- UniqueID_ = lockdown_copy_value(lockdown, NULL, kLockdownUniqueDeviceIDKey);
-+ UniqueID_ = (CFStringRef)lockdown_copy_value(lockdown, NULL, kLockdownUniqueDeviceIDKey);
- lockdown_disconnect(lockdown);
- }
-
diff --git a/data/_apt7/date-errors.diff b/data/_apt7/date-errors.diff
deleted file mode 100644
index 53ee7dd4b..000000000
--- a/data/_apt7/date-errors.diff
+++ /dev/null
@@ -1,12 +0,0 @@
---- apt/apt-pkg/deb/debmetaindex.cc 2018-07-30 21:45:07.000000000 -1000
-+++ apt+iPhone/apt-pkg/deb/debmetaindex.cc 2018-08-02 00:03:17.000000000 -1000
-@@ -458,9 +458,6 @@
-
- if (CheckValidUntil == true)
- {
-- if (Date == 0)
-- _error->Warning( _("Invalid '%s' entry in Release file %s"), "Date", Filename.c_str());
--
- std::string const Label = Section.FindS("Label");
- std::string const StrValidUntil = Section.FindS("Valid-Until");
-
diff --git a/data/_apt7/deblistparser.diff b/data/_apt7/deblistparser.diff
new file mode 100644
index 000000000..2a0d6c9b0
--- /dev/null
+++ b/data/_apt7/deblistparser.diff
@@ -0,0 +1,27 @@
+diff -ur apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2018-12-03 12:52:15.000000000 -1000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2018-12-03 12:53:11.000000000 -1000
+@@ -248,18 +248,18 @@
+ /* Strip out any spaces from the text, this undoes dpkgs reformatting
+ of certain fields. dpkg also has the rather interesting notion of
+ reformatting depends operators < -> <= */
+- char *I = S;
++ char *L = S;
+ for (; Start != End; Start++)
+ {
+ if (isspace(*Start) == 0)
+- *I++ = tolower_ascii(*Start);
++ *L++ = tolower_ascii(*Start);
+ if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
+- *I++ = '=';
++ *L++ = '=';
+ if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
+- *I++ = '=';
++ *L++ = '=';
+ }
+
+- Result = AddCRC16(Result,S,I - S);
++ Result = AddCRC16(Result,S,L - S);
+ }
+
+ return Result;
diff --git a/data/_apt7/deprecated.diff b/data/_apt7/deprecated.diff
new file mode 100644
index 000000000..737aed6f9
--- /dev/null
+++ b/data/_apt7/deprecated.diff
@@ -0,0 +1,13 @@
+diff -ru apt-0.7.25.3/apt-pkg/contrib/macros.h apt-0.7.25.3+iPhone/apt-pkg/contrib/macros.h
+--- apt-0.7.25.3/apt-pkg/contrib/macros.h 2010-02-22 18:11:17.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/macros.h 2010-02-01 19:44:40.000000000 +0000
+@@ -57,7 +57,9 @@
+ // some nice optional GNUC features
+ #if __GNUC__ >= 3
+ #define __must_check __attribute__ ((warn_unused_result))
++#ifndef __deprecated
+ #define __deprecated __attribute__ ((deprecated))
++#endif
+ /* likely() and unlikely() can be used to mark boolean expressions
+ as (not) likely true which will help the compiler to optimise */
+ #define likely(x) __builtin_expect (!!(x), 1)
diff --git a/data/_apt7/display.diff b/data/_apt7/display.diff
new file mode 100644
index 000000000..d4686ed59
--- /dev/null
+++ b/data/_apt7/display.diff
@@ -0,0 +1,125 @@
+diff -ru apt-0.7.25.3/apt-pkg/cacheiterators.h apt-0.7.25.3+iPhone/apt-pkg/cacheiterators.h
+--- apt-0.7.25.3/apt-pkg/cacheiterators.h 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/cacheiterators.h 2010-02-23 20:59:22.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);};
+@@ -132,6 +133,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.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-23 20:59:56.000000000 +0000
+@@ -39,6 +39,18 @@
+ // ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
++unsigned long debListParser::FindTagWrite(const char *Tag)
++{
++ const char *Start;
++ const char *Stop;
++ if (Section.Find(Tag,Start,Stop) == false)
++ return 0;
++ return WriteString(Start,Stop - Start);
++}
++ /*}}}*/
++// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
++// ---------------------------------------------------------------------
++/* */
+ unsigned long debListParser::UniqFindTagWrite(const char *Tag)
+ {
+ const char *Start;
+@@ -74,6 +86,10 @@
+ /* */
+ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
+ {
++ Ver->Display = FindTagWrite("Name");
++ if (Ver->Display == 0)
++ Ver->Display = FindTagWrite("Maemo-Display-Name");
++
+ // Parse the section
+ Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
+@@ -170,6 +186,10 @@
+ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
+ pkgCache::VerIterator Ver)
+ {
++ if (Pkg->Display == 0)
++ Pkg->Display = FindTagWrite("Name");
++ if (Pkg->Display == 0)
++ Pkg->Display = FindTagWrite("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.25.3/apt-pkg/deb/deblistparser.h apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.h 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h 2010-02-23 20:59:46.000000000 +0000
+@@ -33,6 +33,7 @@
+ unsigned long iOffset;
+ string Arch;
+
++ unsigned long FindTagWrite(const char *Tag);
+ unsigned long UniqFindTagWrite(const char *Tag);
+ bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
+ bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
+diff -ru apt-0.7.25.3/apt-pkg/deb/debrecords.cc apt-0.7.25.3+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.25.3/apt-pkg/deb/debrecords.cc 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/debrecords.cc 2010-02-23 20:59: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.25.3/apt-pkg/deb/debrecords.h apt-0.7.25.3+iPhone/apt-pkg/deb/debrecords.h
+--- apt-0.7.25.3/apt-pkg/deb/debrecords.h 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/debrecords.h 2010-02-23 20:59:22.000000000 +0000
+@@ -47,6 +47,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.25.3/apt-pkg/pkgcache.h apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.25.3/apt-pkg/pkgcache.h 2010-02-23 20:58:32.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h 2010-02-23 20:59:22.000000000 +0000
+@@ -206,6 +206,7 @@
+ {
+ // Pointers
+ map_ptrloc Name; // Stringtable
++ map_ptrloc Display; // Stringtable
+ map_ptrloc VersionList; // Version
+ map_ptrloc CurrentVer; // Version
+ map_ptrloc Section; // StringTable (StringItem)
+@@ -271,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/_apt7/find.diff b/data/_apt7/find.diff
new file mode 100644
index 000000000..56eb1e2ab
--- /dev/null
+++ b/data/_apt7/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/_apt7/finddesc.diff b/data/_apt7/finddesc.diff
new file mode 100644
index 000000000..15bba37e2
--- /dev/null
+++ b/data/_apt7/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/_apt7/hashtable.diff b/data/_apt7/hashtable.diff
new file mode 100644
index 000000000..fe5c046c8
--- /dev/null
+++ b/data/_apt7/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/_apt7/iconv.diff b/data/_apt7/iconv.diff
new file mode 100644
index 000000000..d8887b1aa
--- /dev/null
+++ b/data/_apt7/iconv.diff
@@ -0,0 +1,23 @@
+diff -ru apt-0.7.20.2/apt-pkg/makefile apt-0.7.20.2+iPhone/apt-pkg/makefile
+--- apt-0.7.20.2/apt-pkg/makefile 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/makefile 2009-04-15 19:36:09.000000000 +0000
+@@ -15,7 +15,7 @@
+ LIBRARY=apt-pkg
+ MAJOR=$(LIBAPTPKG_MAJOR)
+ MINOR=$(LIBAPTPKG_RELEASE)
+-SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl
++SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl $(LIBICONV)
+ APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR)
+
+ # Source code for the contributed non-core things
+diff -ru apt-0.7.20.2/buildlib/environment.mak.in apt-0.7.20.2+iPhone/buildlib/environment.mak.in
+--- apt-0.7.20.2/buildlib/environment.mak.in 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/buildlib/environment.mak.in 2009-04-15 19:36:23.000000000 +0000
+@@ -55,6 +55,7 @@
+ PYTHONINCLUDE = @PYTHONINCLUDE@
+ BDBLIB = @BDBLIB@
+ INTLLIBS = @INTLLIBS@
++LIBICONV = @LIBICONV@
+
+ # Shim Headerfile control
+ HAVE_C9X = @HAVE_C9X@
diff --git a/data/_apt7/insensitive.diff b/data/_apt7/insensitive.diff
new file mode 100644
index 000000000..c9e4d3215
--- /dev/null
+++ b/data/_apt7/insensitive.diff
@@ -0,0 +1,12 @@
+diff -ru apt-0.7.25.3/apt-pkg/pkgcache.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc
+--- apt-0.7.25.3/apt-pkg/pkgcache.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc 2011-03-11 01:33:44.000000000 +0000
+@@ -185,7 +185,7 @@
+ Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
+ for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
+ {
+- if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
++ if (Pkg->Name != 0 &&
+ stringcasecmp(Name,StrP + Pkg->Name) == 0)
+ return PkgIterator(*this,Pkg);
+ }
diff --git a/data/_apt7/intl.diff b/data/_apt7/intl.diff
new file mode 100644
index 000000000..f2f35eb6d
--- /dev/null
+++ b/data/_apt7/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/_apt7/longdesc.diff b/data/_apt7/longdesc.diff
new file mode 100644
index 000000000..d2cd4bbbe
--- /dev/null
+++ b/data/_apt7/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/_apt7/make.sh b/data/_apt7/make.sh
index 03f8b6868..5ec612bc9 100644
--- a/data/_apt7/make.sh
+++ b/data/_apt7/make.sh
@@ -1,24 +1,9 @@
pkg:setup
-cat >iphoneos_toolchain.cmake <<EOF
-set(CMAKE_SYSTEM_NAME Darwin) # Tell CMake we're cross-compiling
-set(CMAKE_CROSSCOMPILING true)
-#include(CMakeForceCompiler)
-# Prefix detection only works with compiler id "GNU"
-# CMake will look for prefixed g++, cpp, ld, etc. automatically
-set(CMAKE_SYSTEM_PROCESSOR aarch64)
-set(triple ${PKG_TARG})
-set(CMAKE_FIND_ROOT_PATH $(echo ${PKG_PATH} | sed -e s/:/' '/g))
-set(CMAKE_LIBRARY_PATH $(echo ${LIBRARY_PATH} | sed -e s/:/' '/g))
-set(CMAKE_INCLUDE_PATH $(echo ${INCLUDE_PATH} | sed -e s/:/' '/g))
-set(CMAKE_C_COMPILER ${PKG_TARG}-gcc)
-set(CMAKE_CXX_COMPILER ${PKG_TARG}-g++)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-EOF
-
-cmake -j8 -DCMAKE_TOOLCHAIN_FILE=iphoneos_toolchain.cmake -DCMAKE_LOCALSTATEDIR="/private/var" -DCMAKE_INSTALL_NAME_DIR="/usr/lib" -DCMAKE_INSTALL_RPATH="/usr/" -DCMAKE_OSX_SYSROOT="${PKG_ROOT}" -DCMAKE_INSTALL_PREFIX="/usr/" -DCMAKE_SHARED_LINKER_FLAGS="-lresolv" -DCURRENT_VENDOR=debian -DUSE_NLS=0 -DWITH_DOC=0 -DCOMMON_ARCH=${PKG_ARCH} .
-make -j16
+rm buildlib/config.sub
+cp ${PKG_BASE}/config.sub buildlib/
+autoconf
+DPKG_DATADIR=$(ls -d $(PKG_WORK_ _dpkg)/dpkg-*/data) DPKG_ARCH=$(ls -d $(PKG_WORK_ _dpkg)/dpkg-*/scripts) pkg:configure --disable-nls
+make
pkg: mkdir -p /etc/apt/apt.conf.d
pkg: mkdir -p /etc/apt/preferences.d
@@ -29,4 +14,13 @@ pkg: mkdir -p /var/lib/apt/lists/partial
pkg: mkdir -p /var/lib/apt/periodic
pkg: mkdir -p /var/log/apt
-pkg:install
+pkg: mkdir -p /usr/bin /usr/lib/apt
+pkg: cp -a bin/apt-* /usr/bin
+pkg: cp -a bin/libapt-* /usr/lib
+pkg: cp -a bin/methods /usr/lib/apt
+
+pkg: mkdir -p /usr/lib/dpkg/methods
+pkg: cp -a scripts/dselect /usr/lib/dpkg/methods/apt
+
+pkg: mkdir -p /usr/include
+pkg: cp -a include/apt-pkg /usr/include
diff --git a/data/_apt7/map_anon.diff b/data/_apt7/map_anon.diff
new file mode 100644
index 000000000..283d36d36
--- /dev/null
+++ b/data/_apt7/map_anon.diff
@@ -0,0 +1,17 @@
+diff -ru apt-0.7.25.3/apt-pkg/contrib/mmap.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/mmap.cc
+--- apt-0.7.25.3/apt-pkg/contrib/mmap.cc 2010-02-22 18:15:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/mmap.cc 2010-02-22 18:14:42.000000000 +0000
+@@ -174,11 +174,11 @@
+ #ifdef _POSIX_MAPPED_FILES
+ // Set the permissions.
+ int Prot = PROT_READ;
+- int Map = MAP_PRIVATE | MAP_ANONYMOUS;
++ int Map = MAP_PRIVATE | MAP_ANON;
+ if ((Flags & ReadOnly) != ReadOnly)
+ Prot |= PROT_WRITE;
+ if ((Flags & Public) == Public)
+- Map = MAP_SHARED | MAP_ANONYMOUS;
++ Map = MAP_SHARED | MAP_ANON;
+
+ // use anonymous mmap() to get the memory
+ Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
diff --git a/data/_apt7/memrchr.c b/data/_apt7/memrchr.c
new file mode 100644
index 000000000..da93ca0ba
--- /dev/null
+++ b/data/_apt7/memrchr.c
@@ -0,0 +1,161 @@
+/* memrchr -- find the last occurrence of a byte in a memory block
+
+ Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2005,
+ 2006, 2007, 2008 Free Software Foundation, Inc.
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if defined _LIBC
+# include <memcopy.h>
+#else
+# include <config.h>
+# define reg_char char
+#endif
+
+#include <string.h>
+#include <limits.h>
+
+#undef __memrchr
+#ifdef _LIBC
+# undef memrchr
+#endif
+
+#ifndef weak_alias
+# define __memrchr memrchr
+#endif
+
+/* Search no more than N bytes of S for C. */
+void *
+__memrchr (void const *s, int c_in, size_t n)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned reg_char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the last few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s + n;
+ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+ --n)
+ if (*--char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will test a
+ longword at a time. The tricky part is testing if *any of the four*
+ bytes in the longword in question are equal to c. We first use an xor
+ with repeated_c. This reduces the task to testing whether *any of the
+ four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ So, the test whether any byte in longword1 is zero is equivalent to
+ testing whether tmp is nonzero. */
+
+ while (n >= sizeof (longword))
+ {
+ longword longword1 = *--longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ {
+ longword_ptr++;
+ break;
+ }
+ n -= sizeof (longword);
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that either n < sizeof (longword), or one of the
+ sizeof (longword) bytes starting at char_ptr is == c. On little-endian
+ machines, we could determine the first such byte without any further
+ memory accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines. Choose code
+ that works in both cases. */
+
+ while (n-- > 0)
+ {
+ if (*--char_ptr == c)
+ return (void *) char_ptr;
+ }
+
+ return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memrchr, memrchr)
+#endif
diff --git a/data/_apt7/memrchr.diff b/data/_apt7/memrchr.diff
new file mode 100644
index 000000000..8913e1816
--- /dev/null
+++ b/data/_apt7/memrchr.diff
@@ -0,0 +1,195 @@
+diff -ru apt-0.7.20.2/ftparchive/cachedb.cc apt-0.7.20.2+iPhone/ftparchive/cachedb.cc
+--- apt-0.7.20.2/ftparchive/cachedb.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/ftparchive/cachedb.cc 2009-04-14 16:10:02.000000000 +0000
+@@ -315,6 +315,14 @@
+ }
+ }
+
++void *memrchr(void *data, char value, int size) {
++ char *cdata = (char *) data;
++ for (int i = 0; i != size; ++i)
++ if (cdata[size - i - 1] == value)
++ return cdata + size - i - 1;
++ return NULL;
++}
++
+ // CacheDB::GetMD5 - Get the MD5 hash /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
+diff -ru apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc
+--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc 2009-04-15 19:25:04.000000000 +0000
+@@ -501,6 +501,7 @@
+
+ // now move the unprocessed bits (after the final \n that is now a 0x0)
+ // to the start and update dpkgbuf_pos
++ void *memrchr(void const *, int, size_t);
+ p = (char*)memrchr(dpkgbuf, 0, dpkgbuf_pos);
+ if(p == NULL)
+ return;
+@@ -974,3 +975,165 @@
+ List.erase(List.begin(),List.end());
+ }
+ /*}}}*/
++
++/* memrchr -- find the last occurrence of a byte in a memory block
++
++ Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2005,
++ 2006, 2007, 2008 Free Software Foundation, Inc.
++
++ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
++ with help from Dan Sahlin (dan@sics.se) and
++ commentary by Jim Blandy (jimb@ai.mit.edu);
++ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
++ and implemented by Roland McGrath (roland@ai.mit.edu).
++
++ This program is free software: you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#if defined _LIBC
++# include <memcopy.h>
++#else
++# include <config.h>
++# define reg_char char
++#endif
++
++#include <string.h>
++#include <limits.h>
++
++#undef __memrchr
++#ifdef _LIBC
++# undef memrchr
++#endif
++
++#ifndef weak_alias
++# define __memrchr memrchr
++#endif
++
++/* Search no more than N bytes of S for C. */
++void *
++__memrchr (void const *s, int c_in, size_t n)
++{
++ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
++ long instead of a 64-bit uintmax_t tends to give better
++ performance. On 64-bit hardware, unsigned long is generally 64
++ bits already. Change this typedef to experiment with
++ performance. */
++ typedef unsigned long int longword;
++
++ const unsigned char *char_ptr;
++ const longword *longword_ptr;
++ longword repeated_one;
++ longword repeated_c;
++ unsigned reg_char c;
++
++ c = (unsigned char) c_in;
++
++ /* Handle the last few bytes by reading one byte at a time.
++ Do this until CHAR_PTR is aligned on a longword boundary. */
++ for (char_ptr = (const unsigned char *) s + n;
++ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
++ --n)
++ if (*--char_ptr == c)
++ return (void *) char_ptr;
++
++ longword_ptr = (const longword *) char_ptr;
++
++ /* All these elucidatory comments refer to 4-byte longwords,
++ but the theory applies equally well to any size longwords. */
++
++ /* Compute auxiliary longword values:
++ repeated_one is a value which has a 1 in every byte.
++ repeated_c has c in every byte. */
++ repeated_one = 0x01010101;
++ repeated_c = c | (c << 8);
++ repeated_c |= repeated_c << 16;
++ if (0xffffffffU < (longword) -1)
++ {
++ repeated_one |= repeated_one << 31 << 1;
++ repeated_c |= repeated_c << 31 << 1;
++ if (8 < sizeof (longword))
++ {
++ size_t i;
++
++ for (i = 64; i < sizeof (longword) * 8; i *= 2)
++ {
++ repeated_one |= repeated_one << i;
++ repeated_c |= repeated_c << i;
++ }
++ }
++ }
++
++ /* Instead of the traditional loop which tests each byte, we will test a
++ longword at a time. The tricky part is testing if *any of the four*
++ bytes in the longword in question are equal to c. We first use an xor
++ with repeated_c. This reduces the task to testing whether *any of the
++ four* bytes in longword1 is zero.
++
++ We compute tmp =
++ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
++ That is, we perform the following operations:
++ 1. Subtract repeated_one.
++ 2. & ~longword1.
++ 3. & a mask consisting of 0x80 in every byte.
++ Consider what happens in each byte:
++ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
++ and step 3 transforms it into 0x80. A carry can also be propagated
++ to more significant bytes.
++ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
++ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
++ the byte ends in a single bit of value 0 and k bits of value 1.
++ After step 2, the result is just k bits of value 1: 2^k - 1. After
++ step 3, the result is 0. And no carry is produced.
++ So, if longword1 has only non-zero bytes, tmp is zero.
++ Whereas if longword1 has a zero byte, call j the position of the least
++ significant zero byte. Then the result has a zero at positions 0, ...,
++ j-1 and a 0x80 at position j. We cannot predict the result at the more
++ significant bytes (positions j+1..3), but it does not matter since we
++ already have a non-zero bit at position 8*j+7.
++
++ So, the test whether any byte in longword1 is zero is equivalent to
++ testing whether tmp is nonzero. */
++
++ while (n >= sizeof (longword))
++ {
++ longword longword1 = *--longword_ptr ^ repeated_c;
++
++ if ((((longword1 - repeated_one) & ~longword1)
++ & (repeated_one << 7)) != 0)
++ {
++ longword_ptr++;
++ break;
++ }
++ n -= sizeof (longword);
++ }
++
++ char_ptr = (const unsigned char *) longword_ptr;
++
++ /* At this point, we know that either n < sizeof (longword), or one of the
++ sizeof (longword) bytes starting at char_ptr is == c. On little-endian
++ machines, we could determine the first such byte without any further
++ memory accesses, just by looking at the tmp result from the last loop
++ iteration. But this does not work on big-endian machines. Choose code
++ that works in both cases. */
++
++ while (n-- > 0)
++ {
++ if (*--char_ptr == c)
++ return (void *) char_ptr;
++ }
++
++ return NULL;
++}
++#ifdef weak_alias
++weak_alias (__memrchr, memrchr)
++#endif
diff --git a/data/_apt7/mmap.diff b/data/_apt7/mmap.diff
new file mode 100644
index 000000000..1b745e8b5
--- /dev/null
+++ b/data/_apt7/mmap.diff
@@ -0,0 +1,199 @@
+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,12 @@
+ // ---------------------------------------------------------------------
+ /* */
+ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
+- Fd(*pFd),
+- Size(Size)
++ Fd(*pFd)
+ {
+- if (Fd.IsOpen() == false)
++ if (Fd.IsOpen() == false || Fd.Size() == 0)
+ {
++ _error->Discard();
++ 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;
+ TrimRecord(false,End);
+ 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/_apt7/parallel.diff b/data/_apt7/parallel.diff
new file mode 100644
index 000000000..40d28fb3d
--- /dev/null
+++ b/data/_apt7/parallel.diff
@@ -0,0 +1,33 @@
+diff -ru apt-0.6.46.4.1/apt-pkg/acquire.cc apt-0.6.46.4.1+iPhone/apt-pkg/acquire.cc
+--- apt-0.6.46.4.1/apt-pkg/acquire.cc 2006-12-04 14:37:34.000000000 +0000
++++ apt-0.6.46.4.1+iPhone/apt-pkg/acquire.cc 2009-01-21 10:47:16.000000000 +0000
+@@ -238,9 +238,27 @@
+ /* Single-Instance methods get exactly one queue per URI. This is
+ also used for the Access queue method */
+ if (Config->SingleInstance == true || QueueMode == QueueAccess)
+- return U.Access;
++ return U.Access;
++ string name(U.Access + ':' + U.Host);
+
+- return U.Access + ':' + U.Host;
++ int parallel(_config->FindI("Acquire::"+U.Access+"::MaxParallel",8));
++ if (parallel <= 0)
++ return name;
++
++ typedef map<string, int> indexmap;
++ static indexmap indices;
++
++ pair<indexmap::iterator, bool> cache(indices.insert(indexmap::value_type(name, -1)));
++ if (cache.second || cache.first->second == -1) {
++ int &index(indices[U.Access]);
++ if (index >= parallel)
++ index = 0;
++ cache.first->second = index++;
++ }
++
++ ostringstream value;
++ value << U.Access << "::" << cache.first->second;
++ return value.str();
+ }
+ /*}}}*/
+ // Acquire::GetConfig - Fetch the configuration information /*{{{*/
diff --git a/data/_apt7/port.diff b/data/_apt7/port.diff
new file mode 100644
index 000000000..f2190eca7
--- /dev/null
+++ b/data/_apt7/port.diff
@@ -0,0 +1,216 @@
+diff -ru apt-0.7.20.2/apt-inst/deb/dpkgdb.cc apt-0.7.20.2+iPhone/apt-inst/deb/dpkgdb.cc
+--- apt-0.7.20.2/apt-inst/deb/dpkgdb.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-inst/deb/dpkgdb.cc 2009-04-14 16:10:02.000000000 +0000
+@@ -22,6 +22,7 @@
+
+ #include <stdio.h>
+ #include <errno.h>
++#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/mman.h>
+ #include <fcntl.h>
+diff -ru apt-0.7.25.3/buildlib/libversion.mak apt-0.7.25.3+iPhone/buildlib/libversion.mak
+--- apt-0.7.25.3/buildlib/libversion.mak 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/buildlib/libversion.mak 2010-02-22 18:03:29.000000000 +0000
+@@ -18,4 +18,4 @@
+ # want to drop this, but this a ABI break.
+ # And we don't want to do this now. So we hardcode a value here,
+ # and drop it later on (hopefully as fast as possible).
+-LIBEXT=-libc6.9-6
++LIBEXT=
+diff -ru apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc
+--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc 2009-04-14 16:10:02.000000000 +0000
+@@ -766,6 +766,8 @@
+ clog << flush;
+ cerr << flush;
+
++ typedef void (*sighandler_t)(int);
++
+ /* Mask off sig int/quit. We do this because dpkg also does when
+ it forks scripts. What happens is that when you hit ctrl-c it sends
+ it to all processes in the group. Since dpkg ignores the signal
+diff -ru apt-0.7.20.2/buildlib/environment.mak.in apt-0.7.20.2+iPhone/buildlib/environment.mak.in
+--- apt-0.7.20.2/buildlib/environment.mak.in 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/buildlib/environment.mak.in 2009-04-14 16:11:50.000000000 +0000
+@@ -67,8 +67,14 @@
+ ifneq ($(words $(filter gnu% linux-gnu% kfreebsd-gnu% %-gnu,$(HOST_OS))),0)
+ SONAME_MAGIC=-Wl,-soname -Wl,
+ LFLAGS_SO=
++ SOEXT=so
++else
++ifneq ($(words $(filter darwin%,$(HOST_OS))),0)
++ SONAME_MAGIC=-Wl,-dylib_install_name,
++ LFLAGS_SO=
++ SOEXT=dylib
+ else
+ # Do not know how to create shared libraries here.
+ ONLYSTATICLIBS = yes
+ endif
+-
++endif
+diff -ru apt-0.7.20.2/buildlib/library.mak apt-0.7.20.2+iPhone/buildlib/library.mak
+--- apt-0.7.20.2/buildlib/library.mak 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/buildlib/library.mak 2009-04-14 16:14:05.000000000 +0000
+@@ -16,11 +16,11 @@
+ # See defaults.mak for information about LOCAL
+
+ # Some local definitions
+-LOCAL := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
++LOCAL := lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
+ $(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
+ $(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
+ $(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
+-$(LOCAL)-SONAME := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
++$(LOCAL)-SONAME := lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR)
+ $(LOCAL)-SLIBS := $(SLIBS)
+ $(LOCAL)-LIBRARY := $(LIBRARY)
+
+@@ -29,7 +29,7 @@
+
+ # Install the command hooks
+ headers: $($(LOCAL)-HEADERS)
+-library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
++library: $(LIB)/lib$(LIBRARY).$(SOEXT) $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR)
+ clean: clean/$(LOCAL)
+ veryclean: veryclean/$(LOCAL)
+
+@@ -41,21 +41,21 @@
+ clean/$(LOCAL):
+ -rm -f $($(@F)-OBJS) $($(@F)-DEP)
+ veryclean/$(LOCAL): clean/$(LOCAL)
+- -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
++ -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.$(SOEXT)*
+
+ # Build rules for the two symlinks
+-.PHONY: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
+-$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR): $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
++.PHONY: $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR) $(LIB)/lib$(LIBRARY).$(SOEXT)
++$(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR): $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
+ ln -sf $(<F) $@
+-$(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
++$(LIB)/lib$(LIBRARY).$(SOEXT): $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
+ ln -sf $(<F) $@
+
+ # The binary build rule
+-$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
+- -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
++$(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
++ -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.$(SOEXT)* 2> /dev/null
+ echo Building shared library $@
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
+- -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
++ -o $@ $(SONAME_MAGIC)$(patsubst $(LIB)/%,/usr/lib/%,$@) -dynamiclib \
+ $(filter %.opic,$^) \
+ $($(@F)-SLIBS)
+
+diff -ru apt-0.7.20.2/buildlib/podomain.mak apt-0.7.20.2+iPhone/buildlib/podomain.mak
+--- apt-0.7.20.2/buildlib/podomain.mak 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/buildlib/podomain.mak 2009-04-14 16:10:02.000000000 +0000
+@@ -14,7 +14,8 @@
+ $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list: SRC := $(addprefix $(SUBDIR)/,$(SOURCE))
+ $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list: makefile
+ (echo $(SRC) | xargs -n1 echo) > $@
+-binary program clean: $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
++binary program clean:
++#$(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
+
+ veryclean: veryclean/$(LOCAL)
+ veryclean/po/$(LOCAL): LIST := $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
+diff -ru apt-0.7.20.2/buildlib/program.mak apt-0.7.20.2+iPhone/buildlib/program.mak
+--- apt-0.7.20.2/buildlib/program.mak 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/buildlib/program.mak 2009-04-14 16:10:02.000000000 +0000
+@@ -44,6 +44,7 @@
+ # The binary build rule
+ $($(LOCAL)-BIN): $($(LOCAL)-OBJS) $($(LOCAL)-MKS)
+ echo Building program $@
++ echo $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
+
+ # Compilation rules
+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
+@@ -53,7 +53,8 @@
+ #include <termios.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
+-#include <sys/statfs.h>
++#include <sys/param.h>
++#include <sys/mount.h>
+ #include <sys/statvfs.h>
+ #include <signal.h>
+ #include <unistd.h>
+@@ -66,12 +66,13 @@
+
+ #define RAMFS_MAGIC 0x858458f6
+
++#define _trace() printf("_trace(%s:%d)\n", __FILE__, __LINE__)
++
+ using namespace std;
+
+ ostream c0out(0);
+ ostream c1out(0);
+ ostream c2out(0);
+-ofstream devnull("/dev/null");
+ unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
+
+ // class CacheFile - Cover class for some dependency cache functions /*{{{*/
+@@ -2786,6 +2787,9 @@
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
+ _config->Set("quiet","1");
+
++ ofstream devnull;
++ devnull.open("/dev/null");
++
+ // Setup the output streams
+ c0out.rdbuf(cout.rdbuf());
+ c1out.rdbuf(cout.rdbuf());
+diff -ru apt-0.7.20.2/ftparchive/contents.cc apt-0.7.20.2+iPhone/ftparchive/contents.cc
+--- apt-0.7.20.2/ftparchive/contents.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/ftparchive/contents.cc 2009-04-14 16:10:02.000000000 +0000
+@@ -41,7 +41,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <malloc.h>
++#include <memory.h>
+ /*}}}*/
+
+ // GenContents::~GenContents - Free allocated memory /*{{{*/
+diff -ru apt-0.7.20.2/Makefile apt-0.7.20.2+iPhone/Makefile
+--- apt-0.7.20.2/Makefile 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/Makefile 2009-04-14 16:10:02.000000000 +0000
+@@ -18,7 +18,5 @@
+ $(MAKE) -C ftparchive $@
+ $(MAKE) -C dselect $@
+- $(MAKE) -C doc $@
+- $(MAKE) -C po $@
+
+ # Some very common aliases
+ .PHONY: maintainer-clean dist-clean distclean pristine sanity
+diff -ru apt-0.7.20.2/configure.in apt-0.7.20.2+iPhone/configure.in
+--- apt-0.7.20.2/configure.in 2009-02-07 15:10:44.000000000 +0000
++++ apt-0.7.20.2+iPhone/configure.in 2009-04-15 18:58:36.000000000 +0000
+@@ -88,7 +88,7 @@
+ dnl First check against the full canonical canoncial-system-type in $target
+ dnl and if that fails, just look for the cpu
+ AC_MSG_CHECKING(debian architecture)
+-archset="`dpkg-architecture -qDEB_HOST_ARCH`"
++archset="`cd "$DPKG_ARCH"; PERL5LIB=$(pwd) ./dpkg-architecture -qDEB_HOST_ARCH -t$host`"
+ if test "x$archset" = "x"; then
+ AC_MSG_ERROR([failed: use --host= or output from dpkg-architecture])
+ fi
+diff -ru apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc
+--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc 2009-04-15 19:25:41.000000000 +0000
+@@ -33,7 +33,8 @@
+ #include <termios.h>
+ #include <unistd.h>
+ #include <sys/ioctl.h>
+-#include <pty.h>
++#include <sys/stat.h>
++#include <util.h>
+
+ #include <config.h>
+ #include <apti18n.h>
diff --git a/data/_apt7/printf.diff b/data/_apt7/printf.diff
new file mode 100644
index 000000000..847758bf2
--- /dev/null
+++ b/data/_apt7/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/_apt7/public.diff b/data/_apt7/public.diff
new file mode 100644
index 000000000..04e5051f8
--- /dev/null
+++ b/data/_apt7/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/_apt7/reinstreq.diff b/data/_apt7/reinstreq.diff
new file mode 100644
index 000000000..7f34536e6
--- /dev/null
+++ b/data/_apt7/reinstreq.diff
@@ -0,0 +1,21 @@
+diff -ru apt-0.6.46.4.1/apt-pkg/deb/dpkgpm.cc apt-0.6.46.4.1+iPhone/apt-pkg/deb/dpkgpm.cc
+--- apt-0.6.46.4.1/apt-pkg/deb/dpkgpm.cc 2006-12-04 16:33:53.000000000 +0000
++++ apt-0.6.46.4.1+iPhone/apt-pkg/deb/dpkgpm.cc 2008-06-22 09:41:01.000000000 +0000
+@@ -451,6 +451,8 @@
+ case Item::Remove:
+ Args[n++] = "--force-depends";
+ Size += strlen(Args[n-1]);
++ Args[n++] = "--force-remove-reinstreq";
++ Size += strlen(Args[n-1]);
+ Args[n++] = "--force-remove-essential";
+ Size += strlen(Args[n-1]);
+ Args[n++] = "--remove";
+@@ -460,6 +462,8 @@
+ case Item::Purge:
+ Args[n++] = "--force-depends";
+ Size += strlen(Args[n-1]);
++ Args[n++] = "--force-remove-reinstreq";
++ Size += strlen(Args[n-1]);
+ Args[n++] = "--force-remove-essential";
+ Size += strlen(Args[n-1]);
+ Args[n++] = "--purge";
diff --git a/data/_apt7/sandbox-errors.diff b/data/_apt7/sandbox-errors.diff
deleted file mode 100644
index 706aeb23c..000000000
--- a/data/_apt7/sandbox-errors.diff
+++ /dev/null
@@ -1,10 +0,0 @@
---- apt/apt-pkg/acquire.cc 2018-07-30 21:45:07.000000000 -1000
-+++ apt+iPhone/apt-pkg/acquire.cc 2018-08-02 00:04:25.000000000 -1000
-@@ -603,7 +603,6 @@
- struct passwd const * const pw = getpwnam(SandboxUser.c_str());
- if (pw == NULL)
- {
-- _error->Warning(_("No sandbox user '%s' on the system, can not drop privileges"), SandboxUser.c_str());
- _config->Set("APT::Sandbox::User", "");
- return;
- }
diff --git a/data/_apt7/sha1.diff b/data/_apt7/sha1.diff
deleted file mode 100644
index e681382ca..000000000
--- a/data/_apt7/sha1.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ur apt/methods/gpgv.cc apt+iPhone/methods/gpgv.cc
---- apt/methods/gpgv.cc 2018-07-30 21:45:07.000000000 -1000
-+++ apt+iPhone/methods/gpgv.cc 2018-08-03 20:59:27.000000000 -1000
-@@ -67,7 +67,7 @@
- static constexpr Digest Digests[] = {
- {Digest::State::Untrusted, "Invalid digest"},
- {Digest::State::Untrusted, "MD5"},
-- {Digest::State::Untrusted, "SHA1"},
-+ {Digest::State::Trusted, "SHA1"},
- {Digest::State::Untrusted, "RIPE-MD/160"},
- {Digest::State::Trusted, "Reserved digest"},
- {Digest::State::Trusted, "Reserved digest"},
diff --git a/data/_apt7/strdupa.diff b/data/_apt7/strdupa.diff
new file mode 100644
index 000000000..03a179e01
--- /dev/null
+++ b/data/_apt7/strdupa.diff
@@ -0,0 +1,80 @@
+diff -ru apt-0.7.25.3/apt-pkg/contrib/netrc.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.cc
+--- apt-0.7.25.3/apt-pkg/contrib/netrc.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.cc 2010-02-22 18:26:01.000000000 +0000
+@@ -40,13 +40,13 @@
+ #define NETRC DOT_CHAR "netrc"
+
+ /* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
+-int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
++int parsenetrc (const char *host, char *login, char *password, const char *netrcfile = NULL)
+ {
+ FILE *file;
+ int retcode = 1;
+ int specific_login = (login[0] != 0);
+ char *home = NULL;
+- bool netrc_alloc = false;
++ char *netrc_alloc = NULL;
+ int state = NOTHING;
+
+ char state_login = 0; /* Found a login keyword */
+@@ -67,11 +67,11 @@
+ if (!home)
+ return -1;
+
+- asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC);
+- if(!netrcfile)
++ asprintf (&netrc_alloc, "%s%s%s", home, DIR_CHAR, NETRC);
++ if(!netrc_alloc)
+ return -1;
+ else
+- netrc_alloc = true;
++ netrcfile = netrc_alloc;
+ }
+
+ file = fopen (netrcfile, "r");
+@@ -144,7 +144,7 @@
+ }
+
+ if (netrc_alloc)
+- free(netrcfile);
++ free(netrc_alloc);
+
+ return retcode;
+ }
+@@ -160,11 +160,11 @@
+ {
+ char login[64] = "";
+ char password[64] = "";
+- char *netrcfile = strdupa (NetRCFile.c_str ());
++ const char *netrcfile = NetRCFile.c_str ();
+
+ // first check for a generic host based netrc entry
+- char *host = strdupa (Uri.Host.c_str ());
+- if (host && parsenetrc (host, login, password, netrcfile) == 0)
++ const char *host = Uri.Host.c_str ();
++ if (parsenetrc (host, login, password, netrcfile) == 0)
+ {
+ if (_config->FindB("Debug::Acquire::netrc", false) == true)
+ std::clog << "host: " << host
+@@ -179,7 +179,8 @@
+ // if host did not work, try Host+Path next, this will trigger
+ // a lookup uri.startswith(host) in the netrc file parser (because
+ // of the "/"
+- char *hostpath = strdupa (string(Uri.Host+Uri.Path).c_str ());
++ std::string temp(Uri.Host+Uri.Path);
++ const char *hostpath = temp.c_str ();
+ if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
+ {
+ if (_config->FindB("Debug::Acquire::netrc", false) == true)
+diff -ru apt-0.7.25.3/apt-pkg/contrib/netrc.h apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.h
+--- apt-0.7.25.3/apt-pkg/contrib/netrc.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.h 2010-02-22 18:23:20.000000000 +0000
+@@ -23,7 +23,7 @@
+ // If login[0] = 0, search for login and password within a machine section
+ // in the netrc.
+ // If login[0] != 0, search for password within machine and login.
+-int parsenetrc (char *host, char *login, char *password, char *filename);
++int parsenetrc (const char *host, char *login, char *password, const char *filename);
+
+ void maybe_add_auth (URI &Uri, string NetRCFile);
+ #endif
diff --git a/data/_apt7/tag.diff b/data/_apt7/tag.diff
new file mode 100644
index 000000000..78ce39645
--- /dev/null
+++ b/data/_apt7/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/_apt7/_metadata/in.1443.00 b/data/_apt7/timestamp.diff
index e69de29bb..e69de29bb 100644
--- a/data/_apt7/_metadata/in.1443.00
+++ b/data/_apt7/timestamp.diff
diff --git a/data/_apt7/tolerance.diff b/data/_apt7/tolerance.diff
new file mode 100644
index 000000000..ce2ff0adb
--- /dev/null
+++ b/data/_apt7/tolerance.diff
@@ -0,0 +1,24 @@
+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 2010-02-22 08:57:37.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-22 09:40:28.000000000 +0000
+@@ -643,11 +643,18 @@
+ iOffset = Tags.Offset();
+ while (Tags.Step(Section) == true)
+ {
++ const char *Start;
++ const char *Stop;
++
++ if (Section.Find("Package",Start,Stop) == false) {
++ _error->Warning("Encountered a section with no Package: header");
++ continue;
++ }
++
+ /* See if this is the correct Architecture, if it isn't then we
+ drop the whole section. A missing arch tag only happens (in theory)
+ inside the Status file, so that is a positive return */
+- const char *Start;
+- const char *Stop;
++
+ if (Section.Find("Architecture",Start,Stop) == false)
+ return true;
+
diff --git a/data/_apt7/tornado.diff b/data/_apt7/tornado.diff
new file mode 100644
index 000000000..e276f3356
--- /dev/null
+++ b/data/_apt7/tornado.diff
@@ -0,0 +1,719 @@
+diff -Nru apt-0.7.25.3/apt-pkg/contrib/md5.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.cc
+--- apt-0.7.25.3/apt-pkg/contrib/md5.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.cc 2010-02-24 08:11:38.000000000 +0000
+@@ -173,6 +173,12 @@
+ memset(Sum,0,sizeof(Sum));
+ Set(Str);
+ }
++
++MD5SumValue::MD5SumValue(const srkString &Str)
++{
++ memset(Sum, 0, sizeof(Sum));
++ Set(Str);
++}
+ /*}}}*/
+ // MD5SumValue::MD5SumValue - Default constructor /*{{{*/
+ // ---------------------------------------------------------------------
+@@ -189,6 +195,11 @@
+ {
+ return Hex2Num(Str,Sum,sizeof(Sum));
+ }
++
++bool MD5SumValue::Set(const srkString &Str)
++{
++ return Hex2Num(Str,Sum,sizeof(Sum));
++}
+ /*}}}*/
+ // MD5SumValue::Value - Convert the number into a string /*{{{*/
+ // ---------------------------------------------------------------------
+diff -Nru apt-0.7.25.3/apt-pkg/contrib/md5.h apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.h
+--- apt-0.7.25.3/apt-pkg/contrib/md5.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.h 2010-02-24 08:09:10.000000000 +0000
+@@ -29,6 +29,8 @@
+ #include <algorithm>
+ #include <stdint.h>
+
++#include <apt-pkg/srkstring.h>
++
+ using std::string;
+ using std::min;
+
+@@ -48,10 +50,12 @@
+ {for (int I = 0; I != sizeof(Sum); I++) S[I] = Sum[I];};
+ inline operator string() const {return Value();};
+ bool Set(string Str);
++ bool Set(const srkString &Str);
+ inline void Set(unsigned char S[16])
+ {for (int I = 0; I != sizeof(Sum); I++) Sum[I] = S[I];};
+
+ MD5SumValue(string Str);
++ MD5SumValue(const srkString &Str);
+ MD5SumValue();
+ };
+
+diff -Nru apt-0.7.25.3/apt-pkg/contrib/strutl.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.cc
+--- apt-0.7.25.3/apt-pkg/contrib/strutl.cc 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.cc 2010-02-24 08:13:39.000000000 +0000
+@@ -943,12 +943,17 @@
+ /* The length of the buffer must be exactly 1/2 the length of the string. */
+ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length)
+ {
++ return Hex2Num(srkString(Str), Num, Length);
++}
++
++bool Hex2Num(const srkString &Str,unsigned char *Num,unsigned int Length)
++{
+ if (Str.length() != Length*2)
+ return false;
+
+ // Convert each digit. We store it in the same order as the string
+ int J = 0;
+- for (string::const_iterator I = Str.begin(); I != Str.end();J++, I += 2)
++ for (srkString::const_iterator I = Str.begin(); I != Str.end();J++, I += 2)
+ {
+ if (isxdigit(*I) == 0 || isxdigit(I[1]) == 0)
+ return false;
+diff -Nru apt-0.7.25.3/apt-pkg/contrib/strutl.h apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.h
+--- apt-0.7.25.3/apt-pkg/contrib/strutl.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.h 2010-02-24 08:10:45.000000000 +0000
+@@ -25,6 +25,8 @@
+ #include <iostream>
+ #include <time.h>
+
++#include <apt-pkg/srkstring.h>
++
+ using std::string;
+ using std::vector;
+ using std::ostream;
+@@ -57,6 +59,7 @@
+ bool ReadMessages(int Fd, vector<string> &List);
+ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
+ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
++bool Hex2Num(const srkString &Str,unsigned char *Num,unsigned int Length);
+ bool TokSplitString(char Tok,char *Input,char **List,
+ unsigned long ListMax);
+ void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
+@@ -66,6 +69,7 @@
+ int tolower_ascii(int c);
+
+ #define APT_MKSTRCMP(name,func) \
++inline int name(const srkString &A,const char *B) {return func(A.Start,A.Start+A.Size,B,B+strlen(B));}; \
+ inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \
+ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
+ inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \
+@@ -77,6 +77,7 @@
+ inline int name(const string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);};
+
+ #define APT_MKSTRCMP2(name,func) \
++inline int name(const srkString &A,const char *B) {return func(A.Start,A.Start+A.Size,B,B+strlen(B));}; \
+ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
+ inline int name(const string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \
+ inline int name(const string& A,const string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \
+diff -Nru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-24 08:51:50.000000000 +0000
+@@ -106,7 +106,7 @@
+ const char *Stop;
+ if (Section.Find("Priority",Start,Stop) == true)
+ {
+- if (GrabWord(string(Start,Stop-Start),PrioList,Ver->Priority) == false)
++ if (GrabWord(srkString(Start,Stop-Start),PrioList,Ver->Priority) == false)
+ Ver->Priority = pkgCache::State::Extra;
+ }
+
+@@ -144,10 +144,19 @@
+ only describe package properties */
+ string debListParser::Description()
+ {
+- if (DescriptionLanguage().empty())
+- return Section.FindS("Description");
+- else
+- return Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str());
++ srkString description;
++ Description(description);
++ return description;
++}
++
++void debListParser::Description(srkString &Str) {
++ const char *Start, *Stop;
++ if (!Section.Find("Description", Start, Stop))
++ if (!Section.Find(("Description-" + pkgIndexFile::LanguageCode()).c_str(), Start, Stop)) {
++ Start = NULL;
++ Stop = NULL;
++ }
++ Str.assign(Start, Stop);
+ }
+ /*}}}*/
+ // ListParser::DescriptionLanguage - Return the description lang string /*{{{*/
+@@ -157,7 +166,8 @@
+ assumed to describe original description. */
+ string debListParser::DescriptionLanguage()
+ {
+- return Section.FindS("Description").empty() ? pkgIndexFile::LanguageCode() : "";
++ const char *Start, *Stop;
++ return Section.Find("Description", Start, Stop) ? std::string() : pkgIndexFile::LanguageCode();
+ }
+ /*}}}*/
+ // ListParser::Description - Return the description_md5 MD5SumValue /*{{{*/
+@@ -168,15 +178,18 @@
+ */
+ MD5SumValue debListParser::Description_md5()
+ {
+- string value = Section.FindS("Description-md5");
+-
+- if (value.empty())
++ const char *Start;
++ const char *Stop;
++ if (!Section.Find("Description-md5", Start, Stop))
+ {
+ MD5Summation md5;
+- md5.Add((Description() + "\n").c_str());
++ srkString description;
++ Description(description);
++ md5.Add((const unsigned char *) description.Start, description.Size);
++ md5.Add("\n");
+ return md5.Result();
+ } else
+- return MD5SumValue(value);
++ return MD5SumValue(srkString(Start, Stop));
+ }
+ /*}}}*/
+ // ListParser::UsePackage - Update a package structure /*{{{*/
+@@ -286,7 +299,7 @@
+ {"deinstall",pkgCache::State::DeInstall},
+ {"purge",pkgCache::State::Purge},
+ {}};
+- if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
++ if (GrabWord(srkString(Start,I-Start),WantList,Pkg->SelectedState) == false)
+ return _error->Error("Malformed 1st word in the Status line");
+
+ // Isloate the next word
+@@ -302,7 +315,7 @@
+ {"hold",pkgCache::State::HoldInst},
+ {"hold-reinstreq",pkgCache::State::HoldReInstReq},
+ {}};
+- if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
++ if (GrabWord(srkString(Start,I-Start),FlagList,Pkg->InstState) == false)
+ return _error->Error("Malformed 2nd word in the Status line");
+
+ // Isloate the last word
+@@ -324,7 +337,7 @@
+ {"post-inst-failed",pkgCache::State::HalfConfigured},
+ {"removal-failed",pkgCache::State::HalfInstalled},
+ {}};
+- if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
++ if (GrabWord(srkString(Start,I-Start),StatusList,Pkg->CurrentState) == false)
+ return _error->Error("Malformed 3rd word in the Status line");
+
+ /* A Status line marks the package as indicating the current
+@@ -410,6 +423,17 @@
+ string &Package,string &Ver,
+ unsigned int &Op, bool ParseArchFlags)
+ {
++ srkString cPackage, cVer;
++ const char *Value = ParseDepends(Start, Stop, cPackage, cVer, Op, ParseArchFlags);
++ Package = cPackage;
++ Ver = cVer;
++ return Value;
++}
++
++const char *debListParser::ParseDepends(const char *Start,const char *Stop,
++ srkString &Package,srkString &Ver,
++ unsigned int &Op, bool ParseArchFlags)
++{
+ // Strip off leading space
+ for (;Start != Stop && isspace(*Start) != 0; Start++);
+
+@@ -509,7 +533,7 @@
+ Found = !Found;
+
+ if (Found == false)
+- Package = ""; /* not for this arch */
++ Package.clear(); /* not for this arch */
+ }
+
+ // Skip whitespace
+@@ -541,8 +565,8 @@
+ if (Section.Find(Tag,Start,Stop) == false)
+ return true;
+
+- string Package;
+- string Version;
++ srkString Package;
++ srkString Version;
+ unsigned int Op;
+
+ while (1)
+@@ -569,8 +593,8 @@
+ if (Section.Find("Provides",Start,Stop) == false)
+ return true;
+
+- string Package;
+- string Version;
++ srkString Package;
++ srkString Version;
+ unsigned int Op;
+
+ while (1)
+@@ -579,7 +603,7 @@
+ if (Start == 0)
+ return _error->Error("Problem parsing Provides line");
+ if (Op != pkgCache::Dep::NoOp) {
+- _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
++ _error->Warning("Ignoring Provides line with DepCompareOp for package %s", std::string(Package).c_str());
+ } else {
+ if (NewProvides(Ver,Package,Version) == false)
+ return false;
+@@ -637,9 +661,14 @@
+ /* Looks for a word in a list of words - for ParseStatus */
+ bool debListParser::GrabWord(string Word,WordList *List,unsigned char &Out)
+ {
++ return GrabWord(srkString(Word), List, Out);
++}
++
++bool debListParser::GrabWord(const srkString &Word,WordList *List,unsigned char &Out)
++{
+ for (unsigned int C = 0; List[C].Str != 0; C++)
+ {
+- if (strcasecmp(Word.c_str(),List[C].Str) == 0)
++ if (strncasecmp(Word.Start,List[C].Str,Word.Size) == 0)
+ {
+ Out = List[C].Val;
+ return true;
+diff -Nru apt-0.7.25.3/apt-pkg/deb/deblistparser.h apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.h 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h 2010-02-24 08:43:20.000000000 +0000
+@@ -41,9 +41,22 @@
+ bool ParseProvides(pkgCache::VerIterator Ver);
+ bool ParseTag(pkgCache::PkgIterator Pkg);
+ static bool GrabWord(string Word,WordList *List,unsigned char &Out);
++ static bool GrabWord(const srkString &Word,WordList *List,unsigned char &Out);
+
+ public:
+
++ srkString Find(const char *Tag) {
++ srkString S;
++ const char *Stop;
++ if (Section.Find(Tag, S.Start, Stop))
++ S.Size = Stop - S.Start;
++ else {
++ S.Start = NULL;
++ S.Size = 0;
++ }
++ return S;
++ }
++
+ static unsigned char GetPrio(string Str);
+
+ // These all operate against the current section
+@@ -51,6 +64,7 @@
+ virtual string Version();
+ virtual bool NewVersion(pkgCache::VerIterator Ver);
+ virtual string Description();
++ void Description(srkString &Str);
+ virtual string DescriptionLanguage();
+ virtual MD5SumValue Description_md5();
+ virtual unsigned short VersionHash();
+@@ -67,6 +81,9 @@
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ string &Package,string &Ver,unsigned int &Op,
+ bool ParseArchFlags = false);
++ static const char *ParseDepends(const char *Start,const char *Stop,
++ srkString &Package,srkString &Ver,unsigned int &Op,
++ bool ParseArchFlags = false);
+ static const char *ConvertRelation(const char *I,unsigned int &Op);
+
+ debListParser(FileFd *File);
+diff -Nru apt-0.7.25.3/apt-pkg/makefile apt-0.7.25.3+iPhone/apt-pkg/makefile
+--- apt-0.7.25.3/apt-pkg/makefile 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/makefile 2010-02-24 07:57:37.000000000 +0000
+@@ -42,7 +42,7 @@
+ acquire.h acquire-worker.h acquire-item.h acquire-method.h \
+ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \
+ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \
+- vendorlist.h cdrom.h indexcopy.h aptconfiguration.h
++ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h srkstring.h
+
+ # Source code for the debian specific components
+ # In theory the deb headers do not need to be exported..
+diff -Nru apt-0.7.25.3/apt-pkg/pkgcache.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc
+--- apt-0.7.25.3/apt-pkg/pkgcache.cc 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc 2010-02-24 08:51:28.000000000 +0000
+@@ -176,12 +176,25 @@
+ return Hash % _count(HeaderP->HashTable);
+ }
+
++unsigned long pkgCache::sHash(const srkString &Str) const
++{
++ unsigned long Hash = 0;
++ for (const char *I = Str.Start, *E = I + Str.Size; I != E; I++)
++ Hash = 5*Hash + tolower_ascii(*I);
++ return Hash % _count(HeaderP->HashTable);
++}
++
+ /*}}}*/
+ // Cache::FindPkg - Locate a package by name /*{{{*/
+ // ---------------------------------------------------------------------
+ /* Returns 0 on error, pointer to the package otherwise */
+ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name)
+ {
++ return FindPkg(srkString(Name));
++}
++
++pkgCache::PkgIterator pkgCache::FindPkg(const srkString &Name)
++{
+ // Look at the hash bucket
+ Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
+ for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
+diff -Nru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc
+--- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2010-02-24 08:50:06.000000000 +0000
+@@ -33,6 +33,8 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <stdio.h>
++
++#include <apt-pkg/deblistparser.h>
+ /*}}}*/
+ typedef vector<pkgIndexFile *>::iterator FileIterator;
+
+@@ -103,26 +105,37 @@
+ pkgCache::VerIterator *OutVer)
+ {
+ List.Owner = this;
++ debListParser *debian(dynamic_cast<debListParser *>(&List));
+
+ unsigned int Counter = 0;
+ while (List.Step() == true)
+ {
+ // Get a pointer to the package structure
+- string PackageName = List.Package();
++ srkString PackageName;
++ if (debian != NULL)
++ PackageName = debian->Find("Package");
++ else
++ PackageName = List.Package();
+ if (PackageName.empty() == true)
+ return false;
+
+ pkgCache::PkgIterator Pkg;
+ if (NewPackage(Pkg,PackageName) == false)
+- return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str());
++ return _error->Error(_("Error occurred while processing %s (NewPackage)"),std::string(PackageName).c_str());
+ Counter++;
+ if (Counter % 100 == 0 && Progress != 0)
+ Progress->Progress(List.Offset());
+
++ string language(List.DescriptionLanguage());
++
+ /* Get a pointer to the version structure. We know the list is sorted
+ so we use that fact in the search. Insertion of new versions is
+ done with correct sorting */
+- string Version = List.Version();
++ srkString Version;
++ if (debian != NULL)
++ Version = debian->Find("Version");
++ else
++ Version = List.Version();
+ if (Version.empty() == true)
+ {
+ // we first process the package, then the descriptions
+@@ -130,7 +143,7 @@
+ // of MMap space)
+ if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
+ return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ // Find the right version to write the description
+ MD5SumValue CurMd5 = List.Description_md5();
+@@ -147,7 +160,7 @@
+ // md5 && language
+ for ( ; Desc.end() == false; Desc++)
+ if (MD5SumValue(Desc.md5()) == CurMd5 &&
+- Desc.LanguageCode() == List.DescriptionLanguage())
++ Desc.LanguageCode() == language)
+ duplicate=true;
+ if(duplicate)
+ continue;
+@@ -159,11 +172,11 @@
+ if (MD5SumValue(Desc.md5()) == CurMd5)
+ {
+ // Add new description
+- *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
++ *LastDesc = NewDescription(Desc, language, CurMd5, *LastDesc);
+ Desc->ParentPkg = Pkg.Index();
+
+ if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str());
++ return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),std::string(PackageName).c_str());
+ break;
+ }
+ }
+@@ -189,11 +202,11 @@
+ {
+ if (List.UsePackage(Pkg,Ver) == false)
+ return _error->Error(_("Error occurred while processing %s (UsePackage2)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ if (NewFileVer(Ver,List) == false)
+ return _error->Error(_("Error occurred while processing %s (NewFileVer1)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ // Read only a single record and return
+ if (OutVer != 0)
+@@ -224,15 +237,15 @@
+
+ if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false)
+ return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ if (List.UsePackage(Pkg,Ver) == false)
+ return _error->Error(_("Error occurred while processing %s (UsePackage3)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ if (NewFileVer(Ver,List) == false)
+ return _error->Error(_("Error occurred while processing %s (NewVersion2)"),
+- PackageName.c_str());
++ std::string(PackageName).c_str());
+
+ // Read only a single record and return
+ if (OutVer != 0)
+@@ -251,11 +264,11 @@
+ for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++);
+
+ // Add new description
+- *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
++ *LastDesc = NewDescription(Desc, language, List.Description_md5(), *LastDesc);
+ Desc->ParentPkg = Pkg.Index();
+
+ if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
++ return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),std::string(PackageName).c_str());
+ }
+
+ FoundFileDeps |= List.HasFileDeps();
+@@ -328,6 +341,11 @@
+ /* This creates a new package structure and adds it to the hash table */
+ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name)
+ {
++ return NewPackage(Pkg, srkString(Name));
++}
++
++bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const srkString &Name)
++{
+ Pkg = Cache.FindPkg(Name);
+ if (Pkg.end() == false)
+ return true;
+@@ -345,7 +363,7 @@
+ Cache.HeaderP->HashTable[Hash] = Package;
+
+ // Set the name and the ID
+- Pkg->Name = Map.WriteString(Name);
++ Pkg->Name = Map.WriteString(Name.Start,Name.Size);
+ if (Pkg->Name == 0)
+ return false;
+ Pkg->ID = Cache.HeaderP->PackageCount++;
+@@ -393,6 +411,13 @@
+ const string &VerStr,
+ unsigned long Next)
+ {
++ return NewVersion(Ver, srkString(VerStr), Next);
++}
++
++unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
++ const srkString &VerStr,
++ unsigned long Next)
++{
+ // Get a structure
+ unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
+ if (Version == 0)
+@@ -402,7 +427,7 @@
+ Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
+ Ver->NextVer = Next;
+ Ver->ID = Cache.HeaderP->VersionCount++;
+- Ver->VerStr = Map.WriteString(VerStr);
++ Ver->VerStr = Map.WriteString(VerStr.Start, VerStr.Size);
+ if (Ver->VerStr == 0)
+ return 0;
+
+@@ -478,6 +503,15 @@
+ unsigned int Op,
+ unsigned int Type)
+ {
++ return NewDepends(Ver, srkString(PackageName), srkString(Version), Op, Type);
++}
++
++bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
++ const srkString &PackageName,
++ const srkString &Version,
++ unsigned int Op,
++ unsigned int Type)
++{
+ pkgCache &Cache = Owner->Cache;
+
+ // Get a structure
+@@ -541,6 +575,13 @@
+ const string &PackageName,
+ const string &Version)
+ {
++ return NewProvides(Ver, srkString(PackageName), srkString(Version));
++}
++
++bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
++ const srkString &PackageName,
++ const srkString &Version)
++{
+ pkgCache &Cache = Owner->Cache;
+
+ // We do not add self referencing provides
+diff -Nru apt-0.7.25.3/apt-pkg/pkgcachegen.h apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h
+--- apt-0.7.25.3/apt-pkg/pkgcachegen.h 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h 2010-02-24 08:49:18.000000000 +0000
+@@ -52,9 +52,11 @@
+ bool FoundFileDeps;
+
+ bool NewPackage(pkgCache::PkgIterator &Pkg,const string &PkgName);
++ bool NewPackage(pkgCache::PkgIterator &Pkg,const srkString &PkgName);
+ bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
+ bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List);
+ unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next);
++ unsigned long NewVersion(pkgCache::VerIterator &Ver,const srkString &VerStr,unsigned long Next);
+ map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next);
+
+ public:
+@@ -96,11 +98,17 @@
+ inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
+ inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
+ inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
++ inline unsigned long WriteString(const srkString &S) {return Owner->Map.WriteString(S.Start,S.Size);};
+ bool NewDepends(pkgCache::VerIterator Ver,const string &Package,
+ const string &Version,unsigned int Op,
+ unsigned int Type);
++ bool NewDepends(pkgCache::VerIterator Ver,const srkString &Package,
++ const srkString &Version,unsigned int Op,
++ unsigned int Type);
+ bool NewProvides(pkgCache::VerIterator Ver,const string &Package,
+ const string &Version);
++ bool NewProvides(pkgCache::VerIterator Ver,const srkString &Package,
++ const srkString &Version);
+ bool NewTag(pkgCache::PkgIterator Pkg,const char *NameStart,unsigned int NameSize);
+
+ public:
+diff -Nru apt-0.7.25.3/apt-pkg/pkgcache.h apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.25.3/apt-pkg/pkgcache.h 2010-02-24 08:53:52.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h 2010-02-24 07:57:37.000000000 +0000
+@@ -23,9 +23,10 @@
+ #include <string>
+ #include <time.h>
+ #include <apt-pkg/mmap.h>
++#include <apt-pkg/srkstring.h>
+
+ using std::string;
+-
++
+ class pkgVersioningSystem;
+ class pkgCache /*{{{*/
+ {
+@@ -102,6 +103,7 @@
+
+ unsigned long sHash(const string &S) const;
+ unsigned long sHash(const char *S) const;
++ unsigned long sHash(const srkString &S) const;
+
+ public:
+
+@@ -127,12 +129,14 @@
+ // String hashing function (512 range)
+ inline unsigned long Hash(const string &S) const {return sHash(S);};
+ inline unsigned long Hash(const char *S) const {return sHash(S);};
++ inline unsigned long Hash(const srkString &S) const {return sHash(S);};
+
+ // Usefull transformation things
+ const char *Priority(unsigned char Priority);
+
+ // Accessors
+ PkgIterator FindPkg(const string &Name);
++ PkgIterator FindPkg(const srkString &Name);
+ Header &Head() {return *HeaderP;};
+ inline PkgIterator PkgBegin();
+ inline PkgIterator PkgEnd();
+diff -Nru apt-0.7.25.3/apt-pkg/srkstring.h apt-0.7.25.3+iPhone/apt-pkg/srkstring.h
+--- apt-0.7.25.3/apt-pkg/srkstring.h 1970-01-01 00:00:00.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/srkstring.h 2010-02-24 08:37:27.000000000 +0000
+@@ -0,0 +1,59 @@
++// -*- mode: cpp; mode: fold -*-
++// Description /*{{{*/
++// $Id: pkgcache.h,v 1.25 2001/07/01 22:28:24 jgg Exp $
++/* ######################################################################
++
++ Cache - Structure definitions for the cache file
++
++ Please see doc/apt-pkg/cache.sgml for a more detailed description of
++ this format. Also be sure to keep that file up-to-date!!
++
++ Clients should always use the CacheIterators classes for access to the
++ cache. They provide a simple STL-like method for traversing the links
++ of the datastructure.
++
++ See pkgcachegen.h for information about generating cache structures.
++
++ ##################################################################### */
++ /*}}}*/
++#ifndef PKGLIB_PKGSTRING_H
++#define PKGLIB_PKGSTRING_H
++
++#include <string>
++
++class srkString
++{
++ public:
++ const char *Start;
++ size_t Size;
++
++ srkString() : Start(NULL), Size(0) {}
++
++ srkString(const char *Start, size_t Size) : Start(Start), Size(Size) {}
++ srkString(const char *Start, const char *Stop) : Start(Start), Size(Stop - Start) {}
++ srkString(const std::string &string) : Start(string.c_str()), Size(string.size()) {}
++
++ bool empty() const { return Size == 0; }
++ void clear() { Start = NULL; Size = 0; }
++
++ void assign(const char *nStart, const char *nStop) { Start = nStart; Size = nStop - nStart; }
++ void assign(const char *nStart, size_t nSize) { Start = nStart; Size = nSize; }
++
++ size_t length() const { return Size; }
++ size_t size() const { return Size; }
++
++ typedef const char *const_iterator;
++ const char *begin() const { return Start; }
++ const char *end() const { return Start + Size; }
++
++ char operator [](size_t index) const { return Start[index]; }
++
++ operator std::string() { std::string Str; Str.assign(Start, Size); return Str; }
++};
++
++int stringcmp(const std::string &lhs, const char *rhsb, const char *rhse);
++inline bool operator ==(const std::string &lhs, const srkString &rhs) {
++ return stringcmp(lhs, rhs.begin(), rhs.end()) == 0;
++}
++
++#endif
+diff -Nru apt-0.7.25.3/apt-pkg/version.h apt-0.7.25.3+iPhone/apt-pkg/version.h
+--- apt-0.7.25.3/apt-pkg/version.h 2010-02-01 19:44:40.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/version.h 2010-02-24 07:57:37.000000000 +0000
+@@ -20,7 +20,7 @@
+ #ifndef PKGLIB_VERSION_H
+ #define PKGLIB_VERSION_H
+
+-
++#include <apt-pkg/srkstring.h>
+ #include <apt-pkg/strutl.h>
+ #include <string>
+
diff --git a/data/_apt7/torque.diff b/data/_apt7/torque.diff
new file mode 100644
index 000000000..e93870d64
--- /dev/null
+++ b/data/_apt7/torque.diff
@@ -0,0 +1,147 @@
+diff -ru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2011-05-27 06:16:43.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2011-05-27 06:17:16.000000000 +0000
+@@ -572,8 +572,10 @@
+ while (1)
+ {
+ Start = ParseDepends(Start,Stop,Package,Version,Op);
+- if (Start == 0)
+- return _error->Error("Problem parsing dependency %s",Tag);
++ if (Start == 0) {
++ _error->Warning("Problem parsing dependency %s",Tag);
++ return false;
++ }
+
+ if (NewDepends(Ver,Package,Version,Op,Type) == false)
+ return false;
+@@ -600,8 +602,11 @@
+ while (1)
+ {
+ Start = ParseDepends(Start,Stop,Package,Version,Op);
+- if (Start == 0)
+- return _error->Error("Problem parsing Provides line");
++ if (Start == 0) {
++ _error->Warning("Problem parsing Provides line");
++ return false;
++ }
++
+ if (Op != pkgCache::Dep::NoOp) {
+ _error->Warning("Ignoring Provides line with DepCompareOp for package %s", std::string(Package).c_str());
+ } else {
+diff -ru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc
+--- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2011-05-27 06:16:43.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2011-05-27 06:17:16.000000000 +0000
+@@ -108,6 +108,7 @@
+ debListParser *debian(dynamic_cast<debListParser *>(&List));
+
+ unsigned int Counter = 0;
++ step:
+ while (List.Step() == true)
+ {
+ // Get a pointer to the package structure
+@@ -120,8 +121,11 @@
+ return false;
+
+ pkgCache::PkgIterator Pkg;
+- if (NewPackage(Pkg,PackageName) == false)
+- return _error->Error(_("Error occurred while processing %s (NewPackage)"),std::string(PackageName).c_str());
++ if (NewPackage(Pkg,PackageName) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewPackage)"),std::string(PackageName).c_str());
++ goto step;
++ }
++
+ Counter++;
+ if (Counter % 100 == 0 && Progress != 0)
+ Progress->Progress(List.Offset());
+@@ -141,9 +145,11 @@
+ // we first process the package, then the descriptions
+ // (this has the bonus that we get MMap error when we run out
+ // of MMap space)
+- if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
+- return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
++ if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false) {
++ _error->Warning(_("Error occurred while processing %s (UsePackage1)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+ // Find the right version to write the description
+ MD5SumValue CurMd5 = List.Description_md5();
+@@ -175,8 +181,10 @@
+ *LastDesc = NewDescription(Desc, language, CurMd5, *LastDesc);
+ Desc->ParentPkg = Pkg.Index();
+
+- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),std::string(PackageName).c_str());
++ if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewFileDesc1)"),std::string(PackageName).c_str());
++ goto step;
++ }
+ break;
+ }
+ }
+@@ -200,13 +208,17 @@
+ unsigned long Hash = List.VersionHash();
+ if (Res == 0 && Ver->Hash == Hash)
+ {
+- if (List.UsePackage(Pkg,Ver) == false)
+- return _error->Error(_("Error occurred while processing %s (UsePackage2)"),
++ if (List.UsePackage(Pkg,Ver) == false) {
++ _error->Warning(_("Error occurred while processing %s (UsePackage2)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+- if (NewFileVer(Ver,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewFileVer1)"),
++ if (NewFileVer(Ver,List) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewFileVer1)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+ // Read only a single record and return
+ if (OutVer != 0)
+@@ -235,17 +247,23 @@
+ Ver->ParentPkg = Pkg.Index();
+ Ver->Hash = Hash;
+
+- if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false)
+- return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
++ if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewVersion1)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+- if (List.UsePackage(Pkg,Ver) == false)
+- return _error->Error(_("Error occurred while processing %s (UsePackage3)"),
++ if (List.UsePackage(Pkg,Ver) == false) {
++ _error->Warning(_("Error occurred while processing %s (UsePackage3)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+- if (NewFileVer(Ver,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewVersion2)"),
++ if (NewFileVer(Ver,List) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewVersion2)"),
+ std::string(PackageName).c_str());
++ goto step;
++ }
+
+ // Read only a single record and return
+ if (OutVer != 0)
+@@ -267,8 +285,10 @@
+ *LastDesc = NewDescription(Desc, language, List.Description_md5(), *LastDesc);
+ Desc->ParentPkg = Pkg.Index();
+
+- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+- return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),std::string(PackageName).c_str());
++ if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) {
++ _error->Warning(_("Error occurred while processing %s (NewFileDesc2)"),std::string(PackageName).c_str());
++ goto step;
++ }
+ }
+
+ FoundFileDeps |= List.HasFileDeps();
diff --git a/data/_apt7/turbulence.diff b/data/_apt7/turbulence.diff
new file mode 100644
index 000000000..0f80e2bd1
--- /dev/null
+++ b/data/_apt7/turbulence.diff
@@ -0,0 +1,64 @@
+diff -ru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc
+--- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2014-05-13 10:14:37.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2014-05-13 08:54:35.000000000 +0000
+@@ -296,7 +296,7 @@
+ if (Cache.HeaderP->PackageCount >= (1ULL<<sizeof(Cache.PkgP->ID)*8)-1)
+ return _error->Error(_("Wow, you exceeded the number of package "
+ "names this APT is capable of."));
+- if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1)
++ if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID1)*8+sizeof(Cache.VerP->ID2)*8))-1)
+ return _error->Error(_("Wow, you exceeded the number of versions "
+ "this APT is capable of."));
+ if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1)
+@@ -446,7 +446,9 @@
+ // Fill it in
+ Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
+ Ver->NextVer = Next;
+- Ver->ID = Cache.HeaderP->VersionCount++;
++ unsigned int ID = Cache.HeaderP->VersionCount++;
++ Ver->ID1 = ID & 0xffff;
++ Ver->ID2 = ID >> 16;
+ Ver->VerStr = Map.WriteString(VerStr.Start, VerStr.Size);
+ if (Ver->VerStr == 0)
+ return 0;
+diff -ru apt-0.7.25.3/apt-pkg/pkgcache.h apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.25.3/apt-pkg/pkgcache.h 2014-05-13 10:14:37.000000000 +0000
++++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h 2014-05-13 10:17:33.000000000 +0000
+@@ -226,7 +226,7 @@
+ unsigned char InstState; // Flags
+ unsigned char CurrentState; // State
+
+- unsigned short ID;
++ unsigned int ID;
+ unsigned long Flags;
+ };
+
+@@ -247,7 +247,7 @@
+
+ // Linked list
+ map_ptrloc NextFile; // PackageFile
+- unsigned short ID;
++ unsigned int ID;
+ time_t mtime; // Modification time for the file
+ };
+ /*}}}*/
+@@ -291,8 +291,9 @@
+ map_ptrloc Size; // These are the .deb size
+ map_ptrloc InstalledSize;
+ unsigned short Hash;
+- unsigned short ID;
++ unsigned short ID1;
+ unsigned char Priority;
++ unsigned short ID2;
+ };
+ /*}}}*/
+ struct pkgCache::Description /*{{{*/
+@@ -308,7 +309,7 @@
+ map_ptrloc NextDesc; // Description
+ map_ptrloc ParentPkg; // Package
+
+- unsigned short ID;
++ unsigned int ID;
+ };
+ /*}}}*/
+ struct pkgCache::Dependency /*{{{*/