summaryrefslogtreecommitdiff
path: root/lib/thandy/repository.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-11-30 06:19:04 +0000
committerNick Mathewson <nickm@torproject.org>2008-11-30 06:19:04 +0000
commit3bef6462fa8117dde2f55a3ff06dbf1b1a8e02a8 (patch)
tree4dd9ef4282482e81422b28624fd1dbfb442e4f61 /lib/thandy/repository.py
parentbd2a8dad04994c28086c7c30636273a40be01243 (diff)
Big thandy installation refactoring. Things should be saner now: we recognize that checking an item is sometimes orthogonal to installing it; we do not carry around big bits of unimplemented machinery; we actually document what stuff does in thandy-spec.txt; we do more OO in the places that make sense and less in the places that do not; and almost as an afterthought, we support the command installer type internally. Now all we need is a frontend to make command installers.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17414 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/repository.py')
-rw-r--r--lib/thandy/repository.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/lib/thandy/repository.py b/lib/thandy/repository.py
index 2dea1c4..a9b0d19 100644
--- a/lib/thandy/repository.py
+++ b/lib/thandy/repository.py
@@ -2,6 +2,7 @@
import thandy.formats
import thandy.util
+import thandy.packagesys.PackageSystem
try:
import json
@@ -297,11 +298,11 @@ class LocalRepository:
return None
def getFilesToUpdate(self, now=None, trackingBundles=(), hashDict=None,
- pkgSystems=None, installableDict=None):
+ usePackageSystem=True, installableDict=None):
"""Return a set of relative paths for all files that we need
to fetch. Assumes that we care about the bundles
'trackingBundles'.
- DOCDOC pkgSystems, installableDict, hashDict
+ DOCDOC installableDict, hashDict, usePackageSystem
"""
if now == None:
@@ -314,6 +315,8 @@ class LocalRepository:
if installableDict == None:
installableDict = {}
+ pkgItems = None
+
need = set()
# Fetch missing metafiles.
@@ -468,26 +471,31 @@ class LocalRepository:
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
+ alreadyInstalled = set()
+ pkgItems = {}
+
+ if usePackageSystem:
+ pkgItems = thandy.packagesys.PackageSystem.getItemsFromPackage(
+ package)
+
+ for f in package['files']:
+ item = pkgItems[f[0]]
+ if not item.canCheck():
+ logging.info("No way to check whether %s is "
+ "up-to-date.", f[0])
+ else:
+ try:
+ if item.getChecker().isInstalled():
+ alreadyInstalled.add(item.getRelativePath())
+ except thandy.CheckNotSupported, err:
+ logging.warn("Can't check installed-ness of %s: %s",
+ f[0], err)
pkg_rp = pfile.getRelativePath()
for f in package['files']:
rp, h = f[:2]
- if alreadyInstalled.has_key(rp):
+ if rp in alreadyInstalled:
logging.info("%s is already installed; no need to download",
rp)
continue
@@ -506,8 +514,8 @@ class LocalRepository:
logging.info("Hash for %s not as expected; must load.", rp)
need.add(rp)
else:
- if allHandles.has_key(rp):
- installableDict.setdefault(pkg_rp, {})[rp] = allHandles[rp]
+ if pkgItems.has_key(rp):
+ installableDict.setdefault(pkg_rp, {})[rp] = pkgItems[rp]
# Okay; these are the files we need.
return need