summaryrefslogtreecommitdiff
path: root/data/apt7
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2009-04-22 01:03:34 +0000
committerJay Freeman <saurik@saurik.com>2009-04-22 01:03:34 +0000
commitacbc714acbaf253bf121a217a755089c74c7f01b (patch)
tree3ce08044b81687d87e402253cd60d5ee4690946d /data/apt7
parentb7f32003140cce0188e8a2fc66368a860e474a44 (diff)
The beginning of the future: futzing with APT.
git-svn-id: http://svn.telesphoreo.org/trunk@601 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/apt7')
l---------data/apt7/_metadata/berkeleydb.dep1
l---------data/apt7/_metadata/bzip2.dep1
-rw-r--r--data/apt7/_metadata/conflicts1
l---------data/apt7/_metadata/curl.dep1
-rw-r--r--data/apt7/_metadata/description1
l---------data/apt7/_metadata/dpkg.dep1
l---------data/apt7/_metadata/gnupg.dep1
l---------data/apt7/_metadata/gzip.dep1
-rw-r--r--data/apt7/_metadata/license142
l---------data/apt7/_metadata/maintainer1
-rw-r--r--data/apt7/_metadata/name1
-rw-r--r--data/apt7/_metadata/notes2
-rw-r--r--data/apt7/_metadata/priority1
-rw-r--r--data/apt7/_metadata/role1
-rw-r--r--data/apt7/_metadata/section1
l---------data/apt7/_metadata/sed.dep1
-rw-r--r--data/apt7/_metadata/tags1
-rw-r--r--data/apt7/_metadata/version1
-rw-r--r--data/apt7/apt_0.7.20.2.tar.gzbin0 -> 2032040 bytes
-rw-r--r--data/apt7/cfnetwork.diff655
-rw-r--r--data/apt7/display.diff95
-rw-r--r--data/apt7/dllimit.diff12
-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/intl.diff12
-rw-r--r--data/apt7/longdesc.diff17
-rw-r--r--data/apt7/make.sh21
-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.diff233
-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/tag.diff280
-rw-r--r--data/apt7/timestamp.diff0
39 files changed, 2301 insertions, 0 deletions
diff --git a/data/apt7/_metadata/berkeleydb.dep b/data/apt7/_metadata/berkeleydb.dep
new file mode 120000
index 000000000..f945cb1a2
--- /dev/null
+++ b/data/apt7/_metadata/berkeleydb.dep
@@ -0,0 +1 @@
+../../berkeleydb \ No newline at end of file
diff --git a/data/apt7/_metadata/bzip2.dep b/data/apt7/_metadata/bzip2.dep
new file mode 120000
index 000000000..15aa44a77
--- /dev/null
+++ b/data/apt7/_metadata/bzip2.dep
@@ -0,0 +1 @@
+../../bzip2 \ No newline at end of file
diff --git a/data/apt7/_metadata/conflicts b/data/apt7/_metadata/conflicts
new file mode 100644
index 000000000..fa15e31d4
--- /dev/null
+++ b/data/apt7/_metadata/conflicts
@@ -0,0 +1 @@
+cydia (<< 1.0.2843-1)
diff --git a/data/apt7/_metadata/curl.dep b/data/apt7/_metadata/curl.dep
new file mode 120000
index 000000000..9c4438112
--- /dev/null
+++ b/data/apt7/_metadata/curl.dep
@@ -0,0 +1 @@
+../../curl \ No newline at end of file
diff --git a/data/apt7/_metadata/description b/data/apt7/_metadata/description
new file mode 100644
index 000000000..2bec7476f
--- /dev/null
+++ b/data/apt7/_metadata/description
@@ -0,0 +1 @@
+advanced packaging tool from Debian
diff --git a/data/apt7/_metadata/dpkg.dep b/data/apt7/_metadata/dpkg.dep
new file mode 120000
index 000000000..3e57eea03
--- /dev/null
+++ b/data/apt7/_metadata/dpkg.dep
@@ -0,0 +1 @@
+../../dpkg \ No newline at end of file
diff --git a/data/apt7/_metadata/gnupg.dep b/data/apt7/_metadata/gnupg.dep
new file mode 120000
index 000000000..277e892bf
--- /dev/null
+++ b/data/apt7/_metadata/gnupg.dep
@@ -0,0 +1 @@
+../../gnupg \ No newline at end of file
diff --git a/data/apt7/_metadata/gzip.dep b/data/apt7/_metadata/gzip.dep
new file mode 120000
index 000000000..c6c801e81
--- /dev/null
+++ b/data/apt7/_metadata/gzip.dep
@@ -0,0 +1 @@
+../../gzip \ No newline at end of file
diff --git a/data/apt7/_metadata/license b/data/apt7/_metadata/license
new file mode 100644
index 000000000..9e277e57d
--- /dev/null
+++ b/data/apt7/_metadata/license
@@ -0,0 +1,142 @@
+Apt is copyright 1997, 1998, 1999 Jason Gunthorpe and others.
+
+Apt is licened under the terms of the GNU General Public License (GPL),
+version 2.0 or later, as published by the Free Software Foundation. See
+the file COPYING.GPL [included], /usr/share/common-licenses/GPL, or
+<http://www.gnu.org/copyleft/gpl.txt> for the terms of the latest version
+of the GNU General Public License.
+
+In addition, prior to November 15th, 2000, apt may be distributed under
+terms identical to the above with the following addition:
+
+Works using apt may link against the GUI library "libqt", copyright by
+Troll Tech AS, Norway, provided that:
+
+1. The version of "libqt" is licensed under the terms of the "Qt Free Edition
+ License" published by Troll Tech AS. The license terms identified as
+ the Qt Free Edition License below are the only such terms under which
+ distribution of works derived from both apt and "libqt" are permitted;
+
+and
+
+2. The source code of the version of "libqt" used is
+
+ a) Distributed with the binary version;
+
+ or
+
+ b) Downloadable by anyone, without fee, using a publicly-announced
+ URL on the Internet, for a duration of at least three years
+ starting with distribution of the binary version.
+
+On and after November 15th, 2000, the above additional terms lose all
+force, and apt will be licensed only under the terms of the GNU General
+Public License, version 2.0 or later.
+
+ _______________________________________________________________
+
+The following text, up to the text of the Qt Free Edition License, is
+informational and not part of the license terms on apt.
+
+Modifications to apt in either source or compiled form must be licensed
+under the terms of the GNU General Public License, version 2.0 (or later),
+but need not include the above clause permitting usage of the "libqt"
+library under the Qt Free Edition License. Note that removal of this
+clause will result in software which is not licensed for binary
+redistribution linked against software governed by the Qt Free Edition
+License. In the event that a version of "libqt" is released that is
+licensed under terms that do not conflict with the GPL, the additional
+clause above is not required to grant permission for distribution of works
+that are derived from both apt and "libqt".
+
+No part of apt is licensed under the Qt Free Edition License. The terms
+below are provided to help identify the circumstances under which the
+"libqt" library may be used with apt (or a work derived from both). The
+terms below are copied from the LICENSE file of the qt-1.44 distribution,
+as of November 10th, 1999.
+
+ _______________________________________________________________
+
+ QT FREE EDITION LICENSE
+
+Copyright (C) 1992-1999 Troll Tech AS. All rights reserved.
+
+This is the license for Qt Free Edition version 1.44; it covers private use,
+use of third-party application programs based on Qt, and development of
+free software for the free software community.
+
+
+ COPYRIGHT AND RESTRICTIONS
+
+The Qt toolkit is a product of Troll Tech AS. The Qt Free Edition is limited
+to use with the X Window System.
+
+You may copy this version of the Qt Free Edition provided that the entire
+archive is distributed unchanged and as a whole, including this notice.
+
+You may use this version of the Qt Free Edition to compile, link and run
+application programs legally developed by third parties.
+
+You may use the Qt Free Edition to create application programs
+provided that:
+
+ You accept this license.
+ Your software does not require modifications to Qt Free Edition.
+ You satisfy ONE of the following three requirements
+ EITHER
+ Users of your software can freely obtain source code for the
+ software, freely modify the source code (possibly with
+ restrictions on copyright notices, attributions and legal
+ responsibility), and freely redistribute original or modified
+ versions of the software.
+ OR
+ Your software is distributed under the GNU GENERAL
+ PUBLIC LICENSE, version 2 or later, as defined by the
+ Free Software Foundation.
+ OR
+ Your software is distributed under the GNU LIBRARY
+ GENERAL PUBLIC LICENSE, version 2 or later, as
+ defined by the Free Software Foundation.
+
+If you are paid to develop something with Qt Free Edition or it is a part of
+your job the following conditions also apply:
+
+ Your software must not require libraries, programs, data or
+ documentation that are not available outside your organization in
+ order to compile or use.
+ If and when your organization starts using the software, you must
+ notify Troll Tech AS of the following:
+ Your organization's name and purpose.
+ The software's name and purpose.
+ The software's license.
+ That your organization considers the software to be free
+ software.
+
+You may also use the Qt Free Edition to create reusable components
+(such as libraries) provided that you accept the terms above, and in
+addition that:
+
+ Your components' license includes the following text:
+
+ [Your package] requires the Qt library, which is
+ copyright Troll Tech AS. Freely distributable
+ programs may generally use Qt Free Edition free of
+ charge, see [README.QT] for details.
+
+ README.QT is distributed along with your components.
+ Qt Free Edition is not distributed as an integral part of your
+ components.
+
+ LIMITATIONS OF LIABILITY
+
+Troll Tech AS makes no obligation under this license to support or
+upgrade Qt Free Edition, or assist in the use of Qt Free Edition.
+
+In no event shall Troll Tech AS be liable for any lost revenue or profits or
+other direct, indirect, special, incidental or consequential damages, even
+if Troll Tech has been advised of the possibility of such damages.
+
+QT FREE EDITION IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND,
+INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE.
+ _______________________________________________________________
diff --git a/data/apt7/_metadata/maintainer b/data/apt7/_metadata/maintainer
new file mode 120000
index 000000000..0fa66e077
--- /dev/null
+++ b/data/apt7/_metadata/maintainer
@@ -0,0 +1 @@
+../../../people/saurik \ No newline at end of file
diff --git a/data/apt7/_metadata/name b/data/apt7/_metadata/name
new file mode 100644
index 000000000..ce9e5bf4c
--- /dev/null
+++ b/data/apt7/_metadata/name
@@ -0,0 +1 @@
+APT
diff --git a/data/apt7/_metadata/notes b/data/apt7/_metadata/notes
new file mode 100644
index 000000000..616ed7297
--- /dev/null
+++ b/data/apt7/_metadata/notes
@@ -0,0 +1,2 @@
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146877
+pkgIndexFile::CheckLanguageCode doesn't handle the common cases
diff --git a/data/apt7/_metadata/priority b/data/apt7/_metadata/priority
new file mode 100644
index 000000000..d0b3ce728
--- /dev/null
+++ b/data/apt7/_metadata/priority
@@ -0,0 +1 @@
++required
diff --git a/data/apt7/_metadata/role b/data/apt7/_metadata/role
new file mode 100644
index 000000000..52b4d7301
--- /dev/null
+++ b/data/apt7/_metadata/role
@@ -0,0 +1 @@
+hacker
diff --git a/data/apt7/_metadata/section b/data/apt7/_metadata/section
new file mode 100644
index 000000000..702b7b8d3
--- /dev/null
+++ b/data/apt7/_metadata/section
@@ -0,0 +1 @@
+Packaging
diff --git a/data/apt7/_metadata/sed.dep b/data/apt7/_metadata/sed.dep
new file mode 120000
index 000000000..315b5c89c
--- /dev/null
+++ b/data/apt7/_metadata/sed.dep
@@ -0,0 +1 @@
+../../sed \ No newline at end of file
diff --git a/data/apt7/_metadata/tags b/data/apt7/_metadata/tags
new file mode 100644
index 000000000..b7fdc65c3
--- /dev/null
+++ b/data/apt7/_metadata/tags
@@ -0,0 +1 @@
+purpose::console, purpose::library
diff --git a/data/apt7/_metadata/version b/data/apt7/_metadata/version
new file mode 100644
index 000000000..015cc16c2
--- /dev/null
+++ b/data/apt7/_metadata/version
@@ -0,0 +1 @@
+0.7.20.2
diff --git a/data/apt7/apt_0.7.20.2.tar.gz b/data/apt7/apt_0.7.20.2.tar.gz
new file mode 100644
index 000000000..52d2429ee
--- /dev/null
+++ b/data/apt7/apt_0.7.20.2.tar.gz
Binary files differ
diff --git a/data/apt7/cfnetwork.diff b/data/apt7/cfnetwork.diff
new file mode 100644
index 000000000..7da0635a0
--- /dev/null
+++ b/data/apt7/cfnetwork.diff
@@ -0,0 +1,655 @@
+diff -ru apt-0.7.20.2/methods/http.cc apt-0.7.20.2+iPhone/methods/http.cc
+--- apt-0.7.20.2/methods/http.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/methods/http.cc 2009-04-14 16:34:31.000000000 +0000
+@@ -30,6 +30,7 @@
+ #include <apt-pkg/error.h>
+ #include <apt-pkg/hashes.h>
+
++#include <sys/sysctl.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ #include <utime.h>
+@@ -40,9 +41,16 @@
+ #include <string.h>
+ #include <iostream>
+ #include <apti18n.h>
++#include <set>
+
+ // Internet stuff
+ #include <netdb.h>
++#include <arpa/inet.h>
++
++#include <lockdown.h>
++#include <CoreFoundation/CoreFoundation.h>
++#include <CoreServices/CoreServices.h>
++#include <SystemConfiguration/SystemConfiguration.h>
+
+ #include "config.h"
+ #include "connect.h"
+@@ -52,6 +60,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;
+@@ -632,6 +685,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 */
+@@ -1043,6 +1141,8 @@
+ signal(SIGINT,SigTerm);
+
+ Server = 0;
++
++ std::set<std::string> cached;
+
+ int FailCounter = 0;
+ while (1)
+@@ -1063,173 +1163,313 @@
+ 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;
+
+- // 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;
+- }
+- };
++ 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);
++ }
++
++ 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 the server is sending back sizeless responses then fill in
+- the size now */
++ 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);
++
++ 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;
++ }
++
++ dt += sz;
++ rd -= sz;
++ }
++
++ rd = CFReadStreamRead(rs, data, sizeof(data));
++ goto read;
++ }
++ }
++
++ goto done;
++ done_:
++ CFRelease(hm);
++ done:
++ CFReadStreamClose(rs);
++ CFRelease(rs);
++ free(url);
+
+- // 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;
+- }
+-
+- default:
+- Fail(_("Internal error"));
+- break;
+- }
+-
+ FailCounter = 0;
+ }
+
+@@ -1242,6 +1482,34 @@
+ setlocale(LC_ALL, "");
+
+ 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 (void *lockdown = lockdown_connect()) {
++ UniqueID_ = lockdown_copy_value(lockdown, NULL, kLockdownUniqueDeviceIDKey);
++ lockdown_disconnect(lockdown);
++ }
+
+ return Mth.Loop();
+ }
+diff -ru apt-0.7.20.2/methods/makefile apt-0.7.20.2+iPhone/methods/makefile
+--- apt-0.7.20.2/methods/makefile 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/methods/makefile 2009-04-14 16:18:18.000000000 +0000
+@@ -47,7 +47,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/display.diff b/data/apt7/display.diff
new file mode 100644
index 000000000..2e8fdb375
--- /dev/null
+++ b/data/apt7/display.diff
@@ -0,0 +1,95 @@
+diff -ru apt-0.7.20.2/apt-pkg/cacheiterators.h apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h
+--- apt-0.7.20.2/apt-pkg/cacheiterators.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/cacheiterators.h 2009-04-20 16:50:43.000000000 +0000
+@@ -71,6 +71,7 @@
+ inline pkgCache *Cache() {return Owner;};
+
+ inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
++ inline const char *Display() const {return Pkg->Display == 0?0:Owner->StrP + Pkg->Display;};
+ inline const char *Section() const {return Pkg->Section == 0?0:Owner->StrP + Pkg->Section;};
+ inline bool Purge() const {return Pkg->CurrentState == pkgCache::State::Purge ||
+ (Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotInstalled);};
+@@ -123,6 +124,7 @@
+ inline pkgCache *Cache() {return Owner;};
+
+ inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner->StrP + Ver->VerStr;};
++ inline const char *Display() const {return Ver->Display == 0?0:Owner->StrP + Ver->Display;};
+ inline const char *Section() const {return Ver->Section == 0?0:Owner->StrP + Ver->Section;};
+ inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
+ inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
+diff -ru apt-0.7.20.2/apt-pkg/deb/deblistparser.cc apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc
+--- apt-0.7.20.2/apt-pkg/deb/deblistparser.cc 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/deblistparser.cc 2009-04-20 17:02:43.000000000 +0000
+@@ -75,6 +75,10 @@
+ /* */
+ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
+ {
++ Ver->Display = UniqFindTagWrite("Name");
++ if (Ver->Display == 0)
++ Ver->Display = UniqFindTagWrite("Maemo-Display-Name");
++
+ // Parse the section
+ Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
+@@ -169,6 +169,10 @@
+ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
+ pkgCache::VerIterator Ver)
+ {
++ if (Pkg->Display == 0)
++ Pkg->Display = UniqFindTagWrite("Name");
++ if (Pkg->Display == 0)
++ Pkg->Display = UniqFindTagWrite("Maemo-Display-Name");
+ if (Pkg->Section == 0)
+ Pkg->Section = UniqFindTagWrite("Section");
+ if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.cc apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.cc 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.cc 2009-04-20 17:26:22.000000000 +0000
+@@ -51,6 +51,17 @@
+ return Section.FindS("Package");
+ }
+ /*}}}*/
++// RecordParser::Display - Return the package display name /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++string debRecordParser::Display()
++{
++ string display(Section.FindS("Name"));
++ if (display.empty())
++ display = Section.FindS("Maemo-Display-Name");
++ return display;
++}
++ /*}}}*/
+ // RecordParser::Homepage - Return the package homepage /*{{{*/
+ // ---------------------------------------------------------------------
+ /* */
+diff -ru apt-0.7.20.2/apt-pkg/deb/debrecords.h apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h
+--- apt-0.7.20.2/apt-pkg/deb/debrecords.h 2009-04-20 08:54:09.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/deb/debrecords.h 2009-04-20 17:20:31.000000000 +0000
+@@ -39,6 +39,7 @@
+ virtual string ShortDesc();
+ virtual string LongDesc();
+ virtual string Name();
++ virtual string Display();
+ virtual string Homepage();
+
+ virtual void GetRec(const char *&Start,const char *&Stop);
+diff -ru apt-0.7.20.2/apt-pkg/pkgcache.h apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h
+--- apt-0.7.20.2/apt-pkg/pkgcache.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/pkgcache.h 2009-04-20 16:49:55.000000000 +0000
+@@ -200,6 +200,7 @@
+ {
+ // Pointers
+ map_ptrloc Name; // Stringtable
++ map_ptrloc Display; // Stringtable
+ map_ptrloc VersionList; // Version
+ map_ptrloc CurrentVer; // Version
+ map_ptrloc Section; // StringTable (StringItem)
+@@ -259,6 +272,7 @@
+ struct pkgCache::Version
+ {
+ map_ptrloc VerStr; // Stringtable
++ map_ptrloc Display; // Stringtable
+ map_ptrloc Section; // StringTable (StringItem)
+ map_ptrloc Arch; // StringTable
+
diff --git a/data/apt7/dllimit.diff b/data/apt7/dllimit.diff
new file mode 100644
index 000000000..367c73006
--- /dev/null
+++ b/data/apt7/dllimit.diff
@@ -0,0 +1,12 @@
+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
+@@ -268,7 +286,7 @@
+ return 0;
+
+ /* if a method uses DownloadLimit, we switch to SingleInstance mode */
+- if(_config->FindI("Acquire::"+Access+"::DlLimit",0) > 0)
++ if(_config->FindI("Acquire::"+Access+"::Dl-Limit",0) > 0)
+ Conf->SingleInstance = true;
+
+ return Conf;
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..f6808de2b
--- /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 @@
+ LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
+ MAJOR=4.6
+ MINOR=0
+-SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
++SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil $(LIBICONV)
+ APT_DOMAIN:=libapt-pkg$(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/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
new file mode 100644
index 000000000..fbfc6a7a2
--- /dev/null
+++ b/data/apt7/make.sh
@@ -0,0 +1,21 @@
+pkg:setup
+autoconf
+DPKG_ARCH=$(ls -d $(PKG_WORK_ dpkg)/dpkg-*/scripts) pkg:configure --disable-nls
+make
+
+pkg: mkdir -p /etc/apt/sources.list.d
+pkg: mkdir -p /var/cache/apt/archives/partial
+pkg: mkdir -p /var/lib/apt/lists/partial
+pkg: mkdir -p /var/lib/apt/periodic
+pkg: mkdir -p /var/log/apt
+
+pkg: mkdir -p /usr/bin /usr/lib/apt
+pkg: cp -a bin/apt-* /usr/bin
+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/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..06f4dbac0
--- /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;
+ for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++);
+ return true;
+diff -ru apt-0.7.20.2/apt-pkg/tagfile.h apt-0.7.20.2+iPhone/apt-pkg/tagfile.h
+--- apt-0.7.20.2/apt-pkg/tagfile.h 2009-02-07 15:09:35.000000000 +0000
++++ apt-0.7.20.2+iPhone/apt-pkg/tagfile.h 2009-04-19 03:04:07.000000000 +0000
+@@ -21,6 +21,7 @@
+ #define PKGLIB_TAGFILE_H
+
+
++#include <apt-pkg/mmap.h>
+ #include <apt-pkg/fileutl.h>
+ #include <stdio.h>
+
+@@ -71,10 +72,9 @@
+ char *End;
+ bool Done;
+ unsigned long iOffset;
+- unsigned long Size;
++ MMap *Map;
+
+ bool Fill();
+- bool Resize();
+
+ public:
+
diff --git a/data/apt7/parallel.diff b/data/apt7/parallel.diff
new file mode 100644
index 000000000..1643fd2c7
--- /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",0));
++ 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..af30d7269
--- /dev/null
+++ b/data/apt7/port.diff
@@ -0,0 +1,233 @@
+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.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-14 16:10:02.000000000 +0000
+@@ -11,7 +11,8 @@
+
+ # The library name
+ LIBRARY=apt-inst
+-LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
++LIBEXT=
++#$(GLIBC_VER)$(LIBSTDCPP_VER)
+ MAJOR=1.1
+ MINOR=0
+ SLIBS=$(PTHREADLIB) -lapt-pkg
+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/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-14 16:16:15.000000000 +0000
+@@ -12,7 +12,8 @@
+ # The library name, don't forget to update init.h and the copy in
+ # methods/makefile - FIXME
+ LIBRARY=apt-pkg
+-LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
++LIBEXT=
++#$(GLIBC_VER)$(LIBSTDCPP_VER)
+ MAJOR=4.6
+ MINOR=0
+ SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
+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,6 @@
+ $(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/tag.diff b/data/apt7/tag.diff
new file mode 100644
index 000000000..b315e2e50
--- /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/timestamp.diff b/data/apt7/timestamp.diff
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/data/apt7/timestamp.diff