* bu dependency'deki bir parametre karisikligini giderip, bir iki isim

duzenlemesi yapiyor ve yeni bir dependency kontrol daha ekliyor
  - installed: sistemdeki bir paket satisfy ediyor mu?
  - repo: repo'daki herhangi bir paket ediyor mu?
  - upgradable: su anda install edilmis package, upgrade edilebiliyor
mu?
* hala bir karisiklik var grrrr
This commit is contained in:
Eray Özkural
2005-08-09 14:43:14 +00:00
parent 77128581ee
commit 7b4f83d545
2 changed files with 41 additions and 25 deletions
+34 -18
View File
@@ -74,37 +74,53 @@ class DepInfo:
s += 'rel <= ' + self.releaseTo
return s
def upgradableDep(pkg_name, depinfo):
"""determine if package in *repository* satisfies given dependency spec in installdb"""
if not installdb.is_installed(depinfo.package):
return False
else:
pkg = packagedb.get_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
def satisfiesDep(pkg_name, depinfo):
"""determine if an *already installed* package can be upgraded given dependency spec in installdb"""
if not installdb.is_installed(depinfo.package):
def installedSatisfiesDep(depinfo):
"""determine if a package in *repository* satisfies given
dependency spec"""
pkg_name = depinfo.package
if not installdb.is_installed(pkg_name):
return False
else:
pkg = packagedb.inst_packagedb.get_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
def satisfiesDeps(pkg, deps):
def repoSatisfiesDep(depinfo):
"""determine if a package in *repository* satisfies given
dependency spec"""
pkg_name = depinfo.package
if not packagedb.has_package(pkg_name):
return False
else:
pkg = packagedb.get_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
def upgradableDep(depinfo):
"""determine if an *already installed* package can be upgraded given dependency spec in installdb"""
if not installdb.is_installed(depinfo.package):
return False
else:
pkg = packagedb.get_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
## pkg_name = depinfo.package
## pkg = packagedb.inst_packagedb.get_package(pkg_name)
## (version, release) = (pkg.version, pkg.release)
## pkg_then = packagedb.get_package(pkg_name)
## (version_then, release_then) = (pkg_then.version, pkg_then.release)
## return depinfo.upgradable(pkg_name, release, release_then)
def satisfiesDeps(pkg, deps, sat = installedSatisfiesDep):
for dep in deps:
if not satisfiesDep(pkg, dep):
if not sat(dep):
ui.error('Package %s does not satisfy dependency %s\n' %
(pkg,dep))
return False
return True
def runtimeDeps(pkg):
return packagedb.get_package(pkg).runtimeDeps
def satisfiesRuntimeDeps(pkg):
deps = runtimeDeps(pkg)
deps = packagedb.get_package(pkg).runtimeDeps
return satisfiesDeps(pkg, deps)
def installable(pkg):
+7 -7
View File
@@ -47,9 +47,9 @@ def install(packages):
ui.error("PackageDBError: (%s)\n" % e)
ui.error("Package is not installable.\n")
except Exception, e:
print e
ui.error("Error: %s\n" % e)
#except Exception, e:
# print e
# ui.error("Error: %s\n" % e)
def install_pkg_files(packages):
@@ -117,8 +117,8 @@ def install_pkg_names(A):
print pkg
for dep in pkg.runtimeDeps:
print 'checking ', dep
# we don't deal with satisfied dependencies
if not dependency.satisfiesDep(x, dep):
# we don't deal with already *satisfied* dependencies
if not dependency.installedSatisfiesDep(dep):
if not dep.package in G_f.vertices():
Bp.add(str(dep.package))
G_f.add_dep(x, dep)
@@ -184,7 +184,7 @@ def upgrade_pkg_names(A):
for dep in pkg.runtimeDeps:
print 'checking ', dep
# add packages that can be upgraded
if not dependency.upgradableDep(x, dep):
if not dependency.upgradableDep(dep):
if not dep.package in G_f.vertices():
Bp.add(str(dep.package))
G_f.add_dep(x, dep)
@@ -235,7 +235,7 @@ def remove(A):
for (rev_dep, depinfo) in rev_deps:
print 'checking ', rev_dep
# we don't deal with unsatisfied dependencies
if dependency.satisfiesDep(rev_dep, depinfo):
if dependency.installedSatisfiesDep(depinfo):
if not rev_dep in G_f.vertices():
Bp.add(rev_dep)
G_f.add_plain_dep(rev_dep, x)