* 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 s += 'rel <= ' + self.releaseTo
return s return s
def upgradableDep(pkg_name, depinfo): def installedSatisfiesDep(depinfo):
"""determine if package in *repository* satisfies given dependency spec in installdb""" """determine if a package in *repository* satisfies given
if not installdb.is_installed(depinfo.package): dependency spec"""
return False pkg_name = depinfo.package
else: if not installdb.is_installed(pkg_name):
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):
return False return False
else: else:
pkg = packagedb.inst_packagedb.get_package(pkg_name) pkg = packagedb.inst_packagedb.get_package(pkg_name)
(version, release) = (pkg.version, pkg.release) (version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, 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: for dep in deps:
if not satisfiesDep(pkg, dep): if not sat(dep):
ui.error('Package %s does not satisfy dependency %s\n' % ui.error('Package %s does not satisfy dependency %s\n' %
(pkg,dep)) (pkg,dep))
return False return False
return True return True
def runtimeDeps(pkg):
return packagedb.get_package(pkg).runtimeDeps
def satisfiesRuntimeDeps(pkg): def satisfiesRuntimeDeps(pkg):
deps = runtimeDeps(pkg) deps = packagedb.get_package(pkg).runtimeDeps
return satisfiesDeps(pkg, deps) return satisfiesDeps(pkg, deps)
def installable(pkg): def installable(pkg):
+7 -7
View File
@@ -47,9 +47,9 @@ def install(packages):
ui.error("PackageDBError: (%s)\n" % e) ui.error("PackageDBError: (%s)\n" % e)
ui.error("Package is not installable.\n") ui.error("Package is not installable.\n")
except Exception, e: #except Exception, e:
print e # print e
ui.error("Error: %s\n" % e) # ui.error("Error: %s\n" % e)
def install_pkg_files(packages): def install_pkg_files(packages):
@@ -117,8 +117,8 @@ def install_pkg_names(A):
print pkg print pkg
for dep in pkg.runtimeDeps: for dep in pkg.runtimeDeps:
print 'checking ', dep print 'checking ', dep
# we don't deal with satisfied dependencies # we don't deal with already *satisfied* dependencies
if not dependency.satisfiesDep(x, dep): if not dependency.installedSatisfiesDep(dep):
if not dep.package in G_f.vertices(): if not dep.package in G_f.vertices():
Bp.add(str(dep.package)) Bp.add(str(dep.package))
G_f.add_dep(x, dep) G_f.add_dep(x, dep)
@@ -184,7 +184,7 @@ def upgrade_pkg_names(A):
for dep in pkg.runtimeDeps: for dep in pkg.runtimeDeps:
print 'checking ', dep print 'checking ', dep
# add packages that can be upgraded # 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(): if not dep.package in G_f.vertices():
Bp.add(str(dep.package)) Bp.add(str(dep.package))
G_f.add_dep(x, dep) G_f.add_dep(x, dep)
@@ -235,7 +235,7 @@ def remove(A):
for (rev_dep, depinfo) in rev_deps: for (rev_dep, depinfo) in rev_deps:
print 'checking ', rev_dep print 'checking ', rev_dep
# we don't deal with unsatisfied dependencies # 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(): if not rev_dep in G_f.vertices():
Bp.add(rev_dep) Bp.add(rev_dep)
G_f.add_plain_dep(rev_dep, x) G_f.add_plain_dep(rev_dep, x)