]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
* apt-pkg/deb/dpkgpm.cc:
[apt.git] / apt-pkg / depcache.cc
index ac667d51d6f3931c69306ba82d31b91203d71c79..491ba6d4cb24a9729ff0b08db0ae41cc8c7b13b2 100644 (file)
@@ -23,6 +23,8 @@
 #include <sstream>    
 #include <set>
 
+#include <sys/stat.h>
+
 #include <apti18n.h>    
 
 pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) :
@@ -176,7 +178,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)
    return true;
 }
 
-bool pkgDepCache::writeStateFile(OpProgress *prog)
+bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)
 {
    if(_config->FindB("Debug::pkgAutoRemove",false))
       std::clog << "pkgDepCache::writeStateFile()" << std::endl;
@@ -238,6 +240,9 @@ bool pkgDepCache::writeStateFile(OpProgress *prog)
               std::clog << "Skipping already written " << pkg.Name() << std::endl;
            continue;
         }
+         // skip not installed ones if requested
+         if(InstalledOnly && pkg->CurrentVer == 0)
+            continue;
         if(_config->FindB("Debug::pkgAutoRemove",false))
            std::clog << "Writing new AutoInstall: " 
                      << pkg.Name() << std::endl;
@@ -250,8 +255,9 @@ bool pkgDepCache::writeStateFile(OpProgress *prog)
    }
    fclose(OutFile);
 
-   // move the outfile over the real file
+   // move the outfile over the real file and set permissions
    rename(outfile.c_str(), state.c_str());
+   chmod(state.c_str(), 0644);
 
    return true;
 }
@@ -1126,34 +1132,6 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg)
    return Last;
 }
                                                                        /*}}}*/
-// Policy::IsImportantDep - True if the dependency is important                /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep)
-{
-   if(Dep.IsCritical())
-      return true;
-   else if(Dep->Type == pkgCache::Dep::Recommends) 
-   {
-      if ( _config->FindB("APT::Install-Recommends", false))
-        return true;
-      // we suport a special mode to only install-recommends for certain
-      // sections
-      // FIXME: this is a meant as a temporarly solution until the 
-      //        recommends are cleaned up
-      string s = _config->Find("APT::Install-Recommends-Section","");
-      if(s.size() > 0) 
-      {
-        const char *sec = Dep.TargetPkg().Section();
-        if (sec && strcmp(sec, s.c_str()) == 0)
-           return true;
-      }
-   }
-   else if(Dep->Type == pkgCache::Dep::Suggests)
-     return _config->FindB("APT::Install-Suggests", false);
-
-   return false;
-}
                                                                        /*}}}*/
 
 pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc()
@@ -1372,3 +1350,34 @@ bool pkgDepCache::Sweep()
 
    return true;
 }
+
+// Policy::IsImportantDep - True if the dependency is important                /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep)
+{
+   if(Dep.IsCritical())
+      return true;
+   else if(Dep->Type == pkgCache::Dep::Recommends) 
+   {
+      if ( _config->FindB("APT::Install-Recommends", false))
+        return true;
+      // we suport a special mode to only install-recommends for certain
+      // sections
+      // FIXME: this is a meant as a temporarly solution until the 
+      //        recommends are cleaned up
+      string s = _config->Find("APT::Install-Recommends-Section","");
+      if(s.size() > 0) 
+      {
+        const char *sec = Dep.ParentVer().Section();
+        if (sec && strcmp(sec, s.c_str()) == 0)
+           return true;
+      }
+   }
+   else if(Dep->Type == pkgCache::Dep::Suggests)
+     return _config->FindB("APT::Install-Suggests", false);
+
+   return false;
+}
+                                                                       /*}}}*/
+