Objectify dependency operations into Dependency class for implementing AnyDependency
This commit is contained in:
+1
-1
@@ -497,7 +497,7 @@ def package_graph(A, packagedb, ignore_installed = False):
|
|||||||
#print pkg
|
#print pkg
|
||||||
for dep in pkg.runtimeDependencies():
|
for dep in pkg.runtimeDependencies():
|
||||||
if ignore_installed:
|
if ignore_installed:
|
||||||
if dependency.installed_satisfies_dep(dep):
|
if dep.satisfied_by_installed():
|
||||||
continue
|
continue
|
||||||
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))
|
||||||
|
|||||||
+8
-39
@@ -46,44 +46,13 @@ class Dependency(pisi.relation.Relation):
|
|||||||
(version, release) = (pkg.version, pkg.release)
|
(version, release) = (pkg.version, pkg.release)
|
||||||
return self.satisfies_relation(version, release)
|
return self.satisfies_relation(version, release)
|
||||||
|
|
||||||
def installed_satisfies_dep(depinfo):
|
def satisfied_by_installed(self):
|
||||||
"""determine if a package in *repository* satisfies given
|
return pisi.relation.installed_package_satisfies(self)
|
||||||
dependency spec"""
|
|
||||||
return pisi.relation.installed_package_satisfies(depinfo)
|
|
||||||
|
|
||||||
def repo_satisfies_dep(depinfo):
|
def satisfied_by_repo(self):
|
||||||
"""determine if a package in *repository* satisfies given
|
packagedb = pisi.db.packagedb.PackageDB()
|
||||||
dependency spec"""
|
if not packagedb.has_package(self.package):
|
||||||
packagedb = pisi.db.packagedb.PackageDB()
|
|
||||||
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_relation(version, release)
|
|
||||||
|
|
||||||
def satisfies_dependencies(pkg, deps, sat = installed_satisfies_dep):
|
|
||||||
for dep in deps:
|
|
||||||
if not sat(dep):
|
|
||||||
ctx.ui.error(_('%s dependency of package %s is not satisfied') %
|
|
||||||
(dep, pkg))
|
|
||||||
return False
|
return False
|
||||||
return True
|
else:
|
||||||
|
pkg = packagedb.get_package(self.package)
|
||||||
def satisfies_runtime_deps(pkg):
|
return self.satisfies_relation(pkg.version, pkg.release)
|
||||||
packagedb = pisi.db.packagedb.PackageDB()
|
|
||||||
deps = packagedb.get_package(pkg).runtimeDependencies()
|
|
||||||
return satisfies_dependencies(pkg, deps)
|
|
||||||
|
|
||||||
def installable(pkg):
|
|
||||||
"""calculate if pkg name is installable currently
|
|
||||||
which means it has to satisfy both install and runtime dependencies"""
|
|
||||||
packagedb = pisi.db.packagedb.PackageDB()
|
|
||||||
if not packagedb.has_package(pkg):
|
|
||||||
ctx.ui.info(_("Package %s is not present in the package database") % pkg);
|
|
||||||
return False
|
|
||||||
elif satisfies_runtime_deps(pkg):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ class Builder:
|
|||||||
# find out the build dependencies that are not satisfied...
|
# find out the build dependencies that are not satisfied...
|
||||||
dep_unsatis = []
|
dep_unsatis = []
|
||||||
for dep in build_deps:
|
for dep in build_deps:
|
||||||
if not dependency.installed_satisfies_dep(dep):
|
if not dep.satisfied_by_installed():
|
||||||
dep_unsatis.append(dep)
|
dep_unsatis.append(dep)
|
||||||
|
|
||||||
if dep_unsatis:
|
if dep_unsatis:
|
||||||
@@ -566,7 +566,7 @@ class Builder:
|
|||||||
|
|
||||||
if not ctx.config.get_option('ignore_dependency'):
|
if not ctx.config.get_option('ignore_dependency'):
|
||||||
for dep in dep_unsatis:
|
for dep in dep_unsatis:
|
||||||
if not dependency.repo_satisfies_dep(dep):
|
if not dep.satisfied_by_repo():
|
||||||
raise Error(_('Build dependency %s cannot be satisfied') % str(dep))
|
raise Error(_('Build dependency %s cannot be satisfied') % str(dep))
|
||||||
if ctx.ui.confirm(
|
if ctx.ui.confirm(
|
||||||
_('Do you want to install the unsatisfied build dependencies')):
|
_('Do you want to install the unsatisfied build dependencies')):
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ def plan_emerge(A):
|
|||||||
# add dependencies
|
# add dependencies
|
||||||
|
|
||||||
def process_dep(dep):
|
def process_dep(dep):
|
||||||
if not dependency.installed_satisfies_dep(dep):
|
if not dep.satisfied_by_installed():
|
||||||
if dependency.repo_satisfies_dep(dep):
|
if dep.satisfied_by_repo():
|
||||||
install_list.add(dep.package)
|
install_list.add(dep.package)
|
||||||
return
|
return
|
||||||
srcdep = pkgtosrc(dep.package)
|
srcdep = pkgtosrc(dep.package)
|
||||||
|
|||||||
@@ -129,8 +129,7 @@ def install_pkg_files(package_URIs, reinstall = False):
|
|||||||
def satisfiesDep(dep):
|
def satisfiesDep(dep):
|
||||||
# is dependency satisfied among available packages
|
# is dependency satisfied among available packages
|
||||||
# or packages to be installed?
|
# or packages to be installed?
|
||||||
return dependency.installed_satisfies_dep(dep) \
|
return dep.satisfied_by_installed() or dep.satisfied_by_dict_repo(d_t)
|
||||||
or dep.satisfied_by_dict_repo(d_t)
|
|
||||||
|
|
||||||
# for this case, we have to determine the dependencies
|
# for this case, we have to determine the dependencies
|
||||||
# that aren't already satisfied and try to install them
|
# that aren't already satisfied and try to install them
|
||||||
@@ -146,7 +145,7 @@ def install_pkg_files(package_URIs, reinstall = False):
|
|||||||
# now determine if these unsatisfied dependencies could
|
# now determine if these unsatisfied dependencies could
|
||||||
# be satisfied by installing packages from the repo
|
# be satisfied by installing packages from the repo
|
||||||
for dep in dep_unsatis:
|
for dep in dep_unsatis:
|
||||||
if not dependency.repo_satisfies_dep(dep):
|
if not dep.satisfied_by_repo():
|
||||||
raise Exception(_('External dependencies not satisfied: %s') % dep)
|
raise Exception(_('External dependencies not satisfied: %s') % dep)
|
||||||
|
|
||||||
# if so, then invoke install_pkg_names
|
# if so, then invoke install_pkg_names
|
||||||
@@ -232,8 +231,8 @@ def plan_install_pkg_names(A, ignore_package_conflicts = False):
|
|||||||
for dep in pkg.runtimeDependencies():
|
for dep in pkg.runtimeDependencies():
|
||||||
ctx.ui.debug('checking %s' % str(dep))
|
ctx.ui.debug('checking %s' % str(dep))
|
||||||
# we don't deal with already *satisfied* dependencies
|
# we don't deal with already *satisfied* dependencies
|
||||||
if not dependency.installed_satisfies_dep(dep):
|
if not dep.satisfied_by_installed():
|
||||||
if not dependency.repo_satisfies_dep(dep):
|
if not dep.satisfied_by_repo():
|
||||||
raise Exception(_('%s dependency of package %s is not satisfied') % (dep, pkg.name))
|
raise Exception(_('%s dependency of package %s is not satisfied') % (dep, pkg.name))
|
||||||
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))
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def plan_remove(A):
|
|||||||
for (rev_dep, depinfo) in rev_deps:
|
for (rev_dep, depinfo) in rev_deps:
|
||||||
# we don't deal with uninstalled rev deps
|
# we don't deal with uninstalled rev deps
|
||||||
# and unsatisfied dependencies (this is important, too)
|
# and unsatisfied dependencies (this is important, too)
|
||||||
if installdb.has_package(rev_dep) and dependency.installed_satisfies_dep(depinfo):
|
if installdb.has_package(rev_dep) and depinfo.satisfied_by_installed():
|
||||||
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)
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ def plan_upgrade(A):
|
|||||||
pkg = packagedb.get_package(x)
|
pkg = packagedb.get_package(x)
|
||||||
for dep in pkg.runtimeDependencies():
|
for dep in pkg.runtimeDependencies():
|
||||||
# add packages that can be upgraded
|
# add packages that can be upgraded
|
||||||
if installdb.has_package(dep.package) and dependency.installed_satisfies_dep(dep):
|
if installdb.has_package(dep.package) and dep.satisfied_by_installed():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if dependency.repo_satisfies_dep(dep):
|
if dep.satisfied_by_repo():
|
||||||
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)
|
||||||
@@ -217,8 +217,8 @@ def plan_upgrade(A):
|
|||||||
for (rev_dep, depinfo) in rev_deps:
|
for (rev_dep, depinfo) in rev_deps:
|
||||||
# add only installed but unsatisfied reverse dependencies
|
# add only installed but unsatisfied reverse dependencies
|
||||||
if (installdb.has_package(rev_dep) and
|
if (installdb.has_package(rev_dep) and
|
||||||
not dependency.installed_satisfies_dep(depinfo) and is_upgradable(rev_dep)):
|
not depinfo.satisfied_by_installed() and is_upgradable(rev_dep)):
|
||||||
if not dependency.repo_satisfies_dep(depinfo):
|
if not depinfo.satisfied_by_repo():
|
||||||
raise Exception(_('Reverse dependency %s of %s cannot be satisfied') % (rev_dep, x))
|
raise Exception(_('Reverse dependency %s of %s cannot be satisfied') % (rev_dep, x))
|
||||||
if not rev_dep in G_f.vertices():
|
if not rev_dep in G_f.vertices():
|
||||||
Bp.add(rev_dep)
|
Bp.add(rev_dep)
|
||||||
|
|||||||
+8
-3
@@ -157,7 +157,6 @@ class Archive:
|
|||||||
s = _('URI: %s, type: %s, sha1sum: %s') % (self.uri, self.type, self.sha1sum)
|
s = _('URI: %s, type: %s, sha1sum: %s') % (self.uri, self.type, self.sha1sum)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
class Source:
|
class Source:
|
||||||
|
|
||||||
t_Name = [autoxml.String, autoxml.mandatory]
|
t_Name = [autoxml.String, autoxml.mandatory]
|
||||||
@@ -214,10 +213,16 @@ class Package:
|
|||||||
|
|
||||||
return util.join_path(ctx.config.packages_dir(), packageDir)
|
return util.join_path(ctx.config.packages_dir(), packageDir)
|
||||||
|
|
||||||
|
def satisfies_runtime_dependencies(self):
|
||||||
|
for dep in self.runtimeDependencies():
|
||||||
|
if not dep.satisfied_by_installed():
|
||||||
|
ctx.ui.error(_('%s dependency of package %s is not satisfied') % (dep, self.name))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def installable(self):
|
def installable(self):
|
||||||
"""calculate if pkg is installable currently"""
|
"""calculate if pkg is installable currently"""
|
||||||
deps = self.runtimeDependencies()
|
return self.satisfies_runtime_dependencies()
|
||||||
return pisi.dependency.satisfies_dependencies(self.name, deps)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.build:
|
if self.build:
|
||||||
|
|||||||
Reference in New Issue
Block a user