Attachment '155195.patch'

Download

   1 From 8e5f3d589bbfeaa837d61e7ebc371d749fa9ac92 Mon Sep 17 00:00:00 2001
   2 From: Sam Lidder <sam.lidder@gmail.com>
   3 Date: Wed, 4 Apr 2012 21:25:34 -0400
   4 Subject: [PATCH] add 'apt-cache showpkglocal' to restrict package-relation
   5  info to installed packages
   6 
   7 ---
   8  cmdline/apt-cache.cc |   67 ++++++++++++++++++++++++++++++++++++++++++--------
   9  1 file changed, 57 insertions(+), 10 deletions(-)
  10 
  11 diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
  12 index db54752..c673dfb 100644
  13 --- a/cmdline/apt-cache.cc
  14 +++ b/cmdline/apt-cache.cc
  15 @@ -204,10 +204,10 @@ bool UnMet(CommandLine &CmdL)
  16     return true;
  17  }
  18  									/*}}}*/
  19 -// DumpPackage - Show a dump of a package record			/*{{{*/
  20 +// DumpPackageInfo - Helper for showing dump of a package record	/*{{{*/
  21  // ---------------------------------------------------------------------
  22  /* */
  23 -bool DumpPackage(CommandLine &CmdL)
  24 +bool DumpPackageInfo(CommandLine &CmdL, bool const InstalledOnly)
  25  {
  26     pkgCacheFile CacheFile;
  27     APT::CacheSetHelper helper(true, GlobalError::NOTICE);
  28 @@ -234,22 +234,42 @@ bool DumpPackage(CommandLine &CmdL)
  29        
  30        cout << endl;
  31        
  32 -      cout << "Reverse Depends: " << endl;
  33 +      cout << (InstalledOnly == true ? "Installed " : "") << "Reverse Depends: " << endl;
  34        for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D)
  35        {
  36 -	 cout << "  " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true);
  37 -	 if (D->Version != 0)
  38 -	    cout << ' ' << DeNull(D.TargetVer()) << endl;
  39 +	 if (InstalledOnly == true)
  40 +	 {
  41 +	    if (D.ParentPkg()->CurrentState == pkgCache::State::Installed)
  42 +	    {
  43 +	       cout << "  " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true);
  44 +	       if (D->Version != 0)
  45 +	          cout << ' ' << DeNull(D.TargetVer());
  46 +	       cout << endl;
  47 +	    }
  48 +	 }
  49  	 else
  50 +	 {
  51 +	    cout << "  " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true);
  52 +	    if (D->Version != 0)
  53 +	       cout << ' ' << DeNull(D.TargetVer());
  54  	    cout << endl;
  55 +	 }
  56        }
  57        
  58 -      cout << "Dependencies: " << endl;
  59 +      cout << (InstalledOnly == true ? "Installed " : "") << "Dependencies: " << endl;
  60        for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
  61        {
  62  	 cout << Cur.VerStr() << " - ";
  63  	 for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; ++Dep)
  64 -	    cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
  65 +	 {
  66 +	    if (InstalledOnly == true)
  67 +	    {
  68 +	       if (Dep.TargetPkg()->CurrentState == pkgCache::State::Installed)
  69 +	          cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
  70 +	    }
  71 +	    else
  72 +	       cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
  73 +	 }
  74  	 cout << endl;
  75        }      
  76  
  77 @@ -261,14 +281,39 @@ bool DumpPackage(CommandLine &CmdL)
  78  	    cout << Prv.ParentPkg().FullName(true) << " ";
  79  	 cout << endl;
  80        }
  81 -      cout << "Reverse Provides: " << endl;
  82 +
  83 +      cout << (InstalledOnly == true ? "Installed " : "") << "Reverse Provides: " << endl;
  84        for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; ++Prv)
  85 -	 cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl;
  86 +      {
  87 +	 if (InstalledOnly == true)
  88 +	 {
  89 +	    if (Prv.OwnerPkg()->CurrentState == pkgCache::State::Installed)
  90 +	       cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl;
  91 +	 }
  92 +	 else
  93 +	    cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl;
  94 +      }
  95     }
  96  
  97     return true;
  98  }
  99  									/*}}}*/
 100 +// DumpPackage - Show a dump of a package record			/*{{{*/
 101 +// ---------------------------------------------------------------------
 102 +/* */
 103 +bool DumpPackage(CommandLine &CmdL)
 104 +{
 105 +   return DumpPackageInfo(CmdL, false);
 106 +}
 107 +									/*}}}*/
 108 +// DumpPackageLocal - Show install-specific dump of a package record	/*{{{*/
 109 +// ---------------------------------------------------------------------
 110 +/* */
 111 +bool DumpPackageLocal(CommandLine &CmdL)
 112 +{
 113 +   return DumpPackageInfo(CmdL, true);
 114 +}
 115 +									/*}}}*/
 116  // Stats - Dump some nice statistics					/*{{{*/
 117  // ---------------------------------------------------------------------
 118  /* */
 119 @@ -1689,6 +1734,7 @@ bool ShowHelp(CommandLine &Cmd)
 120        "Commands:\n"
 121        "   gencaches - Build both the package and source cache\n"
 122        "   showpkg - Show some general information for a single package\n"
 123 +      "   showpkglocal - Like showpkg, but only list installed packages\n"
 124        "   showsrc - Show source records\n"
 125        "   stats - Show some basic statistics\n"
 126        "   dump - Show the entire file in a terse form\n"
 127 @@ -1749,6 +1795,7 @@ int main(int argc,const char *argv[])					/*{{{*/
 128                                      {"showsrc",&ShowSrcPackage},
 129                                      {0,0}};
 130     CommandLine::Dispatch CmdsB[] = {{"showpkg",&DumpPackage},
 131 +                                    {"showpkglocal",&DumpPackageLocal},
 132                                      {"stats",&Stats},
 133                                      {"dump",&Dump},
 134                                      {"dumpavail",&DumpAvail},
 135 -- 
 136 1.7.9.5

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-04-05 23:26:13, 5.2 KB) [[attachment:155195.patch]]
  • [get | view] (2012-04-05 23:25:10, 0.8 KB) [[attachment:218995.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.