From b917917067e757c4479a344a263ef7cf43c00866 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 12 Aug 2013 23:24:08 +0200 Subject: squash merge of the feature/apt-binary branch without the changes from experimental --- apt-private/private-update.cc | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 apt-private/private-update.cc (limited to 'apt-private/private-update.cc') diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc new file mode 100644 index 000000000..61259748d --- /dev/null +++ b/apt-private/private-update.cc @@ -0,0 +1,93 @@ +// Include files /*{{{*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "private-cachefile.h" +#include "private-output.h" +#include "acqprogress.h" + +#include + /*}}}*/ + +// DoUpdate - Update the package lists /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool DoUpdate(CommandLine &CmdL) +{ + if (CmdL.FileSize() != 1) + return _error->Error(_("The update command takes no arguments")); + + CacheFile Cache; + + // Get the source list + if (Cache.BuildSourceList() == false) + 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 + // (GetAll=true) + if (List->GetIndexes(&Fetcher,true) == false) + return false; + + pkgAcquire::UriIterator I = Fetcher.UriBegin(); + for (; I != Fetcher.UriEnd(); ++I) + c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << + I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl; + return true; + } + + // do the work + if (_config->FindB("APT::Get::Download",true) == true) + ListUpdate(Stat, *List); + + // Rebuild the cache. + if (_config->FindB("pkgCacheFile::Generate", true) == true) + { + pkgCacheFile::RemoveCaches(); + if (Cache.BuildCaches() == false) + return false; + } + + return true; +} + /*}}}*/ -- cgit v1.2.3