=== modified file 'apt-pkg/contrib/netrc.cc'
--- apt-pkg/contrib/netrc.cc	2012-03-20 16:05:11 +0000
+++ apt-pkg/contrib/netrc.cc	2012-10-15 07:59:12 +0000
@@ -15,6 +15,7 @@
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 
 #include <iostream>
@@ -39,16 +40,16 @@
 };
 
 /* make sure we have room for at least this size: */
-#define LOGINSIZE 64
-#define PASSWORDSIZE 64
+#define LOGINSIZE 256
+#define PASSWORDSIZE 256
 #define NETRC DOT_CHAR "netrc"
 
 /* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
-int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
+static int parsenetrc_string (char *host, std::string &login, std::string &password, char *netrcfile = NULL)
 {
   FILE *file;
   int retcode = 1;
-  int specific_login = (login[0] != 0);
+  int specific_login = (login.empty() == false);
   char *home = NULL;
   bool netrc_alloc = false;
 
@@ -79,16 +80,17 @@
     char *tok;
     char *tok_buf;
     bool done = false;
-    char netrcbuffer[256];
+    char *netrcbuffer = NULL;
+    size_t netrcbuffer_size = 0;
 
     int state = NOTHING;
     char state_login = 0;        /* Found a login keyword */
     char state_password = 0;     /* Found a password keyword */
 
-    while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) {
+    while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) {
       tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
       while (!done && tok) {
-        if(login[0] && password[0]) {
+        if(login.empty() == false && password.empty() == false) {
           done = true;
           break;
         }
@@ -120,13 +122,13 @@
           /* we are now parsing sub-keywords concerning "our" host */
           if (state_login) {
             if (specific_login)
-              state_our_login = !strcasecmp (login, tok);
+              state_our_login = !strcasecmp (login.c_str(), tok);
             else
-              strncpy (login, tok, LOGINSIZE - 1);
+              login = tok;
             state_login = 0;
           } else if (state_password) {
             if (state_our_login || !specific_login)
-              strncpy (password, tok, PASSWORDSIZE - 1);
+              password = tok;
             state_password = 0;
           } else if (!strcasecmp ("login", tok))
             state_login = 1;
@@ -142,8 +144,9 @@
 
         tok = strtok_r (NULL, " \t\n", &tok_buf);
       } /* while(tok) */
-    } /* while fgets() */
+    } /* while getline() */
 
+    free(netrcbuffer);
     fclose(file);
   }
 
@@ -152,6 +155,18 @@
 
   return retcode;
 }
+// for some unknown reason this method is exported so keep a compatible interface for now …
+int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
+{
+   std::string login_string, password_string;
+   int const ret = parsenetrc_string(host, login_string, password_string, netrcfile);
+   if (ret < 0)
+      return ret;
+   strncpy(login, login_string.c_str(), LOGINSIZE - 1);
+   strncpy(password, password_string.c_str(), PASSWORDSIZE - 1);
+   return ret;
+}
+
 
 void maybe_add_auth (URI &Uri, string NetRCFile)
 {
@@ -162,21 +177,20 @@
   {
     if (NetRCFile.empty () == false)
     {
-      char login[64] = "";
-      char password[64] = "";
+       std::string login, password;
       char *netrcfile = strdup(NetRCFile.c_str());
 
       // first check for a generic host based netrc entry
       char *host = strdup(Uri.Host.c_str());
-      if (host && parsenetrc (host, login, password, netrcfile) == 0)
+      if (host && parsenetrc_string(host, login, password, netrcfile) == 0)
       {
 	 if (_config->FindB("Debug::Acquire::netrc", false) == true)
 	    std::clog << "host: " << host 
 		      << " user: " << login
-		      << " pass-size: " << strlen(password)
+		      << " pass-size: " << password.size()
 		      << std::endl;
-        Uri.User = string (login);
-        Uri.Password = string (password);
+        Uri.User = login;
+        Uri.Password = password;
 	free(netrcfile);
 	free(host);
 	return;
@@ -187,15 +201,15 @@
       // a lookup uri.startswith(host) in the netrc file parser (because
       // of the "/"
       char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
-      if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
+      if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0)
       {
 	 if (_config->FindB("Debug::Acquire::netrc", false) == true)
 	    std::clog << "hostpath: " << hostpath
 		      << " user: " << login
-		      << " pass-size: " << strlen(password)
+		      << " pass-size: " << password.size()
 		      << std::endl;
-	 Uri.User = string (login);
-	 Uri.Password = string (password);
+	 Uri.User = login;
+	 Uri.Password = password;
       }
       free(netrcfile);
       free(hostpath);

=== modified file 'apt-pkg/contrib/netrc.h'
--- apt-pkg/contrib/netrc.h	2011-12-13 00:22:38 +0000
+++ apt-pkg/contrib/netrc.h	2012-10-15 07:59:12 +0000
@@ -25,11 +25,9 @@
 
 class URI;
 
-// Assume: password[0]=0, host[0] != 0.
-// If login[0] = 0, search for login and password within a machine section
-// in the netrc.
-// If login[0] != 0, search for password within machine and login.
-int parsenetrc (char *host, char *login, char *password, char *filename);
+// kill this export on the next ABI break - strongly doubt its in use anyway
+// outside of the apt itself, its really a internal interface
+__deprecated int parsenetrc (char *host, char *login, char *password, char *filename);
 
 void maybe_add_auth (URI &Uri, std::string NetRCFile);
 #endif

=== modified file 'apt-pkg/depcache.cc'
--- apt-pkg/depcache.cc	2012-04-23 20:03:23 +0000
+++ apt-pkg/depcache.cc	2012-09-19 10:04:02 +0000
@@ -346,7 +346,7 @@
    /* Check simple depends. A depends -should- never self match but 
       we allow it anyhow because dpkg does. Technically it is a packaging
       bug. Conflicts may never self match */
-   if (Dep.TargetPkg() != Dep.ParentPkg() || Dep.IsNegative() == false)
+   if (Dep.IsIgnorable(Res) == false)
    {
       PkgIterator Pkg = Dep.TargetPkg();
       // Check the base package

=== modified file 'apt-pkg/edsp.cc'
--- apt-pkg/edsp.cc	2012-06-10 23:31:27 +0000
+++ apt-pkg/edsp.cc	2012-10-13 10:14:44 +0000
@@ -214,9 +214,11 @@
       if (Progress != NULL && p % 100 == 0)
          Progress->Progress(p);
       string* req;
-      if (Cache[Pkg].Delete() == true)
+      pkgDepCache::StateCache &P = Cache[Pkg];
+      if (P.Delete() == true)
 	 req = &del;
-      else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
+      else if (P.NewInstall() == true || P.Upgrade() == true || P.ReInstall() == true ||
+	       (P.Mode == pkgDepCache::ModeKeep && (P.iFlags & pkgDepCache::Protected) == pkgDepCache::Protected))
 	 req = &inst;
       else
 	 continue;

=== modified file 'apt-pkg/pkgcache.cc'
--- apt-pkg/pkgcache.cc	2012-09-09 14:03:52 +0000
+++ apt-pkg/pkgcache.cc	2012-09-19 10:04:02 +0000
@@ -690,8 +690,29 @@
    on virtual packages. */
 bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const
 {
-   if (ParentPkg() == TargetPkg())
-      return IsNegative();
+   if (IsNegative() == false)
+      return false;
+
+   pkgCache::PkgIterator PP = ParentPkg();
+   pkgCache::PkgIterator PT = TargetPkg();
+   if (PP->Group != PT->Group)
+      return false;
+   // self-conflict
+   if (PP == PT)
+      return true;
+   pkgCache::VerIterator PV = ParentVer();
+   // ignore group-conflict on a M-A:same package - but not our implicit dependencies
+   // so that we can have M-A:same packages conflicting with their own real name
+   if ((PV->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
+   {
+      // Replaces: ${self}:other ( << ${binary:Version})
+      if (S->Type == pkgCache::Dep::Replaces && S->CompareOp == pkgCache::Dep::Less && strcmp(PV.VerStr(), TargetVer()) == 0)
+	 return false;
+      // Breaks: ${self}:other (!= ${binary:Version})
+      if (S->Type == pkgCache::Dep::DpkgBreaks && S->CompareOp == pkgCache::Dep::NotEquals && strcmp(PV.VerStr(), TargetVer()) == 0)
+	 return false;
+      return true;
+   }
 
    return false;
 }

=== modified file 'apt-pkg/pkgcachegen.cc'
--- apt-pkg/pkgcachegen.cc	2012-09-09 19:22:54 +0000
+++ apt-pkg/pkgcachegen.cc	2012-10-15 14:00:44 +0000
@@ -69,7 +69,9 @@
       *Cache.HeaderP = pkgCache::Header();
       map_ptrloc const idxVerSysName = WriteStringInMap(_system->VS->Label);
       Cache.HeaderP->VerSysName = idxVerSysName;
-      map_ptrloc const idxArchitecture = WriteStringInMap(_config->Find("APT::Architecture"));
+      // this pointer is set in ReMap, but we need it now for WriteUniqString
+      Cache.StringItemP = (pkgCache::StringItem *)Map.Data();
+      map_ptrloc const idxArchitecture = WriteUniqString(_config->Find("APT::Architecture"));
       Cache.HeaderP->Architecture = idxArchitecture;
       if (unlikely(idxVerSysName == 0 || idxArchitecture == 0))
 	 return;
@@ -209,6 +211,7 @@
 	    just for these :none packages to a proper MultiArchCache, so just ensure
 	    that we have always a native package structure first for SingleArch */
 	 pkgCache::PkgIterator NP;
+	 Dynamic<pkgCache::PkgIterator> DynPkg(NP);
 	 if (NewPackage(NP, PackageName, _config->Find("APT::Architecture")) == false)
 	 // TRANSLATOR: The first placeholder is a package name,
 	 // the other two should be copied verbatim as they include debug info
@@ -459,6 +462,7 @@
 
 	       map_ptrloc *OldDepLast = NULL;
 	       pkgCache::VerIterator ConVersion = D.ParentVer();
+	       Dynamic<pkgCache::VerIterator> DynV(ConVersion);
 	       // duplicate the Conflicts/Breaks/Replaces for :none arch
 	       if (D->Version == 0)
 		  NewDepends(Pkg, ConVersion, "", 0, D->Type, OldDepLast);
@@ -772,6 +776,7 @@
    
    // Fill it in
    Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
+   //Dynamic<pkgCache::VerIterator> DynV(Ver); // caller MergeListVersion already takes care of it
    Ver->NextVer = Next;
    Ver->ID = Cache.HeaderP->VersionCount++;
    map_ptrloc const idxVerStr = WriteStringInMap(VerStr);
@@ -922,7 +927,7 @@
    // Locate the target package
    pkgCache::PkgIterator Pkg = Grp.FindPkg(Arch);
    // we don't create 'none' packages and their dependencies if we can avoid it …
-   if (Pkg.end() == true && Arch == "none")
+   if (Pkg.end() == true && Arch == "none" && strcmp(Ver.ParentPkg().Arch(), "none") != 0)
       return true;
    Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
    if (Pkg.end() == true) {
@@ -970,8 +975,12 @@
    Prv->Version = Ver.Index();
    Prv->NextPkgProv = Ver->ProvidesList;
    Ver->ProvidesList = Prv.Index();
-   if (Version.empty() == false && unlikely((Prv->ProvideVersion = WriteString(Version)) == 0))
-      return false;
+   if (Version.empty() == false) {
+      map_ptrloc const idxProvideVersion = WriteString(Version);
+      Prv->ProvideVersion = idxProvideVersion;
+      if (unlikely(idxProvideVersion == 0))
+	 return false;
+   }
    
    // Locate the target package
    pkgCache::PkgIterator Pkg;

=== modified file 'apt-pkg/policy.cc'
--- apt-pkg/policy.cc	2011-10-30 18:48:05 +0000
+++ apt-pkg/policy.cc	2012-10-13 11:18:29 +0000
@@ -27,6 +27,7 @@
 
 #include <apt-pkg/policy.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/cachefilter.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
@@ -259,17 +260,33 @@
    }
 
    // find the package (group) this pin applies to
-   pkgCache::GrpIterator Grp;
-   pkgCache::PkgIterator Pkg;
-   if (Arch.empty() == false)
-      Pkg = Cache->FindPkg(Name, Arch);
-   else {
-      Grp = Cache->FindGrp(Name);
-      if (Grp.end() == false)
-	 Pkg = Grp.PackageList();
+   pkgCache::GrpIterator Grp = Cache->FindGrp(Name);
+   bool matched = false;
+   if (Grp.end() == false)
+   {
+      std::string MatchingArch;
+      if (Arch.empty() == true)
+	 MatchingArch = Cache->NativeArch();
+      else
+	 MatchingArch = Arch;
+      APT::CacheFilter::PackageArchitectureMatchesSpecification pams(MatchingArch);
+      for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
+      {
+	 if (pams(Pkg.Arch()) == false)
+	    continue;
+	 Pin *P = Pins + Pkg->ID;
+	 // the first specific stanza for a package is the ruler,
+	 // all others need to be ignored
+	 if (P->Type != pkgVersionMatch::None)
+	    P = &*Unmatched.insert(Unmatched.end(),PkgPin(Pkg.FullName()));
+	 P->Type = Type;
+	 P->Priority = Priority;
+	 P->Data = Data;
+	 matched = true;
+      }
    }
 
-   if (Pkg.end() == true)
+   if (matched == false)
    {
       PkgPin *P = &*Unmatched.insert(Unmatched.end(),PkgPin(Name));
       if (Arch.empty() == false)
@@ -279,20 +296,6 @@
       P->Data = Data;
       return;
    }
-
-   for (; Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
-   {
-      Pin *P = Pins + Pkg->ID;
-      // the first specific stanza for a package is the ruler,
-      // all others need to be ignored
-      if (P->Type != pkgVersionMatch::None)
-	 P = &*Unmatched.insert(Unmatched.end(),PkgPin(Pkg.FullName()));
-      P->Type = Type;
-      P->Priority = Priority;
-      P->Data = Data;
-      if (Grp.end() == true)
-	 break;
-   }
 }
 									/*}}}*/
 // Policy::GetMatch - Get the matching version for a package pin	/*{{{*/

=== modified file 'cmdline/apt-cache.cc'
--- cmdline/apt-cache.cc	2012-03-21 23:16:11 +0000
+++ cmdline/apt-cache.cc	2012-09-26 19:34:49 +0000
@@ -597,6 +597,7 @@
    bool const Installed = _config->FindB("APT::Cache::Installed", false);
    bool const Important = _config->FindB("APT::Cache::Important", false);
    bool const ShowDepType = _config->FindB("APT::Cache::ShowDependencyType", RevDepends == false);
+   bool const ShowVersion = _config->FindB("APT::Cache::ShowVersion", false);
    bool const ShowPreDepends = _config->FindB("APT::Cache::ShowPre-Depends", true);
    bool const ShowDepends = _config->FindB("APT::Cache::ShowDepends", true);
    bool const ShowRecommends = _config->FindB("APT::Cache::ShowRecommends", Important == false);
@@ -646,10 +647,13 @@
 		if (ShowDepType == true)
 		  cout << D.DepType() << ": ";
 		if (Trg->VersionList == 0)
-		  cout << "<" << Trg.FullName(true) << ">" << endl;
+		  cout << "<" << Trg.FullName(true) << ">";
 		else
-		  cout << Trg.FullName(true) << endl;
-	    
+		  cout << Trg.FullName(true);
+		if (ShowVersion == true && D->Version != 0)
+		   cout << " (" << pkgCache::CompTypeDeb(D->CompareOp) << ' ' << D.TargetVer() << ')';
+		cout << std::endl;
+
 		if (Recurse == true && Shown[Trg->ID] == false)
 		{
 		  Shown[Trg->ID] = true;

=== modified file 'configure.in'
--- configure.in	2012-09-11 16:07:34 +0000
+++ configure.in	2012-10-16 16:29:59 +0000
@@ -18,7 +18,7 @@
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 PACKAGE="apt"
-PACKAGE_VERSION="0.9.7.5"
+PACKAGE_VERSION="0.9.7.6"
 PACKAGE_MAIL="APT Development Team <deity@lists.debian.org>"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"$PACKAGE_VERSION")

=== modified file 'debian/changelog'
--- debian/changelog	2012-09-11 16:07:34 +0000
+++ debian/changelog	2012-10-16 16:29:59 +0000
@@ -1,3 +1,41 @@
+apt (0.9.7.6) unstable; urgency=low
+
+  [ Program translation updates ]
+  * Ukrainian (A. Bondarenko)
+
+  [ David Kalnischkies ]
+  * apt-pkg/pkgcachegen.cc:
+    - ensure that dependencies for packages:none are always generated
+    - add 2 missing remap registrations causing a segfault in case
+      we use the not remapped iterators after a move of the mmap again
+    - write the native architecture as unique string into the cache header
+      as it is used for arch:all packages as a map to arch:native.
+      Otherwise arch comparisons later will see differences (Closes: #689323)
+  * apt-pkg/pkgcache.cc:
+    - ignore negative dependencies applying in the same group for M-A:same
+      packages on the real package name as self-conflicts (Closes: #688863)
+  * cmdline/apt-cache.cc:
+    - print versioned dependency relations in (r)depends if the option
+      APT::Cache::ShowVersion is true (default: false) as discussed in
+      #218995 to help debian-cd fixing #687949. Thanks to Sam Lidder
+      for initial patch and Steve McIntyre for nagging and testing!
+  * apt-pkg/edsp.cc:
+    - include reinstall requests and already installed (= protected) packages
+      in the install-request for external resolvers (Closes: #689331)
+  * apt-pkg/policy.cc:
+    - match pins with(out) an architecture as we do on the commandline
+      (partly fixing #687255, b= support has to wait for jessie)
+  * apt-pkg/contrib/netrc.cc:
+    - remove the 64 char limit for login/password in internal usage
+    - remove 256 char line limit by using getline() (POSIX.1-2008)
+  
+  [ Colin Watson ]
+  * apt-pkg/pkgcachegen.cc:
+    - Fix crash if the cache is remapped while writing a Provides version
+      (LP: #1066445).
+
+ -- Michael Vogt <mvo@debian.org>  Tue, 16 Oct 2012 18:08:53 +0200
+
 apt (0.9.7.5) unstable; urgency=low
 
   [ Manpages translation updates ]

=== modified file 'doc/apt-verbatim.ent'
--- doc/apt-verbatim.ent	2012-09-11 16:07:34 +0000
+++ doc/apt-verbatim.ent	2012-10-16 16:29:59 +0000
@@ -213,7 +213,7 @@
 ">
 
 <!-- this will be updated by 'prepare-release' -->
-<!ENTITY apt-product-version "0.9.7.5">
+<!ENTITY apt-product-version "0.9.7.6">
 
 <!-- Codenames for debian releases -->
 <!ENTITY oldstable-codename "squeeze">

=== modified file 'test/integration/test-bug-686346-package-missing-architecture'
--- test/integration/test-bug-686346-package-missing-architecture	2012-09-09 14:03:52 +0000
+++ test/integration/test-bug-686346-package-missing-architecture	2012-09-19 09:35:53 +0000
@@ -85,3 +85,25 @@
  pkgg : Conflicts: pkgb but 2 is installed
         Conflicts: pkgb:none but 1 is installed
 E: Unmet dependencies. Try using -f." aptget check
+
+# check that dependencies are generated for none-packages
+rm rootdir/var/lib/dpkg/status
+insertinstalledpackage 'pkgx' 'none' '1'
+insertinstalledpackage 'pkgy' 'none' '1' 'Depends: pkgz, pkgx (>= 1)'
+insertinstalledpackage 'pkgz' 'none' '1'
+testequal 'Reading package lists...
+Building dependency tree...
+Reading state information...
+The following packages will be REMOVED:
+  pkgx:none* pkgy:none*
+0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
+Purg pkgy:none [1]
+Purg pkgx:none [1]' aptget purge pkgx -s
+testequal 'Reading package lists...
+Building dependency tree...
+Reading state information...
+The following packages will be REMOVED:
+  pkgy:none* pkgz:none*
+0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
+Purg pkgy:none [1]
+Purg pkgz:none [1]' aptget purge pkgz -s

=== added file 'test/integration/test-conflicts-real-multiarch-same'
--- test/integration/test-conflicts-real-multiarch-same	1970-01-01 00:00:00 +0000
+++ test/integration/test-conflicts-real-multiarch-same	2012-09-19 10:04:02 +0000
@@ -0,0 +1,50 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable' 'virtual-provider' 'amd64,i386' '2' 'Provides: virtual
+Conflicts: virtual
+Multi-Arch: same'
+insertpackage 'unstable' 'real' 'amd64,i386' '2' 'Conflicts: real
+Multi-Arch: same'
+insertpackage 'unstable' 'real-provider' 'amd64,i386' '2' 'Provides: real-provider
+Conflicts: real-provider
+Multi-Arch: same'
+setupaptarchive
+
+testequal "Reading package lists...
+Building dependency tree...
+Note, selecting 'virtual-provider' instead of 'virtual'
+Note, selecting 'virtual-provider:i386' instead of 'virtual:i386'
+The following NEW packages will be installed:
+  virtual-provider virtual-provider:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst virtual-provider (2 unstable [amd64])
+Inst virtual-provider:i386 (2 unstable [i386])
+Conf virtual-provider (2 unstable [amd64])
+Conf virtual-provider:i386 (2 unstable [i386])" aptget install virtual:* -s -q=0
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  real real:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst real (2 unstable [amd64])
+Inst real:i386 (2 unstable [i386])
+Conf real (2 unstable [amd64])
+Conf real:i386 (2 unstable [i386])' aptget install real:* -s -q=0
+
+# ensure that we are not confused by the provides
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  real-provider real-provider:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst real-provider (2 unstable [amd64])
+Inst real-provider:i386 (2 unstable [i386])
+Conf real-provider (2 unstable [amd64])
+Conf real-provider:i386 (2 unstable [i386])' aptget install real-provider:* -s -q=0

