]> git.saurik.com Git - apt.git/commitdiff
Fixed segfault in re-install/upgrade condition
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:39 +0000 (16:53 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:39 +0000 (16:53 +0000)
Author: jgg
Date: 1999-04-28 22:48:44 GMT
Fixed segfault in re-install/upgrade condition

apt-pkg/acquire-item.cc
apt-pkg/algorithms.cc
apt-pkg/depcache.cc
apt-pkg/pkgcachegen.h

index 35ae7d8b74395b37d33dca161b8305ed2b5bd35f..f2fd0b8b8a406aac8ee08c9ecb1fc55ab2264881 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.28 1999/04/20 05:59:29 jgg Exp $
+// $Id: acquire-item.cc,v 1.29 1999/04/28 22:48:44 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -346,7 +346,12 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                StoreFilename(StoreFilename), Vf(Version.FileList())
 {
    Retries = _config->FindI("Acquire::Retries",0);
                StoreFilename(StoreFilename), Vf(Version.FileList())
 {
    Retries = _config->FindI("Acquire::Retries",0);
-      
+
+   if (Version.Arch() == 0)
+      _error->Error("I wasn't able to locate file for the %s package. "
+                   "This might mean you need to manually fix this package. (due to missing arch)",
+                   Version.ParentPkg().Name());
+   
    // Generate the final file name as: package_version_arch.deb
    StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
                    QuoteString(Version.VerStr(),"_:") + '_' +
    // Generate the final file name as: package_version_arch.deb
    StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
                    QuoteString(Version.VerStr(),"_:") + '_' +
index 967aba1800de96c74d8fe1795b3e6a11d357efcf..991a612283e51bffc30ad8004839dab8279455fd 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: algorithms.cc,v 1.16 1999/02/05 02:26:00 jgg Exp $
+// $Id: algorithms.cc,v 1.17 1999/04/28 22:48:45 jgg Exp $
 /* ######################################################################
 
    Algorithms - A set of misc algorithms
 /* ######################################################################
 
    Algorithms - A set of misc algorithms
@@ -169,16 +169,37 @@ bool pkgApplyStatus(pkgDepCache &Cache)
       if (I->InstState == pkgCache::State::ReInstReq ||
          I->InstState == pkgCache::State::HoldReInstReq)
       {
       if (I->InstState == pkgCache::State::ReInstReq ||
          I->InstState == pkgCache::State::HoldReInstReq)
       {
-        Cache.MarkKeep(I);
+        if (I.CurrentVer().Downloadable() == true)
+           Cache.MarkKeep(I);
+        else
+        {
+           // Is this right? Will dpkg choke on an upgrade?
+           if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+              Cache.MarkInstall(I);
+           else
+              return _error->Error("The package %s needs to be reinstalled, "
+                                   "but I can't find an archive for it.",I.Name());
+        }
+        
         continue;
       }
       
       switch (I->CurrentState)
       {
         continue;
       }
       
       switch (I->CurrentState)
       {
-        // This means installation failed somehow
+        /* This means installation failed somehow - it does not need to be
+           re-unpacked (probably) */
         case pkgCache::State::UnPacked:
         case pkgCache::State::HalfConfigured:
         case pkgCache::State::UnPacked:
         case pkgCache::State::HalfConfigured:
-        Cache.MarkKeep(I);
+        if (I.CurrentVer().Downloadable() == true || 
+            I.State() != pkgCache::PkgIterator::NeedsUnpack)
+           Cache.MarkKeep(I);
+        else
+        {
+           if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+              Cache.MarkInstall(I);
+           else
+              Cache.MarkDelete(I);
+        }
         break;
 
         // This means removal failed
         break;
 
         // This means removal failed
index 7d1ff05ead192836d7766d40de867d87701385a7..36abcddd4359406ecce3543c1ce2cd2c4c2a847c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: depcache.cc,v 1.17 1999/04/16 21:46:13 jgg Exp $
+// $Id: depcache.cc,v 1.18 1999/04/28 22:48:45 jgg Exp $
 /* ######################################################################
 
    Dependency Cache - Caches Dependency information.
 /* ######################################################################
 
    Dependency Cache - Caches Dependency information.
@@ -519,6 +519,12 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg,bool Soft)
    // Simplifies other routines.
    if (Pkg.end() == true)
       return;
    // Simplifies other routines.
    if (Pkg.end() == true)
       return;
+
+   /* Reject an attempt to keep a non-source broken installed package, those
+      must be upgraded */
+   if (Pkg.State() == PkgIterator::NeedsUnpack && 
+       Pkg.CurrentVer().Downloadable() == false)
+      return;
    
    /* We changed the soft state all the time so the UI is a bit nicer
       to use */
    
    /* We changed the soft state all the time so the UI is a bit nicer
       to use */
index 66a9913713b8d27b35c65d7f1bd7a94a8e7fe0f4..af234bae2d2a786edbcc8c83ab1fe1874750d013 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.h,v 1.13 1999/04/18 06:36:36 jgg Exp $
+// $Id: pkgcachegen.h,v 1.14 1999/04/28 22:48:45 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -55,8 +55,8 @@ class pkgCacheGenerator
    unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
 
    unsigned long WriteUniqString(const char *S,unsigned int Size);
    unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
 
    unsigned long WriteUniqString(const char *S,unsigned int Size);
-   inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
-   
+   inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());};
+
    public:   
 
    bool SelectFile(string File,unsigned long Flags = 0);
    public:   
 
    bool SelectFile(string File,unsigned long Flags = 0);
@@ -85,7 +85,7 @@ class pkgCacheGenerator::ListParser
    __apt_ptrloc *OldDepLast;
       
    protected:
    __apt_ptrloc *OldDepLast;
       
    protected:
-   
+
    inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
    inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
    inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
    inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
    inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
    inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};