From 1a4a015ff918774f41a35c093bbe19eaa6fd30e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Sun, 18 Dec 2005 22:14:56 +0000 Subject: [PATCH] * fix: in upgrade, first download, then install --- pisi/atomicoperations.py | 46 ++++++++++++++++++++++------------------ pisi/operations.py | 7 ++++-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 20c29d6c..068a1a36 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -56,6 +56,29 @@ class AtomicOperation(object): class Install(AtomicOperation): "Install class, provides install routines for pisi packages" + @staticmethod + def from_name(name): + # download package and return an installer object + # find package in repository + repo = packagedb.which_repo(name) + if repo: + repo = ctx.repodb.get_repo(repo) + pkg = packagedb.get_package(name) + + # FIXME: let pkg.packageURI be stored as URI type rather than string + pkg_uri = URI(pkg.packageURI) + if pkg_uri.is_absolute_path(): + pkg_path = str(pkg.packageURI) + else: + pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()), + str(pkg_uri.path())) + + ctx.ui.debug(_("Package URI: %s") % pkg_path) + + return Install(pkg_path) + else: + raise Error(_("Package %s not found in any active repository.") % name) + def __init__(self, package_fname, ignore_dep = None): "initialize from a file name" super(Install, self).__init__(ignore_dep) @@ -292,27 +315,8 @@ def install_single_file(pkg_location, upgrade = False): def install_single_name(name, upgrade = False): """install a single package from ID""" - # find package in repository - repo = packagedb.which_repo(name) - if repo: - repo = ctx.repodb.get_repo(repo) - pkg = packagedb.get_package(name) - - # FIXME: let pkg.packageURI be stored as URI type rather than string - pkg_uri = URI(pkg.packageURI) - if pkg_uri.is_absolute_path(): - pkg_path = str(pkg.packageURI) - else: - pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()), - str(pkg_uri.path())) - - ctx.ui.debug(_("Package URI: %s") % pkg_path) - - # Package will handle remote file for us! - install_single_file(pkg_path, upgrade) - else: - raise Error(_("Package %s not found in any active repository.") % name) - + install = Install.from_name(name) + install.install(not upgrade) class Remove(AtomicOperation): diff --git a/pisi/operations.py b/pisi/operations.py index d551bedf..3c3e1501 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -323,8 +323,11 @@ version %s, release %s, build %s.') if len(order) > len(A_0): if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False - for x in order: - atomicoperations.install_single_name(x, True) + + install_ops = [atomicoperations.Install.from_name(x) for x in order] + + for install in install_ops: + install.install(True) def plan_upgrade(A): # try to construct a pisi graph of packages to