From 8dfb633524d187950f6aa79b32842022c7089cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Thu, 8 Dec 2005 21:34:49 +0000 Subject: [PATCH] * implement --reinstall option for install cmd * don't install packages already installed by default --- pisi/cli/commands.py | 6 ++++-- pisi/operations.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index ba82885d..7ea57bd9 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -397,7 +397,9 @@ expanded to package names. super(Install, self).options() p = self.parser p.add_option("", "--bypass-ldconfig", action="store_true", - default=False, help=_("Bypass ldconfig phase")) + default=False, help=_("Bypass ldconfig phase")) + p.add_option("", "--reinstall", action="store_true", + default=False, help=_("Reinstall already installed packages")) buildno_opts(self) def run(self): @@ -406,7 +408,7 @@ expanded to package names. return self.init() - pisi.api.install(self.args) + pisi.api.install(self.args, ctx.get_option('reinstall')) self.finalize() diff --git a/pisi/operations.py b/pisi/operations.py index ac792304..8efbcf36 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -40,7 +40,7 @@ class Error(pisi.Error): pass # high level operations -def install(packages): +def install(packages, reinstall = False): """install a list of packages (either files/urls, or names)""" # FIXME: this function name "install" makes impossible to import @@ -51,7 +51,7 @@ def install(packages): if packages[0].endswith(ctx.const.package_suffix): # they all have to! return install_pkg_files(packages) else: - return install_pkg_names(packages) + return install_pkg_names(packages, reinstall) def install_pkg_files(package_URIs): """install a number of pisi package files""" @@ -183,7 +183,7 @@ def expand_components(A): Ap.add(x) return Ap -def install_pkg_names(A): +def install_pkg_names(A, reinstall = False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" @@ -192,6 +192,15 @@ def install_pkg_names(A): A_0 = A = expand_components(set(A)) ctx.ui.debug('A = %s' % str(A)) + # filter packages that are already installed + if not reinstall: + Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A)) + d = A - Ap + if len(d) > 0: + ctx.ui.warning(_('Not re-installing the following packages: ') + + util.strlist(d)) + A = Ap + if len(A)==0: ctx.ui.info(_('No packages to install.')) return