* packagedb api changes

This commit is contained in:
Faik Uygur
2007-03-12 10:20:12 +00:00
parent c9fbc1aebc
commit 96a8b96a27
7 changed files with 52 additions and 26 deletions
-1
View File
@@ -55,7 +55,6 @@ api layer from the needed places.
* sourcedb.list
* installdb.list_pending
* filesdb.match_files
*
Package Manager
===============
+32 -4
View File
@@ -196,7 +196,7 @@ def package_graph(A, repo = pisi.db.itembyrepodb.installed, ignore_installed = F
while len(B) > 0:
Bp = set()
for x in B:
pkg = ctx.packagedb.get_package(x, repo)
pkg = get_repo_package(x, repo)
#print pkg
for dep in pkg.runtimeDependencies():
if ignore_installed:
@@ -252,7 +252,7 @@ def generate_pending_order(A):
while len(B) > 0:
Bp = set()
for x in B.keys():
pkg = ctx.packagedb.get_package(x, pisi.db.itembyrepodb.installed)
pkg = get_installed_package(x)
for dep in pkg.runtimeDependencies():
if dep.package in G_f.vertices():
G_f.add_dep(x, dep)
@@ -321,7 +321,7 @@ def info_file(package_fn):
def info_name(package_name, installed=False):
"""Fetch package information for the given package."""
if installed:
package = ctx.packagedb.get_package(package_name, pisi.db.itembyrepodb.installed)
package = get_installed_package(package_name)
else:
package, repo = ctx.packagedb.get_package_repo(package_name, pisi.db.itembyrepodb.repos)
repostr = repo
@@ -356,7 +356,7 @@ def search_in_packages(terms, packages, repo = pisi.db.itembyrepodb.all):
found = []
for name in packages:
pkg = ctx.packagedb.get_package(name, repo)
pkg = get_repo_package(name, repo)
if terms == filter(lambda x:search(pkg, x), terms):
found.append(name)
@@ -552,3 +552,31 @@ def rebuild_db(files=False):
reload_packages(files, txn)
reload_indices(txn)
txn.commit()
############################ Under Construction ##############################
### Package Database Operations ###
## Returns the package informations of the given repository
# @param name Name of the package
# @param repo Name of the repository
def get_repo_package(name, repo=pisi.db.itembyrepodb.repos):
# FIXME: * currently we return the first package in repo order
# * we should get rid of itembyrepodb enums
# * transparent transaction support
return ctx.packagedb.get_package(name, repo, txn=None)
## Returns the installed package information
# @param name Name of the package
def get_installed_package(name):
# FIXME: * we should get rid of itembyrepodb enums
# * transparent transaction support
return ctx.packagedb.get_package(name, pisi.db.itembyrepodb.installed, txn=None)
### Repo Database Operations ###
### Source Database Operations ###
### Component Database Operations ###
### Files Database Operations ###
+2 -3
View File
@@ -63,7 +63,7 @@ class Install(AtomicOperation):
if repo:
ctx.ui.info(_("Package %s found in repository %s") % (name, repo))
repo = ctx.repodb.get_repo(repo)
pkg = ctx.packagedb.get_package(name)
pkg = pisi.api.get_repo_package(name)
delta = None
# Package is installed. This is an upgrade. Check delta.
@@ -188,7 +188,6 @@ class Install(AtomicOperation):
if ctx.installdb.is_installed(pkg.name): # is this a reinstallation?
#FIXME: consider REPOSITORY instead of DISTRIBUTION -- exa
#ipackage = ctx.packagedb.get_package(pkg.name, pisi.db.itembyrepodb.installed)
ipkg = ctx.installdb.get_info(pkg.name)
repomismatch = ipkg.distribution != pkg.distribution
@@ -427,7 +426,7 @@ class Remove(AtomicOperation):
def __init__(self, package_name):
super(Remove, self).__init__()
self.package_name = package_name
self.package = ctx.packagedb.get_package(self.package_name, pisi.db.itembyrepodb.installed)
self.package = pisi.api.get_installed_package(self.package_name)
try:
self.files = ctx.installdb.files(self.package_name)
except pisi.Error, e:
+3 -4
View File
@@ -22,7 +22,6 @@ import pisi.cli
import pisi.context as ctx
from pisi.uri import URI
import pisi.util as util
import pisi.api as api
from colors import colorize
class Error(pisi.Error):
@@ -1124,7 +1123,7 @@ Usage: list-installed
ctx.ui.info(_('Package Name |St| Version| Rel.| Build| Distro| Date'))
print '========================================================================'
for pkg in installed:
package = ctx.packagedb.get_package(pkg, pisi.db.itembyrepodb.installed)
package = pisi.api.get_installed_package(pkg)
inst_info = ctx.installdb.get_info(pkg)
if self.options.long:
ctx.ui.info(unicode(package))
@@ -1367,7 +1366,7 @@ all repositories.
installed_list = ctx.installdb.list_installed()
list.sort()
for p in list:
package = ctx.packagedb.get_package(p)
package = pisi.api.get_repo_package(p)
if self.options.long:
ctx.ui.info(unicode(package))
else:
@@ -1502,7 +1501,7 @@ Lists the packages that will be upgraded.
ctx.ui.info(_('Package Name |St| Version| Rel.| Build| Distro| Date'))
print '========================================================================'
for pkg in upgradable_pkgs:
package = ctx.packagedb.get_package(pkg, pisi.db.itembyrepodb.installed)
package = pisi.api.get_installed_package(pkg)
inst_info = ctx.installdb.get_info(pkg)
if self.options.long:
ctx.ui.info(package)
+1 -1
View File
@@ -75,7 +75,7 @@ given conflicting spec"""
if not ctx.installdb.is_installed(pkg_name):
return False
else:
pkg = ctx.packagedb.get_package(pkg_name, pisi.db.itembyrepodb.installed)
pkg = api.get_installed_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return confinfo.conflicts(pkg_name, version, release)
+4 -3
View File
@@ -16,6 +16,7 @@ import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
import pisi.context as ctx
import pisi.db.packagedb as packagedb
from pisi.version import Version
@@ -86,7 +87,7 @@ dependency spec"""
if not ctx.installdb.is_installed(pkg_name):
return False
else:
pkg = ctx.packagedb.get_package(pkg_name, pisi.db.itembyrepodb.installed)
pkg = pisi.api.get_installed_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
@@ -97,7 +98,7 @@ dependency spec"""
if not ctx.packagedb.has_package(pkg_name):
return False
else:
pkg = ctx.packagedb.get_package(pkg_name)
pkg = pisi.api.get_repo_package(pkg_name)
(version, release) = (pkg.version, pkg.release)
return depinfo.satisfies(pkg_name, version, release)
@@ -110,7 +111,7 @@ def satisfies_dependencies(pkg, deps, sat = installed_satisfies_dep):
return True
def satisfies_runtime_deps(pkg):
deps = ctx.packagedb.get_package(pkg).runtimeDependencies()
deps = pisi.api.get_repo_package(pkg).runtimeDependencies()
return satisfies_dependencies(pkg, deps)
def installable(pkg):
+10 -10
View File
@@ -185,7 +185,7 @@ in the respective order to satisfy extra dependencies:
while len(B) > 0:
Bp = set()
for x in B:
pkg = packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
for dep in pkg.runtimeDependencies():
if dependency.dict_satisfies_dep(d_t, dep):
if not dep.package in G_f.vertices():
@@ -230,7 +230,7 @@ def calculate_conflicts(order, packagedb):
pkg_conflicts = {}
for x in order:
pkg = packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
# check if any package has conflicts with the installed packages
conflicts = check_conflict(pkg, order)
@@ -241,7 +241,7 @@ def calculate_conflicts(order, packagedb):
# now check if any package has conflicts with each other
B_i = B_0.intersection(set(map(lambda c:c.package, pkg.conflicts)))
D_i = set()
for p in map(lambda x:packagedb.get_package(x), B_i):
for p in map(lambda x:pisi.api.get_repo_package(x), B_i):
conflicted = pisi.conflict.package_conflicts(p, pkg.conflicts)
if conflicted:
D_i.add(str(conflicted))
@@ -285,7 +285,7 @@ def is_upgradable(name, ignore_build = False):
return False
(version, release, build) = ctx.installdb.get_version(name)
try:
pkg = ctx.packagedb.get_package(name)
pkg = pisi.api.get_repo_package(name)
except KeyboardInterrupt:
raise
except Exception, e: #FIXME: what exception could we catch here, replace with that.
@@ -391,7 +391,7 @@ def plan_install_pkg_names(A, ignore_package_conflicts = False):
while len(B) > 0:
Bp = set()
for x in B:
pkg = ctx.packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
for dep in pkg.runtimeDependencies():
ctx.ui.debug('checking %s' % str(dep))
# we don't deal with already *satisfied* dependencies
@@ -436,7 +436,7 @@ def upgrade_pkg_names(A = []):
continue
(version, release, build) = ctx.installdb.get_version(x)
if ctx.packagedb.has_package(x):
pkg = ctx.packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
else:
ctx.ui.info(_('Package %s is not available in repositories.') % x, True)
continue
@@ -539,7 +539,7 @@ def plan_upgrade(A, ignore_build = False):
while len(B) > 0:
Bp = set()
for x in B:
pkg = packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
for dep in pkg.runtimeDependencies():
# add packages that can be upgraded
if dependency.repo_satisfies_dep(dep):
@@ -559,7 +559,7 @@ def plan_upgrade(A, ignore_build = False):
while len(B) > 0:
Bp = set()
for x in B:
pkg = packagedb.get_package(x)
pkg = pisi.api.get_repo_package(x)
rev_deps = packagedb.get_rev_deps(x)
for (rev_dep, depinfo) in rev_deps:
# add only installed but unsatisfied reverse dependencies
@@ -648,7 +648,7 @@ def plan_remove(A):
while len(B) > 0:
Bp = set()
for x in B:
pkg = ctx.packagedb.get_package(x, pisi.db.itembyrepodb.installed)
pkg = pisi.api.get_installed_package(x)
rev_deps = ctx.packagedb.get_rev_deps(x, pisi.db.itembyrepodb.installed)
for (rev_dep, depinfo) in rev_deps:
# we don't deal with uninstalled rev deps
@@ -798,7 +798,7 @@ def plan_emerge(A, rebuild_all):
def calculate_download_sizes(order):
total_size = cached_size = 0
for pkg in [ctx.packagedb.get_package(name) for name in order]:
for pkg in [pisi.api.get_repo_package(name) for name in order]:
delta = None
if ctx.installdb.is_installed(pkg.name):