summaryrefslogtreecommitdiff
path: root/lib/thandy/repository.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-11-16 22:27:17 +0000
committerNick Mathewson <nickm@torproject.org>2008-11-16 22:27:17 +0000
commit48adf40595f127c2bd167aa6774f4ba67e191c0f (patch)
tree8f200231a5f2a6f4f45a3f964f847457c5da5f00 /lib/thandy/repository.py
parent115bc0308c9384967ed25975aa21a312a2591524 (diff)
attach per-file type-specific metainfo to packages. use metainfo to tell what is already installed. use database to track things we have installed with not attacked version. notice when we have installable files and optionally install them.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17294 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/repository.py')
-rw-r--r--lib/thandy/repository.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/thandy/repository.py b/lib/thandy/repository.py
index 636ff86..696bbec 100644
--- a/lib/thandy/repository.py
+++ b/lib/thandy/repository.py
@@ -260,7 +260,7 @@ class LocalRepository:
needRole='bundle')
return pkg
- def getRequestedFile(self, relPath):
+ def getRequestedFile(self, relPath, pkgSystems=None):
"""DOCDOC"""
for f in self._metafiles:
if f.getRelativePath() == relPath:
@@ -279,12 +279,14 @@ class LocalRepository:
return None
- def getFilesToUpdate(self, now=None, trackingBundles=(), hashDict=None):
+ def getFilesToUpdate(self, now=None, trackingBundles=(), hashDict=None,
+ pkgSystems=None, installableDict=None):
"""Return a set of relative paths for all files that we need
to fetch. Assumes that we care about the bundles
'trackingBundles'. If hashDict is provided, add mappings to it
from the relative paths we want to fecth to the hashes that we
want those items to have, when we know those hashes.
+ DOCDOC pkgSystems, installableDict
"""
if now == None:
@@ -294,6 +296,9 @@ class LocalRepository:
# Use a dummy hashdict.
hashDict = {}
+ if installableDict == None:
+ installableDict = {}
+
need = set()
# Fetch missing metafiles.
@@ -444,8 +449,29 @@ class LocalRepository:
# files?
for pfile in packages.values():
package = pfile.get()
+
+ alreadyInstalled = {}
+ allHandles = {}
+ if pkgSystems is not None:
+ psys = pkgSystems.getSysForPackage(package)
+ if psys is None:
+ logging.info("No way to check whether a %s package is "
+ "up-to-date." % package['format'])
+ else:
+ handles = psys.packageHandlesFromJSon(package)
+
+ for h in handles:
+ allHandles[h.getRelativePath()] = h
+ if h.isInstalled():
+ alreadyInstalled[h.getRelativePath()] = h
+
for f in package['files']:
rp, h = f[:2]
+ if alreadyInstalled.has_key(rp):
+ logging.info("%s is already installed; no need to download",
+ rp)
+ continue
+
h_expected = thandy.formats.parseHash(h)
hashDict[rp] = h_expected
fn = self.getFilename(rp)
@@ -459,6 +485,9 @@ class LocalRepository:
if h_got != h_expected:
logging.info("Hash for %s not as expected; must load.", rp)
need.add(rp)
+ else:
+ if allHandles.has_key(rp):
+ installableDict[rp] = allHandles[rp]
# Okay; these are the files we need.
return need