]> git.saurik.com Git - apt.git/blame - apt-private/private-download.cc
warning: no previous declaration for foobar() [-Wmissing-declarations]
[apt.git] / apt-private / private-download.cc
CommitLineData
866893a6
DK
1// Include Files /*{{{*/
2#include <config.h>
3
4#include <apt-pkg/acquire.h>
5#include <apt-pkg/acquire-item.h>
6#include <apt-pkg/configuration.h>
7#include <apt-pkg/error.h>
8#include <apt-pkg/strutl.h>
9
10#include "private-output.h"
c3ccac92 11#include "private-download.h"
866893a6
DK
12
13#include <locale.h>
14
15#include <fstream>
16#include <string>
17#include <vector>
18
19#include <apti18n.h>
20 /*}}}*/
21
22// CheckAuth - check if each download comes form a trusted source /*{{{*/
23bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
24{
25 std::string UntrustedList;
26 for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I)
27 if (!(*I)->IsTrusted())
28 UntrustedList += std::string((*I)->ShortDesc()) + " ";
29
30 if (UntrustedList == "")
31 return true;
32
33 ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
34
35 if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
36 {
37 c2out << _("Authentication warning overridden.\n");
38 return true;
39 }
40
41 if (PromptUser == false)
42 return _error->Error(_("Some packages could not be authenticated"));
43
44 if (_config->FindI("quiet",0) < 2
45 && _config->FindB("APT::Get::Assume-Yes",false) == false)
46 {
47 c2out << _("Install these packages without verification?") << std::flush;
48 if (!YnPrompt(false))
49 return _error->Error(_("Some packages could not be authenticated"));
50
51 return true;
52 }
53 else if (_config->FindB("APT::Get::Force-Yes",false) == true)
54 return true;
55
56 return _error->Error(_("There are problems and -y was used without --force-yes"));
57}
58 /*}}}*/
59bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure)/*{{{*/
60{
61 pkgAcquire::RunResult res;
62 if(PulseInterval > 0)
63 res = Fetcher.Run(PulseInterval);
64 else
65 res = Fetcher.Run();
66
67 if (res == pkgAcquire::Failed)
68 return false;
69
70 for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
71 I != Fetcher.ItemsEnd(); ++I)
72 {
73
74 if ((*I)->Status == pkgAcquire::Item::StatDone &&
75 (*I)->Complete == true)
76 continue;
77
78 if (TransientNetworkFailure != NULL && (*I)->Status == pkgAcquire::Item::StatIdle)
79 {
80 *TransientNetworkFailure = true;
81 continue;
82 }
83
84 ::URI uri((*I)->DescURI());
85 uri.User.clear();
86 uri.Password.clear();
87 std::string descUri = std::string(uri);
88 _error->Error(_("Failed to fetch %s %s\n"), descUri.c_str(),
89 (*I)->ErrorText.c_str());
90
91 if (Failure != NULL)
92 *Failure = true;
93 }
94
95 return true;
96}
97 /*}}}*/