]> git.saurik.com Git - apt.git/blame - apt-private/private-update.cc
warning: no previous declaration for foobar() [-Wmissing-declarations]
[apt.git] / apt-private / private-update.cc
CommitLineData
b9179170
MV
1// Include files /*{{{*/
2#include<config.h>
3
4#include <apt-pkg/aptconfiguration.h>
5#include <apt-pkg/error.h>
6#include <apt-pkg/cmndline.h>
7#include <apt-pkg/init.h>
8#include <apt-pkg/depcache.h>
9#include <apt-pkg/sourcelist.h>
10#include <apt-pkg/algorithms.h>
11#include <apt-pkg/acquire-item.h>
12#include <apt-pkg/strutl.h>
13#include <apt-pkg/fileutl.h>
14#include <apt-pkg/clean.h>
15#include <apt-pkg/srcrecords.h>
16#include <apt-pkg/version.h>
17#include <apt-pkg/cachefile.h>
18#include <apt-pkg/cacheset.h>
19#include <apt-pkg/sptr.h>
20#include <apt-pkg/md5.h>
21#include <apt-pkg/versionmatch.h>
22#include <apt-pkg/progress.h>
23#include <apt-pkg/pkgsystem.h>
24#include <apt-pkg/pkgrecords.h>
25#include <apt-pkg/indexfile.h>
d428d131 26#include <apt-pkg/update.h>
b9179170
MV
27
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <unistd.h>
31
32#include "private-cachefile.h"
33#include "private-output.h"
c3ccac92 34#include "private-update.h"
b9179170
MV
35#include "acqprogress.h"
36
37#include <apti18n.h>
38 /*}}}*/
39
40// DoUpdate - Update the package lists /*{{{*/
41// ---------------------------------------------------------------------
42/* */
43bool DoUpdate(CommandLine &CmdL)
44{
45 if (CmdL.FileSize() != 1)
46 return _error->Error(_("The update command takes no arguments"));
47
48 CacheFile Cache;
49
50 // Get the source list
51 if (Cache.BuildSourceList() == false)
52 return false;
53 pkgSourceList *List = Cache.GetSourceList();
54
55 // Create the progress
56 AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
57
58 // Just print out the uris an exit if the --print-uris flag was used
59 if (_config->FindB("APT::Get::Print-URIs") == true)
60 {
61 // force a hashsum for compatibility reasons
62 _config->CndSet("Acquire::ForceHash", "md5sum");
63
64 // get a fetcher
65 pkgAcquire Fetcher;
66 if (Fetcher.Setup(&Stat) == false)
67 return false;
68
69 // Populate it with the source selection and get all Indexes
70 // (GetAll=true)
71 if (List->GetIndexes(&Fetcher,true) == false)
72 return false;
73
74 pkgAcquire::UriIterator I = Fetcher.UriBegin();
75 for (; I != Fetcher.UriEnd(); ++I)
76 c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
77 I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl;
78 return true;
79 }
80
81 // do the work
82 if (_config->FindB("APT::Get::Download",true) == true)
83 ListUpdate(Stat, *List);
84
85 // Rebuild the cache.
86 if (_config->FindB("pkgCacheFile::Generate", true) == true)
87 {
88 pkgCacheFile::RemoveCaches();
89 if (Cache.BuildCaches() == false)
90 return false;
91 }
92
93 return true;
94}
95 /*}}}*/