* installdb'deki yamukluklari duzelt, dependency code'una basla

This commit is contained in:
Eray Özkural
2005-06-19 23:20:02 +00:00
parent 3ff1728a9e
commit 504eb942e1
3 changed files with 74 additions and 26 deletions
+39
View File
@@ -1,3 +1,42 @@
# dependency analyzer
# maintainer: eray and caglar
import installdb
import packagedb
import ui
# FIXME: this is supposed to handle all those attributes
def satisfiesDep(pkg, depinfo):
"""determine if a package satisfies given dependency spec"""
if not installdb.is_installed(depinfo.package):
return False
else:
(version, release) = installdb.get_info(pkg)
# FIXME: specific processing for attributes
return True
def installDeps(pkg):
return packagedb.get_package(pkg).installDeps
def satisfiesInstallDeps(pkg):
deps = installDeps(pkg)
return reduce(lambda x,y:x and y,
map(lambda x: satisfiesDep(pkg, x), deps))
def runtimeDeps(pkg):
return packagedb.get_package(pkg).runtimeDeps
def satisfiesRuntimeDeps(pkg):
deps = runtimeDeps(pkg)
return reduce(lambda x,y:x and y,
map(lambda x: satisfiesDep(pkg, x), deps))
def installable(pkg):
"""calculate if pkg is installable currently
which means it has to satisfy both install and runtime dependencies"""
if not packagedb.has_key(pkgname):
ui.info("package " + pkgname + " not installable");
return False
else:
return satisfiesRuntimeDeps(pkg) and satisfiesInstallDeps(pkg)
+1 -1
View File
@@ -43,4 +43,4 @@ def install_package_file(package_fn):
# installdb
installdb.install(spec.spec.install_dir() + '/files.xml')
+34 -25
View File
@@ -15,38 +15,47 @@ files_dir = ctx.archives_dir() + "/files"
class InstallDBError(Exception):
pass
def files_name(name, version, release):
return files_dir + '/' + name + '-' + version + '-' + release
def files_name(pkg, version, release):
return files_dir + '/' + pkg + '-' + version + '-' release + '.xml'
def files(n, v, r):
return file(files_name(n,v,r))
def files(pkg):
(status, version, release) = d[pkg]
return file(files_name(pkg,version,release))
def is_recorded(name, version, release):
key = name + version + release
return d.has_key(key)
def is_recorded(pkg):
return d.has_key(pkg)
def is_installed(name, version, release):
key = name + version + release
return is_recorded(name,version,release) and d[key]=='i'
def is_installed(pkg):
if is_recorded(pkg):
(status, version, release) = d[pkg]
return status=='i'
else:
return False
def is_removed(name, version, release):
key = name + version + release
return is_recorded(name,version,release) and d[key]=='r'
def get_version(pkg):
(status, version, release) = d[pkg]
return (version, release)
def install(name, version, release, files_xml):
key = name + version + release
if is_installed(name, version, release):
def is_removed(name):
if is_recorded(pkg):
(status, version, release) = d[pkg]
return status=='r'
else:
return False
def install(pkg, version, release, files_xml):
"""install package with specific version and release"""
if is_installed(pkg):
raise InstallDBError("already installed")
d[key] = 'i'
util.copy_file(files_xml, files_name(name, version, release))
d[pkg] = ('i', version, release)
util.copy_file(files_xml, files_name(pkg, version, release))
def remove(name, version, release):
key = name + version + release
d[key] = 'r'
def remove(pkg):
d[pkg] = 'r'
def purge(name, version, release):
os.unlink(files_name(name, version, release))
key = name + version + release
del d[key]
def purge(pkg):
(status, version, release) = d[pkg]
os.unlink(files_name(pkg, version, release))
del d[pkg]