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