]>
git.saurik.com Git - apt.git/blob - apt-private/private-download.cc
80795f964264afbe23536145bb3af377f5c9e33d
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 "private-output.h"
11 #include "private-download.h"
22 // CheckAuth - check if each download comes form a trusted source /*{{{*/
23 bool CheckAuth(pkgAcquire
& Fetcher
, bool const PromptUser
)
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()) + " ";
30 if (UntrustedList
== "")
33 ShowList(c2out
,_("WARNING: The following packages cannot be authenticated!"),UntrustedList
,"");
35 if (_config
->FindB("APT::Get::AllowUnauthenticated",false) == true)
37 c2out
<< _("Authentication warning overridden.\n");
41 if (PromptUser
== false)
42 return _error
->Error(_("Some packages could not be authenticated"));
44 if (_config
->FindI("quiet",0) < 2
45 && _config
->FindB("APT::Get::Assume-Yes",false) == false)
47 c2out
<< _("Install these packages without verification?") << std::flush
;
49 return _error
->Error(_("Some packages could not be authenticated"));
53 else if (_config
->FindB("APT::Get::Force-Yes",false) == true)
56 return _error
->Error(_("There are problems and -y was used without --force-yes"));
59 bool AcquireRun(pkgAcquire
&Fetcher
, int const PulseInterval
, bool * const Failure
, bool * const TransientNetworkFailure
)/*{{{*/
61 pkgAcquire::RunResult res
;
63 res
= Fetcher
.Run(PulseInterval
);
67 if (res
== pkgAcquire::Failed
)
70 for (pkgAcquire::ItemIterator I
= Fetcher
.ItemsBegin();
71 I
!= Fetcher
.ItemsEnd(); ++I
)
74 if ((*I
)->Status
== pkgAcquire::Item::StatDone
&&
75 (*I
)->Complete
== true)
78 if (TransientNetworkFailure
!= NULL
&& (*I
)->Status
== pkgAcquire::Item::StatIdle
)
80 *TransientNetworkFailure
= true;
84 ::URI
uri((*I
)->DescURI());
87 std::string descUri
= std::string(uri
);
88 _error
->Error(_("Failed to fetch %s %s\n"), descUri
.c_str(),
89 (*I
)->ErrorText
.c_str());