]>
git.saurik.com Git - apt.git/blob - apt-private/private-download.cc
1 // Include Files /*{{{*/
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>
10 #include <apt-private/private-output.h>
11 #include <apt-private/private-download.h>
20 // CheckAuth - check if each download comes form a trusted source /*{{{*/
21 bool CheckAuth(pkgAcquire
& Fetcher
, bool const PromptUser
)
23 std::string UntrustedList
;
24 for (pkgAcquire::ItemIterator I
= Fetcher
.ItemsBegin(); I
< Fetcher
.ItemsEnd(); ++I
)
25 if (!(*I
)->IsTrusted())
26 UntrustedList
+= std::string((*I
)->ShortDesc()) + " ";
28 if (UntrustedList
== "")
31 return AuthPrompt(UntrustedList
, PromptUser
);
34 bool AuthPrompt(std::string UntrustedList
, bool const PromptUser
)
36 ShowList(c2out
,_("WARNING: The following packages cannot be authenticated!"),UntrustedList
,"");
38 if (_config
->FindB("APT::Get::AllowUnauthenticated",false) == true)
40 c2out
<< _("Authentication warning overridden.\n");
44 if (PromptUser
== false)
45 return _error
->Error(_("Some packages could not be authenticated"));
47 if (_config
->FindI("quiet",0) < 2
48 && _config
->FindB("APT::Get::Assume-Yes",false) == false)
50 c2out
<< _("Install these packages without verification?") << std::flush
;
52 return _error
->Error(_("Some packages could not be authenticated"));
56 else if (_config
->FindB("APT::Get::Force-Yes",false) == true)
59 return _error
->Error(_("There are problems and -y was used without --force-yes"));
62 bool AcquireRun(pkgAcquire
&Fetcher
, int const PulseInterval
, bool * const Failure
, bool * const TransientNetworkFailure
)/*{{{*/
64 pkgAcquire::RunResult res
;
66 res
= Fetcher
.Run(PulseInterval
);
70 if (res
== pkgAcquire::Failed
)
73 for (pkgAcquire::ItemIterator I
= Fetcher
.ItemsBegin();
74 I
!= Fetcher
.ItemsEnd(); ++I
)
77 if ((*I
)->Status
== pkgAcquire::Item::StatDone
&&
78 (*I
)->Complete
== true)
81 if (TransientNetworkFailure
!= NULL
&& (*I
)->Status
== pkgAcquire::Item::StatIdle
)
83 *TransientNetworkFailure
= true;
87 ::URI
uri((*I
)->DescURI());
90 std::string descUri
= std::string(uri
);
91 _error
->Error(_("Failed to fetch %s %s\n"), descUri
.c_str(),
92 (*I
)->ErrorText
.c_str());