cli/remove,upgrade: Revise safety switch messages

This commit is contained in:
Fatih Aşıcı
2010-03-21 23:11:42 +00:00
parent 07cd4e46d2
commit 9190b025b6
2 changed files with 11 additions and 8 deletions
+4 -3
View File
@@ -41,11 +41,12 @@ def remove(A, ignore_dep = False, ignore_safety = False):
systembase = set(componentdb.get_union_component('system.base').packages) systembase = set(componentdb.get_union_component('system.base').packages)
refused = A.intersection(systembase) refused = A.intersection(systembase)
if refused: if refused:
raise pisi.Error(_('Safety switch: cannot remove the following packages in system.base: ') + raise pisi.Error(_("Safety switch prevents the removal of "
util.strlist(refused)) "following packages:\n") +
util.format_by_columns(sorted(refused)))
A = A - systembase A = A - systembase
else: else:
ctx.ui.warning(_('Safety switch: the component system.base cannot be found')) ctx.ui.warning(_("Safety switch: The component system.base cannot be found."))
Ap = [] Ap = []
for x in A: for x in A:
+7 -5
View File
@@ -280,8 +280,9 @@ def upgrade_base(A = set()):
extra_installs = filter(lambda x: not installdb.has_package(x), systembase - set(A)) extra_installs = filter(lambda x: not installdb.has_package(x), systembase - set(A))
extra_installs = pisi.blacklist.exclude_from(extra_installs, ctx.const.blacklist) extra_installs = pisi.blacklist.exclude_from(extra_installs, ctx.const.blacklist)
if extra_installs: if extra_installs:
ctx.ui.warning(_('Safety switch: Following packages in system.base will be installed: ') + ctx.ui.warning(_("Safety switch forces the installation of "
util.strlist(extra_installs)) "following packages:"))
ctx.ui.info(util.format_by_columns(sorted(extra_installs)))
G_f, install_order = operations.install.plan_install_pkg_names(extra_installs) G_f, install_order = operations.install.plan_install_pkg_names(extra_installs)
extra_upgrades = filter(lambda x: is_upgradable(x, ignore_build), systembase - set(install_order)) extra_upgrades = filter(lambda x: is_upgradable(x, ignore_build), systembase - set(install_order))
upgrade_order = [] upgrade_order = []
@@ -295,13 +296,14 @@ def upgrade_base(A = set()):
extra_upgrades = pisi.blacklist.exclude(extra_upgrades, ctx.get_option('exclude')) extra_upgrades = pisi.blacklist.exclude(extra_upgrades, ctx.get_option('exclude'))
if extra_upgrades: if extra_upgrades:
ctx.ui.warning(_('Safety switch: Following packages in system.base will be upgraded: ') + ctx.ui.warning(_("Safety switch forces the upgrade of "
util.strlist(extra_upgrades)) "following packages:"))
ctx.ui.info(util.format_by_columns(sorted(extra_upgrades)))
G_f, upgrade_order = plan_upgrade(extra_upgrades, force_replaced=False) G_f, upgrade_order = plan_upgrade(extra_upgrades, force_replaced=False)
# return packages that must be added to any installation # return packages that must be added to any installation
return set(install_order + upgrade_order) return set(install_order + upgrade_order)
else: else:
ctx.ui.warning(_('Safety switch: the component system.base cannot be found')) ctx.ui.warning(_('Safety switch: The component system.base cannot be found.'))
return set() return set()
def is_upgradable(name, ignore_build = False): def is_upgradable(name, ignore_build = False):