]>
git.saurik.com Git - apt.git/blob - apt-private/private-update.cc
1 // Include files /*{{{*/
4 #include <apt-pkg/acquire-item.h>
5 #include <apt-pkg/cachefile.h>
6 #include <apt-pkg/cmndline.h>
7 #include <apt-pkg/error.h>
8 #include <apt-pkg/fileutl.h>
9 #include <apt-pkg/sourcelist.h>
10 #include <apt-pkg/update.h>
11 #include <apt-pkg/acquire.h>
12 #include <apt-pkg/configuration.h>
14 #include <apt-private/acqprogress.h>
15 #include <apt-private/private-cachefile.h>
16 #include <apt-private/private-output.h>
17 #include <apt-private/private-update.h>
25 // DoUpdate - Update the package lists /*{{{*/
26 // ---------------------------------------------------------------------
28 bool DoUpdate(CommandLine
&CmdL
)
30 if (CmdL
.FileSize() != 1)
31 return _error
->Error(_("The update command takes no arguments"));
35 // Get the source list
36 if (Cache
.BuildSourceList() == false)
38 pkgSourceList
*List
= Cache
.GetSourceList();
40 // Create the progress
41 AcqTextStatus
Stat(std::cout
, ScreenWidth
,_config
->FindI("quiet",0));
43 // Just print out the uris an exit if the --print-uris flag was used
44 if (_config
->FindB("APT::Get::Print-URIs") == true)
46 // force a hashsum for compatibility reasons
47 _config
->CndSet("Acquire::ForceHash", "md5sum");
50 pkgAcquire
Fetcher(&Stat
);
52 // Populate it with the source selection and get all Indexes
54 if (List
->GetIndexes(&Fetcher
,true) == false)
57 std::string compExt
= APT::Configuration::getCompressionTypes()[0];
58 pkgAcquire::UriIterator I
= Fetcher
.UriBegin();
59 for (; I
!= Fetcher
.UriEnd(); ++I
)
61 std::string FileName
= flNotDir(I
->Owner
->DestFile
);
62 if(compExt
.empty() == false &&
63 APT::String::Endswith(FileName
, compExt
))
64 FileName
= FileName
.substr(0, FileName
.size() - compExt
.size() - 1);
65 c1out
<< '\'' << I
->URI
<< "' " << FileName
<< ' ' <<
66 I
->Owner
->FileSize
<< ' ' << I
->Owner
->HashSum() << std::endl
;
72 if (_config
->FindB("APT::Get::Download",true) == true)
73 ListUpdate(Stat
, *List
);
76 if (_config
->FindB("pkgCacheFile::Generate", true) == true)
78 pkgCacheFile::RemoveCaches();
79 if (Cache
.BuildCaches() == false)
83 // show basic stats (if the user whishes)
84 if (_config
->FindB("APT::Cmd::Show-Update-Stats", false) == true)
88 for (pkgCache::PkgIterator I
= Cache
->PkgBegin(); I
.end() != true; ++I
)
90 pkgDepCache::StateCache
&state
= Cache
[I
];
91 if (I
->CurrentVer
!= 0 && state
.Upgradable() && state
.CandidateVer
!= NULL
)
95 "%i package can be upgraded. Run 'apt list --upgradable' to see it.\n",
96 "%i packages can be upgraded. Run 'apt list --upgradable' to see them.\n",
99 c1out
<< _("All packages are up to date.") << std::endl
;
101 ioprintf(c1out
, msg
, upgradable
);