Преглед изворни кода

merged from lp:~donkult/apt/sid

Michael Vogt пре 15 година
родитељ
комит
7adf8bb88f

+ 22 - 25
apt-pkg/acquire-item.cc

@@ -1258,9 +1258,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash,	/*{{{*
       if (SigFile == "")
       if (SigFile == "")
       {
       {
          // There was no signature file, so we are finished.  Download
          // There was no signature file, so we are finished.  Download
-         // the indexes and do only hashsum verification
+         // the indexes and do only hashsum verification if possible
          MetaIndexParser->Load(DestFile);
          MetaIndexParser->Load(DestFile);
-         QueueIndexes(true);
+         QueueIndexes(false);
       }
       }
       else
       else
       {
       {
@@ -1378,33 +1378,30 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
         ++Target)
         ++Target)
    {
    {
       HashString ExpectedIndexHash;
       HashString ExpectedIndexHash;
-      if (verify)
+      const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+      if (Record == NULL)
       {
       {
-	 const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
-	 if (Record == NULL)
+	 if (verify == true && (*Target)->IsOptional() == false)
 	 {
 	 {
-	    if ((*Target)->IsOptional() == false)
-	    {
-	       Status = StatAuthError;
-	       strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
-	       return;
-	    }
+	    Status = StatAuthError;
+	    strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+	    return;
 	 }
 	 }
-	 else
+      }
+      else
+      {
+	 ExpectedIndexHash = Record->Hash;
+	 if (_config->FindB("Debug::pkgAcquire::Auth", false))
 	 {
 	 {
-	    ExpectedIndexHash = Record->Hash;
-	    if (_config->FindB("Debug::pkgAcquire::Auth", false))
-	    {
-	       std::cerr << "Queueing: " << (*Target)->URI << std::endl;
-	       std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
-	       std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
-	    }
-	    if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
-	    {
-	       Status = StatAuthError;
-	       strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
-	       return;
-	    }
+	    std::cerr << "Queueing: " << (*Target)->URI << std::endl;
+	    std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
+	    std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
+	 }
+	 if (verify == true && ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
+	 {
+	    Status = StatAuthError;
+	    strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
+	    return;
 	 }
 	 }
       }
       }
 
 

+ 4 - 0
apt-pkg/acquire.cc

@@ -445,6 +445,10 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
    if it is part of the download set. */
    if it is part of the download set. */
 bool pkgAcquire::Clean(string Dir)
 bool pkgAcquire::Clean(string Dir)
 {
 {
+   // non-existing directories are by definition clean…
+   if (DirectoryExists(Dir) == false)
+      return true;
+
    DIR *D = opendir(Dir.c_str());   
    DIR *D = opendir(Dir.c_str());   
    if (D == 0)
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());

+ 14 - 0
apt-pkg/cachefile.cc

@@ -163,6 +163,20 @@ bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
+// CacheFile::RemoveCaches - remove all cache files from disk		/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgCacheFile::RemoveCaches()
+{
+   std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+   std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+
+   if (pkgcache.empty() == false && RealFileExists(pkgcache) == true)
+      unlink(pkgcache.c_str());
+   if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
+      unlink(srcpkgcache.c_str());
+}
+									/*}}}*/
 // CacheFile::Close - close the cache files				/*{{{*/
 // CacheFile::Close - close the cache files				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */

+ 1 - 0
apt-pkg/cachefile.h

@@ -57,6 +57,7 @@ class pkgCacheFile
    bool Open(OpProgress *Progress = NULL, bool WithLock = true);
    bool Open(OpProgress *Progress = NULL, bool WithLock = true);
    inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
    inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
    __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
    __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
+   static void RemoveCaches();
    void Close();
    void Close();
 
 
    inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
    inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };

+ 16 - 5
apt-pkg/indexrecords.cc

@@ -113,10 +113,14 @@ bool indexRecords::Load(const string Filename)				/*{{{*/
    }
    }
    // get the user settings for this archive and use what expires earlier
    // get the user settings for this archive and use what expires earlier
    int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
    int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
-   if (Label.empty() == true)
+   if (Label.empty() == false)
       MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
       MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+   int MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
+   if (Label.empty() == false)
+      MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
 
 
-   if(MaxAge == 0) // No user settings, use the one from the Release file
+   if(MaxAge == 0 &&
+      (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file
       return true;
       return true;
 
 
    time_t date;
    time_t date;
@@ -125,10 +129,17 @@ bool indexRecords::Load(const string Filename)				/*{{{*/
       strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
       strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
       return false;
       return false;
    }
    }
-   date += 24*60*60*MaxAge;
 
 
-   if (ValidUntil == 0 || ValidUntil > date)
-      ValidUntil = date;
+   if (MinAge != 0 && ValidUntil != 0) {
+      time_t const min_date = date + MinAge;
+      if (ValidUntil < min_date)
+	 ValidUntil = min_date;
+   }
+   if (MaxAge != 0) {
+      time_t const max_date = date + MaxAge;
+      if (ValidUntil == 0 || ValidUntil > max_date)
+	 ValidUntil = max_date;
+   }
 
 
    return true;
    return true;
 }
 }

+ 53 - 17
apt-pkg/orderlist.cc

@@ -152,7 +152,7 @@ bool pkgOrderList::DoRun()
    iterator OldEnd = End;
    iterator OldEnd = End;
    End = NList;
    End = NList;
    for (iterator I = List; I != OldEnd; ++I)
    for (iterator I = List; I != OldEnd; ++I)
-      if (VisitNode(PkgIterator(Cache,*I)) == false)
+      if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false)
       {
       {
 	 End = OldEnd;
 	 End = OldEnd;
 	 return false;
 	 return false;
@@ -495,33 +495,69 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver)
 									/*}}}*/
 									/*}}}*/
 // OrderList::VisitProvides - Visit all of the providing packages	/*{{{*/
 // OrderList::VisitProvides - Visit all of the providing packages	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-/* This routine calls visit on all providing packages. */
+/* This routine calls visit on all providing packages.
+
+   If the dependency is negative it first visits packages which are
+   intended to be removed and after that all other packages.
+   It does so to avoid situations in which this package is used to
+   satisfy a (or-group/provides) dependency of another package which
+   could have been satisfied also by upgrading another package -
+   otherwise we have more broken packages dpkg needs to auto-
+   deconfigure and in very complicated situations it even decides
+   against it! */
 bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
 bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
-{   
+{
    SPtrArray<Version *> List = D.AllTargets();
    SPtrArray<Version *> List = D.AllTargets();
-   for (Version **I = List; *I != 0; I++)
+   for (Version **I = List; *I != 0; ++I)
    {
    {
       VerIterator Ver(Cache,*I);
       VerIterator Ver(Cache,*I);
       PkgIterator Pkg = Ver.ParentPkg();
       PkgIterator Pkg = Ver.ParentPkg();
 
 
+      if (D.IsNegative() == true && Cache[Pkg].Delete() == false)
+	 continue;
+
       if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
       if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
 	 continue;
 	 continue;
-      
+
       if (D.IsNegative() == false &&
       if (D.IsNegative() == false &&
 	  Cache[Pkg].InstallVer != *I)
 	  Cache[Pkg].InstallVer != *I)
 	 continue;
 	 continue;
-      
+
       if (D.IsNegative() == true &&
       if (D.IsNegative() == true &&
 	  (Version *)Pkg.CurrentVer() != *I)
 	  (Version *)Pkg.CurrentVer() != *I)
 	 continue;
 	 continue;
-      
+
+      // Skip over missing files
+      if (Critical == false && IsMissing(D.ParentPkg()) == true)
+	 continue;
+
+      if (VisitNode(Pkg, "Provides-1") == false)
+	 return false;
+   }
+   if (D.IsNegative() == false)
+      return true;
+   for (Version **I = List; *I != 0; ++I)
+   {
+      VerIterator Ver(Cache,*I);
+      PkgIterator Pkg = Ver.ParentPkg();
+
+      if (Cache[Pkg].Delete() == true)
+	 continue;
+
+      if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
+	 continue;
+
+      if ((Version *)Pkg.CurrentVer() != *I)
+	 continue;
+
       // Skip over missing files
       // Skip over missing files
       if (Critical == false && IsMissing(D.ParentPkg()) == true)
       if (Critical == false && IsMissing(D.ParentPkg()) == true)
 	 continue;
 	 continue;
 
 
-      if (VisitNode(Pkg) == false)
+      if (VisitNode(Pkg, "Provides-2") == false)
 	 return false;
 	 return false;
    }
    }
+
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -530,7 +566,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
 /* This is the core ordering routine. It calls the set dependency
 /* This is the core ordering routine. It calls the set dependency
    consideration functions which then potentialy call this again. Finite
    consideration functions which then potentialy call this again. Finite
    depth is achived through the colouring mechinism. */
    depth is achived through the colouring mechinism. */
-bool pkgOrderList::VisitNode(PkgIterator Pkg)
+bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
 {
 {
    // Looping or irrelevent.
    // Looping or irrelevent.
    // This should probably trancend not installed packages
    // This should probably trancend not installed packages
@@ -541,7 +577,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg)
    if (Debug == true)
    if (Debug == true)
    {
    {
       for (int j = 0; j != Depth; j++) clog << ' ';
       for (int j = 0; j != Depth; j++) clog << ' ';
-      clog << "Visit " << Pkg.FullName() << endl;
+      clog << "Visit " << Pkg.FullName() << " from " << from << endl;
    }
    }
    
    
    Depth++;
    Depth++;
@@ -636,7 +672,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
 	 if (CheckDep(D) == true)
 	 if (CheckDep(D) == true)
 	    continue;
 	    continue;
 
 
-	 if (VisitNode(D.ParentPkg()) == false)
+	 if (VisitNode(D.ParentPkg(), "UnPackCrit") == false)
 	    return false;
 	    return false;
       }
       }
       else
       else
@@ -811,7 +847,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
 	    if (IsMissing(D.ParentPkg()) == true)
 	    if (IsMissing(D.ParentPkg()) == true)
 	       continue;
 	       continue;
 	    
 	    
-	    if (VisitNode(D.ParentPkg()) == false)
+	    if (VisitNode(D.ParentPkg(), "UnPackDep-Parent") == false)
 	       return false;
 	       return false;
 	 }
 	 }
 	 else
 	 else
@@ -825,7 +861,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
 	       if (CheckDep(D) == true)
 	       if (CheckDep(D) == true)
 		 continue;
 		 continue;
 
 
-	       if (VisitNode(D.TargetPkg()) == false)
+	       if (VisitNode(D.TargetPkg(), "UnPackDep-Target") == false)
 		 return false;
 		 return false;
 	    }
 	    }
 	 }
 	 }
@@ -924,7 +960,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
 			if (IsFlag(P, InList) == true &&
 			if (IsFlag(P, InList) == true &&
 			    IsFlag(P, AddPending) == false &&
 			    IsFlag(P, AddPending) == false &&
 			    Cache[P].InstallVer != 0 &&
 			    Cache[P].InstallVer != 0 &&
-			    VisitNode(P) == true)
+			    VisitNode(P, "Remove-P") == true)
 			{
 			{
 			   Flag(P, Immediate);
 			   Flag(P, Immediate);
 			   tryFixDeps = false;
 			   tryFixDeps = false;
@@ -960,7 +996,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
 		  if (IsFlag(F.TargetPkg(), InList) == true &&
 		  if (IsFlag(F.TargetPkg(), InList) == true &&
 		      IsFlag(F.TargetPkg(), AddPending) == false &&
 		      IsFlag(F.TargetPkg(), AddPending) == false &&
 		      Cache[F.TargetPkg()].InstallVer != 0 &&
 		      Cache[F.TargetPkg()].InstallVer != 0 &&
-		      VisitNode(F.TargetPkg()) == true)
+		      VisitNode(F.TargetPkg(), "Remove-Target") == true)
 		  {
 		  {
 		     Flag(F.TargetPkg(), Immediate);
 		     Flag(F.TargetPkg(), Immediate);
 		     tryFixDeps = false;
 		     tryFixDeps = false;
@@ -974,7 +1010,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
 			if (IsFlag(Prv.OwnerPkg(), InList) == true &&
 			if (IsFlag(Prv.OwnerPkg(), InList) == true &&
 			    IsFlag(Prv.OwnerPkg(), AddPending) == false &&
 			    IsFlag(Prv.OwnerPkg(), AddPending) == false &&
 			    Cache[Prv.OwnerPkg()].InstallVer != 0 &&
 			    Cache[Prv.OwnerPkg()].InstallVer != 0 &&
-			    VisitNode(Prv.OwnerPkg()) == true)
+			    VisitNode(Prv.OwnerPkg(), "Remove-Owner") == true)
 			{
 			{
 			   Flag(Prv.OwnerPkg(), Immediate);
 			   Flag(Prv.OwnerPkg(), Immediate);
 			   tryFixDeps = false;
 			   tryFixDeps = false;
@@ -994,7 +1030,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
 	 if (IsMissing(D.ParentPkg()) == true)
 	 if (IsMissing(D.ParentPkg()) == true)
 	    continue;
 	    continue;
 	 
 	 
-	 if (VisitNode(D.ParentPkg()) == false)
+	 if (VisitNode(D.ParentPkg(), "Remove-Parent") == false)
 	    return false;
 	    return false;
       }
       }
    
    

+ 3 - 1
apt-pkg/orderlist.h

@@ -18,6 +18,7 @@
 
 
 
 
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
 
 
 class pkgDepCache;
 class pkgDepCache;
 class pkgOrderList : protected pkgCache::Namespace
 class pkgOrderList : protected pkgCache::Namespace
@@ -45,7 +46,8 @@ class pkgOrderList : protected pkgCache::Namespace
    bool Debug;
    bool Debug;
    
    
    // Main visit function
    // Main visit function
-   bool VisitNode(PkgIterator Pkg);
+   __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); };
+   bool VisitNode(PkgIterator Pkg, char const* from);
    bool VisitDeps(DepFunc F,PkgIterator Pkg);
    bool VisitDeps(DepFunc F,PkgIterator Pkg);
    bool VisitRDeps(DepFunc F,PkgIterator Pkg);
    bool VisitRDeps(DepFunc F,PkgIterator Pkg);
    bool VisitRProvides(DepFunc F,VerIterator Ver);
    bool VisitRProvides(DepFunc F,VerIterator Ver);

+ 26 - 5
apt-pkg/packagemanager.cc

@@ -603,18 +603,39 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate)
 
 
    List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
    List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
 
 
-   if (instVer->MultiArch == pkgCache::Version::Same)
+   if (Immediate == true && instVer->MultiArch == pkgCache::Version::Same)
+   {
+      /* Do lockstep M-A:same unpacking in two phases:
+	 First unpack all installed architectures, then the not installed.
+	 This way we avoid that M-A: enabled packages are installed before
+	 their older non-M-A enabled packages are replaced by newer versions */
+      bool const installed = Pkg->CurrentVer != 0;
+      if (installed == true && Install(Pkg,FileNames[Pkg->ID]) == false)
+	 return false;
       for (PkgIterator P = Pkg.Group().PackageList();
       for (PkgIterator P = Pkg.Group().PackageList();
 	   P.end() == false; P = Pkg.Group().NextPkg(P))
 	   P.end() == false; P = Pkg.Group().NextPkg(P))
       {
       {
-	 if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
+	 if (P->CurrentVer == 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
 	     Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
 	     Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
 	      (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
 	      (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
 	    continue;
 	    continue;
-	 SmartUnPack(P, false);
+	 if (SmartUnPack(P, false) == false)
+	    return false;
       }
       }
-
-   if(Install(Pkg,FileNames[Pkg->ID]) == false)
+      if (installed == false && Install(Pkg,FileNames[Pkg->ID]) == false)
+	 return false;
+      for (PkgIterator P = Pkg.Group().PackageList();
+	   P.end() == false; P = Pkg.Group().NextPkg(P))
+      {
+	 if (P->CurrentVer != 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
+	     Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
+	      (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
+	    continue;
+	 if (SmartUnPack(P, false) == false)
+	    return false;
+      }
+   }
+   else if (Install(Pkg,FileNames[Pkg->ID]) == false)
       return false;
       return false;
 
 
    // Perform immedate configuration of the package.
    // Perform immedate configuration of the package.

+ 14 - 6
cmdline/apt-get.cc

@@ -1625,7 +1625,8 @@ bool DoUpdate(CommandLine &CmdL)
    if (_config->FindB("APT::Get::Download",true) == true)
    if (_config->FindB("APT::Get::Download",true) == true)
        ListUpdate(Stat, *List);
        ListUpdate(Stat, *List);
 
 
-   // Rebuild the cache.   
+   // Rebuild the cache.
+   pkgCacheFile::RemoveCaches();
    if (Cache.BuildCaches() == false)
    if (Cache.BuildCaches() == false)
       return false;
       return false;
    
    
@@ -2203,10 +2204,14 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
 /* */
 /* */
 bool DoClean(CommandLine &CmdL)
 bool DoClean(CommandLine &CmdL)
 {
 {
+   std::string const archivedir = _config->FindDir("Dir::Cache::archives");
+   std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+   std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+
    if (_config->FindB("APT::Get::Simulate") == true)
    if (_config->FindB("APT::Get::Simulate") == true)
    {
    {
-      cout << "Del " << _config->FindDir("Dir::Cache::archives") << "* " <<
-	 _config->FindDir("Dir::Cache::archives") << "partial/*" << endl;
+      cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl
+	   << "Del " << pkgcache << " " << srcpkgcache << endl;
       return true;
       return true;
    }
    }
    
    
@@ -2214,14 +2219,17 @@ bool DoClean(CommandLine &CmdL)
    FileFd Lock;
    FileFd Lock;
    if (_config->FindB("Debug::NoLocking",false) == false)
    if (_config->FindB("Debug::NoLocking",false) == false)
    {
    {
-      Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
+      Lock.Fd(GetLock(archivedir + "lock"));
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
 	 return _error->Error(_("Unable to lock the download directory"));
 	 return _error->Error(_("Unable to lock the download directory"));
    }
    }
    
    
    pkgAcquire Fetcher;
    pkgAcquire Fetcher;
-   Fetcher.Clean(_config->FindDir("Dir::Cache::archives"));
-   Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/");
+   Fetcher.Clean(archivedir);
+   Fetcher.Clean(archivedir + "partial/");
+
+   pkgCacheFile::RemoveCaches();
+
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 1
cmdline/apt-key

@@ -152,7 +152,7 @@ if [ "$1" = "--keyring" ]; then
         #echo "keyfile given"
         #echo "keyfile given"
 	shift
 	shift
 	TRUSTEDFILE="$1"
 	TRUSTEDFILE="$1"
-	if [ -r "$TRUSTEDFILE" ]; then
+	if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ]; then
 		GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE"
 		GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE"
 	else
 	else
 		echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable"
 		echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable"

+ 29 - 3
debian/changelog

@@ -3,16 +3,42 @@ apt (0.8.15.7) UNRELEASED; urgency=low
   [ David Kalnischkies ]
   [ David Kalnischkies ]
   * apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc:
   * apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc:
     - ignore "self"-conflicts for all architectures of a package
     - ignore "self"-conflicts for all architectures of a package
-      instead of just for the architecture of the package locked at
-      in the ordering of installations too (Closes: #802901)
+      instead of just for the architecture of the package look at
+      in the ordering of installations, too (LP: #802901)
+    - M-A:same lockstep unpack should operate on installed
+      packages first (LP: #835625)
   * test/*
   * test/*
     - reorganize the various testcases and helper we have and
     - reorganize the various testcases and helper we have and
       integrate them better into the buildsystem
       integrate them better into the buildsystem
     - run the test/libapt testcases at package build-time
     - run the test/libapt testcases at package build-time
   * debian/apt.symbols:
   * debian/apt.symbols:
     - add the newly added symbols since 0.8.15.3
     - add the newly added symbols since 0.8.15.3
+  * cmdline/apt-get.cc:
+    - remove the binary caches in 'apt-get clean' as it is the first
+      thing recommend by many supporters in case of APT segfaults
+    - remove the caches in 'apt-get update', too, as they will be
+      invalid in most cases anyway
+  * apt-pkg/acquire-item.cc:
+    - if no Release.gpg file is found try to verify with hashes,
+      but do not fail if a hash can't be found
+  * apt-pkg/acquire.cc:
+    - non-existing directories are by definition clean
+  * cmdline/apt-key:
+    - if command is 'add' do not error out if the specified
+      keyring doesn't exist, it will be created by gpg
+  * apt-pkg/orderlist.cc:
+    - prefer visiting packages marked for deletion in VisitProvides
+      if we are operating on a negative dependency so that we can
+      deal early with the fallout of this remove
+  * apt-pkg/indexrecords.cc:
+    - fix Acquire::Max-ValidTime option by interpreting it really
+      as seconds as specified in the manpage and not as days
+    - add an Acquire::Min-ValidTime option (Closes: #640122)
+  * doc/apt.conf.5.xml:
+    - reword Acquire::Max-ValidTime documentation to make clear
+      that it doesn't provide the new Min-ValidTime functionality
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 17 Aug 2011 15:09:16 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 09 Sep 2011 12:49:24 +0200
 
 
 apt (0.8.15.6) unstable; urgency=low
 apt (0.8.15.6) unstable; urgency=low
 
 

+ 17 - 8
doc/apt.conf.5.xml

@@ -267,14 +267,23 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
 
 
      <varlistentry><term>Max-ValidTime</term>
      <varlistentry><term>Max-ValidTime</term>
 	 <listitem><para>Seconds the Release file should be considered valid after
 	 <listitem><para>Seconds the Release file should be considered valid after
-	 it was created. The default is "for ever" (0) if the Release file of the
-	 archive doesn't include a <literal>Valid-Until</literal> header.
-	 If it does then this date is the default. The date from the Release file or
-	 the date specified by the creation time of the Release file
-	 (<literal>Date</literal> header) plus the seconds specified with this
-	 options are used to check if the validation of a file has expired by using
-	 the earlier date of the two. Archive specific settings can be made by
-	 appending the label of the archive to the option name.
+	 it was created (indicated by the <literal>Date</literal> header).
+	 If the Release file itself includes a <literal>Valid-Until</literal> header
+	 the earlier date of the two is used as the expiration date.
+	 The default value is <literal>0</literal> which stands for "for ever".
+	 Archive specific settings can be made by appending the label of the archive
+	 to the option name.
+	 </para></listitem>
+     </varlistentry>
+
+     <varlistentry><term>Min-ValidTime</term>
+	 <listitem><para>Minimum of seconds the Release file should be considered
+	 valid after it was created (indicated by the <literal>Date</literal> header).
+	 Use this if you need to use a seldomly updated (local) mirror of a more
+	 regular updated archive with a <literal>Valid-Until</literal> header
+	 instead of competely disabling the expiration date checking.
+	 Archive specific settings can and should be used by appending the label of
+	 the archive to the option name.
 	 </para></listitem>
 	 </para></listitem>
      </varlistentry>
      </varlistentry>
 
 

+ 23 - 13
test/integration/framework

@@ -513,10 +513,12 @@ buildaptarchivefromfiles() {
 # can be overridden by testcases for their pleasure
 # can be overridden by testcases for their pleasure
 getcodenamefromsuite() { echo -n "$1"; }
 getcodenamefromsuite() { echo -n "$1"; }
 getreleaseversionfromsuite() { true; }
 getreleaseversionfromsuite() { true; }
+getlabelfromsuite() { true; }
 
 
 generatereleasefiles() {
 generatereleasefiles() {
+	# $1 is the Date header and $2 is the ValidUntil header to be set
+	# both should be given in notation date/touch can understand
 	msgninfo "\tGenerate Release files… "
 	msgninfo "\tGenerate Release files… "
-	local DATE="${1:-now}"
 	if [ -e aptarchive/dists ]; then
 	if [ -e aptarchive/dists ]; then
 		for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do
 		for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do
 			aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index
 			aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index
@@ -525,27 +527,35 @@ generatereleasefiles() {
 			local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
 			local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
 			local CODENAME="$(getcodenamefromsuite $SUITE)"
 			local CODENAME="$(getcodenamefromsuite $SUITE)"
 			local VERSION="$(getreleaseversionfromsuite $SUITE)"
 			local VERSION="$(getreleaseversionfromsuite $SUITE)"
-			if [ -z "$VERSION" ]; then
-				aptftparchive -qq release $dir \
-					-o APT::FTPArchive::Release::Suite="${SUITE}" \
-					-o APT::FTPArchive::Release::Codename="${CODENAME}" \
-						| sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
-			else
-				aptftparchive -qq release $dir \
-					-o APT::FTPArchive::Release::Suite="${SUITE}" \
-					-o APT::FTPArchive::Release::Codename="${CODENAME}" \
-					-o APT::FTPArchive::Release::Version="${VERSION}" \
-						| sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+			local LABEL="$(getlabelfromsuite $SUITE)"
+			if [ -n "$VERSION" ]; then
+				VERSION="-o APT::FTPArchive::Release::Version=${VERSION}"
 			fi
 			fi
+			if [ -n "$LABEL" ]; then
+				LABEL="-o APT::FTPArchive::Release::Label=${LABEL}"
+			fi
+			aptftparchive -qq release $dir \
+				-o APT::FTPArchive::Release::Suite="${SUITE}" \
+				-o APT::FTPArchive::Release::Codename="${CODENAME}" \
+				${LABEL} \
+				${VERSION} \
+					| sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
 			if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
 			if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
 				sed -i '/^Date: / a\
 				sed -i '/^Date: / a\
 NotAutomatic: yes' $dir/Release
 NotAutomatic: yes' $dir/Release
 			fi
 			fi
+			if [ -n "$1" -a "$1" != "now" ]; then
+				sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
+			fi
+			if [ -n "$2" ]; then
+				sed -i "/^Date: / a\
+Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
+			fi
 		done
 		done
 	else
 	else
 		aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
 		aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
 	fi
 	fi
-	if [ "$DATE" != "now" ]; then
+	if [ -n "$1" -a "$1" != "now" ]; then
 		for release in $(find ./aptarchive -name 'Release'); do
 		for release in $(find ./aptarchive -name 'Release'); do
 			touch -d "$1" $release
 			touch -d "$1" $release
 		done
 		done

+ 0 - 1
test/integration/test-bug-254770-segfault-if-cache-not-buildable

@@ -12,7 +12,6 @@ trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 chmod a-x rootdir/var/lib/dpkg
 chmod a-x rootdir/var/lib/dpkg
 
 
 testsegfault() {
 testsegfault() {
-	rm -f rootdir/var/cache/apt/*.bin
 	msgtest "No segfault in" "$*"
 	msgtest "No segfault in" "$*"
 	local TEST="$($* 2>&1 | grep -v 'E:')"
 	local TEST="$($* 2>&1 | grep -v 'E:')"
 	if [ -z "$TEST" ]; then
 	if [ -z "$TEST" ]; then

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

@@ -25,7 +25,6 @@ MD5sum: 8489687ce10e656babd467c9ee389349
 Description-de: Verschiedene Dateien für das Basis-System von Debian"
 Description-de: Verschiedene Dateien für das Basis-System von Debian"
 
 
 predependsgawk() {
 predependsgawk() {
-	rm rootdir/var/cache/apt/*.bin
 	cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
 	cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
 	echo "$pkgbasefile
 	echo "$pkgbasefile
 Pre-Depends: $1
 Pre-Depends: $1
@@ -57,7 +56,6 @@ predependsgawk "awk | aawk"
 predependsgawk "awk"
 predependsgawk "awk"
 
 
 predependsgawk2() {
 predependsgawk2() {
-	rm rootdir/var/cache/apt/*.bin
 	cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
 	cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status
 	echo "$pkgbasefile
 	echo "$pkgbasefile
 Pre-Depends: $1
 Pre-Depends: $1

+ 1 - 1
test/integration/test-bug-595691-empty-and-broken-archive-files

@@ -11,7 +11,7 @@ touch aptarchive/Packages
 setupflataptarchive
 setupflataptarchive
 
 
 testaptgetupdate() {
 testaptgetupdate() {
-	rm -rf rootdir/var/lib/apt rootdir/var/cache/apt
+	rm -rf rootdir/var/lib/apt
 	aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
 	aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
 	sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
 	sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
 	GIVEN="$1"
 	GIVEN="$1"

+ 1 - 1
test/integration/test-bug-601016-description-translation

@@ -57,7 +57,7 @@ Description-${LOCALE}: Mächtige Oberfläche für dpkg
 testrun() {
 testrun() {
 	echo "Acquire::Languages { \"${LOCALE}\"; \"en\"; };" > rootdir/etc/apt/apt.conf.d/00languages
 	echo "Acquire::Languages { \"${LOCALE}\"; \"en\"; };" > rootdir/etc/apt/apt.conf.d/00languages
 	export LC_ALL=""
 	export LC_ALL=""
-	rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt/
+	rm -rf rootdir/var/lib/apt/lists
 	setupaptarchive
 	setupaptarchive
 	testequal "$LOCALESTANZA" aptcache show apt -o Test=File-${LOCALE}
 	testequal "$LOCALESTANZA" aptcache show apt -o Test=File-${LOCALE}
 	testequal "$NOLONGSTANZA" aptcache show apt -o Acquire::Languages="ww" -o Test=File-${LOCALE}
 	testequal "$NOLONGSTANZA" aptcache show apt -o Acquire::Languages="ww" -o Test=File-${LOCALE}

+ 2 - 2
test/integration/test-bug-618288-multiarch-same-lockstep

@@ -22,8 +22,8 @@ Building dependency tree...
 The following packages will be upgraded:
 The following packages will be upgraded:
   apt:i386 apt2 libsame libsame:i386
   apt:i386 apt2 libsame libsame:i386
 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
-Inst libsame [1] (2 unstable [amd64]) [libsame:amd64 on libsame:i386] [libsame:i386 on libsame:amd64] [libsame:i386 apt2:amd64 ]
-Inst libsame:i386 [1] (2 unstable [i386]) [apt2:amd64 apt:i386 ]
+Inst libsame:i386 [1] (2 unstable [i386]) [libsame:amd64 on libsame:i386] [libsame:i386 on libsame:amd64] [libsame:amd64 apt:i386 ]
+Inst libsame [1] (2 unstable [amd64]) [apt2:amd64 apt:i386 ]
 Conf libsame:i386 (2 unstable [i386]) [apt2:amd64 apt:i386 ]
 Conf libsame:i386 (2 unstable [i386]) [apt2:amd64 apt:i386 ]
 Conf libsame (2 unstable [amd64]) [apt2:amd64 apt:i386 ]
 Conf libsame (2 unstable [amd64]) [apt2:amd64 apt:i386 ]
 Inst apt2 [1] (2 unstable [amd64]) [apt:i386 ]
 Inst apt2 [1] (2 unstable [amd64]) [apt:i386 ]

+ 8 - 8
test/integration/test-bug-632221-cross-dependency-satisfaction

@@ -47,10 +47,10 @@ Inst amdboot (1.0 unstable [amd64])
 Inst cool (1.0 unstable [amd64])
 Inst cool (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst foreigner (1.0 unstable [amd64])
 Inst foreigner (1.0 unstable [amd64])
-Inst libc6:armel (1.0 unstable [armel])
 Inst libc6 (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [amd64])
-Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libc6:armel (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [amd64])
+Inst libc6-dev:armel (1.0 unstable [armel])
 Conf amdboot (1.0 unstable [amd64])
 Conf amdboot (1.0 unstable [amd64])
 Conf cool (1.0 unstable [amd64])
 Conf cool (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
@@ -90,10 +90,10 @@ Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst cool (1.0 unstable [armel])
 Inst cool (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
 Inst foreigner (1.0 unstable [armel])
 Inst foreigner (1.0 unstable [armel])
-Inst libc6 (1.0 unstable [armel])
 Inst libc6:amd64 (1.0 unstable [amd64])
 Inst libc6:amd64 (1.0 unstable [amd64])
-Inst libc6-dev (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [armel])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf cool (1.0 unstable [armel])
 Conf cool (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
@@ -129,10 +129,10 @@ The following NEW packages will be installed:
 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
 Inst amdboot (1.0 unstable [amd64])
 Inst amdboot (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [amd64])
-Inst libc6:armel (1.0 unstable [armel])
 Inst libc6 (1.0 unstable [amd64])
 Inst libc6 (1.0 unstable [amd64])
-Inst libc6-dev:armel (1.0 unstable [armel])
+Inst libc6:armel (1.0 unstable [armel])
 Inst libc6-dev (1.0 unstable [amd64])
 Inst libc6-dev (1.0 unstable [amd64])
+Inst libc6-dev:armel (1.0 unstable [armel])
 Conf amdboot (1.0 unstable [amd64])
 Conf amdboot (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
 Conf libc6 (1.0 unstable [amd64])
@@ -169,10 +169,10 @@ The following NEW packages will be installed:
 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst amdboot:amd64 (1.0 unstable [amd64])
 Inst doxygen (1.0 unstable [armel])
 Inst doxygen (1.0 unstable [armel])
-Inst libc6 (1.0 unstable [armel])
 Inst libc6:amd64 (1.0 unstable [amd64])
 Inst libc6:amd64 (1.0 unstable [amd64])
-Inst libc6-dev (1.0 unstable [armel])
+Inst libc6 (1.0 unstable [armel])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
 Inst libc6-dev:amd64 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [armel])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf amdboot:amd64 (1.0 unstable [amd64])
 Conf doxygen (1.0 unstable [armel])
 Conf doxygen (1.0 unstable [armel])
 Conf libc6:amd64 (1.0 unstable [amd64])
 Conf libc6:amd64 (1.0 unstable [amd64])

+ 1 - 1
test/integration/test-bug-633350-do-not-kill-last-char-in-Release

@@ -15,7 +15,7 @@ echo 'NotAutomatic: yes' >> aptarchive/dists/unstable/Release
 signreleasefiles
 signreleasefiles
 find aptarchive/dists -name 'InRelease' -delete
 find aptarchive/dists -name 'InRelease' -delete
 
 
-rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt
+rm -rf rootdir/var/lib/apt/lists
 
 
 OUTPUT="$(aptget update 2>&1)"
 OUTPUT="$(aptget update 2>&1)"
 msgtest 'Check that parsing happens without warnings' 'with missing newline'
 msgtest 'Check that parsing happens without warnings' 'with missing newline'

+ 8 - 9
test/integration/test-compressed-indexes

@@ -10,10 +10,10 @@ configarchitecture "i386"
 buildsimplenativepackage "testpkg" "i386" "1.0"
 buildsimplenativepackage "testpkg" "i386" "1.0"
 setupaptarchive
 setupaptarchive
 
 
-local GOODSHOW="$(aptcache show testpkg)
+GOODSHOW="$(aptcache show testpkg)
 "
 "
-local GOODPOLICY="$(aptcache policy testpkg)"
-local GOODSHOWSRC="$(aptcache showsrc testpkg)
+GOODPOLICY="$(aptcache policy testpkg)"
+GOODSHOWSRC="$(aptcache showsrc testpkg)
 "
 "
 
 
 test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
 test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
@@ -51,17 +51,16 @@ testrun() {
 		aptget clean
 		aptget clean
 		msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
 		msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
 	fi
 	fi
-	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
 	testequal "$GOODSHOW" aptcache show testpkg
 	testequal "$GOODSHOW" aptcache show testpkg
 	testequal "$GOODSHOW" aptcache show testpkg
 	testequal "$GOODSHOW" aptcache show testpkg
-	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
 	testequal "$GOODPOLICY" aptcache policy testpkg
 	testequal "$GOODPOLICY" aptcache policy testpkg
 	testequal "$GOODPOLICY" aptcache policy testpkg
 	testequal "$GOODPOLICY" aptcache policy testpkg
-	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
 	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
 	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
 	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
+	aptget clean
 	msgtest "Check if the source is aptgetable"
 	msgtest "Check if the source is aptgetable"
 	aptget source testpkg -qq 2> /dev/null > /dev/null && msgpass || msgfail
 	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 "\tdsc file is present"; test -f testpkg_1.0.dsc && msgpass || msgfail
@@ -100,7 +99,7 @@ testrun "compressed"
 rm rootdir/etc/apt/apt.conf.d/02compressindex
 rm rootdir/etc/apt/apt.conf.d/02compressindex
 changetowebserver
 changetowebserver
 aptget update -qq
 aptget update -qq
-local GOODPOLICY="$(aptcache policy testpkg)"
+GOODPOLICY="$(aptcache policy testpkg)"
 test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 http://' | wc -l) -eq 4
 test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 http://' | wc -l) -eq 4
 testequal "$GOODPOLICY" aptcache policy testpkg
 testequal "$GOODPOLICY" aptcache policy testpkg
 
 

+ 4 - 4
test/integration/test-disappearing-packages

@@ -12,13 +12,13 @@ buildsimplenativepackage "unrelated" "all" "0.5" "unstable"
 setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg
 setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg
 Replaces: old-pkg
 Replaces: old-pkg
 Conflicts: old-pkg (<< 2.0)"
 Conflicts: old-pkg (<< 2.0)"
-local BUILDDIR="incoming/new-pkg-2.0"
+BUILDDIR="incoming/new-pkg-2.0"
 echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links
 echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links
 buildpackage "$BUILDDIR" "unstable" "main"
 buildpackage "$BUILDDIR" "unstable" "main"
 rm -rf "$BUILDDIR"
 rm -rf "$BUILDDIR"
 
 
 setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg"
 setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg"
-local BUILDDIR="incoming/old-pkg-2.0"
+BUILDDIR="incoming/old-pkg-2.0"
 echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links
 echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links
 echo "
 echo "
 override_dh_link:
 override_dh_link:
@@ -33,9 +33,9 @@ aptget install old-pkg=1.0 --trivial-only -qq 2>&1 > /dev/null
 
 
 testmarkedauto # old-pkg is manual installed
 testmarkedauto # old-pkg is manual installed
 
 
-local CMD="aptget dist-upgrade -y -q=0"
+CMD="aptget dist-upgrade -y -q=0"
 msgtest "Test for equality of" "$CMD"
 msgtest "Test for equality of" "$CMD"
-local COMPAREFILE=$(mktemp)
+COMPAREFILE=$(mktemp)
 echo "The following package disappeared from your system as
 echo "The following package disappeared from your system as
 all files have been overwritten by other packages:
 all files have been overwritten by other packages:
   old-pkg
   old-pkg

+ 0 - 2
test/integration/test-hashsum-verification

@@ -19,8 +19,6 @@ prepare() {
 	for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
 	for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
 		touch -d 'now - 6 hours' $release
 		touch -d 'now - 6 hours' $release
 	done
 	done
-	rm -rf rootdir/var/cache/apt/archives
-	rm -f rootdir/var/cache/apt/*.bin
 	cp $1 aptarchive/Packages
 	cp $1 aptarchive/Packages
 	find aptarchive -name 'Release' -delete
 	find aptarchive -name 'Release' -delete
 	cat aptarchive/Packages | gzip > aptarchive/Packages.gz
 	cat aptarchive/Packages | gzip > aptarchive/Packages.gz

+ 0 - 7
test/integration/test-policy-pinning

@@ -30,21 +30,18 @@ testequalpolicy 100 500
 testequalpolicy 990 500 -t now
 testequalpolicy 990 500 -t now
 
 
 sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
 sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicy 100 1 -o Test=NotAutomatic
 testequalpolicy 100 1 -o Test=NotAutomatic
 testequalpolicy 990 1 -o Test=NotAutomatic -t now
 testequalpolicy 990 1 -o Test=NotAutomatic -t now
 
 
 sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
 sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
 testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
 testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
 testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
 
 
 sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
 sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicy 100 500 -o Test=Automatic
 testequalpolicy 100 500 -o Test=Automatic
@@ -135,7 +132,6 @@ Pin-Priority: -1" > rootdir/etc/apt/preferences
 rm rootdir/etc/apt/preferences
 rm rootdir/etc/apt/preferences
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 signreleasefiles
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
 testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
@@ -164,7 +160,6 @@ testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t s
 rm rootdir/etc/apt/preferences
 rm rootdir/etc/apt/preferences
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 signreleasefiles
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
@@ -211,7 +206,6 @@ setupaptarchive
 
 
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 signreleasefiles
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
@@ -220,7 +214,6 @@ testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=N
 
 
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 signreleasefiles
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
 aptget update -qq
 aptget update -qq
 
 
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades

+ 95 - 0
test/integration/test-releasefile-valid-until

@@ -0,0 +1,95 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+insertpackage 'wheezy' 'apt' 'all' '0.8.15'
+
+getlabelfromsuite() {
+	echo -n 'Testcases'
+}
+
+
+setupaptarchive
+
+setupreleasefile() {
+	rm -rf rootdir/var/lib/apt/lists
+	aptget clean
+	generatereleasefiles "$1" "$2"
+	signreleasefiles
+}
+
+aptgetupdate() {
+	if aptget update $* 2>&1 | grep -q 'is expired'; then
+		return 1
+	else
+		return 0
+	fi
+}
+
+setupreleasefile
+msgtest 'Release file is accepted as it has' 'no Until'
+aptgetupdate && msgpass || msgfail
+
+setupreleasefile
+msgtest 'Release file is accepted as it has' 'no Until and good Max-Valid'
+aptgetupdate -o Acquire::Max-ValidTime=3600 && msgpass || msgfail
+
+setupreleasefile 'now - 2 days'
+msgtest 'Release file is rejected as it has' 'no Until, but bad Max-Valid'
+aptgetupdate -o Acquire::Max-ValidTime=3600 && msgfail || msgpass
+
+setupreleasefile 'now - 3 days' 'now + 1 day'
+msgtest 'Release file is accepted as it has' 'good Until'
+aptgetupdate && msgpass || msgfail
+
+setupreleasefile 'now - 7 days' 'now - 4 days'
+msgtest 'Release file is rejected as it has' 'bad Until'
+aptgetupdate && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now - 4 days'
+msgtest 'Release file is rejected as it has' 'bad Until (ignore good Max-Valid)'
+aptgetupdate -o Acquire::Max-ValidTime=1209600 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now - 4 days'
+msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until)'
+aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now + 4 days'
+msgtest 'Release file is rejected as it has' 'bad Max-Valid (good Until)'
+aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now + 4 days'
+msgtest 'Release file is accepted as it has' 'good labeled Max-Valid'
+aptgetupdate -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcases=1209600 && msgpass || msgfail
+
+setupreleasefile 'now - 7 days' 'now + 4 days'
+msgtest 'Release file is rejected as it has' 'bad labeled Max-Valid'
+aptgetupdate -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now + 1 days'
+msgtest 'Release file is accepted as it has' 'good Until (good Min-Valid, no Max-Valid)'
+aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail
+
+setupreleasefile 'now - 7 days' 'now - 4 days'
+msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, no Max-Valid)'
+aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail
+
+setupreleasefile 'now - 7 days' 'now - 2 days'
+msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, good Max-Valid) <'
+aptgetupdate -o Acquire::Min-ValidTime=1209600 -o Acquire::Max-ValidTime=2419200 && msgpass || msgfail
+
+setupreleasefile 'now - 7 days' 'now - 2 days'
+msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, good Min-Valid) >'
+aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=2419200 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now - 2 days'
+msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) <'
+aptgetupdate -o Acquire::Min-ValidTime=12096 -o Acquire::Max-ValidTime=241920 && msgfail || msgpass
+
+setupreleasefile 'now - 7 days' 'now - 2 days'
+msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) >'
+aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920 && msgfail || msgpass

+ 1 - 2
test/integration/test-releasefile-verification

@@ -19,8 +19,7 @@ prepare() {
 	for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
 	for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
 		touch -d 'now - 6 hours' $release
 		touch -d 'now - 6 hours' $release
 	done
 	done
-	rm -rf rootdir/var/cache/apt/archives
-	rm -f rootdir/var/cache/apt/*.bin
+	aptget clean
 	cp $1 aptarchive/Packages
 	cp $1 aptarchive/Packages
 	find aptarchive -name 'Release' -delete
 	find aptarchive -name 'Release' -delete
 	cat aptarchive/Packages | gzip > aptarchive/Packages.gz
 	cat aptarchive/Packages | gzip > aptarchive/Packages.gz

+ 31 - 0
test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first

@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertinstalledpackage 'libsame' 'i386' '1'
+insertinstalledpackage 'apt' 'i386' '1' 'Depends: libsame (= 1)'
+
+insertpackage 'unstable' 'libsame' 'i386,amd64' '2' 'Multi-Arch: same'
+insertpackage 'unstable' 'apt' 'i386' '2' 'Depends: libsame (= 2)'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+  apt:i386 libsame:i386
+The following NEW packages will be installed:
+  libsame
+The following packages will be upgraded:
+  apt:i386 libsame:i386
+2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame:i386 [1] (2 unstable [i386]) [apt:i386 ]
+Inst libsame (2 unstable [amd64]) [apt:i386 ]
+Conf libsame:i386 (2 unstable [i386]) [apt:i386 ]
+Conf libsame (2 unstable [amd64]) [apt:i386 ]
+Inst apt:i386 [1] (2 unstable [i386])
+Conf apt:i386 (2 unstable [i386])' aptget install libsame:amd64 -s