X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/be20eef52da4b7f361333ea70a8d705a98ae779e..cb6020cdfea3d6dec6f6ad13843ab46f0c10d562:/apt-private/private-update.cc diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc index da83d7741..1e5d69512 100644 --- a/apt-private/private-update.cc +++ b/apt-private/private-update.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -37,35 +38,38 @@ bool DoUpdate(CommandLine &CmdL) return false; pkgSourceList *List = Cache.GetSourceList(); - // Create the progress - AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); - // Just print out the uris an exit if the --print-uris flag was used if (_config->FindB("APT::Get::Print-URIs") == true) { // force a hashsum for compatibility reasons _config->CndSet("Acquire::ForceHash", "md5sum"); - // get a fetcher - pkgAcquire Fetcher; - if (Fetcher.Setup(&Stat) == false) - return false; - - // Populate it with the source selection and get all Indexes + // Populate it with the source selection and get all Indexes // (GetAll=true) + aptAcquireWithTextStatus Fetcher; if (List->GetIndexes(&Fetcher,true) == false) return false; + std::string compExt = APT::Configuration::getCompressionTypes()[0]; pkgAcquire::UriIterator I = Fetcher.UriBegin(); for (; I != Fetcher.UriEnd(); ++I) - c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << + { + std::string FileName = flNotDir(I->Owner->DestFile); + if(compExt.empty() == false && + APT::String::Endswith(FileName, compExt)) + FileName = FileName.substr(0, FileName.size() - compExt.size() - 1); + c1out << '\'' << I->URI << "' " << FileName << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl; + } return true; } // do the work if (_config->FindB("APT::Get::Download",true) == true) - ListUpdate(Stat, *List); + { + AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); + ListUpdate(Stat, *List); + } // Rebuild the cache. if (_config->FindB("pkgCacheFile::Generate", true) == true) @@ -75,6 +79,28 @@ bool DoUpdate(CommandLine &CmdL) return false; } + // show basic stats (if the user whishes) + if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true) + { + int upgradable = 0; + if (Cache.Open() == false) + return false; + for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I) + { + pkgDepCache::StateCache &state = Cache[I]; + if (I->CurrentVer != 0 && state.Upgradable() && state.CandidateVer != NULL) + upgradable++; + } + const char *msg = P_( + "%i package can be upgraded. Run 'apt list --upgradable' to see it.\n", + "%i packages can be upgraded. Run 'apt list --upgradable' to see them.\n", + upgradable); + if (upgradable == 0) + c1out << _("All packages are up to date.") << std::endl; + else + ioprintf(c1out, msg, upgradable); + } + return true; } /*}}}*/