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

* merged the apt--install-recommends branch
* ABI break, bumped the version number

Michael Vogt лет назад: 20
Родитель
Сommit
2ae2e04d97
8 измененных файлов с 56 добавлено и 16 удалено
  1. 21 10
      apt-pkg/depcache.cc
  2. 5 1
      apt-pkg/depcache.h
  3. 1 1
      apt-pkg/init.h
  4. 1 1
      apt-pkg/makefile
  5. 16 1
      cmdline/apt-get.cc
  6. 1 1
      configure.in
  7. 10 0
      debian/changelog
  8. 1 1
      methods/makefile

+ 21 - 10
apt-pkg/depcache.cc

@@ -399,9 +399,11 @@ void pkgDepCache::AddStates(const PkgIterator &Pkg,int Add)
 {
 {
    StateCache &State = PkgState[Pkg->ID];
    StateCache &State = PkgState[Pkg->ID];
    
    
-   // The Package is broken
+   // The Package is broken (either minimal dep or policy dep)
    if ((State.DepState & DepInstMin) != DepInstMin)
    if ((State.DepState & DepInstMin) != DepInstMin)
       iBrokenCount += Add;
       iBrokenCount += Add;
+   if ((State.DepState & DepInstPolicy) != DepInstPolicy)
+      iPolicyBrokenCount += Add;
    
    
    // Bad state
    // Bad state
    if (Pkg.State() != PkgIterator::NeedsNothing)
    if (Pkg.State() != PkgIterator::NeedsNothing)
@@ -763,7 +765,8 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
 void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
-			      unsigned long Depth, bool FromUser)
+			      unsigned long Depth, bool FromUser,
+			      bool ForceImportantDeps)
 {
 {
    if (Depth > 100)
    if (Depth > 100)
       return;
       return;
@@ -846,24 +849,26 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 
 
       /* Check if this dep should be consider for install. If it is a user
       /* Check if this dep should be consider for install. If it is a user
          defined important dep and we are installed a new package then 
          defined important dep and we are installed a new package then 
-	 it will be installed. Otherwise we only worry about critical deps */
+	 it will be installed. Otherwise we only check for important
+         deps that have changed from the installed version
+      */
       if (IsImportantDep(Start) == false)
       if (IsImportantDep(Start) == false)
 	 continue;
 	 continue;
-
+      
       /* check if any ImportantDep() (but not Critial) where added
       /* check if any ImportantDep() (but not Critial) where added
-       * since we installed the thing
+       * since we installed the package
        */
        */
       bool isNewImportantDep = false;
       bool isNewImportantDep = false;
-      if(IsImportantDep(Start) && !Start.IsCritical())
+      if(!ForceImportantDeps && !Start.IsCritical())
       {
       {
 	 bool found=false;
 	 bool found=false;
 	 VerIterator instVer = Pkg.CurrentVer();
 	 VerIterator instVer = Pkg.CurrentVer();
-	 for (DepIterator D = instVer.DependsList(); !D.end(); D++)
+	 for (DepIterator D = instVer.DependsList(); D.end() != true; D++)
 	 {
 	 {
 	    //FIXME: deal better with or-groups(?)
 	    //FIXME: deal better with or-groups(?)
 	    DepIterator LocalStart = D;
 	    DepIterator LocalStart = D;
 	    
 	    
-	    if(IsImportantDep(Dep) && Start.TargetPkg() == D.TargetPkg())
+	    if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg())
 	       found=true;
 	       found=true;
 	 }
 	 }
 	 // this is a new dep if it was not found to be already
 	 // this is a new dep if it was not found to be already
@@ -875,7 +880,9 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    std::clog << "new important dependency: " 
 	    std::clog << "new important dependency: " 
 		      << Start.TargetPkg().Name() << std::endl;
 		      << Start.TargetPkg().Name() << std::endl;
 
 
-      if (Pkg->CurrentVer != 0 && Start.IsCritical() == false && !isNewImportantDep)
+      // skip important deps if the package is already installed
+      if (Pkg->CurrentVer != 0 && Start.IsCritical() == false 
+	  && !isNewImportantDep && !ForceImportantDeps)
 	 continue;
 	 continue;
       
       
       /* If we are in an or group locate the first or that can 
       /* If we are in an or group locate the first or that can 
@@ -923,7 +930,11 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	       std::clog << "Installing " << InstPkg.Name() 
 	       std::clog << "Installing " << InstPkg.Name() 
 			 << " as dep of " << Pkg.Name() 
 			 << " as dep of " << Pkg.Name() 
 			 << std::endl;
 			 << std::endl;
-	   MarkInstall(InstPkg, true, Depth + 1, false);
+	    MarkInstall(InstPkg,true,Depth + 1, false, ForceImportantDeps);
+
+	    // Set the autoflag, after MarkInstall because MarkInstall unsets it
+	    if (P->CurrentVer == 0)
+	       PkgState[InstPkg->ID].Flags |= Flag::Auto;
 	 }
 	 }
 	 continue;
 	 continue;
       }
       }

+ 5 - 1
apt-pkg/depcache.h

@@ -248,6 +248,7 @@ class pkgDepCache : protected pkgCache::Namespace
       inline bool Downgrade() const {return Status < 0 && Mode == ModeInstall;};
       inline bool Downgrade() const {return Status < 0 && Mode == ModeInstall;};
       inline bool Held() const {return Status != 0 && Keep();};
       inline bool Held() const {return Status != 0 && Keep();};
       inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
       inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
+      inline bool NowPolicyBroken() const {return (DepState & DepNowPolicy) != DepNowPolicy;};
       inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;};
       inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;};
       inline bool InstPolicyBroken() const {return (DepState & DepInstPolicy) != DepInstPolicy;};
       inline bool InstPolicyBroken() const {return (DepState & DepInstPolicy) != DepInstPolicy;};
       inline bool Install() const {return Mode == ModeInstall;};
       inline bool Install() const {return Mode == ModeInstall;};
@@ -293,6 +294,7 @@ class pkgDepCache : protected pkgCache::Namespace
    unsigned long iDelCount;
    unsigned long iDelCount;
    unsigned long iKeepCount;
    unsigned long iKeepCount;
    unsigned long iBrokenCount;
    unsigned long iBrokenCount;
+   unsigned long iPolicyBrokenCount;
    unsigned long iBadCount;
    unsigned long iBadCount;
    
    
    Policy *delLocalPolicy;           // For memory clean up..
    Policy *delLocalPolicy;           // For memory clean up..
@@ -390,7 +392,8 @@ class pkgDepCache : protected pkgCache::Namespace
 		 bool FromUser = true);
 		 bool FromUser = true);
    void MarkDelete(PkgIterator const &Pkg,bool Purge = false);
    void MarkDelete(PkgIterator const &Pkg,bool Purge = false);
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
-		    unsigned long Depth = 0, bool FromUser = true);
+		    unsigned long Depth = 0, bool FromUser = true,
+		    bool ForceImportantDeps = false);
    void SetReInstall(PkgIterator const &Pkg,bool To);
    void SetReInstall(PkgIterator const &Pkg,bool To);
    void SetCandidateVersion(VerIterator TargetVer);
    void SetCandidateVersion(VerIterator TargetVer);
 
 
@@ -412,6 +415,7 @@ class pkgDepCache : protected pkgCache::Namespace
    inline unsigned long KeepCount() {return iKeepCount;};
    inline unsigned long KeepCount() {return iKeepCount;};
    inline unsigned long InstCount() {return iInstCount;};
    inline unsigned long InstCount() {return iInstCount;};
    inline unsigned long BrokenCount() {return iBrokenCount;};
    inline unsigned long BrokenCount() {return iBrokenCount;};
+   inline unsigned long PolicyBrokenCount() {return iPolicyBrokenCount;};
    inline unsigned long BadCount() {return iBadCount;};
    inline unsigned long BadCount() {return iBadCount;};
 
 
    bool Init(OpProgress *Prog);
    bool Init(OpProgress *Prog);

+ 1 - 1
apt-pkg/init.h

@@ -18,7 +18,7 @@
 
 
 // See the makefile
 // See the makefile
 #define APT_PKG_MAJOR 3
 #define APT_PKG_MAJOR 3
-#define APT_PKG_MINOR 50
+#define APT_PKG_MINOR 51
 #define APT_PKG_RELEASE 0
 #define APT_PKG_RELEASE 0
     
     
 extern const char *pkgVersion;
 extern const char *pkgVersion;

+ 1 - 1
apt-pkg/makefile

@@ -13,7 +13,7 @@ include ../buildlib/defaults.mak
 # methods/makefile - FIXME
 # methods/makefile - FIXME
 LIBRARY=apt-pkg
 LIBRARY=apt-pkg
 LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
 LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=3.50
+MAJOR=3.51
 MINOR=0
 MINOR=0
 SLIBS=$(PTHREADLIB) $(INTLLIBS)
 SLIBS=$(PTHREADLIB) $(INTLLIBS)
 APT_DOMAIN:=libapt-pkg$(MAJOR)
 APT_DOMAIN:=libapt-pkg$(MAJOR)

+ 16 - 1
cmdline/apt-get.cc

@@ -629,6 +629,8 @@ void CacheFile::Sort()
    and verifies that the system is OK. */
    and verifies that the system is OK. */
 bool CacheFile::CheckDeps(bool AllowBroken)
 bool CacheFile::CheckDeps(bool AllowBroken)
 {
 {
+   bool FixBroken = _config->FindB("APT::Get::Fix-Broken",false);
+
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
 
 
@@ -640,12 +642,24 @@ bool CacheFile::CheckDeps(bool AllowBroken)
    if (pkgApplyStatus(*DCache) == false)
    if (pkgApplyStatus(*DCache) == false)
       return false;
       return false;
    
    
+   if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true)
+   {
+      FixBroken = true;
+      if ((DCache->PolicyBrokenCount() > 0))
+      {
+	 // upgrade all policy-broken packages with ForceImportantDeps=True
+	 for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++)
+	    if ((*DCache)[I].NowPolicyBroken() == true) 
+	       DCache->MarkInstall(I,true,0,true);
+      }
+   }
+
    // Nothing is broken
    // Nothing is broken
    if (DCache->BrokenCount() == 0 || AllowBroken == true)
    if (DCache->BrokenCount() == 0 || AllowBroken == true)
       return true;
       return true;
 
 
    // Attempt to fix broken things
    // Attempt to fix broken things
-   if (_config->FindB("APT::Get::Fix-Broken",false) == true)
+   if (FixBroken == true)
    {
    {
       c1out << _("Correcting dependencies...") << flush;
       c1out << _("Correcting dependencies...") << flush;
       if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0)
       if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0)
@@ -2618,6 +2632,7 @@ int main(int argc,const char *argv[])
       {0,"auto-remove","APT::Get::AutomaticRemove",0},
       {0,"auto-remove","APT::Get::AutomaticRemove",0},
       {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
       {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
       {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
       {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
+      {0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
       {'o',"option",0,CommandLine::ArbItem},
       {0,0,0,0}};
       {0,0,0,0}};

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 dnl -- SET THIS TO THE RELEASE VERSION --
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.6.45ubuntu1")
+AC_DEFINE_UNQUOTED(VERSION,"0.6.45ubuntu2")
 PACKAGE="apt"
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)
 AC_SUBST(PACKAGE)

+ 10 - 0
debian/changelog

@@ -1,3 +1,13 @@
+apt (0.6.45ubuntu3) edgy; urgency=low
+
+  * ABI break
+  * merged latest apt--install-recommends
+  * added "--fix-policy" option to can be used as "--fix-broken" and
+    will install missing weak depends (recommends, and/or suggests 
+    depending on the settings)
+
+ --
+
 apt (0.6.45ubuntu2) edgy; urgency=low
 apt (0.6.45ubuntu2) edgy; urgency=low
 
 
   * debian/control:
   * debian/control:

+ 1 - 1
methods/makefile

@@ -7,7 +7,7 @@ include ../buildlib/defaults.mak
 BIN := $(BIN)/methods
 BIN := $(BIN)/methods
 
 
 # FIXME..
 # FIXME..
-LIB_APT_PKG_MAJOR = 3.50
+LIB_APT_PKG_MAJOR = 3.51
 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR)
 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR)
 
 
 # The file method
 # The file method