diff options
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/acqprogress.cc | 7 | ||||
-rw-r--r-- | apt-private/private-cachefile.h | 23 | ||||
-rw-r--r-- | apt-private/private-install.cc | 28 | ||||
-rw-r--r-- | apt-private/private-list.cc | 12 |
4 files changed, 56 insertions, 14 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index 0f5b53e50..17a12799c 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; } @@ -142,6 +140,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 +171,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; 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-install.cc b/apt-private/private-install.cc index e08cd8057..55893bda0 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> @@ -680,10 +682,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 b69002103..e85aaf64c 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); } } |