]> git.saurik.com Git - apt.git/blob - apt-private/private-update.cc
Merge remote-tracking branch 'upstream/debian/sid' into feature/install-progress...
[apt.git] / apt-private / private-update.cc
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>
26 #include <apt-pkg/update.h>
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"
34 #include "acqprogress.h"
35
36 #include <apti18n.h>
37 /*}}}*/
38
39 // DoUpdate - Update the package lists /*{{{*/
40 // ---------------------------------------------------------------------
41 /* */
42 bool DoUpdate(CommandLine &CmdL)
43 {
44 if (CmdL.FileSize() != 1)
45 return _error->Error(_("The update command takes no arguments"));
46
47 CacheFile Cache;
48
49 // Get the source list
50 if (Cache.BuildSourceList() == false)
51 return false;
52 pkgSourceList *List = Cache.GetSourceList();
53
54 // Create the progress
55 AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
56
57 // Just print out the uris an exit if the --print-uris flag was used
58 if (_config->FindB("APT::Get::Print-URIs") == true)
59 {
60 // force a hashsum for compatibility reasons
61 _config->CndSet("Acquire::ForceHash", "md5sum");
62
63 // get a fetcher
64 pkgAcquire Fetcher;
65 if (Fetcher.Setup(&Stat) == false)
66 return false;
67
68 // Populate it with the source selection and get all Indexes
69 // (GetAll=true)
70 if (List->GetIndexes(&Fetcher,true) == false)
71 return false;
72
73 pkgAcquire::UriIterator I = Fetcher.UriBegin();
74 for (; I != Fetcher.UriEnd(); ++I)
75 c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
76 I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl;
77 return true;
78 }
79
80 // do the work
81 if (_config->FindB("APT::Get::Download",true) == true)
82 ListUpdate(Stat, *List);
83
84 // Rebuild the cache.
85 if (_config->FindB("pkgCacheFile::Generate", true) == true)
86 {
87 pkgCacheFile::RemoveCaches();
88 if (Cache.BuildCaches() == false)
89 return false;
90 }
91
92 return true;
93 }
94 /*}}}*/