* fix: upgrade system.base before install and upgrade operations
This commit is contained in:
@@ -165,7 +165,6 @@ def list_upgradable():
|
|||||||
Ap.append(x)
|
Ap.append(x)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
#ctx.ui.info('Package %s cannot be upgraded. ' % x)
|
|
||||||
return Ap
|
return Ap
|
||||||
|
|
||||||
def package_graph(A, ignore_installed = False):
|
def package_graph(A, ignore_installed = False):
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ class InstallDB:
|
|||||||
# FIXME: it might be more appropriate to pass date
|
# FIXME: it might be more appropriate to pass date
|
||||||
# as an argument, or installation data afterwards
|
# as an argument, or installation data afterwards
|
||||||
# to do this -- exa
|
# to do this -- exa
|
||||||
# dailywtf. this does not look good -- exa
|
|
||||||
if not rebuild:
|
if not rebuild:
|
||||||
import time
|
import time
|
||||||
ctime = time.localtime()
|
ctime = time.localtime()
|
||||||
|
|||||||
+44
-4
@@ -224,15 +224,51 @@ def expand_components(A):
|
|||||||
Ap.add(x)
|
Ap.add(x)
|
||||||
return Ap
|
return Ap
|
||||||
|
|
||||||
def install_pkg_names(A, reinstall = False):
|
def is_upgradable(name, ignore_build = False):
|
||||||
|
if not ctx.installdb.is_installed(name):
|
||||||
|
return False
|
||||||
|
(version, release, build) = ctx.installdb.get_version(name)
|
||||||
|
pkg = ctx.packagedb.get_package(name)
|
||||||
|
if ignore_build or (not build) or (not pkg.build):
|
||||||
|
if Version(release) < Version(pkg.release):
|
||||||
|
return True
|
||||||
|
elif build < pkg.build:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def upgrade_base(A = set()):
|
||||||
|
ignore_build = ctx.get_option('ignore_build_no')
|
||||||
|
if not ctx.get_option('bypass_safety'):
|
||||||
|
if ctx.componentdb.has_component('system.base'):
|
||||||
|
extra_packages = set(ctx.componentdb.get_component('system.base').packages) - A
|
||||||
|
extra_installs = filter(lambda x: not ctx.installdb.is_installed(x), extra_packages)
|
||||||
|
if extra_installs:
|
||||||
|
ctx.ui.warning(_('Safety switch: Following extra packages in system.base will be installed: ') +
|
||||||
|
util.strlist(extra_installs))
|
||||||
|
install_pkg_names(extra_installs, bypass_safety=True)
|
||||||
|
#A |= extra_installs
|
||||||
|
extra_upgrades = filter(lambda x: is_upgradable(x, ignore_build), extra_packages)
|
||||||
|
if extra_upgrades:
|
||||||
|
ctx.ui.warning(_('Safety switch: Following extra packages in system.base will be upgraded: ') +
|
||||||
|
util.strlist(extra_upgrades))
|
||||||
|
upgrade_pkg_names(extra_upgrades, bypass_safety=True)
|
||||||
|
else:
|
||||||
|
ctx.ui.warning(_('Safety switch: the component system.base cannot be found'))
|
||||||
|
|
||||||
|
def install_pkg_names(A, reinstall = False, bypass_safety = 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"""
|
||||||
|
|
||||||
|
A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa
|
||||||
# A was a list, remove duplicates and expand components
|
# A was a list, remove duplicates and expand components
|
||||||
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))
|
||||||
|
|
||||||
|
if not bypass_safety:
|
||||||
|
upgrade_base(A)
|
||||||
|
|
||||||
# filter packages that are already installed
|
# filter packages that are already installed
|
||||||
if not reinstall:
|
if not reinstall:
|
||||||
Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A))
|
Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A))
|
||||||
@@ -264,7 +300,7 @@ in the respective order to satisfy dependencies:
|
|||||||
|
|
||||||
if total_size:
|
if total_size:
|
||||||
total_size, symbol = util.human_readable_size(total_size)
|
total_size, symbol = util.human_readable_size(total_size)
|
||||||
ctx.ui.warning(_('Total size of packages: %.2f %s') % (total_size, symbol))
|
ctx.ui.info(_('Total size of packages: %.2f %s') % (total_size, symbol))
|
||||||
|
|
||||||
if ctx.get_option('dry_run'):
|
if ctx.get_option('dry_run'):
|
||||||
return
|
return
|
||||||
@@ -312,7 +348,7 @@ def plan_install_pkg_names(A):
|
|||||||
def upgrade(A):
|
def upgrade(A):
|
||||||
upgrade_pkg_names(A)
|
upgrade_pkg_names(A)
|
||||||
|
|
||||||
def upgrade_pkg_names(A = []):
|
def upgrade_pkg_names(A = [], bypass_safety = False):
|
||||||
"""Re-installs packages from the repository, trying to perform
|
"""Re-installs packages from the repository, trying to perform
|
||||||
a minimum or maximum number of upgrades according to options."""
|
a minimum or maximum number of upgrades according to options."""
|
||||||
|
|
||||||
@@ -324,6 +360,10 @@ def upgrade_pkg_names(A = []):
|
|||||||
|
|
||||||
# filter packages that are not upgradable
|
# filter packages that are not upgradable
|
||||||
A_0 = A = expand_components(set(A))
|
A_0 = A = expand_components(set(A))
|
||||||
|
|
||||||
|
if not bypass_safety:
|
||||||
|
upgrade_base(A)
|
||||||
|
|
||||||
Ap = []
|
Ap = []
|
||||||
for x in A:
|
for x in A:
|
||||||
if x.endswith(ctx.const.package_suffix):
|
if x.endswith(ctx.const.package_suffix):
|
||||||
@@ -360,7 +400,7 @@ def upgrade_pkg_names(A = []):
|
|||||||
G_f = None
|
G_f = None
|
||||||
order = A
|
order = A
|
||||||
|
|
||||||
ctx.ui.info(_("""The following packages will be upgraded:\n""") +
|
ctx.ui.info(_('The following packages will be upgraded: ') +
|
||||||
util.strlist(order))
|
util.strlist(order))
|
||||||
|
|
||||||
if ctx.get_option('dry_run'):
|
if ctx.get_option('dry_run'):
|
||||||
|
|||||||
Reference in New Issue
Block a user