Browse Source

Множественные изменения

Переименованы названия задач
Изменено оформление размер скачиваемого
Исправлена ошибка разбора блока revdep-rebuild
depclean и пересборка модулей могут выполняться даже если нет
обновлений, но были установленные пакеты
tags/3.2.0_alpha5
Mike khiretskiy 7 years ago
parent
commit
500b9df0dd
3 changed files with 93 additions and 84 deletions
  1. +14
    -9
      update/emerge_parser.py
  2. +58
    -61
      update/update.py
  3. +21
    -14
      update/utils/cl_update.py

+ 14
- 9
update/emerge_parser.py View File

@@ -455,22 +455,27 @@ class RevdepPercentBlock(NotifierInformationBlock):
"""
token = "Collecting system binaries"
end_token = [re.compile("Assigning files to packages|"
"All prepared. Starting rebuild"), pexpect.EOF]
"All prepared. Starting rebuild")]
re_block = re.compile("\[\s(\d+)%\s\]")
action = None

def notify(self, observer, groups):
percent = int(groups[0])
observer(percent)

def get_block(self, child):
while True:
index = child.expect([self.re_block]+self.end_token)
if index == 0:
for observer in self.observers:
self.notify(observer, child.match.groups())
else:
self.result = child.match
break
expect_result = [self.re_block]+self.end_token
try:
while True:
index = child.expect(expect_result)
if index == 0:
for observer in self.observers:
self.notify(observer, child.match.groups())
else:
self.result = child.match
break
except pexpect.EOF:
self.result = ""

class EmergeParser(object):
"""


+ 58
- 61
update/update.py View File

@@ -241,6 +241,9 @@ class Update:
return False

def _printEmergePackage(self, pkg, binary=False, num=1, max_num=1):
"""
Вывод сообщения сборки пакета
"""
self.endTask()
_print = self.color_print
if max_num > 1:
@@ -257,6 +260,9 @@ class Update:
self.startTask(_("Emerging%s %s") % (part, _print(str(pkg))))

def _printInstallPackage(self, pkg, binary=False):
"""
Вывод сообщения установки пакета
"""
self.endTask()
_print = self.color_print
if self.is_binary_pkg(pkg,binary):
@@ -267,6 +273,9 @@ class Update:
_print(str(pkg)))

def _printUninstallPackage(self, pkg, num=1, max_num=1):
"""
Вывод сообщения удаления пакета
"""
self.endTask()
_print = self.color_print
if max_num > 1:
@@ -280,26 +289,21 @@ class Update:
self.startTask(_("Unmerging%s %s") % (part, _print.bold(str(pkg))))

def emergelike(self, cmd, *params):
"""
Запуск команды, которая подразумевает выполнение emerge
"""
cmd_path = getProgPath(cmd)
if not cmd_path:
raise UpdateError(_("Failed to find %s command") % cmd)
with EmergeParser(
emerge_parser.CommandExecutor(cmd_path, params)) as emerge:
emerge.emerging.add_observer(self._printEmergePackage)
emerge.installing.add_observer(self._printInstallPackage)
emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
if emerge.emerging_error:
self.printPre(
self._emerge_translate(emerge.emerging_error.log))
else:
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
self._startEmerging(emerge)
return True

def revdep_rebuild(self, cmd, *params):
"""
Запуск revdep-rebulid
"""
cmd_path = getProgPath(cmd)
if not cmd_path:
raise UpdateError(_("Failed to find %s command") % cmd)
@@ -308,20 +312,10 @@ class Update:
revdep = RevdepPercentBlock(emerge)
self.addProgress()
revdep.add_observer(self.setProgress)
revdep.action = lambda x: (self.endTask(), self.startTask(
_("Calculating dependencies")) if "Assign" in revdep else None)
emerge.emerging.add_observer(self._printEmergePackage)
emerge.installing.add_observer(self._printInstallPackage)
emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
if emerge.emerging_error:
self.printPre(
self._emerge_translate(emerge.emerging_error.log))
else:
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
revdep.action = lambda x: (
self.endTask(), self.startTask(_("Assigning files to packages"))
if "Assign" in revdep else None)
self._startEmerging(emerge)
return True

def _display_pretty_package_list(self, pkglist, remove_list=False):
@@ -358,6 +352,7 @@ class Update:
"""
# подробный список пакетов
_print = self.color_print
highlight = TextState.Colors.WHITE
if self.clVars.Get('cl_verbose_set') == 'on':
self.printPre(str(emerge.install_packages))
else:
@@ -371,9 +366,9 @@ class Update:
self._display_pretty_package_list(
emerge.install_packages.remove_list, remove_list=True)
if str(emerge.download_size) != "0 kB":
self.printSUCCESS(_print(
_("{size} will be downloaded").format(
size=emerge.download_size)))
self.printSUCCESS(_("{size} will be downloaded").format(
size=_print.foreground(highlight)(
str(emerge.download_size))))

def _display_remove_list(self, emerge):
"""
@@ -390,6 +385,9 @@ class Update:
self._display_pretty_package_list(pkglist, remove_list=True)

def getCacheOnWorld(self, params, packages, check=False):
"""
Получить список обновляемых пакетов @world из кэша
"""
if "@world" in packages:
from calculate.update.utils.cl_update import ClUpdateAction
elog = EmergeLog(
@@ -405,6 +403,10 @@ class Update:
return params, packages

def updateCache(self, pkg_list):
"""
Обновить кэш. Оставить отметку в emerge.log о том, выполнено действие
premerge
"""
self.emerge_cache.set_cache(pkg_list)
from calculate.update.utils.cl_update import ClUpdateAction
elog = EmergeLog(
@@ -419,7 +421,7 @@ class Update:
param = [param, "-pv"]

if not packages:
self.printSUCCESS(_("The system is up to date"))
self.printSUCCESS(_("Installed packages are up to date"))
return True
with EmergeParser(EmergeCommand(list(packages),
extra_params=param)) as emerge:
@@ -448,6 +450,9 @@ class Update:
return True

def _emerge_translate(self, s):
"""
Перевести текст из emerge
"""
return RegexpLocalization('cl_emerge').translate(str(s))

def setUpToDateCache(self):
@@ -457,6 +462,25 @@ class Update:
self.updateCache(PackageList([]))
return True

def _startEmerging(self, emerge):
"""
Настроить и выполнить emerge
"""
emerge.command.send("yes\n")
emerge.emerging.add_observer(self._printEmergePackage)
emerge.installing.add_observer(self._printInstallPackage)
emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
self.emerge_cache.drop_cache()
if emerge.emerging_error:
self.printPre(
self._emerge_translate(emerge.emerging_error.log))
else:
self.printPre(self._emerge_translate(emerge.prepare_error))
raise

def emerge(self, param, *packages):
"""
Выполнить сборку пакета
@@ -475,32 +499,12 @@ class Update:
emerge.question.action = lambda x: False
emerge.run()
if not emerge.install_packages.list:
#self.printSUCCESS(_("Nothing to merge"))
return True
#if ask_emerge:
# self.printPre(str(emerge.install_packages))
except EmergeError:
self.emerge_cache.drop_cache()
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
#if (ask_emerge and self.askConfirm(
# _("Would you like to merge these packages?")) == 'no'):
# raise KeyboardInterrupt
emerge.command.send("yes\n")

emerge.emerging.add_observer(self._printEmergePackage)
emerge.installing.add_observer(self._printInstallPackage)
emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
self.emerge_cache.drop_cache()
if emerge.emerging_error:
self.printPre(
self._emerge_translate(emerge.emerging_error.log))
else:
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
self._startEmerging(emerge)
return True

def depclean(self):
@@ -520,14 +524,7 @@ class Update:
if (self.askConfirm(
_("Would you like to unmerge these packages?")) == 'no'):
return False
emerge.command.send("yes\n")

emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
self.printPre(self._emerge_translate(emerge.emerging_error.log))
raise
self._startEmerging(emerge)
return True

def update_task(self, task_name):
@@ -536,10 +533,10 @@ class Update:
"""

def decor(f):
def wrapper(self, *args, **kwargs):
def wrapper(*args, **kwargs):
logger = EmergeLog(EmergeLogNamedTask(task_name))
logger.mark_begin_task()
ret = f(self, *args, **kwargs)
ret = f(*args, **kwargs)
if ret:
logger.mark_end_task()
return ret


+ 21
- 14
update/utils/cl_update.py View File

@@ -58,6 +58,7 @@ class ClUpdateAction(Action):
'python_updater': "update python modules",
'perl_cleaner': "update perl modules",
'kernel_modules': "update kernel modules",
'depclean': "depclean",
'xorg_modules': "update xorg modules",
'preserved_libs': "update preserved libs",
'revdep': "revdep rebuild"}
@@ -76,8 +77,12 @@ class ClUpdateAction(Action):
'condition': lambda Get:Get('cl_update_pretend_set') == 'off',
'depend': Tasks.result("premerge", eq='yes')
},
{'name': 'update_other',
'condition': lambda Get: ( Get('cl_update_pretend_set') == 'off' and
Get('cl_update_sync_only_set') == 'off')
},
{'name': 'update:update_portage',
'group': __("Updating portage"),
'group': __("Updating Portage"),
'tasks': [
{'name': 'update:update_portage_pkg',
'message': __("Updating {0}").format(
@@ -88,7 +93,7 @@ class ClUpdateAction(Action):
]
},
{'name': 'update:update_python',
'group': __("Updating python"),
'group': __("Updating Python"),
'tasks': [
{'name': 'update:update_python_pkg',
'message': __('Updating {0}').format(
@@ -97,7 +102,7 @@ class ClUpdateAction(Action):
'condition': need_upgrade('dev-lang/python$')
},
{'name': 'update:python_updater',
'message': __('Updating python modules'),
'message': __('Updating Python modules'),
'method': 'Update.emergelike("python-updater")',
'condition': was_installed('dev-lang/python$',
log_names['python_updater']),
@@ -115,7 +120,7 @@ class ClUpdateAction(Action):
'condition': need_upgrade('dev-lang/perl$')
},
{'name': 'update:perl_cleaner',
'message': __('Updating perl modules'),
'message': __('Updating Perl modules'),
'method': 'Update.emergelike("perl-cleaner", "all")',
'condition': was_installed('dev-lang/perl$',
log_names['perl_cleaner']),
@@ -136,7 +141,7 @@ class ClUpdateAction(Action):
]
},
{'name': 'update:update_world',
'group': __("Updating all packages"),
'group': __("Updating packages"),
'tasks': [
{'name': 'update:update_world',
'message': __("Calculating dependencies"),
@@ -144,42 +149,44 @@ class ClUpdateAction(Action):
}
]
},
{'name': 'update:depclean',
{'name': 'update_other:depclean',
'group': __("Cleaning system from needless packages"),
'tasks': [
{'name': 'update:update_depclean',
{'name': 'update_other:update_depclean',
'message': __("Emerge depclean"),
'method': 'Update.depclean()',
'condition': was_installed('.*', log_names['depclean']),
'decoration': 'Update.update_task("%s")' % log_names['depclean']
},
]
},
{'name': 'update:update_modules',
{'name': 'update_other:update_modules',
'group': __("Rebuilding dependent modules"),
'tasks': [
{'name': 'update:module_rebuild',
'message': __('Updating kernel modules'),
{'name': 'update_other:module_rebuild',
'message': __('Updating Kernel modules'),
'method': 'Update.emerge("@module-rebuild")',
'condition': was_installed('sys-kernel/.*source',
log_names['kernel_modules']),
'decoration': 'Update.update_task("%s")' % log_names[
'kernel_modules']
},
{'name': 'update:x11_module_rebuild',
'message': __('Updating xorg-server modules'),
{'name': 'update_other:x11_module_rebuild',
'message': __('Updating X.Org server modules'),
'method': 'Update.emerge("@x11-module-rebuild")',
'condition': was_installed('x11-base/xorg-server',
log_names['xorg_modules']),
'decoration': 'Update.update_task("%s")' % log_names[
'xorg_modules']
},
{'name': 'update:preserved_rebuild',
{'name': 'update_other:preserved_rebuild',
'message': __('Updating preserved libraries'),
'method': 'Update.emerge("@preserved-rebuild")',
'condition': was_installed('.*', log_names['preserved_libs']),
'decoration': 'Update.update_task("%s")' % log_names[
'preserved_libs']
},
{'name': 'update:revdev_rebuild',
{'name': 'update_other:revdev_rebuild',
'message': __('Checking reverse dependencies'),
'method': 'Update.revdep_rebuild("revdep-rebuild")',
'condition': was_installed('.*', log_names['revdep']),


Loading…
Cancel
Save