From 0f2e68558607d5cc068f6d61d934572fff216471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Thu, 28 Jul 2005 21:52:12 +0000 Subject: [PATCH] * find which repo a package is in * eger paket install edilmemisse dependency'sini check edemeyiz * packageURI'in olmasi gerekmiyor metadata'da illa * install isini yeniden duzenle * multi install: ilerleme * alpha-light.sh'i yeni komutlara gore yap --- pisi/cli/commands.py | 3 +-- pisi/dependency.py | 17 +++++++++++------ pisi/install.py | 1 + pisi/metadata.py | 1 - pisi/operations.py | 39 ++++++++++++++++----------------------- pisi/packagedb.py | 6 ++++++ pisi/toplevel.py | 2 ++ tests/alpha-light.sh | 6 ++++-- 8 files changed, 41 insertions(+), 34 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 23c6de46..f0d02798 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -200,8 +200,7 @@ class ListInstalled(Command): self.init_db() from pisi.installdb import installdb for pkg in installdb.list_installed(): - from pisi.packagedb import packagedb - package = packagedb.get_package(pkg) + package = pisi.packagedb.get_package(pkg) if not self.options.long: print package.name, '-', package.summary else: diff --git a/pisi/dependency.py b/pisi/dependency.py index 8b2280c8..cdce78f6 100644 --- a/pisi/dependency.py +++ b/pisi/dependency.py @@ -6,12 +6,14 @@ import packagedb from ui import ui from version import Version -def satisfiesDep(pkg, depinfo): +def satisfiesDep(pkg_name, depinfo): """determine if a package satisfies given dependency spec""" + if not installdb.is_installed(pkg_name): + return False if not installdb.is_installed(depinfo.package): return False else: - (version, release) = installdb.get_info(pkg) + (version, release) = installdb.get_version(pkg_name) ret = True if depinfo.versionFrom: ret &= Version(version) >= Version(depinfo.versionFrom) @@ -28,9 +30,12 @@ def runtimeDeps(pkg): def satisfiesRuntimeDeps(pkg): deps = runtimeDeps(pkg) -# print 'runtimedeps = ', deps - return reduce(lambda x,y:x and y, - map(lambda x: satisfiesDep(pkg, x), deps),True) + for dep in deps: + if not satisfiesDep(pkg, dep): + ui.error('Package %s does not satisfy dependency %s\n' % + (pkg,dep.package)) + return False + return True def installable(pkg): """calculate if pkg is installable currently @@ -41,6 +46,6 @@ def installable(pkg): elif satisfiesRuntimeDeps(pkg): return True else: - ui.info("package " + pkg + " does not satisfy dependencies\n"); + #ui.info("package " + pkg + " does not satisfy dependencies\n"); return False diff --git a/pisi/install.py b/pisi/install.py index 46c4f740..568809d1 100644 --- a/pisi/install.py +++ b/pisi/install.py @@ -11,6 +11,7 @@ from constants import const from ui import ui from installdb import installdb import packagedb +from packagedb import inst_packagedb import dependency from metadata import MetaData import comariface diff --git a/pisi/metadata.py b/pisi/metadata.py index 4c7aeb54..8a804e8b 100644 --- a/pisi/metadata.py +++ b/pisi/metadata.py @@ -67,7 +67,6 @@ class PackageInfo(specfile.PackageInfo): ret = ret and self.distribution!=None ret = ret and self.distributionRelease!=None ret = ret and self.architecture!=None and self.installedSize!=None - ret = ret and self.packageURI!=None return ret def __str__(self): diff --git a/pisi/operations.py b/pisi/operations.py index e5ce5ca3..020f2d3b 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -6,7 +6,7 @@ from config import config from constants import const from ui import ui from purl import PUrl -import util +import util, packagedb # single package operations @@ -36,8 +36,8 @@ def remove_single(package_name): inst_packagedb.remove_package(package_name) removeScripts(package_name) -# TODO: repository'den okuma isi yas burada, bu degisecek def install_single(pkg): + """install a single package from URI or ID""" url = PUrl(pkg) # Check if we are dealing with a remote file or a real path of # package filename. Otherwise we'll try installing a package from @@ -45,31 +45,24 @@ def install_single(pkg): if url.isRemoteFile() or os.path.exists(url.uri): install_single_package(pkg) else: - from os.path import join + install_single_name(pkg) - # TODO: tabii burada repodb falan kullanilmali cok inefficient - (repo, index) = util.repo_index() - - # search pkg in index for it's presence in repository - # TODO: normalde hicbir zaman boyle linear search yapilmamali - # buyuk olabilecek listeler uzerinden - for package in index.packages: - if package.name == pkg: - version = package.history[0].version - release = package.history[0].release - - name = util.package_name(pkg, version, release) - package_uri = join(repo, name[0], name) - - ui.info("Installing %s from repository %s\n" %(name, repo)) - install_package(package_uri) - return - ui.error("Package %s not found in the index file.\n" %pkg) - -def install_single_package(pkg_location): +def install_single_uri(pkg_location): from install import Installer Installer(pkg_location).install() +def install_single_name(name): + """install a single package from ID""" + # find package in repository + repo = packagedb.which_repo(name) + if repo: + pkg = packagedb.get_package(name) + ui.info("Installing %s from repository %s\n" %(name, repo)) + ui.debug("Package URI: %s\n" % pkg.packageURI) + install_single_uri(pkg.packageURI) + else: + ui.error("Package %s not found in the repository file.\n" % pkg) + # deneme, don't remove ulan class AtomicOperation(object): def __init__(self, package, ignore_dep = False): diff --git a/pisi/packagedb.py b/pisi/packagedb.py index 0d0043ca..8be5ec39 100644 --- a/pisi/packagedb.py +++ b/pisi/packagedb.py @@ -71,6 +71,12 @@ def has_package(name): return True return False +def which_repo(name): + for repo in packagedbs.keys(): + if get_db(repo).has_package(name): + return repo + return None + def get_package(name): for repo in packagedbs.keys(): if get_db(repo).has_package(name): diff --git a/pisi/toplevel.py b/pisi/toplevel.py index 343bbee7..1660a516 100644 --- a/pisi/toplevel.py +++ b/pisi/toplevel.py @@ -77,6 +77,8 @@ def install_pkg_names(A): l = G_f.topological_sort() l.reverse() print l + for x in l: + operations.install_single_name(x) def remove(packages): #TODO: this for loop is just a placeholder diff --git a/tests/alpha-light.sh b/tests/alpha-light.sh index 54723cc9..0529f7be 100755 --- a/tests/alpha-light.sh +++ b/tests/alpha-light.sh @@ -5,7 +5,9 @@ PATH=$PATH:. set -x pisi-cli build packages/z/zip/pspec.xml packages/u/unzip/pspec.xml pisi-cli index . -pisi-cli updatedb pisi-index.xml +pisi-cli add-repo repo1 pisi-index.xml +pisi-cli update-repo repo1 # database contents -find tmp -iname '*.bdb' | xargs tools/cat-db.py +#find tmp -iname '*.bdb' | xargs tools/cat-db.py pisi-cli install zip +pisi-cli list-installed