[maemo-commits] [maemo-commits] r16132 - in projects/haf/trunk/apt: apt-pkg debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Sep 15 21:17:21 EEST 2008
- Previous message: [maemo-commits] r16131 - projects/haf/trunk/apt
- Next message: [maemo-commits] r16133 - projects/haf/trunk/apt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2008-09-15 21:17:20 +0300 (Mon, 15 Sep 2008)
New Revision: 16132
Modified:
projects/haf/trunk/apt/apt-pkg/acquire-item.cc
projects/haf/trunk/apt/apt-pkg/acquire-item.h
projects/haf/trunk/apt/debian/changelog
Log:
* Applied trusthook.patch
Modified: projects/haf/trunk/apt/apt-pkg/acquire-item.cc
===================================================================
--- projects/haf/trunk/apt/apt-pkg/acquire-item.cc 2008-09-15 18:13:52 UTC (rev 16131)
+++ projects/haf/trunk/apt/apt-pkg/acquire-item.cc 2008-09-15 18:17:20 UTC (rev 16132)
@@ -1217,7 +1217,26 @@
}
/*}}}*/
+static int
+default_index_trust_level_for_package (pkgIndexFile *Index,
+ const pkgCache::VerIterator &Ver)
+{
+ return Index->IsTrusted ()? 1 : 0;
+}
+static int (*index_trust_level_for_package) (pkgIndexFile *Index,
+ const pkgCache::VerIterator &Ver)
+ = default_index_trust_level_for_package;
+
+void
+apt_set_index_trust_level_for_package_hook (int (*hook)
+ (pkgIndexFile *Index,
+ const pkgCache::VerIterator &Ver))
+{
+ index_trust_level_for_package = hook;
+}
+
+
// AcqArchive::AcqArchive - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* This just sets up the initial fetch environment and queues the first
@@ -1226,8 +1245,8 @@
pkgRecords *Recs,pkgCache::VerIterator const &Version,
string &StoreFilename) :
Item(Owner), Version(Version), Sources(Sources), Recs(Recs),
- StoreFilename(StoreFilename), Vf(Version.FileList()),
- Trusted(false)
+ StoreFilename(StoreFilename),
+ TrustLevel(0)
{
Retries = _config->FindI("Acquire::Retries",0);
@@ -1243,6 +1262,9 @@
/* We need to find a filename to determine the extension. We make the
assumption here that all the available sources for this version share
the same extension.. */
+
+ pkgCache::VerFileIterator Vf = Version.FileList();
+
// Skip not source sources, they do not have file fields.
for (; Vf.end() == false; Vf++)
{
@@ -1266,31 +1288,62 @@
"." + flExtension(Parse.FileName());
}
- // check if we have one trusted source for the package. if so, switch
- // to "TrustedOnly" mode
- for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; i++)
- {
- pkgIndexFile *Index;
- if (Sources->FindIndex(i.File(),Index) == false)
- continue;
- if (_config->FindB("Debug::pkgAcquire::Auth", false))
- {
- std::cerr << "Checking index: " << Index->Describe()
- << "(Trusted=" << Index->IsTrusted() << ")\n";
- }
- if (Index->IsTrusted()) {
- Trusted = true;
- break;
- }
- }
+ VerFileCandidates.clear();
+ TrustLevel = 0;
- // "allow-unauthenticated" restores apts old fetching behaviour
- // that means that e.g. unauthenticated file:// uris are higher
- // priority than authenticated http:// uris
if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
- Trusted = false;
+ {
+ // "allow-unauthenticated" restores apts old fetching behaviour
+ // that means that e.g. unauthenticated file:// uris are higher
+ // priority than authenticated http:// uris
+
+ while (!Vf.end())
+ {
+ if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
+ {
+ Vf++;
+ continue;
+ }
+ VerFileCandidates.push_back (Vf);
+ Vf++;
+ }
+ }
+ else
+ {
+ // Find the sources with the highest trust level.
+
+ while (!Vf.end())
+ {
+ pkgIndexFile *Index;
+ if (Sources->FindIndex(Vf.File(),Index) == false)
+ {
+ Vf++;
+ continue;
+ }
+
+ int l = index_trust_level_for_package (Index, Version);
+
+ if (_config->FindB("Debug::pkgAcquire::Auth", false))
+ {
+ std::cerr << "Checking index: " << Index->Describe()
+ << "(Trust level =" << l << ")\n";
+ }
+
+ if (l >= TrustLevel)
+ {
+ if (l > TrustLevel)
+ VerFileCandidates.clear ();
+ VerFileCandidates.push_back (Vf);
+ TrustLevel = l;
+ }
+
+ Vf++;
+ }
+ }
+
// Select a source
+ CurVerFile = VerFileCandidates.begin ();
if (QueueNext() == false && _error->PendingError() == false)
_error->Error(_("I wasn't able to locate file for the %s package. "
"This might mean you need to manually fix this package."),
@@ -1304,22 +1357,15 @@
checking later. */
bool pkgAcqArchive::QueueNext()
{
- for (; Vf.end() == false; Vf++)
+ while (CurVerFile != VerFileCandidates.end())
{
- // Ignore not source sources
- if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
- continue;
+ pkgCache::VerFileIterator Vf = *CurVerFile++;
// Try to cross match against the source list
pkgIndexFile *Index;
if (Sources->FindIndex(Vf.File(),Index) == false)
continue;
- // only try to get a trusted package from another source if that source
- // is also trusted
- if(Trusted && !Index->IsTrusted())
- continue;
-
// Grab the text package record
pkgRecords::Parser &Parse = Recs->Lookup(Vf);
if (_error->PendingError() == true)
@@ -1402,7 +1448,6 @@
Desc.ShortDesc = Version.ParentPkg().Name();
QueueURI(Desc);
- Vf++;
return true;
}
return false;
@@ -1476,7 +1521,7 @@
StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
{
// Vf = Version.FileList();
- while (Vf.end() == false) Vf++;
+ CurVerFile = VerFileCandidates.end ();
StoreFilename = string();
Item::Failed(Message,Cnf);
return;
@@ -1490,7 +1535,7 @@
StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
{
Retries--;
- Vf = Version.FileList();
+ CurVerFile = VerFileCandidates.begin ();
if (QueueNext() == true)
return;
}
@@ -1505,7 +1550,7 @@
// ---------------------------------------------------------------------
bool pkgAcqArchive::IsTrusted()
{
- return Trusted;
+ return TrustLevel > 0;
}
// AcqArchive::Finished - Fetching has finished, tidy up /*{{{*/
Modified: projects/haf/trunk/apt/apt-pkg/acquire-item.h
===================================================================
--- projects/haf/trunk/apt/apt-pkg/acquire-item.h 2008-09-15 18:13:52 UTC (rev 16131)
+++ projects/haf/trunk/apt/apt-pkg/acquire-item.h 2008-09-15 18:17:20 UTC (rev 16132)
@@ -614,6 +614,7 @@
/** \brief The last good signature file */
string LastGoodSig;
+#include <list>
/** \brief The fetch request that is currently being processed. */
pkgAcquire::ItemDesc Desc;
@@ -792,8 +793,8 @@
*/
string &StoreFilename;
- /** \brief The next file for this version to try to download. */
- pkgCache::VerFileIterator Vf;
+ std::list<pkgCache::VerFileIterator> VerFileCandidates;
+ std::list<pkgCache::VerFileIterator>::const_iterator CurVerFile;
/** \brief How many (more) times to try to find a new source from
* which to download this package version if it fails.
@@ -802,10 +803,10 @@
*/
unsigned int Retries;
- /** \brief \b true if this version file is being downloaded from a
+ /** \brief \b Positive if this version file is being downloaded from a
* trusted source.
*/
- bool Trusted;
+ int TrustLevel;
/** \brief Queue up the next available file for this version. */
bool QueueNext();
@@ -908,4 +909,28 @@
/** @} */
+/* For influencing the IsTrusted decision when acquiring a new version
+ of a package and for influencing which source is selected if the
+ highest version of a package is available from multiple sources.
+
+ The hook should return a integer indicating the 'trust level' that
+ a given index should be afforded for a given package. Indices with
+ higher trust levels will be preferred.
+
+ The default behavior is to use a trust level of zero for unsigned
+ repositories and a level of one for repositories with valid
+ signatures.
+
+ The IsTrusted predicate on a pkgAcqArchive object will return true
+ when the highest trust level is non-zero, false otherwise.
+
+ A trust level can be negative. In that case, the index will never
+ be considered as a source for the package.
+*/
+
+void
+apt_set_index_trust_level_for_package_hook (int (*hook)
+ (pkgIndexFile *Index,
+ const pkgCache::VerIterator &V));
+
#endif
Modified: projects/haf/trunk/apt/debian/changelog
===================================================================
--- projects/haf/trunk/apt/debian/changelog 2008-09-15 18:13:52 UTC (rev 16131)
+++ projects/haf/trunk/apt/debian/changelog 2008-09-15 18:17:20 UTC (rev 16132)
@@ -5,6 +5,7 @@
* Applied notdebian.patch
* Applied http-tablet-identification.patch
* Applied gpgvinfo.patch
+ * Applied trusthook.patch
-- Marius Vollmer <marius.vollmer at nokia.com> Mon, 15 Sep 2008 19:50:25 +0300
- Previous message: [maemo-commits] r16131 - projects/haf/trunk/apt
- Next message: [maemo-commits] r16133 - projects/haf/trunk/apt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
