summaryrefslogtreecommitdiff
path: root/apt-private/private-update.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-08-17 09:18:36 +0200
committerMichael Vogt <mvo@debian.org>2013-08-17 09:18:36 +0200
commitf49d103adc47c5c34f4ca852605ee55710e486b9 (patch)
treeeb63a4d80a82b2d9f9aa5bc25165a21cb38b215f /apt-private/private-update.cc
parentb55e706a8794d810fb7c5a7c175c04ea207b1ce7 (diff)
parentdd4d9729975fc2de37cd69220bc05efb16badc77 (diff)
Merge remote-tracking branch 'mvo/feature/apt-binary2' into debian/sid
Conflicts: cmdline/apt-get.cc
Diffstat (limited to 'apt-private/private-update.cc')
-rw-r--r--apt-private/private-update.cc93
1 files changed, 93 insertions, 0 deletions
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<config.h>
+
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/algorithms.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/clean.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
+#include <apt-pkg/sptr.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/versionmatch.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/indexfile.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "private-cachefile.h"
+#include "private-output.h"
+#include "acqprogress.h"
+
+#include <apti18n.h>
+ /*}}}*/
+
+// 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;
+}
+ /*}}}*/