releasing/blocks/cclient/patches/windows/apt-win.patch
changeset 632 934f9131337b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/releasing/blocks/cclient/patches/windows/apt-win.patch	Thu Sep 02 15:02:14 2010 +0800
@@ -0,0 +1,722 @@
+diff -uwrBN apt-0.7.20.2/Makefile apt-0.7.20.2-win/Makefile
+--- apt-0.7.20.2/Makefile	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/Makefile	1970-01-01 02:00:00.000000000 +0200
+@@ -1,34 +0,0 @@
+-# -*- make -*-
+-
+-# This is the top level make file for APT, it recurses to each lower
+-# level make file and runs it with the proper target
+-ifndef NOISY
+-.SILENT:
+-endif
+-
+-.PHONY: default
+-default: startup all
+-
+-.PHONY: headers library clean veryclean all binary program doc
+-all headers library clean veryclean binary program doc dirs:
+-	$(MAKE) -C apt-pkg $@
+-	$(MAKE) -C apt-inst $@
+-	$(MAKE) -C methods $@
+-	$(MAKE) -C cmdline $@
+-	$(MAKE) -C ftparchive $@
+-	$(MAKE) -C dselect $@
+-	$(MAKE) -C doc $@
+-	$(MAKE) -C po $@
+-
+-# Some very common aliases
+-.PHONY: maintainer-clean dist-clean distclean pristine sanity 
+-maintainer-clean dist-clean distclean pristine sanity: veryclean
+-
+-# The startup target builds the necessary configure scripts. It should
+-# be used after a CVS checkout.
+-CONVERTED=environment.mak include/config.h include/apti18n.h build/doc/Doxyfile makefile
+-include buildlib/configure.mak
+-$(BUILDDIR)/include/config.h: buildlib/config.h.in
+-$(BUILDDIR)/include/apti18n.h: buildlib/apti18n.h.in
+-$(BUILDDIR)/environment.mak: buildlib/environment.mak.in
+-$(BUILDDIR)/makefile: buildlib/makefile.in
+diff -uwrBN apt-0.7.20.2/Makefile2 apt-0.7.20.2-win/Makefile2
+--- apt-0.7.20.2/Makefile2	1970-01-01 02:00:00.000000000 +0200
++++ apt-0.7.20.2-win/Makefile2	2010-03-25 19:31:17.957149000 +0200
+@@ -0,0 +1,34 @@
++# -*- make -*-
++
++# This is the top level make file for APT, it recurses to each lower
++# level make file and runs it with the proper target
++ifndef NOISY
++.SILENT:
++endif
++
++.PHONY: default
++default: startup all
++
++.PHONY: headers library clean veryclean all binary program doc
++all headers library clean veryclean binary program doc dirs:
++	$(MAKE) -C apt-pkg $@
++	$(MAKE) -C apt-inst $@
++	$(MAKE) -C methods $@
++	$(MAKE) -C cmdline $@
++	$(MAKE) -C ftparchive $@
++	$(MAKE) -C dselect $@
++	$(MAKE) -C doc $@
++	$(MAKE) -C po $@
++
++# Some very common aliases
++.PHONY: maintainer-clean dist-clean distclean pristine sanity 
++maintainer-clean dist-clean distclean pristine sanity: veryclean
++
++# The startup target builds the necessary configure scripts. It should
++# be used after a CVS checkout.
++CONVERTED=environment.mak include/config.h include/apti18n.h build/doc/Doxyfile makefile
++include buildlib/configure.mak
++$(BUILDDIR)/include/config.h: buildlib/config.h.in
++$(BUILDDIR)/include/apti18n.h: buildlib/apti18n.h.in
++$(BUILDDIR)/environment.mak: buildlib/environment.mak.in
++$(BUILDDIR)/makefile: buildlib/makefile.in
+diff -uwrBN apt-0.7.20.2/apt-pkg/contrib/configuration.cc apt-0.7.20.2-win/apt-pkg/contrib/configuration.cc
+--- apt-0.7.20.2/apt-pkg/contrib/configuration.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/contrib/configuration.cc	2010-03-25 19:31:18.327689200 +0200
+@@ -191,7 +191,9 @@
+    while (Itm->Parent != 0 && Itm->Parent->Value.empty() == false)
+    {	 
+       // Absolute
+-      if (val.length() >= 1 && val[0] == '/')
++      // HH: Windows port
++      if (val.length() >= 3 && val[1] == ':' && val[2] == '/')
++      //if (val.length() >= 1 && val[0] == '/')
+          break;
+ 
+       // ~/foo or ./foo 
+diff -uwrBN apt-0.7.20.2/apt-pkg/contrib/error.cc apt-0.7.20.2-win/apt-pkg/contrib/error.cc
+--- apt-0.7.20.2/apt-pkg/contrib/error.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/contrib/error.cc	2010-03-25 19:31:18.347718400 +0200
+@@ -205,6 +205,22 @@
+ 	 cerr << "W: " << Err << endl;
+    }
+ }
++
++string GlobalError::GetErrorDump()
++{
++   string err;
++   Item *item = List;
++   while (item)
++   {
++      if (item->Error)
++         err += "E: ";
++      else
++	 err += "W: ";
++      err += item->Text + "\n";
++      item = item->Next;
++   }
++   return err;
++}
+ 									/*}}}*/
+ // GlobalError::Discard - Discard									/*{{{*/
+ // ---------------------------------------------------------------------
+diff -uwrBN apt-0.7.20.2/apt-pkg/contrib/error.h apt-0.7.20.2-win/apt-pkg/contrib/error.h
+--- apt-0.7.20.2/apt-pkg/contrib/error.h	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/contrib/error.h	2010-03-25 19:31:18.347718400 +0200
+@@ -87,6 +87,7 @@
+ 
+    // Usefull routine to dump to cerr
+    void DumpErrors();
++   string GetErrorDump();
+    
+    GlobalError();
+ };
+diff -uwrBN apt-0.7.20.2/apt-pkg/contrib/strutl.cc apt-0.7.20.2-win/apt-pkg/contrib/strutl.cc
+--- apt-0.7.20.2/apt-pkg/contrib/strutl.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/contrib/strutl.cc	2010-03-25 19:31:18.417820600 +0200
+@@ -43,7 +43,8 @@
+ {
+   iconv_t cd;
+   const char *inbuf;
+-  char *inptr, *outbuf, *outptr;
++  char *inptr;
++  char *outbuf, *outptr;
+   size_t insize, outsize;
+   
+   cd = iconv_open(codeset, "UTF-8");
+@@ -397,7 +398,9 @@
+    U.Access.clear();
+    
+    // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
+-   string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*");
++   // HH: Windows port
++   // Added : and ? to quoting
++   string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*:?");
+    replace(NewURI.begin(),NewURI.end(),'/','_');
+    return NewURI;
+ }
+@@ -1090,15 +1093,18 @@
+    for (; I < U.end() && *I != ':' ; I++);
+    string::const_iterator FirstColon = I;
+ 
++	 // HH: Windows port
++
+    /* Determine if this is a host type URI with a leading double //
+       and then search for the first single / */
+    string::const_iterator SingleSlash = I;
++   bool InBracket = false;
+    if (I + 3 < U.end() && I[1] == '/' && I[2] == '/')
++   {
+       SingleSlash += 3;
+    
+    /* Find the / indicating the end of the hostname, ignoring /'s in the
+       square brackets */
+-   bool InBracket = false;
+    for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++)
+    {
+       if (*SingleSlash == '[')
+@@ -1106,6 +1112,11 @@
+       if (InBracket == true && *SingleSlash == ']')
+ 	 InBracket = false;
+    }
++	 }
++	 else // single slash?
++	 {
++	 		SingleSlash = I + 1;
++	 }
+    
+    if (SingleSlash > U.end())
+       SingleSlash = U.end();
+@@ -1113,7 +1124,9 @@
+    // We can now write the access and path specifiers
+    Access.assign(U.begin(),FirstColon);
+    if (SingleSlash != U.end())
++   {
+       Path.assign(SingleSlash,U.end());
++   }
+    if (Path.empty() == true)
+       Path = "/";
+ 
+diff -uwrBN apt-0.7.20.2/apt-pkg/deb/debsystem.cc apt-0.7.20.2-win/apt-pkg/deb/debsystem.cc
+--- apt-0.7.20.2/apt-pkg/deb/debsystem.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/deb/debsystem.cc	2010-03-26 11:59:47.087515500 +0200
+@@ -24,7 +24,6 @@
+ #include <errno.h>
+ 									/*}}}*/
+ 
+-debSystem debSys;
+ 
+ // System::debSystem - Constructor					/*{{{*/
+ // ---------------------------------------------------------------------
+diff -uwrBN apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2-win/apt-pkg/deb/dpkgpm.cc
+--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/deb/dpkgpm.cc	2010-03-25 19:31:18.507952000 +0200
+@@ -41,6 +41,33 @@
+ 
+ using namespace std;
+ 
++// HH
++typedef void (*sighandler_t)(int signum);
++
++void* memrchr(void *buffer, int c, size_t n)
++{
++ 	unsigned char *p = reinterpret_cast<unsigned char*>(buffer);
++
++  for (p += n; n ; n--)
++    if (*--p == c)
++      return p;
++  return NULL;
++}
++
++#if defined(__CYGWIN__)
++/* Workaround for Cygwin, which is missing cfmakeraw */
++/* Pasted from man page; added in serial.c arbitrarily */
++void cfmakeraw(struct termios *termios_p)
++{
++    termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
++    termios_p->c_oflag &= ~OPOST;
++    termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
++    termios_p->c_cflag &= ~(CSIZE|PARENB);
++    termios_p->c_cflag |= CS8;
++}
++#endif /* defined(__CYGWIN__) */
++
++
+ namespace
+ {
+   // Maps the dpkg "processing" info to human readable names.  Entry 0
+@@ -737,7 +764,9 @@
+       {
+ 	 for (;I != J && Size < MaxArgBytes; I++)
+ 	 {
+-	    if (I->File[0] != '/')
++			// HH: Windows port
++			if (I->File[1] != ':' && I->File[2] != '/')
++		  //if (I->File[0] != '/')
+ 	       return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
+ 	    Args[n++] = I->File.c_str();
+ 	    Size += strlen(Args[n-1]);
+@@ -812,7 +841,7 @@
+ 	 if(slave >= 0 && master >= 0) 
+ 	 {
+ 	    setsid();
+-	    ioctl(slave, TIOCSCTTY, 0);
++	    ioctl(slave, /*TIOCSCTTY*/O_NOCTTY, 0);
+ 	    close(master);
+ 	    dup2(slave, 0);
+ 	    dup2(slave, 1);
+diff -uwrBN apt-0.7.20.2/apt-pkg/deb/dpkgpm.h apt-0.7.20.2-win/apt-pkg/deb/dpkgpm.h
+--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.h	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/deb/dpkgpm.h	2010-03-25 19:31:18.507952000 +0200
+@@ -18,6 +18,8 @@
+ using std::vector;
+ using std::map;
+ 
++// HH
++void *memrchr (const void *buffer, int c, size_t n);
+ 
+ class pkgDPkgPM : public pkgPackageManager
+ {
+diff -uwrBN apt-0.7.20.2/apt-pkg/init.cc apt-0.7.20.2-win/apt-pkg/init.cc
+--- apt-0.7.20.2/apt-pkg/init.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/apt-pkg/init.cc	2010-03-26 12:00:25.022820300 +0200
+@@ -17,6 +17,8 @@
+ #include <cstdlib>
+ #include <sys/stat.h>
+ 									/*}}}*/
++#include "deb/debsystem.h"
++debSystem debSys;
+ 
+ #define Stringfy_(x) # x
+ #define Stringfy(x)  Stringfy_(x)
+@@ -116,7 +118,7 @@
+ bool pkgInitSystem(Configuration &Cnf,pkgSystem *&Sys)
+ {
+    Sys = 0;
+-   string Label = Cnf.Find("Apt::System","");
++	string Label = Cnf.Find("Apt::System","Debian dpkg interface");
+    if (Label.empty() == false)
+    {
+       Sys = pkgSystem::GetSystem(Label.c_str());
+diff -uwrBN apt-0.7.20.2/buildlib/makefile.in apt-0.7.20.2-win/buildlib/makefile.in
+--- apt-0.7.20.2/buildlib/makefile.in	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/buildlib/makefile.in	2010-03-25 19:31:18.778346200 +0200
+@@ -15,7 +15,7 @@
+ .PHONY: headers library clean veryclean all binary program doc \
+         veryclean/local
+ all headers library clean veryclean binary program doc:
+-	$(MAKE) -C $(SRCDIR) -f Makefile $@
++	$(MAKE) -C $(SRCDIR) -f Makefile2 $@
+ 
+ # Purge everything.
+ .PHONY: maintainer-clean dist-clean pristine sanity distclean
+@@ -30,7 +30,7 @@
+ # and run make dirs and have the shims updated.
+ .PHONY: dirs
+ dirs: 
+-	$(MAKE) -C $(SRCDIR) -f Makefile $@
++	$(MAKE) -C $(SRCDIR) -f Makefile2 $@
+ ifeq ($(HAVE_C9X),yes)
+ 	@rm -f include/inttypes.h > /dev/null 2>&1
+ else
+diff -uwrBN apt-0.7.20.2/cmdline/apt-cache.cc apt-0.7.20.2-win/cmdline/apt-cache.cc
+--- apt-0.7.20.2/cmdline/apt-cache.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/cmdline/apt-cache.cc	2010-03-25 19:31:18.838433800 +0200
+@@ -1233,6 +1233,13 @@
+ 
+    // Get a pointer to start of Description field
+    const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
++   // HH: Bug fix. If descriptions are not found quit now to prevent crash
++   if (DescP == NULL)
++   {
++   		cout << "E: Malformed packages inserted into cache. Description field missing!";
++   		delete [] Buffer;
++   		return false;
++   }
+ 
+    // Write all but Description
+    if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
+@@ -1282,6 +1289,12 @@
+ bool Search(CommandLine &CmdL)
+ {
+    pkgCache &Cache = *GCache;
++   // HH: Bug fix. No need to do anything if no packages
++   if (Cache.HeaderP->PackageCount == 0)
++   {
++   		return true;
++   }
++   	
+    bool ShowFull = _config->FindB("APT::Cache::ShowFull",false);
+    bool NamesOnly = _config->FindB("APT::Cache::NamesOnly",false);
+    unsigned NumPatterns = CmdL.FileSize() -1;
+@@ -1316,7 +1329,8 @@
+    }
+    
+    ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
+-   memset(DFList,0,sizeof(*DFList)*Cache.HeaderP->PackageCount+1);
++   // HH: Bug fix. Memset all the memory
++   memset(DFList, 0, sizeof(*DFList) * (Cache.HeaderP->PackageCount + 1));
+ 
+    // Map versions that we want to write out onto the VerList array.
+    for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
+diff -uwrBN apt-0.7.20.2/configure-cygwin apt-0.7.20.2-win/configure-cygwin
+--- apt-0.7.20.2/configure-cygwin	1970-01-01 02:00:00.000000000 +0200
++++ apt-0.7.20.2-win/configure-cygwin	2010-03-25 19:31:18.898521400 +0200
+@@ -0,0 +1,9 @@
++#! /bin/sh
++
++export CFLAGS="-O2 -march=i686 -s -fomit-frame-pointer"
++export CXXFLAGS="-O2 -march=i686 -s -fomit-frame-pointer"
++export PATH=../dpkg/scripts:$PATH
++export PERL5LIB=../dpkg/scripts
++export DPKG_DATADIR=../dpkg
++./configure
++echo INTLLIBS = -lintl -liconv >> environment.mak
+diff -uwrBN apt-0.7.20.2/ftparchive/apt-ftparchive.cc apt-0.7.20.2-win/ftparchive/apt-ftparchive.cc
+--- apt-0.7.20.2/ftparchive/apt-ftparchive.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/ftparchive/apt-ftparchive.cc	2010-03-25 19:31:20.020156600 +0200
+@@ -729,11 +729,9 @@
+    if (CmdL.FileSize() <= 2)
+    {
+       for (vector<PackageMap>::iterator I = PkgList.begin(); I != PkgList.end(); I++)
+-	 if (I->GenPackages(Setup,Stats) == false)
+-	    _error->DumpErrors();
++	 			I->GenPackages(Setup,Stats);
+       for (vector<PackageMap>::iterator I = PkgList.begin(); I != PkgList.end(); I++)
+-	 if (I->GenSources(Setup,SrcStats) == false)
+-	    _error->DumpErrors();
++	 			I->GenSources(Setup,SrcStats);
+    }
+    else
+    {
+@@ -758,7 +756,6 @@
+ 	 delete [] List;
+ 	 return _error->Error(_("No selections matched"));
+       }
+-      _error->DumpErrors();
+       
+       // Do the generation for Packages
+       for (End = List; End->Str != 0; End++)
+@@ -769,8 +766,7 @@
+ 	 PackageMap *I = (PackageMap *)End->UserData;
+ 	 if (I->PkgDone == true)
+ 	    continue;
+-	 if (I->GenPackages(Setup,Stats) == false)
+-	    _error->DumpErrors();
++	 		I->GenPackages(Setup,Stats);
+       }
+       
+       // Do the generation for Sources
+@@ -782,8 +778,7 @@
+ 	 PackageMap *I = (PackageMap *)End->UserData;
+ 	 if (I->SrcDone == true)
+ 	    continue;
+-	 if (I->GenSources(Setup,SrcStats) == false)
+-	    _error->DumpErrors();
++	 		I->GenSources(Setup,SrcStats);
+       }
+       
+       delete [] List;
+@@ -837,9 +832,7 @@
+ 	    continue;
+       }
+       
+-      if (I->GenContents(Setup,PkgList.begin(),PkgList.end(),
+-			 MaxContentsChange) == false)
+-	 _error->DumpErrors();
++      I->GenContents(Setup,PkgList.begin(),PkgList.end(), MaxContentsChange);
+       
+       // Hit the limit?
+       if (MaxContentsChange == 0)
+@@ -885,8 +878,7 @@
+    {
+       c0out << I->BinCacheDB << endl;
+       CacheDB DB(flCombine(CacheDir,I->BinCacheDB));
+-      if (DB.Clean() == false)
+-	 _error->DumpErrors();
++      DB.Clean();
+       
+       string CacheDB = I->BinCacheDB;
+       for (; I != PkgList.end() && I->BinCacheDB == CacheDB; I++);
+diff -uwrBN apt-0.7.20.2/ftparchive/cachedb.cc apt-0.7.20.2-win/ftparchive/cachedb.cc
+--- apt-0.7.20.2/ftparchive/cachedb.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/ftparchive/cachedb.cc	2010-03-25 19:31:20.020156600 +0200
+@@ -23,6 +23,18 @@
+ #include <netinet/in.h>       // htonl, etc
+ 									/*}}}*/
+ 
++// HH
++								
++void* memrchr(void *buffer, int c, size_t n)
++{
++ 	unsigned char *p = reinterpret_cast<unsigned char*>(buffer);
++
++  for (p += n; n ; n--)
++    if (*--p == c)
++      return p;
++  return NULL;
++}
++
+ // CacheDB::ReadyDB - Ready the DB2					/*{{{*/
+ // ---------------------------------------------------------------------
+ /* This opens the DB2 file for caching package information */
+diff -uwrBN apt-0.7.20.2/ftparchive/cachedb.h apt-0.7.20.2-win/ftparchive/cachedb.h
+--- apt-0.7.20.2/ftparchive/cachedb.h	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/ftparchive/cachedb.h	2010-03-25 19:31:20.030171200 +0200
+@@ -23,6 +21,9 @@
+     
+ #include "contents.h"
+     
++// HH
++void *memrchr (const void *buffer, int c, size_t n);
++    
+ class CacheDB
+ {
+    protected:
+diff -uwrBN apt-0.7.20.2/ftparchive/multicompress.cc apt-0.7.20.2-win/ftparchive/multicompress.cc
+--- apt-0.7.20.2/ftparchive/multicompress.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/ftparchive/multicompress.cc	2010-03-25 19:31:20.050200400 +0200
+@@ -178,7 +178,6 @@
+       Child(Pipe[0]);
+       if (_error->PendingError() == true)
+       {
+-	 _error->DumpErrors();
+ 	 _exit(100);
+       }      
+       _exit(0);
+diff -uwrBN apt-0.7.20.2/ftparchive/writer.cc apt-0.7.20.2-win/ftparchive/writer.cc
+--- apt-0.7.20.2/ftparchive/writer.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/ftparchive/writer.cc	2010-03-25 19:31:20.070229600 +0200
+@@ -118,28 +118,15 @@
+    else
+       Owner->DoPackage(File);
+    
+-   if (_error->empty() == false)
+-   {
+-      // Print any errors or warnings found
+-      string Err;
+-      bool SeenPath = false;
+-      while (_error->empty() == false)
++   if (!_error->empty())
+       {
+-	 Owner->NewLine(1);
+-	 
+-	 bool Type = _error->PopMessage(Err);
+-	 if (Type == true)
+-	    cerr << _("E: ") << Err << endl;
+-	 else
+-	    cerr << _("W: ") << Err << endl;
++      Owner->NewLine(1); // is this needed?
+ 	 
+-	 if (Err.find(File) != string::npos)
+-	    SeenPath = true;
+-      }      
+-      
+-      if (SeenPath == false)
+-	 cerr << _("E: Errors apply to file ") << "'" << File << "'" << endl;
+-      return 0;
++      // HH: Show which file is involved in error if it's not found
++      // from previous errors 
++      string errdump = _error->GetErrorDump();
++      if (errdump.find(File) == string::npos)
++	 _error->Error("Errors apply to file '%s'", File);
+    }
+    
+    return 0;
+@@ -320,8 +307,6 @@
+ 
+    if (ExtOverrides.empty() == false)
+       Over.ReadExtraOverride(ExtOverrides);
+-
+-   _error->DumpErrors();
+ }
+                                                                         /*}}}*/
+ // FTWScanner::SetExts - Set extensions to support                      /*{{{*/
+@@ -794,7 +779,6 @@
+       if (_error->empty() == false)
+       {
+ 	 _error->Error("Errors apply to file '%s'",File.c_str());
+-	 _error->DumpErrors();
+       }
+    }
+    
+diff -uwrBN apt-0.7.20.2/methods/connect.cc apt-0.7.20.2-win/methods/connect.cc
+--- apt-0.7.20.2/methods/connect.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/connect.cc	2010-03-25 19:31:20.110288000 +0200
+@@ -107,7 +107,7 @@
+ 
+    // Check the socket for an error condition
+    unsigned int Err;
+-   unsigned int Len = sizeof(Err);
++   socklen_t Len = sizeof(Err);
+    if (getsockopt(Fd,SOL_SOCKET,SO_ERROR,&Err,&Len) != 0)
+       return _error->Errno("getsockopt",_("Failed"));
+    
+diff -uwrBN apt-0.7.20.2/methods/copy.cc apt-0.7.20.2-win/methods/copy.cc
+--- apt-0.7.20.2/methods/copy.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/copy.cc	2010-03-25 19:31:20.160361000 +0200
+@@ -19,6 +19,7 @@
+ #include <unistd.h>
+ #include <apti18n.h>
+ 									/*}}}*/
++#include <iostream>
+ 
+ class CopyMethod : public pkgAcqMethod
+ {
+diff -uwrBN apt-0.7.20.2/methods/ftp.cc apt-0.7.20.2-win/methods/ftp.cc
+--- apt-0.7.20.2/methods/ftp.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/ftp.cc	2010-03-25 19:31:20.230463200 +0200
+@@ -112,7 +112,7 @@
+    Close();
+    
+    // Determine the proxy setting
+-   if (getenv("ftp_proxy") == 0)
++   if (getenv("FTP_PROXY") == 0)
+    {
+       string DefProxy = _config->Find("Acquire::ftp::Proxy");
+       string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
+@@ -127,12 +127,12 @@
+ 	 Proxy = DefProxy;
+    }
+    else
+-      Proxy = getenv("ftp_proxy");
++      Proxy = getenv("FTP_PROXY");
+    
+    // Parse no_proxy, a , separated list of domains
+-   if (getenv("no_proxy") != 0)
++   if (getenv("NO_PROXY") != 0)
+    {
+-      if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
++      if (CheckDomainList(ServerName.Host,getenv("NO_PROXY")) == true)
+ 	 Proxy = "";
+    }
+    
+@@ -697,7 +697,7 @@
+       if (WaitFd(DataFd,true,TimeOut) == false)
+ 	 return _error->Error(_("Could not connect data socket, connection timed out"));
+       unsigned int Err;
+-      unsigned int Len = sizeof(Err);
++      socklen_t Len = sizeof(Err);
+       if (getsockopt(DataFd,SOL_SOCKET,SO_ERROR,&Err,&Len) != 0)
+ 	 return _error->Errno("getsockopt",_("Failed"));
+       if (Err != 0)
+@@ -1090,16 +1090,16 @@
+ 
+    /* See if we should be come the http client - we do this for http
+       proxy urls */
+-   if (getenv("ftp_proxy") != 0)
++   if (getenv("FTP_PROXY") != 0)
+    {
+-      URI Proxy = string(getenv("ftp_proxy"));
++      URI Proxy = string(getenv("FTP_PROXY"));
+       
+       // Run the HTTP method
+       if (Proxy.Access == "http")
+       {
+ 	 // Copy over the environment setting
+ 	 char S[300];
+-	 snprintf(S,sizeof(S),"http_proxy=%s",getenv("ftp_proxy"));
++	 snprintf(S,sizeof(S),"HTTP_PROXY=%s",getenv("FTP_PROXY"));
+ 	 putenv(S);
+ 	 putenv((char *)"no_proxy=");
+ 	 
+diff -uwrBN apt-0.7.20.2/methods/gpgv.cc apt-0.7.20.2-win/methods/gpgv.cc
+--- apt-0.7.20.2/methods/gpgv.cc	2009-04-20 22:46:30.000000000 +0300
++++ apt-0.7.20.2-win/methods/gpgv.cc	2010-03-25 19:31:20.310580000 +0200
+@@ -88,7 +88,7 @@
+ 
+       Args[i++] = gpgvpath.c_str();
+       Args[i++] = "--status-fd";
+-      Args[i++] = "3";
++      Args[i++] = "2";
+       Args[i++] = "--ignore-time-conflict";
+       Args[i++] = "--keyring";
+       Args[i++] = pubringpath.c_str();
+@@ -124,9 +124,11 @@
+       close(fd[0]);
+       // Redirect output to /dev/null; we read from the status fd
+       dup2(nullfd, STDOUT_FILENO); 
+-      dup2(nullfd, STDERR_FILENO); 
+-      // Redirect the pipe to the status fd (3)
+-      dup2(fd[1], 3);
++      //dup2(nullfd, STDERR_FILENO); 
++      // Windows port: File descriptor 3 is not available so we
++      // have to use STDERR
++      // Redirect the pipe to the status fd (2)
++      dup2(fd[1], 2);
+ 
+       putenv((char *)"LANG=");
+       putenv((char *)"LC_ALL=");
+@@ -241,7 +243,10 @@
+ bool GPGVMethod::Fetch(FetchItem *Itm)
+ {
+    URI Get = Itm->Uri;
+-   string Path = Get.Host + Get.Path; // To account for relative paths
++   // HH: Windows port. Not sure if this is needed, so removing because host
++   // adds drive to path two times
++   //string Path = Get.Host + Get.Path; // To account for relative paths
++   string Path = Get.Path;
+    string keyID;
+    vector<string> GoodSigners;
+    vector<string> BadSigners;
+diff -uwrBN apt-0.7.20.2/methods/gzip.cc apt-0.7.20.2-win/methods/gzip.cc
+--- apt-0.7.20.2/methods/gzip.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/gzip.cc	2010-03-26 12:01:49.596117300 +0200
+@@ -41,7 +42,10 @@
+ bool GzipMethod::Fetch(FetchItem *Itm)
+ {
+    URI Get = Itm->Uri;
+-   string Path = Get.Host + Get.Path; // To account for relative paths
++   // HH: Windows port. Not sure if this is needed, so removing because host
++   // adds drive to path two times
++   //string Path = Get.Host + Get.Path; // To account for relative paths
++   string Path = Get.Path;
+    
+    string GzPathOption = "Dir::bin::"+string(Prog);
+ 
+diff -uwrBN apt-0.7.20.2/methods/http.cc apt-0.7.20.2-win/methods/http.cc
+--- apt-0.7.20.2/methods/http.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/http.cc	2010-03-25 19:31:20.320594600 +0200
+@@ -309,7 +309,7 @@
+    Persistent = true;
+    
+    // Determine the proxy setting
+-   if (getenv("http_proxy") == 0)
++   if (getenv("HTTP_PROXY") == 0)
+    {
+       string DefProxy = _config->Find("Acquire::http::Proxy");
+       string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+@@ -324,12 +324,12 @@
+ 	 Proxy = DefProxy;
+    }
+    else
+-      Proxy = getenv("http_proxy");
++      Proxy = getenv("HTTP_PROXY");
+    
+    // Parse no_proxy, a , separated list of domains
+-   if (getenv("no_proxy") != 0)
++   if (getenv("NO_PROXY") != 0)
+    {
+-      if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
++      if (CheckDomainList(ServerName.Host,getenv("NO_PROXY")) == true)
+ 	 Proxy = "";
+    }
+    
+diff -uwrBN apt-0.7.20.2/methods/https.cc apt-0.7.20.2-win/methods/https.cc
+--- apt-0.7.20.2/methods/https.cc	2009-02-07 17:09:35.000000000 +0200
++++ apt-0.7.20.2-win/methods/https.cc	2010-03-25 19:31:20.330609200 +0200
+@@ -61,7 +61,7 @@
+    URI ServerName = Queue->Uri;
+ 
+    // Determine the proxy setting
+-   if (getenv("http_proxy") == 0)
++   if (getenv("HTTP_PROXY") == 0)
+    {
+       string DefProxy = _config->Find("Acquire::http::Proxy");
+       string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+@@ -77,9 +77,9 @@
+    }
+    
+    // Parse no_proxy, a , separated list of domains
+-   if (getenv("no_proxy") != 0)
++   if (getenv("NO_PROXY") != 0)
+    {
+-      if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
++      if (CheckDomainList(ServerName.Host,getenv("NO_PROXY")) == true)
+ 	 Proxy = "";
+    }
+