* implement --reinstall option for install cmd
* don't install packages already installed by default
This commit is contained in:
@@ -397,7 +397,9 @@ expanded to package names.
|
|||||||
super(Install, self).options()
|
super(Install, self).options()
|
||||||
p = self.parser
|
p = self.parser
|
||||||
p.add_option("", "--bypass-ldconfig", action="store_true",
|
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)
|
buildno_opts(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -406,7 +408,7 @@ expanded to package names.
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.init()
|
self.init()
|
||||||
pisi.api.install(self.args)
|
pisi.api.install(self.args, ctx.get_option('reinstall'))
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -40,7 +40,7 @@ class Error(pisi.Error):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# high level operations
|
# high level operations
|
||||||
def install(packages):
|
def install(packages, reinstall = False):
|
||||||
"""install a list of packages (either files/urls, or names)"""
|
"""install a list of packages (either files/urls, or names)"""
|
||||||
|
|
||||||
# FIXME: this function name "install" makes impossible to import
|
# 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!
|
if packages[0].endswith(ctx.const.package_suffix): # they all have to!
|
||||||
return install_pkg_files(packages)
|
return install_pkg_files(packages)
|
||||||
else:
|
else:
|
||||||
return install_pkg_names(packages)
|
return install_pkg_names(packages, reinstall)
|
||||||
|
|
||||||
def install_pkg_files(package_URIs):
|
def install_pkg_files(package_URIs):
|
||||||
"""install a number of pisi package files"""
|
"""install a number of pisi package files"""
|
||||||
@@ -183,7 +183,7 @@ def expand_components(A):
|
|||||||
Ap.add(x)
|
Ap.add(x)
|
||||||
return Ap
|
return Ap
|
||||||
|
|
||||||
def install_pkg_names(A):
|
def install_pkg_names(A, reinstall = False):
|
||||||
"""This is the real thing. It installs packages from
|
"""This is the real thing. It installs packages from
|
||||||
the repository, trying to perform a minimum number of
|
the repository, trying to perform a minimum number of
|
||||||
installs"""
|
installs"""
|
||||||
@@ -192,6 +192,15 @@ def install_pkg_names(A):
|
|||||||
A_0 = A = expand_components(set(A))
|
A_0 = A = expand_components(set(A))
|
||||||
ctx.ui.debug('A = %s' % str(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:
|
if len(A)==0:
|
||||||
ctx.ui.info(_('No packages to install.'))
|
ctx.ui.info(_('No packages to install.'))
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user