Kaynağa Gözat

merged from debian-experimental-ma

Michael Vogt 16 yıl önce
ebeveyn
işleme
7c122f33c4

+ 3 - 3
apt-pkg/acquire-item.cc

@@ -280,7 +280,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
       ss >> ServerSha1 >> size;
       ss >> ServerSha1 >> size;
       unsigned long const ServerSize = atol(size.c_str());
       unsigned long const ServerSize = atol(size.c_str());
 
 
-      FileFd fd(CurrentPackagesFile, FileFd::ReadOnlyGzip);
+      FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
       SHA1Summation SHA1;
       SHA1Summation SHA1;
       SHA1.AddFD(fd.Fd(), fd.Size());
       SHA1.AddFD(fd.Fd(), fd.Size());
       string const local_sha1 = SHA1.Result();
       string const local_sha1 = SHA1.Result();
@@ -297,7 +297,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
       else 
       else 
       {
       {
 	 if(Debug)
 	 if(Debug)
-	    std::clog << "SHA1-Current: " << ServerSha1 << std::endl;
+	    std::clog << "SHA1-Current: " << ServerSha1 << " and we start at "<< fd.Name() << " " << fd.Size() << " " << local_sha1 << std::endl;
 
 
 	 // check the historie and see what patches we need
 	 // check the historie and see what patches we need
 	 string const history = Tags.FindS("SHA1-History");
 	 string const history = Tags.FindS("SHA1-History");
@@ -511,7 +511,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    string FinalFile = _config->FindDir("Dir::State::lists");
    string FinalFile = _config->FindDir("Dir::State::lists");
    FinalFile += URItoFileName(RealURI);
    FinalFile += URItoFileName(RealURI);
 
 
-   FileFd fd(FinalFile, FileFd::ReadOnlyGzip);
+   FileFd fd(FinalFile, FileFd::ReadOnly);
    SHA1Summation SHA1;
    SHA1Summation SHA1;
    SHA1.AddFD(fd.Fd(), fd.Size());
    SHA1.AddFD(fd.Fd(), fd.Size());
    string local_sha1 = string(SHA1.Result());
    string local_sha1 = string(SHA1.Result());

+ 61 - 42
apt-pkg/algorithms.cc

@@ -58,7 +58,7 @@ void pkgSimulate::Describe(PkgIterator Pkg,ostream &out,bool Current,bool Candid
 {
 {
    VerIterator Ver(Sim);
    VerIterator Ver(Sim);
  
  
-   out << Pkg.Name();
+   out << Pkg.FullName(true);
 
 
    if (Current == true)
    if (Current == true)
    {
    {
@@ -123,9 +123,9 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
          {
          {
 	    if ((Sim[End] & pkgDepCache::DepGInstall) == 0)
 	    if ((Sim[End] & pkgDepCache::DepGInstall) == 0)
 	    {
 	    {
-	       cout << " [" << I.Name() << " on " << Start.TargetPkg().Name() << ']';
+	       cout << " [" << I.FullName(false) << " on " << Start.TargetPkg().FullName(false) << ']';
 	       if (Start->Type == pkgCache::Dep::Conflicts)
 	       if (Start->Type == pkgCache::Dep::Conflicts)
-		  _error->Error("Fatal, conflicts violated %s",I.Name());
+		  _error->Error("Fatal, conflicts violated %s",I.FullName(false).c_str());
 	    }	    
 	    }	    
 	 }
 	 }
       }      
       }      
@@ -165,7 +165,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
 //   Sim.MarkInstall(Pkg,false);
 //   Sim.MarkInstall(Pkg,false);
    if (Sim[Pkg].InstBroken() == true)
    if (Sim[Pkg].InstBroken() == true)
    {
    {
-      cout << "Conf " << Pkg.Name() << " broken" << endl;
+      cout << "Conf " << Pkg.FullName(false) << " broken" << endl;
 
 
       Sim.Update();
       Sim.Update();
       
       
@@ -177,17 +177,17 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
 	    continue;
 	    continue;
 	 
 	 
 	 if (D->Type == pkgCache::Dep::Obsoletes)
 	 if (D->Type == pkgCache::Dep::Obsoletes)
-	    cout << " Obsoletes:" << D.TargetPkg().Name();
+	    cout << " Obsoletes:" << D.TargetPkg().FullName(false);
 	 else if (D->Type == pkgCache::Dep::Conflicts)
 	 else if (D->Type == pkgCache::Dep::Conflicts)
-	    cout << " Conflicts:" << D.TargetPkg().Name();
+	    cout << " Conflicts:" << D.TargetPkg().FullName(false);
 	 else if (D->Type == pkgCache::Dep::DpkgBreaks)
 	 else if (D->Type == pkgCache::Dep::DpkgBreaks)
-	    cout << " Breaks:" << D.TargetPkg().Name();
+	    cout << " Breaks:" << D.TargetPkg().FullName(false);
 	 else
 	 else
-	    cout << " Depends:" << D.TargetPkg().Name();
+	    cout << " Depends:" << D.TargetPkg().FullName(false);
       }	    
       }	    
       cout << endl;
       cout << endl;
 
 
-      _error->Error("Conf Broken %s",Pkg.Name());
+      _error->Error("Conf Broken %s",Pkg.FullName(false).c_str());
    }   
    }   
    else
    else
    {
    {
@@ -254,7 +254,7 @@ void pkgSimulate::ShortBreaks()
       if (Sim[I].InstBroken() == true)
       if (Sim[I].InstBroken() == true)
       {
       {
 	 if (Flags[I->ID] == 0)
 	 if (Flags[I->ID] == 0)
-	    cout << I.Name() << ' ';
+	    cout << I.FullName(false) << ' ';
 /*	 else
 /*	 else
 	    cout << I.Name() << "! ";*/
 	    cout << I.Name() << "! ";*/
       }      
       }      
@@ -290,7 +290,7 @@ bool pkgApplyStatus(pkgDepCache &Cache)
 	       Cache.MarkInstall(I, false, 0, false);
 	       Cache.MarkInstall(I, false, 0, false);
 	    else
 	    else
 	       return _error->Error(_("The package %s needs to be reinstalled, "
 	       return _error->Error(_("The package %s needs to be reinstalled, "
-				    "but I can't find an archive for it."),I.Name());
+				    "but I can't find an archive for it."),I.FullName(true).c_str());
 	 }
 	 }
 	 
 	 
 	 continue;
 	 continue;
@@ -325,7 +325,7 @@ bool pkgApplyStatus(pkgDepCache &Cache)
 	 default:
 	 default:
 	 if (I->InstState != pkgCache::State::Ok)
 	 if (I->InstState != pkgCache::State::Ok)
 	    return _error->Error("The package %s is not ok and I "
 	    return _error->Error("The package %s is not ok and I "
-				 "don't know how to fix it!",I.Name());
+				 "don't know how to fix it!",I.FullName(false).c_str());
       }
       }
    }
    }
    return true;
    return true;
@@ -709,7 +709,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 	 if ((Flags[P->ID] & Protected) == Protected)
 	 if ((Flags[P->ID] & Protected) == Protected)
 	 {
 	 {
 	    if (Debug == true)
 	    if (Debug == true)
-	       clog << "    Reinst Failed because of protected " << P.Name() << endl;
+	       clog << "    Reinst Failed because of protected " << P.FullName(false) << endl;
 	    Fail = true;
 	    Fail = true;
 	 }      
 	 }      
 	 else
 	 else
@@ -720,7 +720,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 	       if (DoUpgrade(P) == false)
 	       if (DoUpgrade(P) == false)
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "    Reinst Failed because of " << P.Name() << endl;
+		     clog << "    Reinst Failed because of " << P.FullName(false) << endl;
 		  Fail = true;
 		  Fail = true;
 	       }
 	       }
 	       else
 	       else
@@ -739,7 +739,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 		   break;
 		   break;
 	       
 	       
 	       if (Debug == true)
 	       if (Debug == true)
-		  clog << "    Reinst Failed early because of " << Start.TargetPkg().Name() << endl;
+		  clog << "    Reinst Failed early because of " << Start.TargetPkg().FullName(false) << endl;
 	       Fail = true;
 	       Fail = true;
 	    }     
 	    }     
 	 }
 	 }
@@ -763,7 +763,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
    }	 
    }	 
    
    
    if (Debug == true)
    if (Debug == true)
-      clog << "  Re-Instated " << Pkg.Name() << endl;
+      clog << "  Re-Instated " << Pkg.FullName(false) << endl;
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -847,6 +847,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
       not be possible for a loop to form (that is a < b < c and fixing b by
       not be possible for a loop to form (that is a < b < c and fixing b by
       changing a breaks c) */
       changing a breaks c) */
    bool Change = true;
    bool Change = true;
+   bool const TryFixByInstall = _config->FindB("pkgProblemResolver::FixByInstall", true);
    for (int Counter = 0; Counter != 10 && Change == true; Counter++)
    for (int Counter = 0; Counter != 10 && Change == true; Counter++)
    {
    {
       Change = false;
       Change = false;
@@ -863,7 +864,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	     (Flags[I->ID] & ReInstateTried) == 0)
 	     (Flags[I->ID] & ReInstateTried) == 0)
 	 {
 	 {
 	    if (Debug == true)
 	    if (Debug == true)
-	       clog << " Try to Re-Instate " << I.Name() << endl;
+	       clog << " Try to Re-Instate (" << Counter << ") " << I.FullName(false) << endl;
 	    unsigned long OldBreaks = Cache.BrokenCount();
 	    unsigned long OldBreaks = Cache.BrokenCount();
 	    pkgCache::Version *OldVer = Cache[I].InstallVer;
 	    pkgCache::Version *OldVer = Cache[I].InstallVer;
 	    Flags[I->ID] &= ReInstateTried;
 	    Flags[I->ID] &= ReInstateTried;
@@ -879,14 +880,14 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    }	    
 	    }	    
 	    else
 	    else
 	       if (Debug == true)
 	       if (Debug == true)
-		  clog << "Re-Instated " << I.Name() << " (" << OldBreaks << " vs " << Cache.BrokenCount() << ')' << endl;
+		  clog << "Re-Instated " << I.FullName(false) << " (" << OldBreaks << " vs " << Cache.BrokenCount() << ')' << endl;
 	 }
 	 }
 	    
 	    
 	 if (Cache[I].InstallVer == 0 || Cache[I].InstBroken() == false)
 	 if (Cache[I].InstallVer == 0 || Cache[I].InstBroken() == false)
 	    continue;
 	    continue;
 	 
 	 
 	 if (Debug == true)
 	 if (Debug == true)
-	    clog << "Investigating " << I.Name() << endl;
+	    clog << "Investigating (" << Counter << ") " << I << endl;
 	 
 	 
 	 // Isolate the problem dependency
 	 // Isolate the problem dependency
 	 PackageKill KillList[100];
 	 PackageKill KillList[100];
@@ -904,22 +905,22 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    if (Start == End)
 	    if (Start == End)
 	    {
 	    {
 	       // Decide what to do
 	       // Decide what to do
-	       if (InOr == true)
+	       if (InOr == true && OldEnd == LEnd)
 	       {
 	       {
-		  if (OldEnd == LEnd && OrOp == OrRemove)
+		  if (OrOp == OrRemove)
 		  {
 		  {
 		     if ((Flags[I->ID] & Protected) != Protected)
 		     if ((Flags[I->ID] & Protected) != Protected)
 		     {
 		     {
 			if (Debug == true)
 			if (Debug == true)
-			   clog << "  Or group remove for " << I.Name() << endl;
+			   clog << "  Or group remove for " << I.FullName(false) << endl;
 			Cache.MarkDelete(I);
 			Cache.MarkDelete(I);
 			Change = true;
 			Change = true;
-		     }		     
-		  }		  
-		  if (OldEnd == LEnd && OrOp == OrKeep)
+		     }
+		  }
+		  else if (OrOp == OrKeep)
 		  {
 		  {
 		     if (Debug == true)
 		     if (Debug == true)
-			clog << "  Or group keep for " << I.Name() << endl;
+			clog << "  Or group keep for " << I.FullName(false) << endl;
 		     Cache.MarkKeep(I, false, false);
 		     Cache.MarkKeep(I, false, false);
 		     Change = true;
 		     Change = true;
 		  }
 		  }
@@ -956,7 +957,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    }
 	    }
 	    
 	    
 	    if (Debug == true)
 	    if (Debug == true)
-	       clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl;
+	       clog << "Broken " << Start << endl;
 
 
 	    /* Look across the version list. If there are no possible
 	    /* Look across the version list. If there are no possible
 	       targets then we keep the package and bail. This is necessary
 	       targets then we keep the package and bail. This is necessary
@@ -987,8 +988,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	       pkgCache::PkgIterator Pkg = Ver.ParentPkg();
 	       pkgCache::PkgIterator Pkg = Ver.ParentPkg();
 
 
 	       if (Debug == true)
 	       if (Debug == true)
-		  clog << "  Considering " << Pkg.Name() << ' ' << (int)Scores[Pkg->ID] <<
-		  " as a solution to " << I.Name() << ' ' << (int)Scores[I->ID] << endl;
+		  clog << "  Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] <<
+		  " as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl;
 
 
 	       /* Try to fix the package under consideration rather than
 	       /* Try to fix the package under consideration rather than
 	          fiddle with the VList package */
 	          fiddle with the VList package */
@@ -1026,7 +1027,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 			Cache.MarkInstall(I, false, 0, false);
 			Cache.MarkInstall(I, false, 0, false);
 		     
 		     
 		     if (Debug == true)
 		     if (Debug == true)
-			clog << "  Holding Back " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
+			clog << "  Holding Back " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl;
 		  }		  
 		  }		  
 		  else
 		  else
 		  {		     
 		  {		     
@@ -1036,11 +1037,29 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 			if (InOr == false)
 			if (InOr == false)
 			{
 			{
 			   if (Debug == true)
 			   if (Debug == true)
-			      clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
+			      clog << "  Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl;
 			   Cache.MarkDelete(I);
 			   Cache.MarkDelete(I);
 			   if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID])
 			   if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID])
 			      Scores[I->ID] = Scores[Pkg->ID];
 			      Scores[I->ID] = Scores[Pkg->ID];
 			}
 			}
+			else if (TryFixByInstall == true &&
+				 Start.TargetPkg()->CurrentVer == 0 &&
+				 Cache[Start.TargetPkg()].Delete() == false &&
+				 Cache.GetCandidateVer(Start.TargetPkg()).end() == false)
+			{
+			   /* Before removing or keeping the package with the broken dependency
+			      try instead to install the first not previously installed package
+			      solving this dependency. This helps every time a previous solver
+			      is removed by the resolver because of a conflict or alike but it is
+			      dangerous as it could trigger new breaks/conflicts… */
+			   if (Debug == true)
+			      clog << "  Try Installing " << Start.TargetPkg() << " before changing " << I.FullName(false) << std::endl;
+			   unsigned long const OldBroken = Cache.BrokenCount();
+			   Cache.MarkInstall(Start.TargetPkg(), true, 1, false);
+			   // FIXME: we should undo the complete MarkInstall process here
+			   if (Cache[Start.TargetPkg()].InstBroken() == true || Cache.BrokenCount() > OldBroken)
+			      Cache.MarkDelete(Start.TargetPkg(), false, 1, false);
+			}
 		     }
 		     }
 		  }
 		  }
 		  		  
 		  		  
@@ -1068,7 +1087,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		     if (Cache[End] & pkgDepCache::DepGCVer) 
 		     if (Cache[End] & pkgDepCache::DepGCVer) 
 		     {
 		     {
 			if (Debug)
 			if (Debug)
-			   clog << "  Upgrading " << Pkg.Name() << " due to Breaks field in " << I.Name() << endl;
+			   clog << "  Upgrading " << Pkg.FullName(false) << " due to Breaks field in " << I.FullName(false) << endl;
 			Cache.MarkInstall(Pkg, false, 0, false);
 			Cache.MarkInstall(Pkg, false, 0, false);
 			continue;
 			continue;
 		     }
 		     }
@@ -1079,7 +1098,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		     continue;
 		     continue;
 		
 		
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "  Added " << Pkg.Name() << " to the remove list" << endl;
+		     clog << "  Added " << Pkg.FullName(false) << " to the remove list" << endl;
 		  
 		  
 		  LEnd->Pkg = Pkg;
 		  LEnd->Pkg = Pkg;
 		  LEnd->Dep = End;
 		  LEnd->Dep = End;
@@ -1111,12 +1130,12 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		     Cache.MarkInstall(I, false, 0, false);
 		     Cache.MarkInstall(I, false, 0, false);
 		  
 		  
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "  Holding Back " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl;
+		     clog << "  Holding Back " << I.FullName(false) << " because I can't find " << Start.TargetPkg().FullName(false) << endl;
 	       }	       
 	       }	       
 	       else
 	       else
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "  Removing " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl;
+		     clog << "  Removing " << I.FullName(false) << " because I can't find " << Start.TargetPkg().FullName(false) << endl;
 		  if (InOr == false)
 		  if (InOr == false)
 		     Cache.MarkDelete(I);
 		     Cache.MarkDelete(I);
 	       }
 	       }
@@ -1146,14 +1165,14 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		      J->Dep->Type == pkgCache::Dep::Obsoletes)
 		      J->Dep->Type == pkgCache::Dep::Obsoletes)
 		  {
 		  {
 		     if (Debug == true)
 		     if (Debug == true)
-			clog << "  Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl;
+			clog << "  Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl;
 		     Cache.MarkDelete(J->Pkg);
 		     Cache.MarkDelete(J->Pkg);
 		  }
 		  }
 	       }
 	       }
 	       else
 	       else
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "  Fixing " << I.Name() << " via keep of " << J->Pkg.Name() << endl;
+		     clog << "  Fixing " << I.FullName(false) << " via keep of " << J->Pkg.FullName(false) << endl;
 		  Cache.MarkKeep(J->Pkg, false, false);
 		  Cache.MarkKeep(J->Pkg, false, false);
 	       }
 	       }
 
 
@@ -1189,7 +1208,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
    for (;I.end() != true; I++) {
    for (;I.end() != true; I++) {
       if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
       if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
 	 if(_config->FindI("Debug::pkgAutoRemove",false)) {
 	 if(_config->FindI("Debug::pkgAutoRemove",false)) {
-	    std::clog << "Resolve installed new pkg: " << I.Name() 
+	    std::clog << "Resolve installed new pkg: " << I.FullName(false) 
 		      << " (now marking it as auto)" << std::endl;
 		      << " (now marking it as auto)" << std::endl;
 	 }
 	 }
 	 Cache[I].Flags |= pkgCache::Flag::Auto;
 	 Cache[I].Flags |= pkgCache::Flag::Auto;
@@ -1252,7 +1271,7 @@ bool pkgProblemResolver::ResolveByKeep()
       if ((Flags[I->ID] & Protected) == 0)
       if ((Flags[I->ID] & Protected) == 0)
       {
       {
 	 if (Debug == true)
 	 if (Debug == true)
-	    clog << "Keeping package " << I.Name() << endl;
+	    clog << "Keeping package " << I.FullName(false) << endl;
 	 Cache.MarkKeep(I, false, false);
 	 Cache.MarkKeep(I, false, false);
 	 if (Cache[I].InstBroken() == false)
 	 if (Cache[I].InstBroken() == false)
 	 {
 	 {
@@ -1283,7 +1302,7 @@ bool pkgProblemResolver::ResolveByKeep()
 	 while (true)
 	 while (true)
 	 {
 	 {
 	    if (Debug == true)
 	    if (Debug == true)
-	       clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl;
+	       clog << "Package " << I.FullName(false) << " " << Start << endl;
 
 
 	    // Look at all the possible provides on this package
 	    // Look at all the possible provides on this package
 	    SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
 	    SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
@@ -1300,7 +1319,7 @@ bool pkgProblemResolver::ResolveByKeep()
 	       if ((Flags[I->ID] & Protected) == 0)
 	       if ((Flags[I->ID] & Protected) == 0)
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
-		     clog << "  Keeping Package " << Pkg.Name() << " due to " << Start.DepType() << endl;
+		     clog << "  Keeping Package " << Pkg.FullName(false) << " due to " << Start.DepType() << endl;
 		  Cache.MarkKeep(Pkg, false, false);
 		  Cache.MarkKeep(Pkg, false, false);
 	       }
 	       }
 	       
 	       
@@ -1325,7 +1344,7 @@ bool pkgProblemResolver::ResolveByKeep()
       
       
       // Restart again.
       // Restart again.
       if (K == LastStop)
       if (K == LastStop)
-	 return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.",I.Name());
+	 return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.",I.FullName(false).c_str());
       LastStop = K;
       LastStop = K;
       K = PList - 1;
       K = PList - 1;
    }   
    }   

+ 3 - 0
apt-pkg/cacheiterators.h

@@ -293,6 +293,9 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
 	inline const char *CompType() const {return Owner->CompType(S->CompareOp);};
 	inline const char *CompType() const {return Owner->CompType(S->CompareOp);};
 	inline const char *DepType() const {return Owner->DepType(S->Type);};
 	inline const char *DepType() const {return Owner->DepType(S->Type);};
 
 
+	//Nice printable representation
+	friend std::ostream& operator <<(std::ostream& out, DepIterator D);
+
 	inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
 	inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
 		if (S == 0)
 		if (S == 0)

+ 1 - 1
apt-pkg/cdrom.cc

@@ -229,7 +229,7 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
       // Between Start and End is the architecture
       // Between Start and End is the architecture
       Start += 8;
       Start += 8;
       if ((End = strstr(Start,"/")) != 0 && Start != End &&
       if ((End = strstr(Start,"/")) != 0 && Start != End &&
-          APT::Configuration::checkArchitecture(string(Start, --End)) == true)
+          APT::Configuration::checkArchitecture(string(Start, End)) == true)
 	 continue; // okay, architecture is accepted
 	 continue; // okay, architecture is accepted
 
 
       // not accepted -> Erase it
       // not accepted -> Erase it

+ 10 - 1
apt-pkg/contrib/fileutl.cc

@@ -669,7 +669,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
       }
       }
       break;
       break;
       
       
-      case WriteEmpty:
+      case WriteAtomic:
       {
       {
 	 Flags |= Replace;
 	 Flags |= Replace;
 	 char *name = strdup((FileName + ".XXXXXX").c_str());
 	 char *name = strdup((FileName + ".XXXXXX").c_str());
@@ -678,6 +678,15 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
 	 free(name);
 	 free(name);
 	 break;
 	 break;
       }
       }
+
+      case WriteEmpty:
+      {
+      	 struct stat Buf;
+	 if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
+	    unlink(FileName.c_str());
+	 iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
+	 break;
+      }
       
       
       case WriteExists:
       case WriteExists:
       iFd = open(FileName.c_str(),O_RDWR);
       iFd = open(FileName.c_str(),O_RDWR);

+ 2 - 1
apt-pkg/contrib/fileutl.h

@@ -46,7 +46,8 @@ class FileFd
    gzFile gz;
    gzFile gz;
 
 
    public:
    public:
-   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip};
+   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
+                  WriteAtomic};
    
    
    inline bool Read(void *To,unsigned long Size,bool AllowEof)
    inline bool Read(void *To,unsigned long Size,bool AllowEof)
    {
    {

+ 1 - 1
apt-pkg/contrib/strutl.cc

@@ -1161,7 +1161,7 @@ void strprintf(string &out,const char *format,...)
 char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
 char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
 {
 {
    va_list args;
    va_list args;
-   unsigned long Did;
+   int Did;
 
 
    va_start(args,Format);
    va_start(args,Format);
 
 

+ 1 - 1
apt-pkg/deb/debsystem.cc

@@ -165,7 +165,7 @@ bool debSystem::Initialize(Configuration &Cnf)
       which is yet to be determined. The functions in pkgcachegen should
       which is yet to be determined. The functions in pkgcachegen should
       be the only users of these */
       be the only users of these */
    Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states"));
    Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states"));
-   Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status");
+   Cnf.CndSet("Dir::State::status", Cnf.FindDir("Dir", "/").append("var/lib/dpkg/status"));
    Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
    Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
 
 
    if (StatusFile) {
    if (StatusFile) {

+ 4 - 2
apt-pkg/deb/dpkgpm.cc

@@ -554,7 +554,7 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
    // the disappeared package was auto-installed - nothing to do
    // the disappeared package was auto-installed - nothing to do
    if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto)
    if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto)
       return;
       return;
-   pkgCache::VerIterator PkgVer = Pkg.CurrentVer();
+   pkgCache::VerIterator PkgVer = Cache[Pkg].InstVerIter(Cache);
    if (unlikely(PkgVer.end() == true))
    if (unlikely(PkgVer.end() == true))
       return;
       return;
    /* search in the list of dependencies for (Pre)Depends,
    /* search in the list of dependencies for (Pre)Depends,
@@ -571,7 +571,9 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
       // the package is already marked as manual
       // the package is already marked as manual
       if ((Cache[Tar].Flags & pkgCache::Flag::Auto) != pkgCache::Flag::Auto)
       if ((Cache[Tar].Flags & pkgCache::Flag::Auto) != pkgCache::Flag::Auto)
 	 continue;
 	 continue;
-      pkgCache::VerIterator TarVer = Tar.CurrentVer();
+      pkgCache::VerIterator TarVer =  Cache[Tar].InstVerIter(Cache);
+      if (TarVer.end() == true)
+	 continue;
       for (pkgCache::DepIterator Rep = TarVer.DependsList(); Rep.end() != true; ++Rep)
       for (pkgCache::DepIterator Rep = TarVer.DependsList(); Rep.end() != true; ++Rep)
       {
       {
 	 if (Rep->Type != pkgCache::Dep::Replaces)
 	 if (Rep->Type != pkgCache::Dep::Replaces)

+ 7 - 4
apt-pkg/depcache.cc

@@ -227,7 +227,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)	/*{{{*/
    // if it does not exist, create a empty one
    // if it does not exist, create a empty one
    if(!FileExists(state)) 
    if(!FileExists(state)) 
    {
    {
-      StateFile.Open(state, FileFd::WriteEmpty);
+      StateFile.Open(state, FileFd::WriteAtomic);
       StateFile.Close();
       StateFile.Close();
    }
    }
 
 
@@ -1425,10 +1425,13 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    VerIterator Ver(*this,*I);
 	    VerIterator Ver(*this,*I);
 	    PkgIterator Pkg = Ver.ParentPkg();
 	    PkgIterator Pkg = Ver.ParentPkg();
 
 
-	    if (Start->Type != Dep::DpkgBreaks)
-	       MarkDelete(Pkg,false,Depth + 1, false);
-	    else if (PkgState[Pkg->ID].CandidateVer != *I)
+	    
+	       
+	    if (PkgState[Pkg->ID].CandidateVer != *I &&
+	        Start->Type == Dep::DpkgBreaks)
 	       MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
 	       MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
+	    else
+	       MarkDelete(Pkg,false,Depth + 1, false);
 	 }
 	 }
 	 continue;
 	 continue;
       }      
       }      

+ 5 - 6
apt-pkg/indexcopy.cc

@@ -134,7 +134,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
       TargetF += URItoFileName(S);
       TargetF += URItoFileName(S);
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
 	 TargetF = "/dev/null";
 	 TargetF = "/dev/null";
-      FileFd Target(TargetF,FileFd::WriteEmpty);
+      FileFd Target(TargetF,FileFd::WriteAtomic);
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
 	 return false;
 	 return false;
@@ -565,7 +565,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,		/*{{{*/
 
 
       FileFd Target;
       FileFd Target;
       FileFd Rel;
       FileFd Rel;
-      Target.Open(TargetF,FileFd::WriteEmpty);
+      Target.Open(TargetF,FileFd::WriteAtomic);
       Rel.Open(prefix + file,FileFd::ReadOnly);
       Rel.Open(prefix + file,FileFd::ReadOnly);
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
 	 return false;
 	 return false;
@@ -661,9 +661,8 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG,
 {
 {
    string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
    string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
    // FIXME: remove support for deprecated APT::GPGV setting
    // FIXME: remove support for deprecated APT::GPGV setting
-   string const trustedFile = _config->FindFile("Dir::Etc::Trusted",
-		_config->Find("APT::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg").c_str());
-   string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts", "/etc/apt/trusted.gpg.d");
+   string const trustedFile = _config->FindFile("Dir::Etc::Trusted");
+   string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts");
 
 
    bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
    bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
 
 
@@ -840,7 +839,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
       TargetF += URItoFileName(S);
       TargetF += URItoFileName(S);
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
 	 TargetF = "/dev/null";
 	 TargetF = "/dev/null";
-      FileFd Target(TargetF,FileFd::WriteEmpty);
+      FileFd Target(TargetF,FileFd::WriteAtomic);
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
 	 return false;
 	 return false;

+ 3 - 0
apt-pkg/init.cc

@@ -70,6 +70,9 @@ bool pkgInitConfig(Configuration &Cnf)
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::preferences","preferences");
    Cnf.Set("Dir::Etc::preferences","preferences");
    Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
    Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
+   string const deprecated = _config->Find("APT::GPGV::TrustedKeyring");
+   Cnf.Set("Dir::Etc::trusted", deprecated.empty() ? "trusted.gpg" : deprecated);
+   Cnf.Set("Dir::Etc::trustedparts","trusted.gpg.d");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    Cnf.Set("Dir::Media::MountPath","/media/apt");
    Cnf.Set("Dir::Media::MountPath","/media/apt");
 
 

+ 30 - 2
apt-pkg/pkgcache.cc

@@ -111,7 +111,10 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
 /* */
 /* */
 pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
 pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
 {
 {
-   MultiArchEnabled = APT::Configuration::getArchitectures().size() > 1;
+   // call getArchitectures() with cached=false to ensure that the 
+   // architectures cache is re-evaulated. this is needed in cases
+   // when the APT::Architecture field changes between two cache creations
+   MultiArchEnabled = APT::Configuration::getArchitectures(false).size() > 1;
    if (DoMap == true)
    if (DoMap == true)
       ReMap();
       ReMap();
 }
 }
@@ -661,6 +664,30 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
    }
    }
 }
 }
 									/*}}}*/
 									/*}}}*/
+// ostream operator to handle string representation of a dependecy	/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::ostream& operator<<(ostream& out, pkgCache::DepIterator D)
+{
+   if (D.end() == true)
+      return out << "invalid dependency";
+
+   pkgCache::PkgIterator P = D.ParentPkg();
+   pkgCache::PkgIterator T = D.TargetPkg();
+
+   out << (P.end() ? "invalid pkg" : P.FullName(false)) << " " << D.DepType()
+	<< " on ";
+   if (T.end() == true)
+      out << "invalid pkg";
+   else
+      out << T;
+
+   if (D->Version != 0)
+      out << " (" << D.CompType() << " " << D.TargetVer() << ")";
+
+   return out;
+}
+									/*}}}*/
 // VerIterator::CompareVer - Fast version compare for same pkgs		/*{{{*/
 // VerIterator::CompareVer - Fast version compare for same pkgs		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This just looks over the version list to see if B is listed before A. In
 /* This just looks over the version list to see if B is listed before A. In
@@ -867,7 +894,8 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
       pkgCache::DescIterator Desc = DescDefault;
       pkgCache::DescIterator Desc = DescDefault;
 
 
       for (; Desc.end() == false; Desc++)
       for (; Desc.end() == false; Desc++)
-	 if (*l == Desc.LanguageCode())
+	 if (*l == Desc.LanguageCode() ||
+	     (*l == "en" && strcmp(Desc.LanguageCode(),"") == 0))
 	    break;
 	    break;
       if (Desc.end() == true) 
       if (Desc.end() == true) 
 	 Desc = DescDefault;
 	 Desc = DescDefault;

+ 2 - 2
apt-pkg/pkgcachegen.cc

@@ -1192,7 +1192,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
    if (Writeable == true && CacheFile.empty() == false)
    if (Writeable == true && CacheFile.empty() == false)
    {
    {
       unlink(CacheFile.c_str());
       unlink(CacheFile.c_str());
-      CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
+      CacheF = new FileFd(CacheFile,FileFd::WriteAtomic);
       fchmod(CacheF->Fd(),0644);
       fchmod(CacheF->Fd(),0644);
       Map = CreateDynamicMMap(CacheF, MMap::Public);
       Map = CreateDynamicMMap(CacheF, MMap::Public);
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
@@ -1254,7 +1254,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
       // Write it back
       // Write it back
       if (Writeable == true && SrcCacheFile.empty() == false)
       if (Writeable == true && SrcCacheFile.empty() == false)
       {
       {
-	 FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
+	 FileFd SCacheF(SrcCacheFile,FileFd::WriteAtomic);
 	 if (_error->PendingError() == true)
 	 if (_error->PendingError() == true)
 	    return false;
 	    return false;
 	 
 	 

+ 9 - 4
cmdline/apt-get.cc

@@ -28,6 +28,7 @@
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 #define _LARGEFILE64_SOURCE
 
 
+#include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/init.h>
 #include <apt-pkg/init.h>
@@ -843,9 +844,11 @@ struct TryToRemove {
    pkgCacheFile* Cache;
    pkgCacheFile* Cache;
    pkgProblemResolver* Fix;
    pkgProblemResolver* Fix;
    bool FixBroken;
    bool FixBroken;
+   bool PurgePkgs;
    unsigned long AutoMarkChanged;
    unsigned long AutoMarkChanged;
 
 
-   TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {};
+   TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM),
+				PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
 
 
    void operator() (pkgCache::VerIterator const &Ver)
    void operator() (pkgCache::VerIterator const &Ver)
    {
    {
@@ -855,10 +858,11 @@ struct TryToRemove {
       Fix->Protect(Pkg);
       Fix->Protect(Pkg);
       Fix->Remove(Pkg);
       Fix->Remove(Pkg);
 
 
-      if (Pkg->CurrentVer == 0)
+      if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
+	  (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
 	 ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str());
 	 ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str());
       else
       else
-	 Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false));
+	 Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs);
    }
    }
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -2493,6 +2497,7 @@ bool DoBuildDep(CommandLine &CmdL)
       return false;
       return false;
 
 
    unsigned J = 0;
    unsigned J = 0;
+   bool const StripMultiArch = APT::Configuration::getArchitectures().size() <= 1;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
    {
    {
       string Src;
       string Src;
@@ -2502,7 +2507,7 @@ bool DoBuildDep(CommandLine &CmdL)
             
             
       // Process the build-dependencies
       // Process the build-dependencies
       vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
       vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
-      if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",true)) == false)
+      if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
       	return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
       	return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
    
    
       // Also ensure that build-essential packages are present
       // Also ensure that build-essential packages are present

+ 9 - 0
debian/apt.cron.daily

@@ -320,6 +320,15 @@ debug_echo()
 
 
 # ------------------------ main ----------------------------
 # ------------------------ main ----------------------------
 
 
+# Backup the 7 last versions of APT's extended_states file
+# shameless copy from dpkg cron
+if cd /var/backups ; then
+    if ! cmp -s apt.extended_states.0 /var/lib/apt/extended_states; then
+	cp -p /var/lib/apt/extended_states apt.extended_states
+	savelog -c 7 apt.extended_states >/dev/null
+    fi
+fi
+
 # check apt-config exstance
 # check apt-config exstance
 if ! which apt-config >/dev/null ; then
 if ! which apt-config >/dev/null ; then
 	exit 0
 	exit 0

+ 71 - 2
debian/changelog

@@ -1,4 +1,4 @@
-apt (0.8.0~pre1) UNRELASED; urgency=low
+apt (0.8.0) unstable; urgency=low
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]
   * merge of the debian-expermental-ma branch
   * merge of the debian-expermental-ma branch
@@ -11,7 +11,76 @@ apt (0.8.0~pre1) UNRELASED; urgency=low
   [ Manpages translations ]
   [ Manpages translations ]
   * French (Christian Perrier)
   * French (Christian Perrier)
 
 
- -- Michael Vogt <mvo@debian.org>  Fri, 30 Jul 2010 12:42:57 +0200
+ -- Michael Vogt <mvo@debian.org>  Tue, 24 Aug 2010 16:32:19 +0200
+
+apt (0.8.0~pre2) experimental; urgency=low
+
+  [ David Kalnischkies ]
+  * apt-pkg/contrib/strutl.cc:
+    - fix error checking for vsnprintf in its safe variant
+  * methods/bzip2.cc:
+    - fix error checking for read in case of failing bzip2/lzma/whatever
+  * debian/apt.cron.daily:
+    - create backups for our extended_states file (Closes: #593430)
+  * apt-pkg/init.cc:
+    - set the default values for dir::etc::trusted options correctly
+  * ftparchive/writer.cc:
+    - init valid-until correctly to prevent garbage entering Release file
+  * apt-pkg/deb/debsystem.cc:
+    - set dir::state::status based at least on dir
+  * apt-pkg/deb/dpkgpm.cc:
+    - use the InstVer instead of the CurrentVer for the autobit transfer
+  * methods/http.cc:
+    - some http servers violate HTTP1.1 by not issuing a Reason-Phrase
+      (or at least a space after the code) especially for 200, but lets
+      be nice and ignore it as we don't need the reason in general
+  * apt-pkg/acquire-item.cc:
+    - don't use ReadOnlyGzip mode for PDiffs as this mode doesn't work
+      in combination with the AddFd methods of our hashclasses
+
+ -- Michael Vogt <mvo@debian.org>  Mon, 23 Aug 2010 19:09:08 +0200
+
+apt (0.8.0~pre1) experimental; urgency=low
+
+  [ Programs translations ]
+  * Swedish translation update. Closes: #592366
+
+  [ Michael Vogt ]
+  * merge of the debian-expermental-ma branch
+  * refresh po/pot files in doc/ and po/
+  * apt-pkg/pkgcache.cc:
+    - re-evaluate the architectures cache when the cache is (re)opened
+
+  [ Colin Watson ]
+  * apt-pkg/cdrom.cc:
+    - fix off-by-one error in DropBinaryArch
+
+  [ Julian Andres Klode ]
+  * apt-pkg/contrib/fileutl.cc:
+    - Add WriteAtomic mode.
+    - Revert WriteEmpty to old behavior (LP: #613211)
+  * apt-pkg, methods:
+    - Convert users of WriteEmpty to WriteAtomic.
+  * apt-pkg/depcache.cc:
+    - Only try upgrade for Breaks if there is a newer version, otherwise
+      handle it as Conflicts (by removing it) (helps for #591882).
+  * debian/control:
+    - Add dependency on gnupg to apt, apt-key uses it.
+
+  [ David Kalnischkies ]
+  * apt-pkg/algorithms.cc:
+    - let the problem resolver install packages to fix or-groups
+      as a needed remove nuked another or-member (helps for #591882)
+    - change the debug outputs to display also arch of the
+      package and version dependencies information
+  * cmdline/apt-get.cc:
+    - let APT::Get::Arch-Only in build-dep default to false again
+      (Closes: #592628) Thanks Mohamed Amine IL Idrissi for report!
+    - purge packages in 'rc' state, thanks Rogier! (Closes: #150831)
+  * apt-pkg/pkgcache.cc:
+    - fix LongDesc handling in LANG=C environment
+
+ -- Michael Vogt <mvo@debian.org>  Fri, 13 Aug 2010 17:00:49 +0200
 
 
 apt (0.7.26~exp12) experimental; urgency=low
 apt (0.7.26~exp12) experimental; urgency=low
 
 

+ 1 - 1
debian/control

@@ -12,7 +12,7 @@ Vcs-Bzr: http://bzr.debian.org/apt/debian-sid/
 
 
 Package: apt
 Package: apt
 Architecture: any
 Architecture: any
-Depends: ${shlibs:Depends}, debian-archive-keyring, ${misc:Depends}
+Depends: ${shlibs:Depends}, debian-archive-keyring, ${misc:Depends}, gnupg
 Replaces: manpages-pl (<< 20060617-3~)
 Replaces: manpages-pl (<< 20060617-3~)
 Provides: ${libapt-pkg:provides}
 Provides: ${libapt-pkg:provides}
 Conflicts: python-apt (<< 0.7.93.2~)
 Conflicts: python-apt (<< 0.7.93.2~)

+ 1 - 1
ftparchive/writer.cc

@@ -925,7 +925,7 @@ ReleaseWriter::ReleaseWriter(string const &DB)
    }
    }
 
 
    time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0);
    time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0);
-   char validstr[128];
+   char validstr[128] = "";
    if (now == validuntil ||
    if (now == validuntil ||
        strftime(validstr, sizeof(validstr), "%a, %d %b %Y %H:%M:%S UTC",
        strftime(validstr, sizeof(validstr), "%a, %d %b %Y %H:%M:%S UTC",
                 gmtime(&validuntil)) == 0)
                 gmtime(&validuntil)) == 0)

+ 2 - 3
methods/bzip2.cc

@@ -91,7 +91,7 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
    close(GzOut[1]);
    close(GzOut[1]);
    
    
    FileFd FromGz(GzOut[0]);  // For autoclose   
    FileFd FromGz(GzOut[0]);  // For autoclose   
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    To.EraseOnFailure();
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
@@ -102,9 +102,8 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
    while (1) 
    while (1) 
    {
    {
       unsigned char Buffer[4*1024];
       unsigned char Buffer[4*1024];
-      unsigned long Count;
       
       
-      Count = read(GzOut[0],Buffer,sizeof(Buffer));
+      ssize_t Count = read(GzOut[0],Buffer,sizeof(Buffer));
       if (Count < 0 && errno == EINTR)
       if (Count < 0 && errno == EINTR)
 	 continue;
 	 continue;
       
       

+ 1 - 1
methods/copy.cc

@@ -52,7 +52,7 @@ bool CopyMethod::Fetch(FetchItem *Itm)
    
    
    // See if the file exists
    // See if the file exists
    FileFd From(File,FileFd::ReadOnly);
    FileFd From(File,FileFd::ReadOnly);
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);
    To.EraseOnFailure();
    To.EraseOnFailure();
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
    {
    {

+ 1 - 1
methods/gpgv.cc

@@ -69,7 +69,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
       {
       {
 	 // TRANSLATOR: %s is the trusted keyring parts directory
 	 // TRANSLATOR: %s is the trusted keyring parts directory
 	 ioprintf(ret, _("No keyring installed in %s."),
 	 ioprintf(ret, _("No keyring installed in %s."),
-		  _config->FindDir("Dir::Etc::TrustedParts", "/etc/apt/trusted.gpg.d").c_str());
+		  _config->FindDir("Dir::Etc::TrustedParts").c_str());
 	 return ret.str();
 	 return ret.str();
       }
       }
       exit(111);
       exit(111);

+ 1 - 1
methods/gzip.cc

@@ -55,7 +55,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
       return true;
       return true;
    }
    }
 
 
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    To.EraseOnFailure();
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;

+ 8 - 2
methods/http.cc

@@ -553,8 +553,14 @@ bool ServerState::HeaderLine(string Line)
       // Evil servers return no version
       // Evil servers return no version
       if (Line[4] == '/')
       if (Line[4] == '/')
       {
       {
-	 if (sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,
-		    &Result,Code) != 4)
+	 int const elements = sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,&Result,Code);
+	 if (elements == 3)
+	 {
+	    Code[0] = '\0';
+	    if (Debug == true)
+	       clog << "HTTP server doesn't give Reason-Phrase for " << Result << std::endl;
+	 }
+	 else if (elements != 4)
 	    return _error->Error(_("The HTTP server sent an invalid reply header"));
 	    return _error->Error(_("The HTTP server sent an invalid reply header"));
       }
       }
       else
       else

+ 2 - 2
methods/rred.cc

@@ -446,7 +446,7 @@ bool RredMethod::Fetch(FetchItem *Itm)						/*{{{*/
    // the cleanup/closing of the fds)
    // the cleanup/closing of the fds)
    FileFd From(Path,FileFd::ReadOnly);
    FileFd From(Path,FileFd::ReadOnly);
    FileFd Patch(Path+".ed",FileFd::ReadOnly);
    FileFd Patch(Path+".ed",FileFd::ReadOnly);
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    To.EraseOnFailure();
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
@@ -458,7 +458,7 @@ bool RredMethod::Fetch(FetchItem *Itm)						/*{{{*/
       // retry with patchFile
       // retry with patchFile
       lseek(Patch.Fd(), 0, SEEK_SET);
       lseek(Patch.Fd(), 0, SEEK_SET);
       lseek(From.Fd(), 0, SEEK_SET);
       lseek(From.Fd(), 0, SEEK_SET);
-      To.Open(Itm->DestFile,FileFd::WriteEmpty);
+      To.Open(Itm->DestFile,FileFd::WriteAtomic);
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
          return false;
          return false;
       if (patchFile(Patch, From, To, &Hash) != ED_OK) {
       if (patchFile(Patch, From, To, &Hash) != ED_OK) {

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1787 - 0
test/integration/Packages-bug-591882-conkeror


+ 34 - 0
test/integration/Packages-pdiff-usage

@@ -0,0 +1,34 @@
+Package: apt
+Version: 0.7.25.3
+Architecture: i386
+Maintainer: APT Development Team <deity@lists.debian.org>
+Installed-Size: 5244
+Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7)
+Provides: libapt-pkg-libc6.9-6-4.8
+Depends: libc6 (>= 2.3.4), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.4.0), debian-archive-keyring
+Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt
+Filename: pool/main/a/apt/apt_0.7.25.3_i386.deb
+Size: 1750610
+MD5sum: 311aadc67d1b72428b54c9b4e1f76671
+SHA1: 3c695e028f74d5c55226f9ef30000bbbd881088c
+SHA256: b46fd1546151c545fe4bfa56a5cc0e7811a9f68826326a529777fd660f28f050
+Description: Advanced front-end for dpkg
+ This is Debian's next generation front-end for the dpkg package manager.
+ It provides the apt-get utility and APT dselect method that provides a
+ simpler, safer way to install and upgrade packages.
+ .
+ APT features complete installation ordering, multiple source capability
+ and several other unique features, see the Users Guide in apt-doc.
+
+Package: oldstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 100
+Filename: pool/oldstuff_1.0_i386.deb
+Size: 100000
+MD5sum: 311aeeadf78324aaff54c9b4e1f76671
+SHA1: 3c695e028f74d5c544deeddaaa1242desa81088c
+SHA256: b46fd1546151c545fe4bfa56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool but old stuff
+ This package will disappear in the next mirror update

+ 37 - 0
test/integration/Packages-pdiff-usage-new

@@ -0,0 +1,37 @@
+Package: newstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 101
+Filename: pool/newstuff_1.0_i386.deb
+Size: 101100
+MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
+SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
+SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool and shiny new stuff
+ This package will appear in the next mirror update
+
+Package: apt
+Priority: important
+Section: admin
+Installed-Size: 5672
+Maintainer: APT Development Team <deity@lists.debian.org>
+Architecture: i386
+Version: 0.8.0~pre1
+Replaces: manpages-pl (<< 20060617-3~)
+Provides: libapt-pkg4.10
+Depends: libc6 (>= 2.3.4), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.4.0), zlib1g (>= 1:1.1.4), debian-archive-keyring, gnupg
+Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt
+Conflicts: python-apt (<< 0.7.93.2~)
+Filename: pool/main/a/apt/apt_0.8.0~pre1_i386.deb
+Size: 2013046
+MD5sum: 6786ca6270c988f2c201716ededaedec
+SHA1: fe26559e745d4c2c977c27170938852041c9adff
+SHA256: a12f968467e1e3cec24191b72bfe84f7aeed3ce422e1a60bb4f1454f2b89b8ee
+Description: Advanced front-end for dpkg
+ This is Debian's next generation front-end for the dpkg package manager.
+ It provides the apt-get utility and APT dselect method that provides a
+ simpler, safer way to install and upgrade packages.
+ .
+ APT features complete installation ordering, multiple source capability
+ and several other unique features, see the Users Guide in apt-doc.

+ 33 - 0
test/integration/create-test-data

@@ -0,0 +1,33 @@
+#!/bin/sh
+set +e # its okay to fail in these script, most of the time the apt* stuff will generate errors
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+BUILDDIRECTORY="${TESTDIR}/../../build/bin"
+
+GENERATE=$1
+CODENAME=$2
+shift 2
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+touch $WORKDIR/status
+TMPGEN=$WORKDIR/Packages
+export LANG=C
+
+LISTOFPKGS=$(aptget install $* -t $CODENAME -so Dir::state::status=$WORKDIR/status -o Dir::Cache::archives=$WORKDIR -o pkgCacheGen::Essential=none -o APT::Immediate-Configure=0 2> /dev/null | awk '/^Inst/ {print $2}' | sed -e "s#\$#/$CODENAME#")
+aptcache show $LISTOFPKGS --no-all-versions 2> /dev/null > $TMPGEN
+sed -i $TMPGEN \
+	-e '/^ / d' \
+	-e '/^SHA1: / d' -e '/^SHA256: / d' \
+	-e '/^Homepage: / d' -e '/^Tag: / d' \
+	-e '/^Xul-Appid: / d' \
+	-e '/^Status: / d'
+
+if echo "$GENERATE" | grep '^status-' > /dev/null; then
+	sed -i $TMPGEN -e '/^Package: / a\
+Status: install ok installed' \
+		-e '/^Filename: / d' -e '/^Size: / d' -e '/^MD5sum: / d'
+fi
+
+apt-sortpkgs $TMPGEN > $GENERATE

+ 321 - 29
test/integration/framework

@@ -28,15 +28,45 @@ msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
 msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
 msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
 
 
 # enable / disable Debugging
 # enable / disable Debugging
-msginfo() { true; }
-msgdebug() { true; }
-msgninfo() { true; }
-msgndebug() { true; }
-msgdone() { if [ "$1" = "debug" -o "$1" = "info" ]; then true; else echo "${CDONE}DONE${CNORMAL}" >&2; fi }
+MSGLEVEL=${MSGLEVEL:-3}
+if [ $MSGLEVEL -le 0 ]; then
+	msgdie() { true; }
+fi
+if [ $MSGLEVEL -le 1 ]; then
+	msgwarn() { true; }
+	msgnwarn() { true; }
+fi
+if [ $MSGLEVEL -le 2 ]; then
+	msgmsg() { true; }
+	msgnmsg() { true; }
+fi
+if [ $MSGLEVEL -le 3 ]; then
+	msginfo() { true; }
+	msgninfo() { true; }
+fi
+if [ $MSGLEVEL -le 4 ]; then
+	msgdebug() { true; }
+	msgndebug() { true; }
+fi
+msgdone() {
+	if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
+	   [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
+	   [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
+	   [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
+	   [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
+		true;
+	else
+		echo "${CDONE}DONE${CNORMAL}" >&2;
+	fi
+}
 
 
 runapt() {
 runapt() {
 	msgdebug "Executing: ${CCMD}$*${CDEBUG} "
 	msgdebug "Executing: ${CCMD}$*${CDEBUG} "
-	APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	if [ -f ./aptconfig.conf ]; then
+		APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	else
+		LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	fi
 }
 }
 aptconfig() { runapt apt-config $*; }
 aptconfig() { runapt apt-config $*; }
 aptcache() { runapt apt-cache $*; }
 aptcache() { runapt apt-cache $*; }
@@ -44,24 +74,27 @@ aptget() { runapt apt-get $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 
 
 setupenvironment() {
 setupenvironment() {
-	local TMPWORKINGDIRECTORY=$(mktemp -d)
+	TMPWORKINGDIRECTORY=$(mktemp -d)
 	local TESTDIR=$(readlink -f $(dirname $0))
 	local TESTDIR=$(readlink -f $(dirname $0))
 	msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
 	msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
 	BUILDDIRECTORY="${TESTDIR}/../../build/bin"
 	BUILDDIRECTORY="${TESTDIR}/../../build/bin"
 	test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
 	test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
 	local OLDWORKINGDIRECTORY=$(pwd)
 	local OLDWORKINGDIRECTORY=$(pwd)
-	trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+	CURRENTTRAP="cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY"
+	trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 	cd $TMPWORKINGDIRECTORY
 	cd $TMPWORKINGDIRECTORY
-	mkdir rootdir aptarchive
+	mkdir rootdir aptarchive keys
 	cd rootdir
 	cd rootdir
-	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg
-	mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial
+	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache
+	mkdir -p var/log/apt var/lib/apt
+	mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
 	local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
 	local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
 	if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
 	if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
 		cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
 		cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
 	else
 	else
 		touch var/lib/dpkg/status
 		touch var/lib/dpkg/status
 	fi
 	fi
+	touch var/lib/dpkg/available
 	mkdir -p usr/lib/apt
 	mkdir -p usr/lib/apt
 	ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
 	ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
 	cd ..
 	cd ..
@@ -69,11 +102,19 @@ setupenvironment() {
 	if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
 	if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
 		cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
 		cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
 	else
 	else
-		touch var/lib/dpkg/status
+		touch aptarchive/Packages
 	fi
 	fi
-	echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
+	cp $(find $TESTDIR -name '*.pub' -o -name '*.sec') keys/
+	ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+	echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
 	echo "Debug::NoLocking \"true\";" >> aptconfig.conf
 	echo "Debug::NoLocking \"true\";" >> aptconfig.conf
 	echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
 	echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
+	echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
+	echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
 	export LC_ALL=C
 	export LC_ALL=C
 	msgdone "info"
 	msgdone "info"
 }
 }
@@ -88,10 +129,193 @@ configarchitecture() {
 	done
 	done
 }
 }
 
 
-buildflataptarchive() {
-	msginfo "Build APT archive for ${CCMD}$0${CINFO}…"
+setupsimplenativepackage() {
+	local NAME="$1"
+	local ARCH="$2"
+	local VERSION="$3"
+	local RELEASE="${4:-unstable}"
+	local DEPENDENCIES="$5"
+	local DESCRIPTION="$6"
+	local SECTION="${7:-others}"
+	local DISTSECTION
+	if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+		DISTSECTION="main"
+	else
+		DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+	fi
+	local BUILDDIR=incoming/${NAME}-${VERSION}
+	mkdir -p ${BUILDDIR}/debian/source
+	cd ${BUILDDIR}
+	echo "* most suckless software product ever" > FEATURES
+	test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
+	test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
+
+  * Initial release
+
+ -- Joe Sixpack <joe@example.org>  $(date -R)" > debian/changelog
+	test -e debian/control || echo "Source: $NAME
+Section: $SECTION
+Priority: optional
+Maintainer: Joe Sixpack <joe@example.org>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.9.1
+
+Package: $NAME
+Architecture: $ARCH" > debian/control
+	test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
+	if [ -z "$DESCRIPTION" ]; then
+		echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ YOU did something horribly wrong! They are autogenerated
+ und used only by testcases for APT and surf no other propose…" >> debian/control
+	else
+		echo "Description: $DESCRIPTION" >> debian/control
+	fi
+	test -e debian/compat || echo "7" > debian/compat
+	test -e debian/source/format || echo "3.0 (native)" > debian/source/format
+	test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
+	cd - > /dev/null
+}
+
+buildsimplenativepackage() {
+	local NAME="$1"
+	local ARCH="$2"
+	local VERSION="$3"
+	local RELEASE="${4:-unstable}"
+	local DEPENDENCIES="$5"
+	local DESCRIPTION="$6"
+	local SECTION="${7:-others}"
+	local DISTSECTION
+	if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+		DISTSECTION="main"
+	else
+		DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+	fi
+	setupsimplenativepackage "$NAME" "$ARCH" "$VERSION" "$RELEASE" "$DEPENDENCIES" "$DESCRIPTION" "$SECTION"
+	buildpackage "incoming/${NAME}-${VERSION}" "$RELEASE" "$DISTSECTION"
+	rm -rf "incoming/${NAME}-${VERSION}"
+}
+
+buildpackage() {
+	local BUILDDIR=$1
+	local RELEASE=$2
+	local SECTION=$3
+	msgninfo "Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… "
+	cd $BUILDDIR
+	if [ "$ARCH" = "all" ]; then
+		ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
+	fi
+	local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)"
+	local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")"
+	local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._-]*$')"
+	cd - > /dev/null
+	for PKG in $PKGS; do
+		echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
+	done
+	for SRC in $SRCS; do
+		echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
+	done
+	msgdone "info"
+}
+
+buildaptarchive() {
+	if [ -d incoming ]; then
+		buildaptarchivefromincoming $*
+	else
+		buildaptarchivefromfiles $*
+	fi
+}
+
+createaptftparchiveconfig() {
+	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
+	echo -n 'Dir {
+	ArchiveDir "' >> ftparchive.conf
+	echo -n $(readlink -f .) >> ftparchive.conf
+	echo -n '";
+	CacheDir "' >> ftparchive.conf
+	echo -n $(readlink -f ..) >> ftparchive.conf
+	echo -n '";
+	FileListDir "' >> ftparchive.conf
+	echo -n $(readlink -f pool/) >> ftparchive.conf
+	echo -n '";
+};
+Default {
+	Packages::Compress ". gzip bzip2 lzma";
+	Sources::Compress ". gzip bzip2 lzma";
+	Contents::Compress ". gzip bzip2 lzma";
+};
+TreeDefault {
+	Directory "pool/";
+	SrcDirectory "pool/";
+};
+APT {
+	FTPArchive {
+		Release {
+			Origin "joesixpack";
+			Label "apttestcases";
+			Suite "unstable";
+			Description "repository with dummy packages";
+			Architectures "' >> ftparchive.conf
+	echo -n "$ARCHS" >> ftparchive.conf
+	echo 'source";
+		};
+	};
+};' >> ftparchive.conf
+	for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
+		echo -n 'tree "dists/' >> ftparchive.conf
+		echo -n "$DIST" >> ftparchive.conf
+		echo -n '" {
+	Architectures "' >> ftparchive.conf
+		echo -n "$ARCHS" >> ftparchive.conf
+		echo -n 'source";
+	FileList "' >> ftparchive.conf
+		echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
+		echo -n '";
+	SourceFileList "' >> ftparchive.conf
+		echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
+		echo -n '";
+	Sections "' >> ftparchive.conf
+		echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf
+		echo '";
+};' >> ftparchive.conf
+	done
+}
+
+buildaptftparchivedirectorystructure() {
+	local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
+	for DIST in $DISTS; do
+		local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
+		for SECTION in $SECTIONS; do
+			local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
+			for ARCH in $ARCHS; do
+				mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
+			done
+			mkdir -p dists/${DIST}/${SECTION}/source
+			mkdir -p dists/${DIST}/${SECTION}/i18n
+		done
+	done
+}
+
+buildaptarchivefromincoming() {
+	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on incoming packages…"
+	cd aptarchive
+	[ -e pool ] || ln -s ../incoming pool
+	[ -e ftparchive.conf ] || createaptftparchiveconfig
+	[ -e dists ] || buildaptftparchivedirectorystructure
+	msgninfo "\tGenerate Packages, Sources and Contents files… "
+	aptftparchive -qq generate ftparchive.conf
+	msgdone "info"
+	msgninfo "\tGenerate Release files… "
+	for dir in $(find ./dists -mindepth 1 -maxdepth 1 -type d); do
+		aptftparchive -qq release $dir -o APT::FTPArchive::Release::Codename="$(echo "$dir" | cut -d'/' -f 3)" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+	done
+	cd - > /dev/null
+	msgdone "info"
+}
+
+buildaptarchivefromfiles() {
+	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on prebuild files…"
 	cd aptarchive
 	cd aptarchive
-	APTARCHIVE=$(readlink -f .)
 	if [ -f Packages ]; then
 	if [ -f Packages ]; then
 		msgninfo "\tPackages file… "
 		msgninfo "\tPackages file… "
 		cat Packages | gzip > Packages.gz
 		cat Packages | gzip > Packages.gz
@@ -106,13 +330,27 @@ buildflataptarchive() {
 		cat Sources | lzma > Sources.lzma
 		cat Sources | lzma > Sources.lzma
 		msgdone "info"
 		msgdone "info"
 	fi
 	fi
+	msgninfo "\tRelease file… "
+	aptftparchive -qq release . | sed -e '/0 Release$/ d' > Release # remove the self reference
+	msgdone "info"
 	cd ..
 	cd ..
-	aptftparchive release . > Release
+}
+
+setupdistsaptarchive() {
+	local APTARCHIVE=$(readlink -f ./aptarchive)
+	rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
+	rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
+	for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
+		SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
+		msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
+		echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
+		echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
+		msgdone "info"
+	done
 }
 }
 
 
 setupflataptarchive() {
 setupflataptarchive() {
-	buildflataptarchive
-	APTARCHIVE=$(readlink -f ./aptarchive)
+	local APTARCHIVE=$(readlink -f ./aptarchive)
 	if [ -f ${APTARCHIVE}/Packages ]; then
 	if [ -f ${APTARCHIVE}/Packages ]; then
 		msgninfo "\tadd deb sources.list line… "
 		msgninfo "\tadd deb sources.list line… "
 		echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
 		echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
@@ -127,10 +365,53 @@ setupflataptarchive() {
 	else
 	else
 		rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
 		rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
 	fi
 	fi
+}
+
+setupaptarchive() {
+	buildaptarchive
+	if [ -e aptarchive/dists ]; then
+		setupdistsaptarchive
+	else
+		setupflataptarchive
+	fi
+	signreleasefiles
+	msgninfo "\tSync APT's cache with the archive… "
 	aptget update -qq
 	aptget update -qq
+	msgdone "info"
+}
+
+signreleasefiles() {
+	local SIGNER="${1:-Joe Sixpack}"
+	msgninfo "\tSign archive with $SIGNER key… "
+	local SECKEYS=""
+	for KEY in $(find keys/ -name '*.sec'); do
+		SECKEYS="$SECKEYS --secret-keyring $KEY"
+	done
+	local PUBKEYS=""
+	for KEY in $(find keys/ -name '*.pub'); do
+		PUBKEYS="$PUBKEYS --keyring $KEY"
+	done
+	for RELEASE in $(find aptarchive/ -name Release); do
+		gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg ${RELEASE}
+	done
+	msgdone "info"
+}
+
+changetowebserver() {
+	if which weborf > /dev/null; then
+		weborf -xb aptarchive/ 2>&1 > /dev/null &
+		CURRENTTRAP="kill $(ps | grep weborf | sed -e 's#^[ ]*##' | cut -d' ' -f 1); $CURRENTTRAP"
+		trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+		local APTARCHIVE="file://$(readlink -f ./aptarchive)"
+		for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
+			sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
+		done
+		return 0
+	fi
+	return 1
 }
 }
 
 
-diff() {
+checkdiff() {
 	local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
 	local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
 	if [ -n "$DIFFTEXT" ]; then
 	if [ -n "$DIFFTEXT" ]; then
 		echo
 		echo
@@ -141,12 +422,23 @@ diff() {
 	fi
 	fi
 }
 }
 
 
+testfileequal() {
+	local FILE="$1"
+	shift
+	msgtest "Test for correctness of file" "$FILE"
+	if [ -z "$*" ]; then
+		echo -n "" | checkdiff $FILE - && msgpass || msgfail
+	else
+		echo "$*" | checkdiff $FILE - && msgpass || msgfail
+	fi
+}
+
 testequal() {
 testequal() {
 	local COMPAREFILE=$(mktemp)
 	local COMPAREFILE=$(mktemp)
 	echo "$1" > $COMPAREFILE
 	echo "$1" > $COMPAREFILE
 	shift
 	shift
 	msgtest "Test for equality of" "$*"
 	msgtest "Test for equality of" "$*"
-	$* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+	$* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 	rm $COMPAREFILE
 	rm $COMPAREFILE
 }
 }
 
 
@@ -159,32 +451,32 @@ testequalor2() {
 	shift 2
 	shift 2
 	msgtest "Test for equality OR of" "$*"
 	msgtest "Test for equality OR of" "$*"
 	$* 2>&1 1> $COMPAREAGAINST
 	$* 2>&1 1> $COMPAREAGAINST
-	(diff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
-		diff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
-		( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \
-		       "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" &&
+	(checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
+		checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
+		( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
+		       "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" &&
 		  msgfail )
 		  msgfail )
 	rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST
 	rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST
 }
 }
 
 
 testshowvirtual() {
 testshowvirtual() {
-	local VIRTUAL="E: Can't select versions from package '$1' as it purely virtual"
+	local VIRTUAL="N: Can't select versions from package '$1' as it purely virtual"
 	local PACKAGE="$1"
 	local PACKAGE="$1"
 	shift
 	shift
 	while [ -n "$1" ]; do
 	while [ -n "$1" ]; do
 		VIRTUAL="${VIRTUAL}
 		VIRTUAL="${VIRTUAL}
-E: Can't select versions from package '$1' as it purely virtual"
+N: Can't select versions from package '$1' as it purely virtual"
 		PACKAGE="${PACKAGE} $1"
 		PACKAGE="${PACKAGE} $1"
 		shift
 		shift
 	done
 	done
 	msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
 	msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
 	VIRTUAL="${VIRTUAL}
 	VIRTUAL="${VIRTUAL}
-E: No packages found"
+N: No packages found"
 	local COMPAREFILE=$(mktemp)
 	local COMPAREFILE=$(mktemp)
 	local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
 	local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
 	eval `apt-config shell ARCH APT::Architecture`
 	eval `apt-config shell ARCH APT::Architecture`
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
-	aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+	aptcache show $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 	rm $COMPAREFILE
 	rm $COMPAREFILE
 }
 }
 
 

BIN
test/integration/joesixpack.pub


BIN
test/integration/joesixpack.sec


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1357 - 0
test/integration/status-bug-591882-conkeror


+ 1 - 1
test/integration/test-bug-590041-prefer-non-virtual-packages

@@ -41,7 +41,7 @@ $pkglibc6
 $pkglibdb1
 $pkglibdb1
 EOF
 EOF
 
 
-setupflataptarchive
+setupaptarchive
 
 
 testshowvirtual libc6:i386
 testshowvirtual libc6:i386
 testequal "$pkglibc6" aptcache show libc6:armel
 testequal "$pkglibc6" aptcache show libc6:armel

+ 1 - 1
test/integration/test-bug-590438-broken-provides-thanks-to-remove-order

@@ -6,7 +6,7 @@ local TESTDIR=$(readlink -f $(dirname $0))
 
 
 setupenvironment
 setupenvironment
 configarchitecture "i386"
 configarchitecture "i386"
-setupflataptarchive
+setupaptarchive
 
 
 pkgbasefile="Package: base-files
 pkgbasefile="Package: base-files
 Status: install ok installed
 Status: install ok installed

+ 75 - 0
test/integration/test-bug-591882-conkeror

@@ -0,0 +1,75 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+setupaptarchive
+
+UPGRADEFAIL="Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+  conkeror libdatrie0 libkrb53 libxcb-xlib0 xulrunner-1.9
+The following NEW packages will be installed:
+  gcc-4.4-base libavahi-client3 libavahi-common-data libavahi-common3 libc-bin
+  libdatrie1 libdb4.7 libdb4.8 libdbus-1-3 libgssapi-krb5-2 libjasper1
+  libk5crypto3 libkrb5-3 libkrb5support0 liblzma2 libpam-modules libpam0g
+  libuuid1 libxcb-atom1 libxcb-aux0 libxcb-event1 libxml2 passwd
+  sensible-utils shared-mime-info xz-utils
+The following packages will be upgraded:
+  coreutils debconf debconf-i18n debianutils defoma dpkg file fontconfig
+  fontconfig-config libacl1 libatk1.0-0 libattr1 libbz2-1.0 libc6 libcairo2
+  libcomerr2 libcups2 libexpat1 libfontconfig1 libfreetype6 libgcc1
+  libgcrypt11 libgdbm3 libglib2.0-0 libgnutls26 libgpg-error0 libgtk2.0-0
+  libgtk2.0-common libhunspell-1.2-0 libice6 libjpeg62 libkeyutils1
+  liblocale-gettext-perl libmagic1 libncurses5 libnewt0.52 libnspr4-0d
+  libnss3-1d libpango1.0-0 libpango1.0-common libpcre3 libpixman-1-0
+  libpng12-0 libpopt0 libselinux1 libslang2 libsm6 libsqlite3-0
+  libstartup-notification0 libstdc++6 libtasn1-3 libtext-charwidth-perl
+  libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtiff4
+  libx11-6 libx11-data libxau6 libxcb-render-util0 libxcb-render0 libxcb1
+  libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2
+  libxi6 libxinerama1 libxrandr2 libxrender1 libxt6 lsb-base ncurses-bin perl
+  perl-base perl-modules readline-common sed ttf-dejavu-core ucf whiptail
+  x11-common zlib1g
+87 upgraded, 26 newly installed, 5 to remove and 0 not upgraded.
+Need to get 0B/54.4MB of archives.
+After this operation, 12.4MB of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation."
+
+UPGRADESUCCESS="Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+  libdatrie0 libkrb53 libxcb-xlib0 xulrunner-1.9
+The following NEW packages will be installed:
+  gcc-4.4-base libasound2 libavahi-client3 libavahi-common-data
+  libavahi-common3 libc-bin libdatrie1 libdb4.7 libdb4.8 libdbus-1-3
+  libgssapi-krb5-2 libjasper1 libk5crypto3 libkrb5-3 libkrb5support0 liblzma2
+  libmozjs2d libpam-modules libpam0g libreadline6 libuuid1 libxcb-atom1
+  libxcb-aux0 libxcb-event1 libxml2 passwd sensible-utils shared-mime-info
+  xulrunner-1.9.1 xz-utils
+The following packages will be upgraded:
+  conkeror coreutils debconf debconf-i18n debianutils defoma dpkg file
+  fontconfig fontconfig-config libacl1 libatk1.0-0 libattr1 libbz2-1.0 libc6
+  libcairo2 libcomerr2 libcups2 libexpat1 libfontconfig1 libfreetype6 libgcc1
+  libgcrypt11 libgdbm3 libglib2.0-0 libgnutls26 libgpg-error0 libgtk2.0-0
+  libgtk2.0-common libhunspell-1.2-0 libice6 libjpeg62 libkeyutils1
+  liblocale-gettext-perl libmagic1 libncurses5 libnewt0.52 libnspr4-0d
+  libnss3-1d libpango1.0-0 libpango1.0-common libpcre3 libpixman-1-0
+  libpng12-0 libpopt0 libselinux1 libslang2 libsm6 libsqlite3-0
+  libstartup-notification0 libstdc++6 libtasn1-3 libtext-charwidth-perl
+  libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtiff4
+  libx11-6 libx11-data libxau6 libxcb-render-util0 libxcb-render0 libxcb1
+  libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2
+  libxi6 libxinerama1 libxrandr2 libxrender1 libxt6 lsb-base ncurses-bin perl
+  perl-base perl-modules readline-common sed ttf-dejavu-core ucf whiptail
+  x11-common zlib1g
+88 upgraded, 30 newly installed, 4 to remove and 0 not upgraded.
+Need to get 0B/62.9MB of archives.
+After this operation, 36.0MB of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation."
+
+# Test that the old behavior can be restored with the option
+testequal "$UPGRADEFAIL" aptget dist-upgrade --trivial-only -o pkgProblemResolver::FixByInstall=0
+testequal "$UPGRADESUCCESS" aptget dist-upgrade --trivial-only #-o pkgProblemResolver::FixByInstall=0

+ 131 - 0
test/integration/test-compressed-indexes

@@ -0,0 +1,131 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage "testpkg" "i386" "1.0"
+setupaptarchive
+
+local GOODSHOW="$(aptcache show testpkg)
+"
+local GOODPOLICY="$(aptcache policy testpkg)"
+local GOODSHOWSRC="$(aptcache showsrc testpkg)
+"
+
+test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3
+testequal "$GOODSHOW" aptcache show testpkg
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 file:/' | wc -l) -eq 4
+testequal "$GOODPOLICY" aptcache policy testpkg
+test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4
+testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+
+
+testrun() {
+	local F
+	if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
+		msgtest "Check if all index files are" "${1:-uncompressed}"
+		if [ "$1" = "compressed" ]; then
+			! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+			test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
+			test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
+		else
+			test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+			test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
+		fi
+		if [ -n "$F" ]; then
+			ls -laR rootdir/var/lib/apt/lists/
+			msgfail
+		else
+			msgpass
+		fi
+		msgtest "Check if package is downloadable"
+		aptget install -d testpkg -qq && msgpass || msgfail
+		msgtest "\tdeb file is present"; test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
+		aptget clean
+		msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
+	fi
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODSHOW" aptcache show testpkg
+	testequal "$GOODSHOW" aptcache show testpkg
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODPOLICY" aptcache policy testpkg
+	testequal "$GOODPOLICY" aptcache policy testpkg
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	rm -rf rootdir/var/cache/apt/archives
+	msgtest "Check if the source is aptgetable"
+	aptget source testpkg -qq 2> /dev/null > /dev/null && msgpass || msgfail
+	msgtest "\tdsc file is present"; test -f testpkg_1.0.dsc && msgpass || msgfail
+	msgtest "\tdirectory is present"; test -d testpkg-1.0 && msgpass || msgfail
+	rm -rf testpkg-1.0
+}
+
+msgmsg "File: Test with uncompressed indexes"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
+testrun
+
+rm -rf rootdir/var/lib/apt/lists
+echo 'Acquire::CompressionTypes::Order:: "gz";
+Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
+
+aptget update -qq
+msgmsg "File: Test with compressed indexes"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
+testrun "compressed"
+
+rm rootdir/etc/apt/apt.conf.d/02compressindex
+changetowebserver
+aptget update -qq
+local GOODPOLICY="$(aptcache policy testpkg)"
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 http://' | wc -l) -eq 4
+testequal "$GOODPOLICY" aptcache policy testpkg
+
+msgmsg "HTTP: Test with uncompressed indexes"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
+testrun
+
+rm -rf rootdir/var/lib/apt/lists
+echo 'Acquire::CompressionTypes::Order:: "gz";
+Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
+
+aptget update -qq
+msgmsg "HTTP: Test with compressed indexes"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
+testrun "compressed"

+ 54 - 0
test/integration/test-disappearing-packages

@@ -0,0 +1,54 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage "old-pkg" "i386" "1.0" "stable"
+buildsimplenativepackage "unrelated" "all" "0.5" "unstable"
+
+setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg
+Replaces: old-pkg
+Conflicts: old-pkg (<< 2.0)"
+local BUILDDIR="incoming/new-pkg-2.0"
+echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links
+buildpackage "$BUILDDIR" "unstable" "main"
+rm -rf "$BUILDDIR"
+
+setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg"
+local BUILDDIR="incoming/old-pkg-2.0"
+echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links
+echo "
+override_dh_link:
+	rm -rf debian/old-pkg/usr/share/doc/old-pkg/
+	dh_link" >> ${BUILDDIR}/debian/rules
+buildpackage "$BUILDDIR" "unstable" "main"
+rm -rf "$BUILDDIR"
+
+setupaptarchive
+
+aptget install old-pkg=1.0 --trivial-only -qq 2>&1 > /dev/null
+
+testfileequal "rootdir/var/lib/apt/extended_states" "" # old-pkg is manual installed
+
+local CMD="aptget dist-upgrade -y -q=0"
+msgtest "Test for equality of" "$CMD"
+local COMPAREFILE=$(mktemp)
+echo "The following package disappeared from your system as
+all files have been overwritten by other packages:
+  old-pkg
+Note: This is done automatic and on purpose by dpkg." > $COMPAREFILE
+$CMD 2>&1 | tail -n 4 | diff $COMPAREFILE - && msgpass || msgfail
+rm $COMPAREFILE
+
+sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d'
+testfileequal "rootdir/var/log/apt/history.log" "
+Install: old-pkg:i386 (1.0)
+
+Install: new-pkg:i386 (2.0, automatic)
+Upgrade: old-pkg:i386 (1.0, 2.0)
+Disappeared: old-pkg (1.0)"
+
+testfileequal "rootdir/var/lib/apt/extended_states" "" # new-pkg should have get the manual flag from old-pkg

+ 51 - 0
test/integration/test-pdiff-usage

@@ -0,0 +1,51 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildaptarchive
+setupflataptarchive
+changetowebserver
+signreleasefiles
+aptget update -qq
+
+testnopackage newstuff
+PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
+testequal "$(cat ${PKGFILE})
+" aptcache show apt oldstuff
+
+cp ${PKGFILE}-new aptarchive/Packages
+cat aptarchive/Packages | gzip > aptarchive/Packages.gz
+cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
+cat aptarchive/Packages | lzma > aptarchive/Packages.lzma
+rm -rf aptarchive/Packages.diff
+aptftparchive release aptarchive/ > aptarchive/Release
+mkdir -p aptarchive/Packages.diff
+PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
+diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
+cat $PATCHFILE | gzip > ${PATCHFILE}.gz
+PATCHINDEX="aptarchive/Packages.diff/Index"
+echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
+SHA1-History:
+ 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
+ $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
+SHA1-Patches:
+ 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
+ $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
+sed -i aptarchive/Release \
+ -e "/^MD5Sum:/ a\
+ \ $(md5sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index" \
+ -e "/^SHA1:/ a\
+ \ $(sha1sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index" \
+ -e "/^SHA256:/ a\
+ \ $(sha256sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index"
+signreleasefiles
+aptget update -qq
+
+testnopackage oldstuff
+testequal "$(cat ${PKGFILE}-new)
+" aptcache show apt newstuff