2005-04-29 14:00:58 +04:00
diff -uNr apt-0.5.15cnc6-orig/cmdline/apt-shell.cc apt-0.5.15cnc6/cmdline/apt-shell.cc
2005-05-18 21:03:04 +04:00
--- apt-0.5.15cnc6-orig/cmdline/apt-shell.cc 2005-05-15 20:35:30 +0400
+++ apt-0.5.15cnc6/cmdline/apt-shell.cc 2005-05-15 20:37:58 +0400
2008-12-31 17:12:21 +03:00
@@ -3507,11 +3507,14 @@ bool DoList(CommandLine &CmdL)
2005-04-29 14:00:58 +04:00
bool ShowVersion = _config->FindB("APT::Cache::ShowVersion", false);
bool ShowSummary = _config->FindB("APT::Cache::ShowSummary", false);
2006-04-02 16:15:03 +04:00
+ std::string MatchSection = _config->Find("APT::Cache::MatchGroup","");
2005-04-29 14:00:58 +04:00
+ bool ShowGroup = _config->FindB("APT::Cache::ShowGroup", false);
const char *PkgName;
+ const char *PkgSection;
int Matches[Cache->Head().PackageCount];
int NumMatches = 0;
2005-05-18 21:03:04 +04:00
- int Len, NameMaxLen = 0, VerMaxLen = 0;
+ int Len = 0, NameMaxLen = 0, VerMaxLen = 0;
bool Matched;
for (unsigned int J = 0; J < Cache->Head().PackageCount; J++)
{
2008-12-31 17:12:21 +03:00
@@ -3524,7 +3527,12 @@ bool DoList(CommandLine &CmdL)
2005-04-29 14:00:58 +04:00
if (ShowUpgradable &&
(Pkg->CurrentVer == 0 || Cache[Pkg].Upgradable() == false))
continue;
+ PkgSection = Pkg.Section();
2006-04-02 16:15:03 +04:00
+ if (!MatchSection.empty() && MatchSection != std::string(PkgSection))
2005-04-29 14:00:58 +04:00
+ continue;
+
PkgName = Pkg.Name();
2005-05-18 21:03:04 +04:00
+
2005-04-29 14:00:58 +04:00
if (MatchAll == true)
Matched = true;
2005-05-18 21:03:04 +04:00
else for (int i=0; i != NumPatterns; i++) {
2008-12-31 17:12:21 +03:00
@@ -3629,6 +3637,7 @@ bool DoList(CommandLine &CmdL)
2005-04-29 14:00:58 +04:00
Blank[ColumnLen] = 0;
const char *Str;
+ const char *PkgSection;
int StrLen;
unsigned int K;
for (unsigned int Line = 0; Line != NumLines; Line++) {
2008-12-31 17:12:21 +03:00
@@ -3638,13 +3647,33 @@ bool DoList(CommandLine &CmdL)
2005-04-29 14:00:58 +04:00
break;
pkgCache::PkgIterator Pkg(Cache,Cache.List[Matches[K]]);
Str = Pkg.Name();
+ PkgSection = Pkg.Section();
StrLen = strlen(Str);
- if (Len < ColumnLen-1)
2005-05-04 13:43:09 +04:00
- c2out << Str << Blank+StrLen;
- else
2005-04-29 14:00:58 +04:00
- c2out << Str << " ";
2005-05-04 13:43:09 +04:00
+ string status = "available";
+ if (Pkg->CurrentVer != 0) status = "installed";
2005-05-18 21:03:04 +04:00
+ if (Pkg->CurrentVer != 0)
+ for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
+ {
+ pkgCache::PkgIterator P = D.ParentPkg();
+ if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential &&
+ (P->Flags & pkgCache::Flag::Important) != pkgCache::Flag::Important)
+ continue;
+ status = "locked";
+ }
2005-05-04 13:43:09 +04:00
+ if (Pkg->CurrentVer != 0 && Cache[Pkg].Upgradable() == true) status = "upgradable";
+ if (Cache[Pkg].NewInstall()) status = "be-installed";
+ if (Cache[Pkg].Delete()) status = "be-removed";
+ if (Cache[Pkg].Upgrade() == true && Cache[Pkg].NewInstall() != true) status = "be-upgraded";
+ if (ShowGroup)
2005-04-29 14:00:58 +04:00
+ c2out << PkgSection << "\t" << Str << endl;
2005-05-04 13:43:09 +04:00
+ else
+ {
+ c2out << Str;
2006-04-02 16:15:03 +04:00
+ if (!MatchSection.empty())
2005-05-04 13:43:09 +04:00
+ cout << "\t" << status;
+ cout << endl;
+ }
2005-04-29 14:00:58 +04:00
}
- c2out << endl;
}
}
2008-12-31 17:12:21 +03:00
@@ -3985,6 +4014,8 @@ void CommandHelp(const char *Name)
" -u Show only installed packages that are upgradable.\n"
" -v Show installed and candidate versions.\n"
" -s Show summaries.\n"
+ " -g Show packages with group name.\n"
+ " -G=? Show packages in specified group.\n"
" -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp\n"
"\n"
);
@@ -4320,6 +4351,8 @@ CommandLine::Args *CommandArgs(const char *Name)
2005-04-29 14:00:58 +04:00
{'i',"installed","APT::Cache::ShowInstalled",0},
{'v',"version","APT::Cache::ShowVersion",0},
{'s',"summary","APT::Cache::ShowSummary",0},
+ {'g',"showgroup","APT::Cache::ShowGroup",0},
+ {'G',"groupmember","APT::Cache::MatchGroup",CommandLine::HasArg},
{'n',"installed","APT::Cache::Installed",0},
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},