commit 245d58049c1657ec5116b0e3598c83a82d11a69a Author: Tomas Touceda chiiph@gentoo.org Date: Thu Jun 23 20:10:16 2011 -0300
Adds the code to introduce Thp Transactions
Recognizes bundles that have all thp packages and arranges them in a separated dict from the installableDict. This bundles will be handled by the ThpInstaller as a whole, so it can order installations by dependencies. --- lib/thandy/ClientCLI.py | 12 ++++++++++-- lib/thandy/repository.py | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index bcbdfc7..97951b4 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -120,6 +120,7 @@ def update(args): lengths = {} installable = {} btMetadata = {} + thpTransactions = {} logging.info("Checking for files to update.") files, downloadingFiles = repo.getFilesToUpdate( trackingBundles=args, @@ -127,13 +128,14 @@ def update(args): lengthDict=lengths, usePackageSystem=use_packagesys, installableDict=installable, - btMetadataDict=btMetadata) + btMetadataDict=btMetadata + thpTransactionDict=thpTransactions)
if forceCheck: files.add("/meta/timestamp.txt") forceCheck = False
- if installable and not files: + if (thpTransactions or installable) and not files: for p, d in installable.items(): for n, i in d.items(): if i.canInstall(): @@ -151,6 +153,12 @@ def update(args): i = h.getInstaller() if i != None: i.install() + + print "Bundles with all THP packages:" + for bundle in thpTransactions: + # TODO: ThpTransaction goes here! + print bundle + return
elif not files: diff --git a/lib/thandy/repository.py b/lib/thandy/repository.py index bc4d73b..1bc1ce4 100644 --- a/lib/thandy/repository.py +++ b/lib/thandy/repository.py @@ -299,12 +299,13 @@ class LocalRepository:
def getFilesToUpdate(self, now=None, trackingBundles=(), hashDict=None, lengthDict=None, usePackageSystem=True, - installableDict=None, btMetadataDict=None): + installableDict=None, btMetadataDict=None, + thpTransactionDict=None): """Return a set of relative paths for all files that we need to fetch, and True if we're fetching actual files to install instead of metadata. Assumes that we care about the bundles 'trackingBundles'. - DOCDOC installableDict, hashDict, usePackageSystem + DOCDOC installableDict, hashDict, usePackageSystem, thpTransaction """
if now == None: @@ -323,6 +324,9 @@ class LocalRepository: if btMetadataDict == None: btMetadataDict = {}
+ if thpTransactionDict == None: + thpTransactionDict = {} + pkgItems = None
need = set() @@ -452,6 +456,7 @@ class LocalRepository:
# Okay. So we have some bundles. See if we have their packages. packages = {} + thpbundle = False for bfile in bundles.values(): bundle = bfile.get() for pkginfo in bundle['packages']: @@ -480,8 +485,20 @@ class LocalRepository: "did not match") # Can't use it. continue + + # We assume that if there is one thp package then all the rest + # are thp too. But we continue with the loop to check every + # package digest and signature + if thpBunle or pfile.get("format") == "thp": + thpBundle = True + continue + packages[rp] = pfile
+ if thpBundle: + thpTransactionDict[bundle['name']] = [bundle['packages']] + thpBundle = False + # We have the packages. If we're downloading via bittorrent, we need # the .torrent metafiles, as well. if thandy.bt_compat.BtCompat.shouldUseBt(): @@ -560,6 +577,7 @@ class LocalRepository: # if that works, we can get rid of the second return # value and just use installableDict from the caller. if pkgItems.has_key(rp): + if pkgItems[rp]: installableDict.setdefault(pkg_rp, {})[rp] = pkgItems[rp]
tor-commits@lists.torproject.org