summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-02-27 22:52:34 +0100
committerMichael Vogt <mvo@debian.org>2014-02-27 22:52:34 +0100
commitfce69e7a0f38299c57ef96ae1c1dd9a5379bfd5a (patch)
treebe7d18baa836e9df166ec63f6c9fe6f94bb84b40 /apt-private
parenta5e790985752c6820e08e7a7e650e1607fa826e4 (diff)
parentfc104da6a583736223b2f941e43a05ea26b63a7d (diff)
Merge branch 'debian/sid' into debian/experimental
Conflicts: apt-private/private-list.cc configure.ac debian/apt.install.in debian/changelog
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/acqprogress.cc7
-rw-r--r--apt-private/acqprogress.h2
-rw-r--r--apt-private/makefile2
-rw-r--r--apt-private/private-cachefile.cc1
-rw-r--r--apt-private/private-cacheset.cc9
-rw-r--r--apt-private/private-cacheset.h5
-rw-r--r--apt-private/private-cmndline.cc25
-rw-r--r--apt-private/private-download.cc96
-rw-r--r--apt-private/private-download.h9
-rw-r--r--apt-private/private-install.cc181
-rw-r--r--apt-private/private-install.h6
-rw-r--r--apt-private/private-list.cc47
-rw-r--r--apt-private/private-output.cc112
-rw-r--r--apt-private/private-output.h5
-rw-r--r--apt-private/private-search.cc16
-rw-r--r--apt-private/private-show.cc84
-rw-r--r--apt-private/private-sources.cc64
-rw-r--r--apt-private/private-sources.h3
-rw-r--r--apt-private/private-update.cc1
-rw-r--r--apt-private/private-upgrade.cc73
-rw-r--r--apt-private/private-upgrade.h2
-rw-r--r--apt-private/private-utils.cc50
-rw-r--r--apt-private/private-utils.h11
23 files changed, 567 insertions, 244 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index af2d0f461..d25ffef75 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -30,10 +30,13 @@ using namespace std;
// AcqTextStatus::AcqTextStatus - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) :
- ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet)
+AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int const Quiet) :
+ pkgAcquireStatus(), ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet)
{
BlankLine[0] = 0;
+ // testcases use it to disable pulses without disabling other user messages
+ if (Quiet == 0 && _config->FindB("quiet::NoUpdate", false) == true)
+ this->Quiet = 1;
}
/*}}}*/
// AcqTextStatus::Start - Downloading has started /*{{{*/
diff --git a/apt-private/acqprogress.h b/apt-private/acqprogress.h
index e47bfb72d..e12dafe50 100644
--- a/apt-private/acqprogress.h
+++ b/apt-private/acqprogress.h
@@ -32,7 +32,7 @@ class AcqTextStatus : public pkgAcquireStatus
bool Pulse(pkgAcquire *Owner);
- AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
+ AcqTextStatus(unsigned int &ScreenWidth,unsigned int const Quiet);
};
#endif
diff --git a/apt-private/makefile b/apt-private/makefile
index 8feb1ce6c..728890b9b 100644
--- a/apt-private/makefile
+++ b/apt-private/makefile
@@ -17,7 +17,7 @@ MAJOR=0.0
MINOR=0
SLIBS=$(PTHREADLIB) -lapt-pkg
-PRIVATES=list install output cachefile cacheset update upgrade cmndline moo search show main
+PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main utils sources
SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc)
HEADERS += $(foreach private, $(PRIVATES), private-$(private).h)
diff --git a/apt-private/private-cachefile.cc b/apt-private/private-cachefile.cc
index 25f65ef09..c822b9bad 100644
--- a/apt-private/private-cachefile.cc
+++ b/apt-private/private-cachefile.cc
@@ -2,6 +2,7 @@
#include<config.h>
#include <apt-pkg/algorithms.h>
+#include <apt-pkg/upgrade.h>
#include <apt-pkg/error.h>
#include <cstdlib>
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-cacheset.h b/apt-private/private-cacheset.h
index 15b531e9d..322b3be6b 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -101,6 +101,11 @@ public:
Pkg.FullName(true).c_str(), pattern.c_str());
explicitlyNamed = false;
}
+ virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
+ ioprintf(out, _("Note, selecting '%s' for glob '%s'\n"),
+ Pkg.FullName(true).c_str(), pattern.c_str());
+ explicitlyNamed = false;
+ }
virtual void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"),
Pkg.FullName(true).c_str(), pattern.c_str());
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index aceb865d5..ef7d65f3c 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -62,8 +62,12 @@ bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * con
{
addArg(0, "all-names", "APT::Cache::AllNames", 0);
}
+ else if (CmdMatches("unmet"))
+ {
+ addArg('i', "important", "APT::Cache::Important", 0);
+ }
else if (CmdMatches("gencaches", "showsrc", "showpkg", "stats", "dump",
- "dumpavail", "unmet", "showauto", "policy", "madison"))
+ "dumpavail", "showauto", "policy", "madison"))
;
else
return false;
@@ -114,9 +118,9 @@ bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * co
bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
- "deselect-upgrade", "autoremove"))
+ "dselect-upgrade", "autoremove"))
{
- addArg(0, "dpkg-progress", "DpkgPM::Progress", 0);
+ addArg(0, "show-progress", "DpkgPM::Progress", 0);
addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
addArg(0, "purge", "APT::Get::Purge", 0);
addArg('V',"verbose-versions","APT::Get::Show-Versions",0);
@@ -125,7 +129,8 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
if (CmdMatches("upgrade"))
{
- addArg(0, "allow-new", "APT::Get::UpgradeAllowNew", 0);
+ addArg(0, "new-pkgs", "APT::Get::Upgrade-Allow-New",
+ CommandLine::Boolean);
}
}
else if (CmdMatches("update"))
@@ -144,7 +149,11 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
else if (CmdMatches("build-dep"))
{
addArg('a', "host-architecture", "APT::Get::Host-Architecture", CommandLine::HasArg);
+ addArg(0, "purge", "APT::Get::Purge", 0);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
+ // this has no effect *but* sbuild is using it (see LP: #1255806)
+ // once sbuild is fixed, this option can be removed
+ addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
}
else if (CmdMatches("clean", "autoclean", "check", "download", "changelog") ||
CmdMatches("markauto", "unmarkauto")) // deprecated commands
@@ -217,7 +226,13 @@ 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('a', "all-versions", "APT::Cmd::AllVersions", 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))
{
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc
new file mode 100644
index 000000000..f02991cde
--- /dev/null
+++ b/apt-private/private-download.cc
@@ -0,0 +1,96 @@
+// Include Files /*{{{*/
+#include <config.h>
+
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/strutl.h>
+
+#include "private-output.h"
+
+#include <locale.h>
+
+#include <fstream>
+#include <string>
+#include <vector>
+
+#include <apti18n.h>
+ /*}}}*/
+
+// CheckAuth - check if each download comes form a trusted source /*{{{*/
+bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
+{
+ std::string UntrustedList;
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I)
+ if (!(*I)->IsTrusted())
+ UntrustedList += std::string((*I)->ShortDesc()) + " ";
+
+ if (UntrustedList == "")
+ return true;
+
+ ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
+
+ if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
+ {
+ c2out << _("Authentication warning overridden.\n");
+ return true;
+ }
+
+ if (PromptUser == false)
+ return _error->Error(_("Some packages could not be authenticated"));
+
+ if (_config->FindI("quiet",0) < 2
+ && _config->FindB("APT::Get::Assume-Yes",false) == false)
+ {
+ c2out << _("Install these packages without verification?") << std::flush;
+ if (!YnPrompt(false))
+ return _error->Error(_("Some packages could not be authenticated"));
+
+ return true;
+ }
+ else if (_config->FindB("APT::Get::Force-Yes",false) == true)
+ return true;
+
+ return _error->Error(_("There are problems and -y was used without --force-yes"));
+}
+ /*}}}*/
+bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure)/*{{{*/
+{
+ pkgAcquire::RunResult res;
+ if(PulseInterval > 0)
+ res = Fetcher.Run(PulseInterval);
+ else
+ res = Fetcher.Run();
+
+ if (res == pkgAcquire::Failed)
+ return false;
+
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
+ I != Fetcher.ItemsEnd(); ++I)
+ {
+
+ if ((*I)->Status == pkgAcquire::Item::StatDone &&
+ (*I)->Complete == true)
+ continue;
+
+ if (TransientNetworkFailure != NULL && (*I)->Status == pkgAcquire::Item::StatIdle)
+ {
+ *TransientNetworkFailure = true;
+ continue;
+ }
+
+ ::URI uri((*I)->DescURI());
+ uri.User.clear();
+ uri.Password.clear();
+ std::string descUri = std::string(uri);
+ _error->Error(_("Failed to fetch %s %s\n"), descUri.c_str(),
+ (*I)->ErrorText.c_str());
+
+ if (Failure != NULL)
+ *Failure = true;
+ }
+
+ return true;
+}
+ /*}}}*/
diff --git a/apt-private/private-download.h b/apt-private/private-download.h
new file mode 100644
index 000000000..b8cc8da1e
--- /dev/null
+++ b/apt-private/private-download.h
@@ -0,0 +1,9 @@
+#ifndef APT_PRIVATE_DOWNLOAD_H
+#define APT_PRIVATE_DOWNLOAD_H
+
+#include <apt-pkg/acquire.h>
+
+bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
+bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
+
+#endif
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index d5052fcc0..3adb00b23 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -23,6 +23,8 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/indexfile.h>
+#include <apt-pkg/install-progress.h>
+#include <apt-pkg/init.h>
#include <set>
#include <locale.h>
@@ -42,6 +44,7 @@
#include <sstream>
#include "private-install.h"
+#include "private-download.h"
#include "private-cachefile.h"
#include "private-output.h"
#include "private-cacheset.h"
@@ -50,52 +53,6 @@
#include <apti18n.h>
/*}}}*/
-// CheckAuth - check if each download comes form a trusted source /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool CheckAuth(pkgAcquire& Fetcher)
-{
- std::string UntrustedList;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I)
- {
- if (!(*I)->IsTrusted())
- {
- UntrustedList += std::string((*I)->ShortDesc()) + " ";
- }
- }
-
- if (UntrustedList == "")
- {
- return true;
- }
-
- ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
-
- if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
- {
- c2out << _("Authentication warning overridden.\n");
- return true;
- }
-
- if (_config->FindI("quiet",0) < 2
- && _config->FindB("APT::Get::Assume-Yes",false) == false)
- {
- c2out << _("Install these packages without verification?") << std::flush;
- if (!YnPrompt(false))
- return _error->Error(_("Some packages could not be authenticated"));
-
- return true;
- }
- else if (_config->FindB("APT::Get::Force-Yes",false) == true)
- {
- return true;
- }
-
- return _error->Error(_("There are problems and -y was used without --force-yes"));
-}
- /*}}}*/
-
-
// InstallPackages - Actually download and install the packages /*{{{*/
// ---------------------------------------------------------------------
/* This displays the informative messages describing what is going to
@@ -148,8 +105,16 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
if (_config->FindB("APT::Get::Simulate") == true)
{
pkgSimulate PM(Cache);
+
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ APT::Progress::PackageManager *progress = APT::Progress::PackageManagerProgressFactory();
+ pkgPackageManager::OrderResult Res = PM.DoInstall(progress);
+ delete progress;
+#else
int status_fd = _config->FindI("APT::Status-Fd",-1);
pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd);
+#endif
+
if (Res == pkgPackageManager::Failed)
return false;
if (Res != pkgPackageManager::Completed)
@@ -301,12 +266,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
{
pkgAcquire::UriIterator I = Fetcher.UriBegin();
for (; I != Fetcher.UriEnd(); ++I)
- c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+ std::cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl;
return true;
}
- if (!CheckAuth(Fetcher))
+ if (!CheckAuth(Fetcher, true))
return false;
/* Unlock the dpkg lock if we are not going to be doing an install
@@ -338,29 +303,10 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
I = Fetcher.ItemsBegin();
}
}
-
- if (Fetcher.Run() == pkgAcquire::Failed)
- return false;
-
- // Print out errors
- bool Failed = false;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
- {
- if ((*I)->Status == pkgAcquire::Item::StatDone &&
- (*I)->Complete == true)
- continue;
-
- if ((*I)->Status == pkgAcquire::Item::StatIdle)
- {
- Transient = true;
- // Failed = true;
- continue;
- }
- fprintf(stderr,_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(),
- (*I)->ErrorText.c_str());
- Failed = true;
- }
+ bool Failed = false;
+ if (AcquireRun(Fetcher, 0, &Failed, &Transient) == false)
+ return false;
/* If we are in no download mode and missing files and there were
'failures' then the user must specify -m. Furthermore, there
@@ -396,8 +342,16 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
}
_system->UnLock();
- int status_fd = _config->FindI("APT::Status-Fd",-1);
+
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ APT::Progress::PackageManager *progress = APT::Progress::PackageManagerProgressFactory();
+ pkgPackageManager::OrderResult Res = PM->DoInstall(progress);
+ delete progress;
+#else
+ int status_fd = _config->FindI("APT::Status-Fd", -1);
pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd);
+#endif
+
if (Res == pkgPackageManager::Failed || _error->PendingError() == true)
return false;
if (Res == pkgPackageManager::Completed)
@@ -429,8 +383,6 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
return true;
}
/*}}}*/
-
-
// DoAutomaticRemove - Remove all automatic unused packages /*{{{*/
// ---------------------------------------------------------------------
/* Remove unused automatic packages */
@@ -504,15 +456,15 @@ bool DoAutomaticRemove(CacheFile &Cache)
do {
Changed = false;
for (APT::PackageSet::const_iterator Pkg = tooMuch.begin();
- Pkg != tooMuch.end() && Changed == false; ++Pkg)
+ Pkg != tooMuch.end(); ++Pkg)
{
APT::PackageSet too;
too.insert(*Pkg);
for (pkgCache::PrvIterator Prv = Cache[Pkg].CandidateVerIter(Cache).ProvidesList();
Prv.end() == false; ++Prv)
too.insert(Prv.ParentPkg());
- for (APT::PackageSet::const_iterator P = too.begin();
- P != too.end() && Changed == false; ++P) {
+ for (APT::PackageSet::const_iterator P = too.begin(); P != too.end(); ++P)
+ {
for (pkgCache::DepIterator R = P.RevDependsList();
R.end() == false; ++R)
{
@@ -531,7 +483,11 @@ bool DoAutomaticRemove(CacheFile &Cache)
Changed = true;
break;
}
+ if (Changed == true)
+ break;
}
+ if (Changed == true)
+ break;
}
} while (Changed == true);
}
@@ -576,32 +532,28 @@ bool DoAutomaticRemove(CacheFile &Cache)
return true;
}
/*}}}*/
+// DoCacheManipulationFromCommandLine /*{{{*/
+static const unsigned short MOD_REMOVE = 1;
+static const unsigned short MOD_INSTALL = 2;
-
-
-
-// DoInstall - Install packages from the command line /*{{{*/
-// ---------------------------------------------------------------------
-/* Install named packages */
-bool DoInstall(CommandLine &CmdL)
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache)
{
- CacheFile Cache;
- if (Cache.OpenForInstall() == false ||
- Cache.CheckDeps(CmdL.FileSize() != 1) == false)
- return false;
-
+ std::map<unsigned short, APT::VersionSet> verset;
+ return DoCacheManipulationFromCommandLine(CmdL, Cache, verset);
+}
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
+ std::map<unsigned short, APT::VersionSet> &verset)
+{
+
// Enter the special broken fixing mode if the user specified arguments
bool BrokenFix = false;
if (Cache->BrokenCount() != 0)
BrokenFix = true;
- pkgProblemResolver* Fix = NULL;
+ SPtr<pkgProblemResolver> Fix;
if (_config->FindB("APT::Get::CallResolver", true) == true)
Fix = new pkgProblemResolver(Cache);
- static const unsigned short MOD_REMOVE = 1;
- static const unsigned short MOD_INSTALL = 2;
-
unsigned short fallback = MOD_INSTALL;
if (strcasecmp(CmdL.FileList[0],"remove") == 0)
fallback = MOD_REMOVE;
@@ -622,14 +574,12 @@ bool DoInstall(CommandLine &CmdL)
mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-",
APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::NEWEST));
CacheSetHelperAPTGet helper(c0out);
- std::map<unsigned short, APT::VersionSet> verset = APT::VersionSet::GroupedFromCommandLine(Cache,
+ verset = APT::VersionSet::GroupedFromCommandLine(Cache,
CmdL.FileList + 1, mods, fallback, helper);
if (_error->PendingError() == true)
{
helper.showVirtualPackageErrors(Cache);
- if (Fix != NULL)
- delete Fix;
return false;
}
@@ -663,8 +613,6 @@ bool DoInstall(CommandLine &CmdL)
if (_error->PendingError() == true)
{
- if (Fix != NULL)
- delete Fix;
return false;
}
@@ -675,8 +623,6 @@ bool DoInstall(CommandLine &CmdL)
{
c1out << _("You might want to run 'apt-get -f install' to correct these:") << std::endl;
ShowBroken(c1out,Cache,false);
- if (Fix != NULL)
- delete Fix;
return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."));
}
@@ -684,7 +630,6 @@ bool DoInstall(CommandLine &CmdL)
{
// Call the scored problem resolver
Fix->Resolve(true);
- delete Fix;
}
// Now we check the state of the packages,
@@ -718,6 +663,33 @@ bool DoInstall(CommandLine &CmdL)
if (!DoAutomaticRemove(Cache))
return false;
+ // if nothing changed in the cache, but only the automark information
+ // we write the StateFile here, otherwise it will be written in
+ // cache.commit()
+ if (InstallAction.AutoMarkChanged > 0 &&
+ Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
+ Cache->BadCount() == 0 &&
+ _config->FindB("APT::Get::Simulate",false) == false)
+ Cache->writeStateFile(NULL);
+
+ return true;
+}
+ /*}}}*/
+// DoInstall - Install packages from the command line /*{{{*/
+// ---------------------------------------------------------------------
+/* Install named packages */
+bool DoInstall(CommandLine &CmdL)
+{
+ CacheFile Cache;
+ if (Cache.OpenForInstall() == false ||
+ Cache.CheckDeps(CmdL.FileSize() != 1) == false)
+ return false;
+
+ std::map<unsigned short, APT::VersionSet> verset;
+
+ if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset))
+ return false;
+
/* Print out a list of packages that are going to be installed extra
to what the user asked */
if (Cache->InstCount() != verset[MOD_INSTALL].size())
@@ -833,15 +805,6 @@ bool DoInstall(CommandLine &CmdL)
}
- // if nothing changed in the cache, but only the automark information
- // we write the StateFile here, otherwise it will be written in
- // cache.commit()
- if (InstallAction.AutoMarkChanged > 0 &&
- Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
- Cache->BadCount() == 0 &&
- _config->FindB("APT::Get::Simulate",false) == false)
- Cache->writeStateFile(NULL);
-
// See if we need to prompt
// FIXME: check if really the packages in the set are going to be installed
if (Cache->InstCount() == verset[MOD_INSTALL].size() && Cache->DelCount() == 0)
diff --git a/apt-private/private-install.h b/apt-private/private-install.h
index fcf4cbced..2187146d3 100644
--- a/apt-private/private-install.h
+++ b/apt-private/private-install.h
@@ -14,6 +14,9 @@
bool DoInstall(CommandLine &Cmd);
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
+ std::map<unsigned short, APT::VersionSet> &verset);
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache);
bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
bool Safety = true);
@@ -92,6 +95,9 @@ struct TryToInstall {
Cache->GetDepCache()->SetCandidateVersion(s->first);
bool Success = true;
+ // the Changed list contains:
+ // first: "new version"
+ // second: "what-caused the change"
std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> > Changed;
for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
s != start.end(); ++s)
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index bbf4607f9..be2e07f43 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -42,7 +42,7 @@
#include <apti18n.h>
/*}}}*/
-struct PackageSortAlphabetic
+struct PackageSortAlphabetic /*{{{*/
{
bool operator () (const pkgCache::PkgIterator &p_lhs,
const pkgCache::PkgIterator &p_rhs)
@@ -52,17 +52,17 @@ struct PackageSortAlphabetic
return (l_name < r_name);
}
};
-
-class PackageNameMatcher : public Matcher
-{
+#ifdef PACKAGE_MATCHER_ABI_COMPAT
+#define PackageMatcher PackageNameMatchesFnmatch
+#endif
public:
PackageNameMatcher(const char **patterns)
{
- for(int i=0; patterns[i] != NULL; i++)
+ for(int i=0; patterns[i] != NULL; ++i)
{
std::string pattern = patterns[i];
APT::CacheFilter::PackageMatcher *cachefilter = NULL;
- if(_config->FindB("APT::Cmd::UseRegexp", false) == true)
+ if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
cachefilter = new APT::CacheFilter::PackageNameMatchesRegEx(pattern);
else
cachefilter = new APT::CacheFilter::PackageNameMatchesFnmatch(pattern);
@@ -71,12 +71,12 @@ class PackageNameMatcher : public Matcher
}
virtual ~PackageNameMatcher()
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
delete *J;
}
virtual bool operator () (const pkgCache::PkgIterator &P)
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
{
APT::CacheFilter::PackageMatcher *cachefilter = *J;
if((*cachefilter)(P))
@@ -90,17 +90,20 @@ private:
std::vector<APT::CacheFilter::PackageMatcher*>::const_iterator J;
#undef PackageMatcher
};
-
-
-void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,
+ /*}}}*/
+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 /*{{{*/
// ---------------------------------------------------------------------
bool List(CommandLine &Cmd)
@@ -125,24 +128,26 @@ bool List(CommandLine &Cmd)
std::map<std::string, std::string> output_map;
std::map<std::string, std::string>::const_iterator K;
+ bool includeSummary = _config->FindB("APT::Cmd::List-Include-Summary");
+
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
- for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); V++)
+ for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
- if(_config->FindB("APT::Cmd::AllVersions", false) == true)
+ 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 {
- ListSingleVersion(CacheFile, records, V, outs);
+ ListSingleVersion(CacheFile, records, V, outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
}
@@ -150,7 +155,7 @@ bool List(CommandLine &Cmd)
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
- for (K = output_map.begin(); K != output_map.end(); K++)
+ for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 659975476..420ca14d5 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -28,9 +28,11 @@ std::ostream c2out(0);
std::ofstream devnull("/dev/null");
unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
-
-bool InitOutput()
+bool InitOutput() /*{{{*/
{
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
+ _config->Set("quiet","1");
+
c0out.rdbuf(cout.rdbuf());
c1out.rdbuf(cout.rdbuf());
c2out.rdbuf(cout.rdbuf());
@@ -60,8 +62,8 @@ bool InitOutput()
return true;
}
-
-std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
+ /*}}}*/
+std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver) /*{{{*/
{
std::string suite = "";
if (ver && ver.FileList() && ver.FileList())
@@ -69,16 +71,18 @@ std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
pkgCache::VerFileIterator VF = ver.FileList();
for (; VF.end() == false ; ++VF)
{
- // XXX: how to figure out the relevant suite? if its in multiple ones?
- suite = suite + "," + VF.File().Archive();
+ if(VF.File() == NULL || VF.File().Archive() == NULL)
+ suite = suite + "," + _("unknown");
+ else
+ suite = suite + "," + VF.File().Archive();
//suite = VF.File().Archive();
}
suite = suite.erase(0, 1);
}
return suite;
}
-
-std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
@@ -94,32 +98,34 @@ std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
flags_str = "-";
return flags_str;
}
-
-std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator cand = policy->GetCandidateVer(P);
return cand ? cand.VerStr() : "(none)";
}
-
-std::string GetInstalledVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetInstalledVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgCache::VerIterator inst = P.CurrentVer();
return inst ? inst.VerStr() : "(none)";
}
-
-std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
+ /*}}}*/
+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;
}
@@ -127,8 +133,8 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
return DeNull(V.VerStr());
return "(none)";
}
-
-std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator inst = P.CurrentVer();
@@ -136,8 +142,8 @@ std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
return inst ? inst.Arch() : cand.Arch();
}
-
-std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
@@ -157,9 +163,10 @@ std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pk
}
return ShortDescription;
}
-
-void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
- pkgCache::VerIterator V, std::ostream &out)
+ /*}}}*/
+void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
+ pkgCache::VerIterator V, std::ostream &out,
+ bool include_summary)
{
pkgCache::PkgIterator P = V.ParentPkg();
@@ -186,52 +193,53 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
// raring/linux-kernel version [upradable: new-version]
// description
pkgPolicy *policy = CacheFile.GetPolicy();
- out << std::setiosflags(std::ios::left)
- << _config->Find("APT::Color::Highlight", "")
- << name_str
- << _config->Find("APT::Color::Neutral", "")
- << "/" << suite
- << " ";
+ std::string VersionStr = GetVersion(CacheFile, V);
+ std::string CandidateVerStr = GetCandidateVersion(CacheFile, P);
+ std::string InstalledVerStr = GetInstalledVersion(CacheFile, P);
+ std::string StatusStr;
if(P.CurrentVer() == V && state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << "[" << _("installed,upgradable to: ")
- << GetCandidateVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[installed,upgradable to: %s]"),
+ CandidateVerStr.c_str());
} else if (P.CurrentVer() == V) {
- out << GetVersion(CacheFile, V)
- << " ";
if(!V.Downloadable())
- out << _("[installed,local]");
+ StatusStr = _("[installed,local]");
else
if(V.Automatic() && state.Garbage)
- out << _("[installed,auto-removable]");
+ StatusStr = _("[installed,auto-removable]");
else if (state.Flags & pkgCache::Flag::Auto)
- out << _("[installed,automatic]");
+ StatusStr = _("[installed,automatic]");
else
- out << _("[installed]");
+ StatusStr = _("[installed]");
} else if (P.CurrentVer() &&
policy->GetCandidateVer(P) == V &&
state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << _("[upgradable from: ")
- << GetInstalledVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[upgradable from: %s]"),
+ InstalledVerStr.c_str());
} else {
if (V.ParentPkg()->CurrentState == pkgCache::State::ConfigFiles)
- out << GetVersion(CacheFile, V)
- << " "
- << _("[residual-config]");
+ StatusStr = _("[residual-config]");
else
- out << GetVersion(CacheFile, V);
+ StatusStr = "";
+ }
+ out << std::setiosflags(std::ios::left)
+ << _config->Find("APT::Color::Highlight", "")
+ << name_str
+ << _config->Find("APT::Color::Neutral", "")
+ << "/" << suite
+ << " "
+ << VersionStr << " "
+ << GetArchitecture(CacheFile, P);
+ if (StatusStr != "")
+ out << " " << StatusStr;
+ if (include_summary)
+ {
+ out << std::endl
+ << " " << GetShortDescription(CacheFile, records, P)
+ << std::endl;
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
- out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
- << std::endl;
}
}
-
-
+ /*}}}*/
// ShowList - Show a list /*{{{*/
// ---------------------------------------------------------------------
/* This prints out a string of space separated words with a title and
diff --git a/apt-private/private-output.h b/apt-private/private-output.h
index 9283e39ab..2a2a69458 100644
--- a/apt-private/private-output.h
+++ b/apt-private/private-output.h
@@ -24,10 +24,11 @@ extern unsigned int ScreenWidth;
bool InitOutput();
void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
- pkgCache::VerIterator V, std::ostream &out);
-
+ pkgCache::VerIterator V, std::ostream &out,
+ 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 6881f482f..0b1a929b0 100644
--- a/apt-private/private-search.cc
+++ b/apt-private/private-search.cc
@@ -1,3 +1,4 @@
+// Includes /*{{{*/
#include <apt-pkg/error.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
@@ -34,9 +35,9 @@
#include "private-search.h"
#include "private-cacheset.h"
+ /*}}}*/
-
-bool FullTextSearch(CommandLine &CmdL)
+bool FullTextSearch(CommandLine &CmdL) /*{{{*/
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -52,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();
@@ -60,18 +61,18 @@ bool FullTextSearch(CommandLine &CmdL)
progress.OverallProgress(50, 100, 50, _("Full Text Search"));
progress.SubProgress(bag.size());
int Done = 0;
- for ( ;V != bag.end(); V++)
+ for ( ;V != bag.end(); ++V)
{
if (Done%500 == 0)
progress.Progress(Done);
- Done++;
+ ++Done;
int i;
pkgCache::DescIterator Desc = V.TranslatedDescription();
pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
bool all_found = true;
- for(i=0; patterns[i] != NULL; i++)
+ for(i=0; patterns[i] != NULL; ++i)
{
// FIXME: use regexp instead of simple find()
const char *pattern = patterns[i];
@@ -92,8 +93,9 @@ bool FullTextSearch(CommandLine &CmdL)
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
- for (K = output_map.begin(); K != output_map.end(); K++)
+ for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;
return true;
}
+ /*}}}*/
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index e26a2b30a..60d951316 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -1,3 +1,4 @@
+// Includes /*{{{*/
#include <apt-pkg/error.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
@@ -23,6 +24,7 @@
#include "private-output.h"
#include "private-cacheset.h"
+ /*}}}*/
namespace APT {
namespace Cmd {
@@ -35,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();
@@ -49,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)
@@ -87,22 +134,29 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
return true;
}
/*}}}*/
-
-bool ShowPackage(CommandLine &CmdL)
+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)
{
c1out << "Package: " << Pkg.FullName(true) << std::endl;
- c1out << "State: " << _("not a real pacakge (virtual)") << std::endl;
+ c1out << "State: " << _("not a real package (virtual)") << std::endl;
// FIXME: show providers, see private-cacheset.h
// CacheSetHelperAPTGet::showVirtualPackageErrors()
}
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
new file mode 100644
index 000000000..41cf6b313
--- /dev/null
+++ b/apt-private/private-sources.cc
@@ -0,0 +1,64 @@
+
+#include <apt-pkg/hashes.h>
+#include <apti18n.h>
+
+#include "private-output.h"
+#include "private-sources.h"
+#include "private-utils.h"
+
+/* Interface discussion with donkult (for the future):
+ apt [add-{archive,release,component}|edit|change-release|disable]-sources
+ and be clever and work out stuff from the Release file
+*/
+
+// EditSource - EditSourcesList /*{{{*/
+// ---------------------------------------------------------------------
+bool EditSources(CommandLine &CmdL)
+{
+ bool res;
+ pkgSourceList sl;
+ std::string outs;
+
+ std::string sourceslist;
+ if (CmdL.FileList[1] != NULL)
+ {
+ sourceslist = _config->FindDir("Dir::Etc::sourceparts") + CmdL.FileList[1];
+ if (!APT::String::Endswith(sourceslist, ".list"))
+ sourceslist += ".list";
+ } else {
+ sourceslist = _config->FindFile("Dir::Etc::sourcelist");
+ }
+ HashString before;
+ if (FileExists(sourceslist))
+ before.FromFile(sourceslist);
+
+ int lockfd = GetLock(sourceslist);
+ if (lockfd < 0)
+ return false;
+
+ do {
+ EditFileInSensibleEditor(sourceslist);
+ _error->PushToStack();
+ res = sl.Read(sourceslist);
+ if (!res) {
+ _error->DumpErrors();
+ strprintf(outs, _("Failed to parse %s. Edit again? "),
+ sourceslist.c_str());
+ std::cout << outs;
+ // FIXME: should we add a "restore previous" option here?
+ res = !YnPrompt(true);
+ }
+ _error->RevertToStack();
+ } while (res == false);
+ close(lockfd);
+
+ if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
+ strprintf(
+ outs, _("Your '%s' file changed, please run 'apt-get update'."),
+ sourceslist.c_str());
+ std::cout << outs << std::endl;
+ }
+
+ return true;
+}
+ /*}}}*/
diff --git a/apt-private/private-sources.h b/apt-private/private-sources.h
new file mode 100644
index 000000000..b394622be
--- /dev/null
+++ b/apt-private/private-sources.h
@@ -0,0 +1,3 @@
+#include <apt-pkg/cmndline.h>
+
+bool EditSources(CommandLine &CmdL);
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index 61259748d..f6c12c26a 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -23,6 +23,7 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/indexfile.h>
+#include <apt-pkg/update.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index eb546e3e3..a97e6d25b 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -1,53 +1,68 @@
+// Includes /*{{{*/
#include <apt-pkg/algorithms.h>
-
+#include <apt-pkg/upgrade.h>
+#include <iostream>
#include "private-install.h"
#include "private-cachefile.h"
#include "private-upgrade.h"
#include "private-output.h"
+ /*}}}*/
-
-// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
-// ---------------------------------------------------------------------
-/* Upgrade all packages without installing new packages or erasing old
- packages */
-bool DoUpgradeNoNewPackages(CommandLine &CmdL)
+// this is actually performing the various upgrade operations
+static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
{
- if (CmdL.FileSize() != 1)
- return _error->Error(_("The upgrade command takes no arguments"));
-
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
- // Do the upgrade
- if (pkgAllUpgrade(Cache) == false)
+ c0out << _("Calculating upgrade... ") << std::flush;
+ if (APT::Upgrade::Upgrade(Cache, UpgradeFlags) == false)
{
+ c0out << _("Failed") << std::endl;
ShowBroken(c1out,Cache,false);
- return _error->Error(_("Internal error, AllUpgrade broke stuff"));
+ return _error->Error(_("Internal error, Upgrade broke stuff"));
}
+ c0out << _("Done") << std::endl;
+
+ // parse additional cmdline pkg manipulation switches
+ if(!DoCacheManipulationFromCommandLine(CmdL, Cache))
+ return false;
return InstallPackages(Cache,true);
}
- /*}}}*/
+// DoDistUpgrade - Automatic smart upgrader /*{{{*/
+// ---------------------------------------------------------------------
+/* Intelligent upgrader that will install and remove packages at will */
+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
+ packages */
+bool DoUpgradeNoNewPackages(CommandLine &CmdL)
+{
+ // Do the upgrade
+ return UpgradeHelper(CmdL,
+ APT::Upgrade::FORBID_REMOVE_PACKAGES|
+ APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES);
+}
+ /*}}}*/
// DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
{
- if (CmdL.FileSize() != 1)
- return _error->Error(_("The upgrade command takes no arguments"));
-
- CacheFile Cache;
- if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
- return false;
-
- // Do the upgrade
- if (pkgAllUpgradeNoDelete(Cache) == false)
- {
- ShowBroken(c1out,Cache,false);
- return _error->Error(_("Internal error, AllUpgrade broke stuff"));
- }
-
- return InstallPackages(Cache,true);
+ return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES);
}
/*}}}*/
diff --git a/apt-private/private-upgrade.h b/apt-private/private-upgrade.h
index 6ede6f96c..5efc66bf7 100644
--- a/apt-private/private-upgrade.h
+++ b/apt-private/private-upgrade.h
@@ -4,6 +4,8 @@
#include <apt-pkg/cmndline.h>
+bool DoDistUpgrade(CommandLine &CmdL);
+bool DoUpgrade(CommandLine &CmdL);
bool DoUpgradeNoNewPackages(CommandLine &CmdL);
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);
diff --git a/apt-private/private-utils.cc b/apt-private/private-utils.cc
new file mode 100644
index 000000000..813f19329
--- /dev/null
+++ b/apt-private/private-utils.cc
@@ -0,0 +1,50 @@
+#include <cstdlib>
+
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
+#include "private-utils.h"
+
+
+// DisplayFileInPager - Display File with pager /*{{{*/
+void DisplayFileInPager(std::string filename)
+{
+ std::string pager = _config->Find("Dir::Bin::Pager",
+ "/usr/bin/sensible-pager");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char *Args[3];
+ Args[0] = pager.c_str();
+ Args[1] = filename.c_str();
+ Args[2] = 0;
+ execvp(Args[0],(char **)Args);
+ exit(100);
+ }
+
+ // Wait for the subprocess
+ ExecWait(Process, "sensible-pager", false);
+}
+ /*}}}*/
+
+// EditFileInSensibleEditor - Edit File with editor /*{{{*/
+void EditFileInSensibleEditor(std::string filename)
+{
+ std::string editor = _config->Find("Dir::Bin::Editor",
+ "/usr/bin/sensible-editor");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char *Args[3];
+ Args[0] = editor.c_str();
+ Args[1] = filename.c_str();
+ Args[2] = 0;
+ execvp(Args[0],(char **)Args);
+ exit(100);
+ }
+
+ // Wait for the subprocess
+ ExecWait(Process, "sensible-editor", false);
+}
+ /*}}}*/
diff --git a/apt-private/private-utils.h b/apt-private/private-utils.h
new file mode 100644
index 000000000..258dd06a8
--- /dev/null
+++ b/apt-private/private-utils.h
@@ -0,0 +1,11 @@
+#ifndef APT_PRIVATE_UTILS_H
+#define APT_PRIVATE_UTILS_H
+
+#include<string>
+
+void DisplayFileInPager(std::string filename);
+void EditFileInSensibleEditor(std::string filename);
+
+
+
+#endif