]>
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 "private-output.h"
21 // CheckAuth - check if each download comes form a trusted source /*{{{*/
22 bool CheckAuth(pkgAcquire
& Fetcher
, bool const PromptUser
)
24 std::string UntrustedList
;
25 for (pkgAcquire::ItemIterator I
= Fetcher
.ItemsBegin(); I
< Fetcher
.ItemsEnd(); ++I
)
26 if (!(*I
)->IsTrusted())
27 UntrustedList
+= std::string((*I
)->ShortDesc()) + " ";
29 if (UntrustedList
== "")
32 ShowList(c2out
,_("WARNING: The following packages cannot be authenticated!"),UntrustedList
,"");
34 if (_config
->FindB("APT::Get::AllowUnauthenticated",false) == true)
36 c2out
<< _("Authentication warning overridden.\n");
40 if (PromptUser
== false)
41 return _error
->Error(_("Some packages could not be authenticated"));
43 if (_config
->FindI("quiet",0) < 2
44 && _config
->FindB("APT::Get::Assume-Yes",false) == false)
46 c2out
<< _("Install these packages without verification?") << std::flush
;
48 return _error
->Error(_("Some packages could not be authenticated"));
52 else if (_config
->FindB("APT::Get::Force-Yes",false) == true)
55 return _error
->Error(_("There are problems and -y was used without --force-yes"));
58 bool AcquireRun(pkgAcquire
&Fetcher
, int const PulseInterval
, bool * const Failure
, bool * const TransientNetworkFailure
)/*{{{*/
60 pkgAcquire::RunResult res
;
62 res
= Fetcher
.Run(PulseInterval
);
66 if (res
== pkgAcquire::Failed
)
69 for (pkgAcquire::ItemIterator I
= Fetcher
.ItemsBegin();
70 I
!= Fetcher
.ItemsEnd(); ++I
)
73 if ((*I
)->Status
== pkgAcquire::Item::StatDone
&&
74 (*I
)->Complete
== true)
77 if (TransientNetworkFailure
!= NULL
&& (*I
)->Status
== pkgAcquire::Item::StatIdle
)
79 *TransientNetworkFailure
= true;
83 ::URI
uri((*I
)->DescURI());
86 std::string descUri
= std::string(uri
);
87 _error
->Error(_("Failed to fetch %s %s\n"), descUri
.c_str(),
88 (*I
)->ErrorText
.c_str());