import package
import files
import os.path
import util

def doUpdate(DBPATH, root, pkgName):
    pkgSet = package.PackageSet(DBPATH, pkgName)

    if (not len(pkgSet.versionList())):
	raise KeyError, "no versions exist of %s" % pkgName

    (version, pkg) = pkgSet.getLatest()

    for (fileName, version) in pkg.fileList():
	infoFile = files.FileDB(DBPATH, fileName)
	f = infoFile.getVersion(version)

	target = "%s/%s" % (root, fileName)
	dir = os.path.split(target)[0]
	util.mkdirChain(dir)

	source = "%s/files/%s.contents/%s" % (DBPATH, fileName, f.md5())

	os.system("cp %s %s" % (source, target))
	os.chmod(target, f.perms())

@@ -47,16 +47,30 @@
 ort util
+%0Aimport shutil
 %0A%0Adef do
@@ -574,31 +574,23 @@
 )%0A%0A%09
-os.system(%22cp %25s %25s%22 %25 
+shutil.copyfile
 (sou
@@ -601,17 +601,16 @@
  target)
-)
 %0A%09os.chm

make matt happy