summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-cacheset.cc9
-rw-r--r--apt-private/private-cmndline.cc5
-rw-r--r--apt-private/private-list.cc14
-rw-r--r--apt-private/private-output.cc8
-rw-r--r--apt-private/private-output.h2
-rw-r--r--apt-private/private-search.cc2
-rw-r--r--apt-private/private-show.cc77
-rw-r--r--apt-private/private-sources.cc5
-rw-r--r--apt-private/private-upgrade.cc9
-rw-r--r--apt-private/private-upgrade.h1
10 files changed, 110 insertions, 22 deletions
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 6fb224010..a7dc0e800 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -52,6 +52,15 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
output_set.insert(policy->GetCandidateVer(P));
}
}
+ else if (_config->FindB("APT::Cmd::Manual-Installed") == true)
+ {
+ if (P.CurrentVer() &&
+ ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false)
+ {
+ pkgPolicy *policy = CacheFile.GetPolicy();
+ output_set.insert(policy->GetCandidateVer(P));
+ }
+ }
else
{
pkgPolicy *policy = CacheFile.GetPolicy();
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 28309af07..ef7d65f3c 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -226,9 +226,14 @@ bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cm
{
addArg(0,"installed","APT::Cmd::Installed",0);
addArg(0,"upgradable","APT::Cmd::Upgradable",0);
+ addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
}
+ else if (CmdMatches("show"))
+ {
+ addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
+ }
else if (addArgumentsAPTGet(Args, Cmd) || addArgumentsAPTCache(Args, Cmd))
{
// we have no (supported) command-name overlaps so far, so we call
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index 898ee7222..44a766c84 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -101,11 +101,15 @@ private:
/*}}}*/
void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
pkgCache::PkgIterator P,
- std::ostream &outs)
+ std::ostream &outs,
+ bool include_summary=true)
{
for (pkgCache::VerIterator Ver = P.VersionList();
- Ver.end() == false; ++Ver)
- ListSingleVersion(CacheFile, records, Ver, outs);
+ Ver.end() == false; ++Ver)
+ {
+ ListSingleVersion(CacheFile, records, Ver, outs, include_summary);
+ outs << "\n";
+ }
}
/*}}}*/
// list - list package based on criteria /*{{{*/
@@ -136,7 +140,7 @@ bool List(CommandLine &Cmd)
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
@@ -147,7 +151,7 @@ bool List(CommandLine &Cmd)
std::stringstream outs;
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
{
- ListAllVersions(CacheFile, records, V.ParentPkg(), outs);
+ ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
} else {
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 91d13f31b..a8bbad9e5 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -114,11 +114,13 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
pkgCache::PkgIterator P = V.ParentPkg();
if (V == P.CurrentVer())
{
+ std::string inst_str = DeNull(V.VerStr());
+#if 0 // FIXME: do we want this or something like this?
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
- std::string inst_str = DeNull(V.VerStr());
if (state.Upgradable())
return "**"+inst_str;
+#endif
return inst_str;
}
@@ -224,11 +226,11 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
else
out << GetVersion(CacheFile, V);
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
+ out << " " << GetArchitecture(CacheFile, P);
if (include_summary)
{
out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
+ << " " << GetShortDescription(CacheFile, records, P)
<< std::endl;
}
}
diff --git a/apt-private/private-output.h b/apt-private/private-output.h
index c3c76bb92..2a2a69458 100644
--- a/apt-private/private-output.h
+++ b/apt-private/private-output.h
@@ -28,7 +28,7 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
bool include_summary=true);
-
+// helper to describe global state
bool ShowList(std::ostream &out, std::string Title, std::string List,
std::string VersionsList);
void ShowBroken(std::ostream &out,CacheFile &Cache,bool Now);
diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc
index ade12353a..0b1a929b0 100644
--- a/apt-private/private-search.cc
+++ b/apt-private/private-search.cc
@@ -53,7 +53,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
std::map<std::string, std::string>::const_iterator K;
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0, 100, 50, _("Sorting"));
GetLocalitySortedVersionSet(CacheFile, bag, progress);
LocalitySortedVersionSet::iterator V = bag.begin();
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index ddc75dbeb..60d951316 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -37,6 +37,9 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
pkgCache *Cache = CacheFile.GetPkgCache();
if (unlikely(Cache == NULL))
return false;
+ pkgDepCache *depCache = CacheFile.GetDepCache();
+ if (unlikely(depCache == NULL))
+ return false;
// Find an appropriate file
pkgCache::VerFileIterator Vf = V.FileList();
@@ -51,36 +54,78 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
if (I.IsOk() == false)
return _error->Error(_("Package file %s is out of sync."),I.FileName());
+ // find matching sources.list metaindex
+ pkgSourceList *SrcList = CacheFile.GetSourceList();
+ pkgIndexFile *Index;
+ if (SrcList->FindIndex(I, Index) == false &&
+ _system->FindIndex(I, Index) == false)
+ return _error->Error("Can not find indexfile for Package %s (%s)",
+ V.ParentPkg().Name(), V.VerStr());
+ std::string source_index_file = Index->Describe(true);
+
// Read the record
FileFd PkgF;
if (PkgF.Open(I.FileName(), FileFd::ReadOnly, FileFd::Extension) == false)
return false;
pkgTagSection Tags;
pkgTagFile TagF(&PkgF);
-
+
+ if (TagF.Jump(Tags, V.FileList()->Offset) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
+
+ // make size nice
+ std::string installed_size;
+ if (Tags.FindI("Installed-Size") > 0)
+ strprintf(installed_size, "%sB", SizeToStr(Tags.FindI("Installed-Size")*1024).c_str());
+ else
+ installed_size = _("unknown");
+ std::string package_size;
+ if (Tags.FindI("Size") > 0)
+ strprintf(package_size, "%sB", SizeToStr(Tags.FindI("Size")).c_str());
+ else
+ package_size = _("unknown");
+
+ pkgDepCache::StateCache &state = (*depCache)[V.ParentPkg()];
+ bool is_installed = V.ParentPkg().CurrentVer() == V;
+ const char *manual_installed;
+ if (is_installed)
+ manual_installed = !(state.Flags & pkgCache::Flag::Auto) ? "yes" : "no";
+ else
+ manual_installed = 0;
+
+ // FIXME: add verbose that does not do the removal of the tags?
TFRewriteData RW[] = {
+ // delete, apt-cache show has this info and most users do not care
+ {"MD5sum", 0},
+ {"SHA1", 0},
+ {"SHA256", 0},
+ {"Filename", 0},
+ {"Multi-Arch", 0},
+ {"Architecture", 0},
{"Conffiles",0},
+ // we use the translated description
{"Description",0},
{"Description-md5",0},
+ // improve
+ {"Installed-Size", installed_size.c_str(), 0},
+ {"Size", package_size.c_str(), "Download-Size"},
+ // add
+ {"APT-Manual-Installed", manual_installed, 0},
+ {"APT-Sources", source_index_file.c_str(), 0},
{}
};
- const char *Zero = 0;
- if (TagF.Jump(Tags, V.FileList()->Offset) == false ||
- TFRewrite(stdout,Tags,&Zero,RW) == false)
- {
- _error->Error("Internal Error, Unable to parse a package record");
- return false;
- }
+
+ if(TFRewrite(stdout, Tags, NULL, RW) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
// write the description
pkgRecords Recs(*Cache);
+ // FIXME: show (optionally) all available translations(?)
pkgCache::DescIterator Desc = V.TranslatedDescription();
if (Desc.end() == false)
{
pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- if (strcmp(Desc.LanguageCode(),"") != 0)
- out << "Description-lang: " << Desc.LanguageCode() << std::endl;
- out << "Description" << P.LongDesc();
+ out << "Description: " << P.LongDesc();
}
// write a final newline (after the description)
@@ -93,12 +138,20 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionList::Version const select = APT::VersionList::CANDIDATE;
+ APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", false) ?
+ APT::VersionList::ALL : APT::VersionList::CANDIDATE;
APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
if (DisplayRecord(CacheFile, Ver, c1out) == false)
return false;
+ if (select == APT::VersionList::CANDIDATE)
+ {
+ APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::ALL, helper);
+ if (verset_all.size() > verset.size())
+ _error->Notice(ngettext("There is %lu additional record. Please use the '-a' switch to see it", "There are %lu additional records. Please use the '-a' switch to see them.", verset_all.size() - verset.size()), verset_all.size() - verset.size());
+ }
+
for (APT::PackageSet::const_iterator Pkg = helper.virtualPkgs.begin();
Pkg != helper.virtualPkgs.end(); ++Pkg)
{
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
index 65706e785..41cf6b313 100644
--- a/apt-private/private-sources.cc
+++ b/apt-private/private-sources.cc
@@ -32,6 +32,10 @@ bool EditSources(CommandLine &CmdL)
if (FileExists(sourceslist))
before.FromFile(sourceslist);
+ int lockfd = GetLock(sourceslist);
+ if (lockfd < 0)
+ return false;
+
do {
EditFileInSensibleEditor(sourceslist);
_error->PushToStack();
@@ -46,6 +50,7 @@ bool EditSources(CommandLine &CmdL)
}
_error->RevertToStack();
} while (res == false);
+ close(lockfd);
if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
strprintf(
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index e76b5d7fc..a97e6d25b 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -1,3 +1,4 @@
+
// Includes /*{{{*/
#include <apt-pkg/algorithms.h>
#include <apt-pkg/upgrade.h>
@@ -39,6 +40,14 @@ bool DoDistUpgrade(CommandLine &CmdL)
return UpgradeHelper(CmdL, 0);
}
/*}}}*/
+bool DoUpgrade(CommandLine &CmdL) /*{{{*/
+{
+ if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
+ return DoUpgradeWithAllowNewPackages(CmdL);
+ else
+ return DoUpgradeNoNewPackages(CmdL);
+}
+ /*}}}*/
// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
// ---------------------------------------------------------------------
/* Upgrade all packages without installing new packages or erasing old
diff --git a/apt-private/private-upgrade.h b/apt-private/private-upgrade.h
index 050d3a668..5efc66bf7 100644
--- a/apt-private/private-upgrade.h
+++ b/apt-private/private-upgrade.h
@@ -5,6 +5,7 @@
bool DoDistUpgrade(CommandLine &CmdL);
+bool DoUpgrade(CommandLine &CmdL);
bool DoUpgradeNoNewPackages(CommandLine &CmdL);
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);