[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#87520: Patch for enhanced debugging output



Package: apt
Version: 0.3.19
Severity: wishlist

Here's a patch which lets you get a trace of every package marked for
installation or deletion as the dependency analyzer works.  I did this
because I couldn't figure out why apt was kicking out certain
packages (even with the other debugging options on).

It may be there are better ways of getting this info, but here's my
contribution.  I've included revised documentation, but I haven't
actually tried to build that part.  I believe that apt.conf.5 is
really the product of apt.conf.5.yo, but I'd already edited the
former.  I am happy to have the .yo file treated as the master.  

This is the output of dpkg-source vs the original distro.

--- apt-0.3.19.orig/apt-pkg/cacheiterators.h
+++ apt-0.3.19/apt-pkg/cacheiterators.h
@@ -66,6 +66,7 @@
    inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
    inline const char *Section() const {return Pkg->Section == 0?0:Owner->StrP + Pkg->Section;};
    inline const char *TargetDist() const {return Pkg->TargetDist == 0?0:Owner->StrP + Pkg->TargetDist;};
+
    inline bool Purge() const {return Pkg->CurrentState == pkgCache::State::Purge ||
 	 (Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotInstalled);};
    inline VerIterator VersionList() const;
@@ -76,6 +77,9 @@
    inline unsigned long Index() const {return Pkg - Owner->PkgP;};
    OkState State() const;
    
+  const char * CandVersion() const;
+  const char * CurVersion() const;
+
    // Constructors
    inline PkgIterator(pkgCache &Owner) : Owner(&Owner), HashIndex(-1)
    {
@@ -91,6 +95,9 @@
    inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {};
 };
 
+//Nice printable representation
+ostream& operator<<(ostream& out, const pkgCache::PkgIterator& p);
+
 // Version Iterator
 class pkgCache::VerIterator
 {
@@ -112,6 +119,9 @@
    inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;};
    int CompareVer(const VerIterator &B) const;
    
+  // Testing
+  inline bool IsGood() const { return Ver && Owner && ! end();};
+
    // Accessors
    inline Version *operator ->() {return Ver;};
    inline Version const *operator ->() const {return Ver;};
--- apt-0.3.19.orig/apt-pkg/depcache.cc
+++ apt-0.3.19/apt-pkg/depcache.cc
@@ -12,10 +12,13 @@
 #pragma implementation "apt-pkg/depcache.h"
 #endif
 #include <apt-pkg/depcache.h>
-
+#include <apt-pkg/configuration.h>  //For debugging
 #include <apt-pkg/version.h>
 #include <apt-pkg/error.h>
-									/*}}}*/
+
+
+
+/*}}}*/
 
 // DepCache::pkgDepCache - Constructors					/*{{{*/
 // ---------------------------------------------------------------------
@@ -23,6 +26,7 @@
 pkgDepCache::pkgDepCache(MMap &Map,OpProgress &Prog) :
              pkgCache(Map), PkgState(0), DepState(0)
 {
+   Verbosity = _config->FindI("Debug::pkgDepCache::Verbosity", 0);
    if (_error->PendingError() == false)
       Init(&Prog);
 }
@@ -524,7 +528,7 @@
 // DepCache::MarkKeep - Put the package in the keep state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgDepCache::MarkKeep(PkgIterator const &Pkg,bool Soft)
+void pkgDepCache::MarkKeep(PkgIterator const &Pkg,bool Soft, int depth)
 {
    // Simplifies other routines.
    if (Pkg.end() == true)
@@ -572,8 +576,15 @@
 // DepCache::MarkDelete - Put the package in the delete state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
+void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, int depth)
 {
+  if (Verbosity > 0) {
+    clog.width(depth+1);
+    clog << " "
+	 << "MarkDelete " << Pkg.Name() << " (" << Pkg.Section() << ")" << endl; 
+  }
+
+
    // Simplifies other routines.
    if (Pkg.end() == true)
       return;
@@ -610,8 +621,9 @@
 // DepCache::MarkInstall - Put the package in the install state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst)
-{   
+void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, int depth)
+{  
+
    // Simplifies other routines.
    if (Pkg.end() == true)
       return;
@@ -631,7 +643,13 @@
    // We dont even try to install virtual packages..
    if (Pkg->VersionList == 0)
       return;
-   
+
+   if (Verbosity > 0) {
+     clog.width(depth+1);
+     clog <<  " "
+	  <<"MarkInstall " << Pkg << endl;
+   }
+
    /* Target the candidate version and remove the autoflag. We reset the
       autoflag below if this was called recursively. Otherwise the user
       should have the ability to de-auto a package by changing its state */
@@ -681,7 +699,7 @@
       PkgIterator P = Start.SmartTargetPkg();
       if ((DepState[Start->ID] & DepCVer) == DepCVer)
       {
-	 MarkInstall(P,true);
+	 MarkInstall(P,true, depth+1);
 	 
 	 // Set the autoflag, after MarkInstall because MarkInstall unsets it
 	 if (P->CurrentVer == 0)
@@ -699,7 +717,9 @@
 	    VerIterator Ver(*this,*I);
 	    PkgIterator Pkg = Ver.ParentPkg();
       
-	    MarkDelete(Pkg);
+	    if (Verbosity > 0)
+	      clog  << "<" << Ver.VerStr() << "> ";
+	    MarkDelete(Pkg, false, depth+1);
 	    PkgState[Pkg->ID].Flags |= Flag::Auto;
 	 }
 	 delete [] List;
--- apt-0.3.19.orig/apt-pkg/depcache.h
+++ apt-0.3.19/apt-pkg/depcache.h
@@ -125,6 +125,7 @@
    unsigned long iKeepCount;
    unsigned long iBrokenCount;
    unsigned long iBadCount;
+   int Verbosity;	// For debugging output.  0, 1 only current values.
       
    // Check for a matching provides
    bool CheckDep(DepIterator Dep,int Type,PkgIterator &Res);
@@ -161,9 +162,9 @@
    inline unsigned char &operator [](DepIterator const &I) {return DepState[I->ID];};
 
    // Manipulators
-   void MarkKeep(PkgIterator const &Pkg,bool Soft = false);
-   void MarkDelete(PkgIterator const &Pkg,bool Purge = false);
-   void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true);
+   void MarkKeep(PkgIterator const &Pkg,bool Soft = false, int depth=0);
+   void MarkDelete(PkgIterator const &Pkg,bool Purge = false, int depth=0);
+   void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, int depth=0);
    void SetReInstall(PkgIterator const &Pkg,bool To);
    
    // This is for debuging
--- apt-0.3.19.orig/apt-pkg/pkgcache.cc
+++ apt-0.3.19/apt-pkg/pkgcache.cc
@@ -258,6 +258,34 @@
       
    return NeedsNothing;
 }
+
+//Return string representing candidate version.
+const char *
+pkgCache::PkgIterator::CandVersion() const { 
+  //TargetVer is empty, so don't use it.
+  VerIterator version = Owner->GetCandidateVer(*this);
+  if (version.IsGood())
+    return version.VerStr();
+  return 0;
+};	
+
+//Return string representing current version.
+const char *
+pkgCache::PkgIterator::CurVersion() const {
+  VerIterator version = CurrentVer();
+  if (version.IsGood())
+    return CurrentVer().VerStr();
+  return 0;
+};
+
+// Output name < cur.rent.version | candid.ate.version > (section)
+// Note that the characters <|>() are all literal above.
+ostream& operator<<(ostream& out, const pkgCache::PkgIterator& p) {
+  out << p.Name() << "<" 
+      << p.CurVersion() << " | " << p.CandVersion() << "> ("
+      << p.Section() << " )";
+}
+
 									/*}}}*/
 // DepIterator::IsCritical - Returns true if the dep is important	/*{{{*/
 // ---------------------------------------------------------------------
--- apt-0.3.19.orig/doc/examples/configure-index
+++ apt-0.3.19/doc/examples/configure-index
@@ -201,7 +201,7 @@
   pkgAcquire "false";
   pkgAcquire::Worker "false";
   pkgDPkgPM "false";
-  
+  pkgDepCache::Verbosity "1";  // Show packages as added or removed  
   pkgInitialize "false";   // This one will dump the configuration space
   NoLocking "false";
   Acquire::Ftp "false";    // Show ftp command traffic
--- apt-0.3.19.orig/doc/apt.conf.5.yo
+++ apt-0.3.19/doc/apt.conf.5.yo
@@ -256,11 +256,31 @@
 manpagesection(Debug Options)
 Most of the options in the bf(debug) section are not interesting to the
 normal user, however bf(Debug::pkgProblemResolver) shows interesting
-output about the decisions dist-upgrade makes. bf(Debug::NoLocking)
+output about the decisions dist-upgrade
+makes. bf(Debug::pkgDepCache::Verbosity) shows even more detailed
+output for all operations.  bf(Debug::NoLocking)
 disables file locking so apt can do some operations as non-root and
 bf(Debug::pkgDPkgPM) will print out the command line for each dpkg 
 invokation. bf(Debug::IdentCdrom) will disable the inclusion of statfs 
 data in CDROM IDs.
+
+startdit()
+
+dit(bf(pkgDepCache::Verbosity))
+Set to non-0 to see the dependencies as packages are marked for addition or
+deletion.  Each line shows a package added or deleted.  Each addition
+or deletion may trigger additional actions; they are shown indented
+one additional space under the original entry. The format for each
+package is 
+startcenter()
+code( package-name <a.b.c | x.y.z> (section) )
+endcenter()
+where code(a.b.c) is the current version of the package and
+code(x.y.z) is the one being considered for installation.
+code(section) is the name of the section the package appears in.  For
+deletions, the version being deleted appears at the start of the line.
+
+enddit()
 
 manpagesection(EXAMPLES)
 bf(/usr/doc/apt/examples/configure-index.gz) contains a sample configuration 
--- apt-0.3.19.orig/doc/apt.conf.5
+++ apt-0.3.19/doc/apt.conf.5
@@ -262,6 +262,19 @@
 invokation\&. \fBDebug::IdentCdrom\fP will disable the inclusion of statfs 
 data in CDROM IDs\&.
 .PP 
+\fBDebug::pkgDepCache::Verbosity\fB set to 1 shows enormous detail
+about the decision process\&.  As packages are marked for addition or
+deletion it prints them out, with the dependencies of a package
+indented an additional space\&.  Note that the initial mark is not
+necessarily the final one\&.  The format for each package is
+.RS
+      package-name <a.b.c | x.y.z> (section)
+.RE
+where a\&.b\&.c is the current version of the package and x\&.y\&.z is
+the one being considered for installation\&.  section if the name of the
+section the package appears in\&.  For deletions, the version being
+deleted appears at the start of the line\&.
+.PP
 .SH "EXAMPLES" 
 \fB/usr/doc/apt/examples/configure-index\&.gz\fP contains a sample configuration 
 file showing the default values for all possible options\&.



Reply to: