Просмотр исходного кода

merged from lp:~donkult/apt/experimental/

Michael Vogt лет назад: 14
Родитель
Сommit
c7ed2c0e34

+ 16 - 17
apt-pkg/algorithms.cc

@@ -475,7 +475,7 @@ pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : Cache(*pCache)
 {
    // Allocate memory
    unsigned long Size = Cache.Head().PackageCount;
-   Scores = new signed short[Size];
+   Scores = new int[Size];
    Flags = new unsigned char[Size];
    memset(Flags,0,sizeof(*Flags)*Size);
    
@@ -515,20 +515,20 @@ void pkgProblemResolver::MakeScores()
    memset(Scores,0,sizeof(*Scores)*Size);
 
    // Important Required Standard Optional Extra
-   signed short PrioMap[] = {
+   int PrioMap[] = {
       0,
-      (signed short) _config->FindI("pkgProblemResolver::Scores::Important",3),
-      (signed short) _config->FindI("pkgProblemResolver::Scores::Required",2),
-      (signed short) _config->FindI("pkgProblemResolver::Scores::Standard",1),
-      (signed short) _config->FindI("pkgProblemResolver::Scores::Optional",-1),
-      (signed short) _config->FindI("pkgProblemResolver::Scores::Extra",-2)
+      _config->FindI("pkgProblemResolver::Scores::Important",3),
+      _config->FindI("pkgProblemResolver::Scores::Required",2),
+      _config->FindI("pkgProblemResolver::Scores::Standard",1),
+      _config->FindI("pkgProblemResolver::Scores::Optional",-1),
+      _config->FindI("pkgProblemResolver::Scores::Extra",-2)
    };
-   signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
-   signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
-   signed short PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
-   signed short PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
-   signed short AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
-   signed short AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
+   int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
+   int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
+   int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
+   int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
+   int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
+   int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
 
    if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true)
       clog << "Settings used to calculate pkgProblemResolver::Scores::" << endl
@@ -550,7 +550,7 @@ void pkgProblemResolver::MakeScores()
       if (Cache[I].InstallVer == 0)
 	 continue;
       
-      signed short &Score = Scores[I->ID];
+      int &Score = Scores[I->ID];
       
       /* This is arbitrary, it should be high enough to elevate an
          essantial package above most other packages but low enough
@@ -588,7 +588,7 @@ void pkgProblemResolver::MakeScores()
    }   
    
    // Copy the scores to advoid additive looping
-   SPtrArray<signed short> OldScores = new signed short[Size];
+   SPtrArray<int> OldScores = new int[Size];
    memcpy(OldScores,Scores,sizeof(*Scores)*Size);
       
    /* Now we cause 1 level of dependency inheritance, that is we add the 
@@ -1098,8 +1098,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
 		  LEnd->Dep = End;
 		  LEnd++;
 		  
-		  if (Start->Type != pkgCache::Dep::Conflicts &&
-		      Start->Type != pkgCache::Dep::Obsoletes)
+		  if (Start.IsNegative() == false)
 		     break;
 	       }
 	    }

+ 1 - 1
apt-pkg/algorithms.h

@@ -96,7 +96,7 @@ class pkgProblemResolver						/*{{{*/
    enum Flags {Protected = (1 << 0), PreInstalled = (1 << 1),
                Upgradable = (1 << 2), ReInstateTried = (1 << 3),
                ToRemove = (1 << 4)};
-   signed short *Scores;
+   int *Scores;
    unsigned char *Flags;
    bool Debug;
    

+ 57 - 8
apt-pkg/aptconfiguration.cc

@@ -20,6 +20,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <stdio.h>
+#include <fcntl.h>
 
 #include <algorithm>
 #include <string>
@@ -328,13 +329,60 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
 	// FIXME: It is a bit unclean to have debian specific code here…
 	if (archs.empty() == true) {
 		archs.push_back(arch);
-		string dpkgcall = _config->Find("Dir::Bin::dpkg", "dpkg");
-		std::vector<string> const dpkgoptions = _config->FindVector("DPkg::options");
-		for (std::vector<string>::const_iterator o = dpkgoptions.begin();
-		     o != dpkgoptions.end(); ++o)
-			dpkgcall.append(" ").append(*o);
-		dpkgcall.append(" --print-foreign-architectures 2> /dev/null");
-		FILE *dpkg = popen(dpkgcall.c_str(), "r");
+
+		// Generate the base argument list for dpkg
+		std::vector<const char *> Args;
+		string Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+		{
+			string const dpkgChrootDir = _config->FindDir("DPkg::Chroot-Directory", "/");
+			size_t dpkgChrootLen = dpkgChrootDir.length();
+			if (dpkgChrootDir != "/" && Tmp.find(dpkgChrootDir) == 0) {
+				if (dpkgChrootDir[dpkgChrootLen - 1] == '/')
+					--dpkgChrootLen;
+				Tmp = Tmp.substr(dpkgChrootLen);
+			}
+		}
+		Args.push_back(Tmp.c_str());
+
+		// Stick in any custom dpkg options
+		::Configuration::Item const *Opts = _config->Tree("DPkg::Options");
+		if (Opts != 0) {
+			Opts = Opts->Child;
+			for (; Opts != 0; Opts = Opts->Next)
+			{
+				if (Opts->Value.empty() == true)
+					continue;
+				Args.push_back(Opts->Value.c_str());
+			}
+		}
+
+		Args.push_back("--print-foreign-architectures");
+		Args.push_back(NULL);
+
+		int external[2] = {-1, -1};
+		if (pipe(external) != 0)
+		{
+			_error->WarningE("getArchitecture", "Can't create IPC pipe for dpkg --print-foreign-architectures");
+			return archs;
+		}
+
+		pid_t dpkgMultiArch = ExecFork();
+		if (dpkgMultiArch == 0) {
+			close(external[0]);
+			std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory");
+			if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0)
+				_error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str());
+			int const nullfd = open("/dev/null", O_RDONLY);
+			dup2(nullfd, STDIN_FILENO);
+			dup2(external[1], STDOUT_FILENO);
+			dup2(nullfd, STDERR_FILENO);
+			execv(Args[0], (char**) &Args[0]);
+			_error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!");
+			_exit(100);
+		}
+		close(external[1]);
+
+		FILE *dpkg = fdopen(external[0], "r");
 		char buf[1024];
 		if(dpkg != NULL) {
 			while (fgets(buf, sizeof(buf), dpkg) != NULL) {
@@ -349,8 +397,9 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
 					arch = strtok(NULL, " ");
 				}
 			}
-			pclose(dpkg);
+			fclose(dpkg);
 		}
+		ExecWait(dpkgMultiArch, "dpkg --print-foreign-architectures", true);
 		return archs;
 	}
 

+ 8 - 2
apt-pkg/contrib/configuration.cc

@@ -185,8 +185,14 @@ string Configuration::FindFile(const char *Name,const char *Default) const
    }
    
    string val = Itm->Value;
-   while (Itm->Parent != 0 && Itm->Parent->Value.empty() == false)
-   {	 
+   while (Itm->Parent != 0)
+   {
+      if (Itm->Parent->Value.empty() == true)
+      {
+	 Itm = Itm->Parent;
+	 continue;
+      }
+
       // Absolute
       if (val.length() >= 1 && val[0] == '/')
          break;

+ 26 - 18
apt-pkg/deb/dpkgpm.cc

@@ -123,6 +123,18 @@ ionice(int PID)
    return ExecWait(Process, "ionice");
 }
 
+// dpkgChrootDirectory - chrooting for dpkg if needed			/*{{{*/
+static void dpkgChrootDirectory()
+{
+   std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory");
+   if (chrootDir == "/")
+      return;
+   std::cerr << "Chrooting into " << chrootDir << std::endl;
+   if (chroot(chrootDir.c_str()) != 0)
+      _exit(100);
+}
+									/*}}}*/
+
 // DPkgPM::pkgDPkgPM - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -328,15 +340,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
 	 SetCloseExec(STDIN_FILENO,false);      
 	 SetCloseExec(STDERR_FILENO,false);
 
-	 if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") 
-	 {
-	    std::cerr << "Chrooting into " 
-		      << _config->FindDir("DPkg::Chroot-Directory") 
-		      << std::endl;
-	    if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0)
-	       _exit(100);
-	 }
-
+	 dpkgChrootDirectory();
 	 const char *Args[4];
 	 Args[0] = "/bin/sh";
 	 Args[1] = "-c";
@@ -832,7 +836,17 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    // Generate the base argument list for dpkg
    std::vector<const char *> Args;
    unsigned long StartSize = 0;
-   string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+   string Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+   {
+      string const dpkgChrootDir = _config->FindDir("DPkg::Chroot-Directory", "/");
+      size_t dpkgChrootLen = dpkgChrootDir.length();
+      if (dpkgChrootDir != "/" && Tmp.find(dpkgChrootDir) == 0)
+      {
+	 if (dpkgChrootDir[dpkgChrootLen - 1] == '/')
+	    --dpkgChrootLen;
+	 Tmp = Tmp.substr(dpkgChrootLen);
+      }
+   }
    Args.push_back(Tmp.c_str());
    StartSize += Tmp.length();
 
@@ -858,6 +872,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    pid_t dpkgAssertMultiArch = ExecFork();
    if (dpkgAssertMultiArch == 0)
    {
+      dpkgChrootDirectory();
       // redirect everything to the ultimate sink as we only need the exit-status
       int const nullfd = open("/dev/null", O_RDONLY);
       dup2(nullfd, STDIN_FILENO);
@@ -1202,14 +1217,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	 }
 	 close(fd[0]); // close the read end of the pipe
 
-	 if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") 
-	 {
-	    std::cerr << "Chrooting into " 
-		      << _config->FindDir("DPkg::Chroot-Directory") 
-		      << std::endl;
-	    if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0)
-	       _exit(100);
-	 }
+	 dpkgChrootDirectory();
 
 	 if (chdir(_config->FindDir("DPkg::Run-Directory","/").c_str()) != 0)
 	    _exit(100);

+ 28 - 11
apt-pkg/depcache.cc

@@ -1240,19 +1240,36 @@ void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
    if (unlikely(Pkg.end() == true))
       return;
 
+   APT::PackageList pkglist;
+   if (Pkg->CurrentVer != 0 &&
+       (Pkg.CurrentVer()-> MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
+   {
+      pkgCache::GrpIterator Grp = Pkg.Group();
+      for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P))
+      {
+	 if (P->CurrentVer != 0)
+	    pkglist.insert(P);
+      }
+   }
+   else
+      pkglist.insert(Pkg);
+
    ActionGroup group(*this);
 
-   RemoveSizes(Pkg);
-   RemoveStates(Pkg);
-   
-   StateCache &P = PkgState[Pkg->ID];
-   if (To == true)
-      P.iFlags |= ReInstall;
-   else
-      P.iFlags &= ~ReInstall;
-   
-   AddStates(Pkg);
-   AddSizes(Pkg);
+   for (APT::PackageList::const_iterator Pkg = pkglist.begin(); Pkg != pkglist.end(); ++Pkg)
+   {
+      RemoveSizes(Pkg);
+      RemoveStates(Pkg);
+
+      StateCache &P = PkgState[Pkg->ID];
+      if (To == true)
+	 P.iFlags |= ReInstall;
+      else
+	 P.iFlags &= ~ReInstall;
+
+      AddStates(Pkg);
+      AddSizes(Pkg);
+   }
 }
 									/*}}}*/
 // DepCache::SetCandidateVersion - Change the candidate version		/*{{{*/

+ 8 - 2
cmdline/apt-get.cc

@@ -2863,10 +2863,16 @@ bool DoBuildDep(CommandLine &CmdL)
 	       if ((BADVER(Ver)) == false)
 	       {
 		  string forbidden;
-		  if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All);
+		  if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All)
+		  {
+		     if (colon == string::npos)
+		     {
+			Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
+		     }
+		  }
 		  else if (Ver->MultiArch == pkgCache::Version::Same)
 		  {
-		     if (colon != string::npos)
+		     if (colon == string::npos)
 			Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
 		     else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
 			forbidden = "Multi-Arch: same";

+ 32 - 0
debian/changelog

@@ -1,3 +1,35 @@
+apt (0.8.16~exp13) UNRELEASED; urgency=low
+
+  [ David Kalnischkies ]
+  * apt-pkg/deb/dpkgpm.cc:
+    - chroot if needed before dpkg --assert-multi-arch
+    - ensure that dpkg binary doesn't have the chroot-directory prefixed
+  * apt-pkg/depcache.cc:
+    - if a M-A:same package is marked for reinstall, mark all it's installed
+      silbings for reinstallation as well (LP: #859188)
+  * apt-pkg/contrib/configuration.cc:
+    - do not stop parent transversal in FindDir if the value is empty
+  * methods/http{s,}.cc:
+    - if a file without an extension is requested send an 'Accept: text/*'
+      header to avoid that the server chooses unsupported compressed files
+      in a content-negotation attempt (Closes: #657560)
+  * apt-pkg/aptconfiguration.cc:
+    - chroot if needed before calling dpkg --print-foreign-architectures
+
+  [ Steve Langasek ]
+  * cmdline/apt-get.cc:
+    - for cross-build-dependencies M-A: none should be DEB_HOST_ARCH,
+      not DEB_BUILD_ARCH (Closes: #646288)
+
+  [ Colin Watson ]
+  * apt-pkg/algorithms.cc:
+    - don't break out of the main-resolver loop for Breaks to deal with all
+      of them in a single iteration (Closes: #657695, LP: #922485)
+    - use a signed int instead of short for score calculation as upgrades
+      become so big now that it can overflow (Closes: #657732, LP: #917173)
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 30 Jan 2012 19:17:09 +0100
+
 apt (0.8.16~exp12) experimental; urgency=low
 
   [ Michael Vogt ]

+ 13 - 1
methods/http.cc

@@ -716,7 +716,19 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
       }
    }
 
-   
+   // If we ask for uncompressed files servers might respond with content-
+   // negotation which lets us end up with compressed files we do not support,
+   // see 657029, 657560 and co, so if we have no extension on the request
+   // ask for text only. As a sidenote: If there is nothing to negotate servers
+   // seem to be nice and ignore it.
+   if (_config->FindB("Acquire::http::SendAccept", true) == true)
+   {
+      size_t const filepos = Itm->Uri.find_last_of('/');
+      string const file = Itm->Uri.substr(filepos + 1);
+      if (flExtension(file) == file)
+	 strcat(Buf,"Accept: text/*\r\n");
+   }
+
    string Req = Buf;
 
    // Check for a partial file

+ 13 - 0
methods/https.cc

@@ -242,6 +242,19 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
    // error handling
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
 
+   // If we ask for uncompressed files servers might respond with content-
+   // negotation which lets us end up with compressed files we do not support,
+   // see 657029, 657560 and co, so if we have no extension on the request
+   // ask for text only. As a sidenote: If there is nothing to negotate servers
+   // seem to be nice and ignore it.
+   if (_config->FindB("Acquire::https::SendAccept", _config->FindB("Acquire::http::SendAccept", true)) == true)
+   {
+      size_t const filepos = Itm->Uri.find_last_of('/');
+      string const file = Itm->Uri.substr(filepos + 1);
+      if (flExtension(file) == file)
+	 headers = curl_slist_append(headers, "Accept: text/*");
+   }
+
    // if we have the file send an if-range query with a range header
    if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
    {

+ 63 - 24
test/integration/test-bug-632221-cross-dependency-satisfaction

@@ -6,43 +6,51 @@ TESTDIR=$(readlink -f $(dirname $0))
 setupenvironment
 configarchitecture 'amd64' 'armel'
 
-insertinstalledpackage 'build-essential' 'all' '11.5'
+insertinstalledpackage 'build-essential' 'all' '11.5' 'Multi-Arch: foreign'
 
-insertpackage 'unstable' 'doxygen' 'amd64,armel' '1.0'
+insertpackage 'unstable' 'doxygen' 'amd64,armel' '1.0' 'Multi-Arch: foreign'
 insertpackage 'unstable' 'libc6' 'amd64,armel' '1.0' 'Multi-Arch: same'
 insertpackage 'unstable' 'libc6-dev' 'amd64,armel' '1.0' 'Depends: libc6
 Multi-Arch: same'
+insertpackage 'unstable' 'libfwibble1' 'amd64,armel' '1.0' 'Depends: libc6
+Multi-Arch: same'
+insertpackage 'unstable' 'libfwibble-dev' 'amd64,armel' '1.0' 'Depends: libfwibble1'
 insertpackage 'unstable' 'cool' 'amd64,armel' '1.0' 'Multi-Arch: allowed'
 insertpackage 'unstable' 'amdboot' 'amd64' '1.0'
 insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign'
 
-insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner'
+insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev'
 
 setupaptarchive
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
-  amdboot cool doxygen foreigner libc6 libc6-dev
-0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
+  amdboot cool doxygen foreigner libc6 libc6-dev libfwibble-dev libfwibble1
+0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
 Inst amdboot (1.0 unstable [amd64])
 Inst cool (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst foreigner (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [amd64])
+Inst libfwibble1 (1.0 unstable [amd64])
+Inst libfwibble-dev (1.0 unstable [amd64])
 Conf amdboot (1.0 unstable [amd64])
 Conf cool (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf foreigner (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
-Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+Conf libc6-dev (1.0 unstable [amd64])
+Conf libfwibble1 (1.0 unstable [amd64])
+Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
   amdboot cool doxygen foreigner libc6 libc6:armel libc6-dev libc6-dev:armel
-0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+  libfwibble-dev:armel libfwibble1:armel
+0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
 Inst amdboot (1.0 unstable [amd64])
 Inst cool (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
@@ -51,6 +59,8 @@ Inst libc6 (1.0 unstable [amd64])
 Inst libc6:armel (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [amd64])
 Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libfwibble1:armel (1.0 unstable [armel])
+Inst libfwibble-dev:armel (1.0 unstable [armel])
 Conf amdboot (1.0 unstable [amd64])
 Conf cool (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
@@ -58,34 +68,41 @@ Conf foreigner (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
 Conf libc6:armel (1.0 unstable [armel])
 Conf libc6-dev (1.0 unstable [amd64])
-Conf libc6-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
+Conf libc6-dev:armel (1.0 unstable [armel])
+Conf libfwibble1:armel (1.0 unstable [armel])
+Conf libfwibble-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
 
 configarchitecture 'armel' 'amd64'
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
-  amdboot:amd64 cool doxygen foreigner libc6 libc6-dev
-0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
+  amdboot:amd64 cool doxygen foreigner libc6 libc6-dev libfwibble-dev
+  libfwibble1
+0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst cool (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
 Inst foreigner (1.0 unstable [armel])
 Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [armel])
+Inst libfwibble1 (1.0 unstable [armel])
+Inst libfwibble-dev (1.0 unstable [armel])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf cool (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
 Conf foreigner (1.0 unstable [armel])
 Conf libc6 (1.0 unstable [armel])
-Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s
+Conf libc6-dev (1.0 unstable [armel])
+Conf libfwibble1 (1.0 unstable [armel])
+Conf libfwibble-dev (1.0 unstable [armel])' aptget build-dep apt -s
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
   amdboot:amd64 cool doxygen foreigner libc6:amd64 libc6 libc6-dev:amd64
-  libc6-dev
-0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+  libc6-dev libfwibble-dev:amd64 libfwibble1:amd64
+0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst cool (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
@@ -94,6 +111,8 @@ Inst libc6:amd64 (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [armel])
+Inst libfwibble1:amd64 (1.0 unstable [amd64])
+Inst libfwibble-dev:amd64 (1.0 unstable [amd64])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf cool (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
@@ -101,7 +120,9 @@ Conf foreigner (1.0 unstable [armel])
 Conf libc6:amd64 (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [armel])
 Conf libc6-dev:amd64 (1.0 unstable [amd64])
-Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s -a amd64
+Conf libc6-dev (1.0 unstable [armel])
+Conf libfwibble1:amd64 (1.0 unstable [amd64])
+Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
 
 configarchitecture 'amd64' 'armel'
 
@@ -111,34 +132,43 @@ insertinstalledpackage 'foreigner' 'armel' '0.5'
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
-  amdboot doxygen libc6 libc6-dev
-0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.
+  amdboot doxygen libc6 libc6-dev libfwibble-dev libfwibble1
+0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
 Inst amdboot (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [amd64])
+Inst libfwibble1 (1.0 unstable [amd64])
+Inst libfwibble-dev (1.0 unstable [amd64])
 Conf amdboot (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
-Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+Conf libc6-dev (1.0 unstable [amd64])
+Conf libfwibble1 (1.0 unstable [amd64])
+Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
   amdboot doxygen libc6 libc6:armel libc6-dev libc6-dev:armel
-0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
+  libfwibble-dev:armel libfwibble1:armel
+0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded.
 Inst amdboot (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [amd64])
 Inst libc6:armel (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [amd64])
 Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libfwibble1:armel (1.0 unstable [armel])
+Inst libfwibble-dev:armel (1.0 unstable [armel])
 Conf amdboot (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
 Conf libc6:armel (1.0 unstable [armel])
 Conf libc6-dev (1.0 unstable [amd64])
-Conf libc6-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
+Conf libc6-dev:armel (1.0 unstable [armel])
+Conf libfwibble1:armel (1.0 unstable [armel])
+Conf libfwibble-dev:armel (1.0 unstable [armel])' aptget build-dep apt -s -a armel
 
 configarchitecture 'armel' 'amd64'
 
@@ -148,36 +178,45 @@ Building dependency tree...
 The following packages will be REMOVED:
   cool:amd64
 The following NEW packages will be installed:
-  amdboot:amd64 cool doxygen libc6 libc6-dev
-0 upgraded, 5 newly installed, 1 to remove and 1 not upgraded.
+  amdboot:amd64 cool doxygen libc6 libc6-dev libfwibble-dev libfwibble1
+0 upgraded, 7 newly installed, 1 to remove and 1 not upgraded.
 Remv cool:amd64 [0.5]
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst cool (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
 Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [armel])
+Inst libfwibble1 (1.0 unstable [armel])
+Inst libfwibble-dev (1.0 unstable [armel])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf cool (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
 Conf libc6 (1.0 unstable [armel])
-Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s
+Conf libc6-dev (1.0 unstable [armel])
+Conf libfwibble1 (1.0 unstable [armel])
+Conf libfwibble-dev (1.0 unstable [armel])' aptget build-dep apt -s
 
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed:
   amdboot:amd64 doxygen libc6:amd64 libc6 libc6-dev:amd64 libc6-dev
-0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
+  libfwibble-dev:amd64 libfwibble1:amd64
+0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded.
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [armel])
 Inst libc6:amd64 (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [armel])
+Inst libfwibble1:amd64 (1.0 unstable [amd64])
+Inst libfwibble-dev:amd64 (1.0 unstable [amd64])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [armel])
 Conf libc6:amd64 (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [armel])
 Conf libc6-dev:amd64 (1.0 unstable [amd64])
-Conf libc6-dev (1.0 unstable [armel])' aptget build-dep apt -s -a amd64
+Conf libc6-dev (1.0 unstable [armel])
+Conf libfwibble1:amd64 (1.0 unstable [amd64])
+Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
 
 

+ 51 - 0
test/integration/test-bug-657695-resolver-breaks-on-virtuals

@@ -0,0 +1,51 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'xserver-xorg-core' 'amd64' '2:1.7.6-2ubuntu7.10'
+for i in $(seq 1 50); do
+	insertinstalledpackage "xserver-xorg-video-driver$i" 'amd64' '1.0' 'Provides: xserver-xorg-video-6'
+done
+
+insertpackage 'unstable' 'xserver-xorg-core' 'amd64' '2:1.11.3-0ubuntu9' 'Breaks: xserver-xorg-video-6'
+
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+  xserver-xorg-video-driver1 xserver-xorg-video-driver10
+  xserver-xorg-video-driver11 xserver-xorg-video-driver12
+  xserver-xorg-video-driver13 xserver-xorg-video-driver14
+  xserver-xorg-video-driver15 xserver-xorg-video-driver16
+  xserver-xorg-video-driver17 xserver-xorg-video-driver18
+  xserver-xorg-video-driver19 xserver-xorg-video-driver2
+  xserver-xorg-video-driver20 xserver-xorg-video-driver21
+  xserver-xorg-video-driver22 xserver-xorg-video-driver23
+  xserver-xorg-video-driver24 xserver-xorg-video-driver25
+  xserver-xorg-video-driver26 xserver-xorg-video-driver27
+  xserver-xorg-video-driver28 xserver-xorg-video-driver29
+  xserver-xorg-video-driver3 xserver-xorg-video-driver30
+  xserver-xorg-video-driver31 xserver-xorg-video-driver32
+  xserver-xorg-video-driver33 xserver-xorg-video-driver34
+  xserver-xorg-video-driver35 xserver-xorg-video-driver36
+  xserver-xorg-video-driver37 xserver-xorg-video-driver38
+  xserver-xorg-video-driver39 xserver-xorg-video-driver4
+  xserver-xorg-video-driver40 xserver-xorg-video-driver41
+  xserver-xorg-video-driver42 xserver-xorg-video-driver43
+  xserver-xorg-video-driver44 xserver-xorg-video-driver45
+  xserver-xorg-video-driver46 xserver-xorg-video-driver47
+  xserver-xorg-video-driver48 xserver-xorg-video-driver49
+  xserver-xorg-video-driver5 xserver-xorg-video-driver50
+  xserver-xorg-video-driver6 xserver-xorg-video-driver7
+  xserver-xorg-video-driver8 xserver-xorg-video-driver9
+The following packages will be upgraded:
+  xserver-xorg-core
+1 upgraded, 0 newly installed, 50 to remove and 0 not upgraded.
+After this operation, 2150 kB disk space will be freed.
+E: Trivial Only specified but this is not a trivial operation.' aptget dist-upgrade --trivial-only

+ 56 - 0
test/integration/test-ordering-ignore-not-matching-breaks

@@ -0,0 +1,56 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable-mp' 'crda' 'i386,amd64' '1.1.1-1ubuntu4mp' 'Provides: wireless-crda
+Multi-Arch: foreign'
+insertpackage 'unstable-m' 'crda' 'i386,amd64' '1.1.1-1ubuntu4m' 'Multi-Arch: foreign'
+insertpackage 'unstable-p' 'crda' 'i386,amd64' '1.1.1-1ubuntu4p' 'Provides: wireless-crda'
+insertpackage 'unstable' 'wireless-crda' 'i386,amd64' '1.16'
+
+
+insertinstalledpackage 'wireless-crda' 'amd64' '1.14'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  crda
+0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst crda (1.1.1-1ubuntu4m unstable-m [amd64])
+Conf crda (1.1.1-1ubuntu4m unstable-m [amd64])' aptget install crda -s -t unstable-m
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  crda
+0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst crda (1.1.1-1ubuntu4p unstable-p [amd64])
+Conf crda (1.1.1-1ubuntu4p unstable-p [amd64])' aptget install crda -s -t unstable-p
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  crda
+0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst crda (1.1.1-1ubuntu4mp unstable-mp [amd64])
+Conf crda (1.1.1-1ubuntu4mp unstable-mp [amd64])' aptget install crda -s -t unstable-mp
+
+rm rootdir/var/lib/dpkg/status
+insertinstalledpackage 'crda' 'amd64' '1.1.1-1ubuntu4mp' 'Provides: wireless-crda
+Conflicts: wireless-crda (<< 1.15)
+Replaces: wireless-crda ( << 1.15)
+Multi-arch: foreign'
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  wireless-crda
+0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst wireless-crda (1.16 unstable [amd64])
+Conf wireless-crda (1.16 unstable [amd64])' aptget install wireless-crda -s -t unstable

+ 28 - 0
test/integration/test-ubuntu-bug-859188-multiarch-reinstall

@@ -0,0 +1,28 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386' 'armel'
+
+buildsimplenativepackage 'libsame' 'amd64,i386,armel' '1.0' 'unstable' 'Multi-Arch: same'
+
+# FIXME: hack around dpkg's current inability to handle multiarch, a clean install would be better…
+insertinstalledpackage 'libsame' 'amd64,i386' '1.0' 'Multi-Arch: same'
+sed -e 's#/installed#/unstable#' -e 's#Installed-Size: 42#Installed-Size: 1#' -i rootdir/var/lib/dpkg/status
+
+setupaptarchive
+
+REINSTALL='Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 2 reinstalled, 0 to remove and 0 not upgraded.
+Inst libsame [1.0] (1.0 unstable [amd64])
+Inst libsame:i386 [1.0] (1.0 unstable [i386])
+Conf libsame (1.0 unstable [amd64])
+Conf libsame:i386 (1.0 unstable [i386])'
+
+testequal "$REINSTALL" aptget install --reinstall libsame -s
+testequal "$REINSTALL" aptget install --reinstall libsame:amd64 -s
+testequal "$REINSTALL" aptget install --reinstall libsame:i386 -s
+testequal "$REINSTALL" aptget install --reinstall libsame:amd64 libsame:i386 -s

+ 9 - 0
test/libapt/configuration_test.cc

@@ -71,6 +71,15 @@ int main(int argc,const char *argv[]) {
 	equals(Cnf.Find("APT2::Version", "33"), "33");
 	equals(Cnf.FindI("APT2::Version", 33), 33);
 
+	equals(Cnf.FindFile("Dir::State"), "");
+	equals(Cnf.FindFile("Dir::Aptitude::State"), "");
+	Cnf.Set("Dir", "/srv/sid");
+	equals(Cnf.FindFile("Dir::State"), "");
+	Cnf.Set("Dir::State", "var/lib/apt");
+	Cnf.Set("Dir::Aptitude::State", "var/lib/aptitude");
+	equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+	equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+
 	//FIXME: Test for configuration file parsing;
 	// currently only integration/ tests test them implicitly