summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/acqprogress.cc14
-rw-r--r--apt-private/private-cachefile.cc4
-rw-r--r--apt-private/private-cachefile.h23
-rw-r--r--apt-private/private-cacheset.cc8
-rw-r--r--apt-private/private-cacheset.h25
-rw-r--r--apt-private/private-cmndline.cc1
-rw-r--r--apt-private/private-install.cc53
-rw-r--r--apt-private/private-list.cc12
-rw-r--r--apt-private/private-show.cc8
-rw-r--r--apt-private/private-update.cc4
-rw-r--r--apt-private/private-upgrade.cc4
11 files changed, 98 insertions, 58 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index 0f5b53e50..14a53eacb 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -64,8 +64,6 @@ void AcqTextStatus::IMSHit(pkgAcquire::ItemDesc &Itm)
cout << '\r' << BlankLine << '\r';
cout << _("Hit ") << Itm.Description;
- if (Itm.Owner->FileSize != 0)
- cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
cout << endl;
Update = true;
}
@@ -119,6 +117,9 @@ void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm)
if (Itm.Owner->Status == pkgAcquire::Item::StatDone)
{
cout << _("Ign ") << Itm.Description << endl;
+ if (Itm.Owner->ErrorText.empty() == false &&
+ _config->FindB("Acquire::Progress::Ignore::ShowErrorText", false) == true)
+ cout << " " << Itm.Owner->ErrorText << endl;
}
else
{
@@ -142,6 +143,9 @@ void AcqTextStatus::Stop()
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r' << flush;
+ if (_config->FindB("quiet::NoStatistic", false) == true)
+ return;
+
if (FetchedBytes != 0 && _error->PendingError() == false)
ioprintf(cout,_("Fetched %sB in %s (%sB/s)\n"),
SizeToStr(FetchedBytes).c_str(),
@@ -170,7 +174,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
ScreenWidth = sizeof(Buffer)-1;
// Put in the percent done
- sprintf(S,"%.0f%%",((CurrentBytes + CurrentItems)*100.0)/(TotalBytes+TotalItems));
+ sprintf(S,"%.0f%%", Percent);
bool Shown = false;
for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
@@ -201,9 +205,9 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
S += strlen(S);
// Show the short mode string
- if (I->CurrentItem->Owner->Mode != 0)
+ if (I->CurrentItem->Owner->ActiveSubprocess.empty() == false)
{
- snprintf(S,End-S," %s",I->CurrentItem->Owner->Mode);
+ snprintf(S,End-S, " %s", I->CurrentItem->Owner->ActiveSubprocess.c_str());
S += strlen(S);
}
diff --git a/apt-private/private-cachefile.cc b/apt-private/private-cachefile.cc
index 5e955ac39..29e665245 100644
--- a/apt-private/private-cachefile.cc
+++ b/apt-private/private-cachefile.cc
@@ -32,8 +32,10 @@ int CacheFile::NameComp(const void *a,const void *b)
const pkgCache::Package &A = **(pkgCache::Package **)a;
const pkgCache::Package &B = **(pkgCache::Package **)b;
+ const pkgCache::Group * const GA = SortCache->GrpP + A.Group;
+ const pkgCache::Group * const GB = SortCache->GrpP + B.Group;
- return strcmp(SortCache->StrP + A.Name,SortCache->StrP + B.Name);
+ return strcmp(SortCache->StrP + GA->Name,SortCache->StrP + GB->Name);
}
/*}}}*/
// CacheFile::Sort - Sort by name /*{{{*/
diff --git a/apt-private/private-cachefile.h b/apt-private/private-cachefile.h
index dce7e0a3a..1fddabfbd 100644
--- a/apt-private/private-cachefile.h
+++ b/apt-private/private-cachefile.h
@@ -6,7 +6,20 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/sourcelist.h>
+#include <apti18n.h>
+// FIXME: we need to find a way to export this
+class APT_PUBLIC SourceList : public pkgSourceList
+{
+
+ public:
+ // Add custom metaIndex (e.g. local files)
+ void AddMetaIndex(metaIndex *mi) {
+ SrcList.push_back(mi);
+ }
+
+};
// class CacheFile - Cover class for some dependency cache functions /*{{{*/
// ---------------------------------------------------------------------
@@ -28,6 +41,16 @@ class APT_PUBLIC CacheFile : public pkgCacheFile
return false;
return true;
}
+ // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way
+ // to add custom metaIndexes (or custom local files or so)
+ bool BuildSourceList(OpProgress */*Progress*/ = NULL) {
+ if (SrcList != NULL)
+ return true;
+ SrcList = new SourceList();
+ if (SrcList->ReadMainList() == false)
+ return _error->Error(_("The list of sources could not be read."));
+ return true;
+ }
bool Open(bool WithLock = true)
{
OpTextProgress Prog(*_config);
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index eb77be274..cb68024db 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -60,22 +60,22 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
if (insertCurrentVer == true)
{
if (P->CurrentVer != 0)
- vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::INSTALLED, helper);
+ vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::INSTALLED, helper);
}
else if (insertUpgradable == true)
{
if(P.CurrentVer() && state.Upgradable())
- vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper);
+ vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper);
}
else if (insertManualInstalled == true)
{
if (P.CurrentVer() &&
((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false)
- vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper);
+ vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper);
}
else
{
- if (vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper) == false)
+ if (vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper) == false)
{
// no candidate, this may happen for packages in
// dpkg "deinstall ok config-file" state - we pick the first ver
diff --git a/apt-private/private-cacheset.h b/apt-private/private-cacheset.h
index ca8f4be5d..059c7637e 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -76,19 +76,16 @@ class CacheSetHelperVirtuals: public APT::CacheSetHelper {
public:
APT::PackageSet virtualPkgs;
- virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
- virtualPkgs.insert(Pkg);
- return CacheSetHelper::canNotFindCandidateVer(Cache, Pkg);
+ virtual pkgCache::VerIterator canNotGetVersion(enum CacheSetHelper::VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+ if (select == NEWEST || select == CANDIDATE || select == ALL)
+ virtualPkgs.insert(Pkg);
+ return CacheSetHelper::canNotGetVersion(select, Cache, Pkg);
}
- virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
- virtualPkgs.insert(Pkg);
- return CacheSetHelper::canNotFindNewestVer(Cache, Pkg);
- }
-
- virtual void canNotFindAllVer(APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
- virtualPkgs.insert(Pkg);
- CacheSetHelper::canNotFindAllVer(vci, Cache, Pkg);
+ virtual void canNotFindVersion(enum CacheSetHelper::VerSelector const select, APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+ if (select == NEWEST || select == CANDIDATE || select == ALL)
+ virtualPkgs.insert(Pkg);
+ return CacheSetHelper::canNotFindVersion(select, vci, Cache, Pkg);
}
CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE) : CacheSetHelper(ShowErrors, ErrorType) {}
@@ -190,7 +187,7 @@ public:
}
virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
- APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDIDATE);
+ APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, CacheSetHelper::CANDIDATE);
if (verset.empty() == false)
return *(verset.begin());
else if (ShowError == true) {
@@ -203,7 +200,7 @@ public:
virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
if (Pkg->ProvidesList != 0)
{
- APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST);
+ APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, CacheSetHelper::NEWEST);
if (verset.empty() == false)
return *(verset.begin());
if (ShowError == true)
@@ -231,7 +228,7 @@ public:
}
APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg,
- APT::VersionSet::Version const &select) {
+ CacheSetHelper::VerSelector const select) {
/* This is a pure virtual package and there is a single available
candidate providing it. */
if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0)
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index a4490f5b4..079f81ee3 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -198,6 +198,7 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
addArg(0,"only-source","APT::Get::Only-Source",0);
addArg(0,"arch-only","APT::Get::Arch-Only",0);
addArg(0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0);
+ addArg(0,"allow-insecure-repositories","Acquire::AllowInsecureRepositories",0);
addArg(0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean);
addArg(0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean);
addArg(0,"fix-policy","APT::Get::Fix-Policy-Broken",0);
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index e08cd8057..c06caeedd 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -20,6 +20,7 @@
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/upgrade.h>
+#include <apt-pkg/install-progress.h>
#include <errno.h>
#include <stdlib.h>
@@ -30,6 +31,7 @@
#include <iostream>
#include <set>
#include <vector>
+#include <map>
#include <apt-private/acqprogress.h>
#include <apt-private/private-install.h>
@@ -117,14 +119,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
return false;
// Create the download object
- pkgAcquire Fetcher;
- AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
+ AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
+ pkgAcquire Fetcher(&Stat);
if (_config->FindB("APT::Get::Print-URIs", false) == true)
{
// force a hashsum for compatibility reasons
_config->CndSet("Acquire::ForceHash", "md5sum");
}
- else if (Fetcher.Setup(&Stat, _config->FindDir("Dir::Cache::Archives")) == false)
+ else if (Fetcher.GetLock(_config->FindDir("Dir::Cache::Archives")) == false)
return false;
// Read the source list
@@ -558,9 +560,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
std::list<APT::VersionSet::Modifier> mods;
mods.push_back(APT::VersionSet::Modifier(MOD_INSTALL, "+",
- APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDIDATE));
+ APT::VersionSet::Modifier::POSTFIX, APT::CacheSetHelper::CANDIDATE));
mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-",
- APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::NEWEST));
+ APT::VersionSet::Modifier::POSTFIX, APT::CacheSetHelper::NEWEST));
CacheSetHelperAPTGet helper(c0out);
verset = APT::VersionSet::GroupedFromCommandLine(Cache,
CmdL.FileList + 1, mods, fallback, helper);
@@ -617,15 +619,14 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
if (Fix != NULL)
{
// Call the scored problem resolver
+ OpTextProgress Progress(*_config);
+ bool const distUpgradeMode = strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0;
+
bool resolver_fail = false;
- if (UpgradeMode == 0)
- {
- if (strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0)
- resolver_fail = APT::Upgrade::Upgrade(Cache, 0);
- else
- resolver_fail = Fix->Resolve(true);
- } else
- resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode);
+ if (distUpgradeMode == true || UpgradeMode != APT::Upgrade::ALLOW_EVERYTHING)
+ resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode, &Progress);
+ else
+ resolver_fail = Fix->Resolve(true, &Progress);
if (resolver_fail == false && Cache->BrokenCount() == 0)
return false;
@@ -680,10 +681,34 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
bool DoInstall(CommandLine &CmdL)
{
CacheFile Cache;
+ // first check for local pkgs and add them to the cache
+ for (const char **I = CmdL.FileList; *I != 0; I++)
+ {
+ if(FileExists(*I))
+ {
+ // FIXME: make this more elegant
+ std::string TypeStr = flExtension(*I) + "-file";
+ pkgSourceList::Type *Type = pkgSourceList::Type::GetType(TypeStr.c_str());
+ if(Type != 0)
+ {
+ std::vector<metaIndex *> List;
+ std::map<std::string, std::string> Options;
+ if(Type->CreateItem(List, *I, "", "", Options))
+ {
+ // we have our own CacheFile that gives us a SourceList
+ // with superpowerz
+ SourceList *sources = (SourceList*)Cache.GetSourceList();
+ sources->AddMetaIndex(List[0]);
+ }
+ }
+ }
+ }
+
+ // then open the 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, 0))
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index 536348640..aa3a2c24b 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -37,28 +37,20 @@ struct PackageSortAlphabetic /*{{{*/
return (l_name < r_name);
}
};
- /*}}}*/
-class PackageNameMatcher : public Matcher /*{{{*/
+
+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)
{
std::string pattern = patterns[i];
-#ifdef PACKAGE_MATCHER_ABI_COMPAT
- APT::CacheFilter::PackageNameMatchesFnmatch *cachefilter = NULL;
- cachefilter = new APT::CacheFilter::PackageNameMatchesFnmatch(pattern);
-#else
APT::CacheFilter::PackageMatcher *cachefilter = NULL;
if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
cachefilter = new APT::CacheFilter::PackageNameMatchesRegEx(pattern);
else
cachefilter = new APT::CacheFilter::PackageNameMatchesFnmatch(pattern);
-#endif
filters.push_back(cachefilter);
}
}
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index 8ae6a6dac..289f035a6 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -141,16 +141,16 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", false) ?
- APT::VersionList::ALL : APT::VersionList::CANDIDATE;
+ APT::CacheSetHelper::VerSelector const select = _config->FindB("APT::Cache::AllVersions", false) ?
+ APT::CacheSetHelper::ALL : APT::CacheSetHelper::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)
+ if (select == APT::CacheSetHelper::CANDIDATE)
{
- APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::ALL, helper);
+ APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::CacheSetHelper::ALL, helper);
int const records = verset_all.size() - verset.size();
if (records > 0)
_error->Notice(P_("There is %i additional record. Please use the '-a' switch to see it", "There are %i additional records. Please use the '-a' switch to see them.", records), records);
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index 1cf3012ed..df77ac33a 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -47,9 +47,7 @@ bool DoUpdate(CommandLine &CmdL)
_config->CndSet("Acquire::ForceHash", "md5sum");
// get a fetcher
- pkgAcquire Fetcher;
- if (Fetcher.Setup(&Stat) == false)
- return false;
+ pkgAcquire Fetcher(&Stat);
// Populate it with the source selection and get all Indexes
// (GetAll=true)
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index 31f067576..d13a6af49 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -22,10 +22,8 @@ static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
- c0out << _("Calculating upgrade... ") << std::flush;
if(!DoCacheManipulationFromCommandLine(CmdL, Cache, UpgradeFlags))
return false;
- c0out << _("Done") << std::endl;
return InstallPackages(Cache,true);
}
@@ -35,7 +33,7 @@ static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
/* Intelligent upgrader that will install and remove packages at will */
bool DoDistUpgrade(CommandLine &CmdL)
{
- return UpgradeHelper(CmdL, 0);
+ return UpgradeHelper(CmdL, APT::Upgrade::ALLOW_EVERYTHING);
}
/*}}}*/
bool DoUpgrade(CommandLine &CmdL) /*{{{*/