Добавлен dispatch-conf при обновлении

master3.3 3.2.0_alpha11
Mike khiretskiy 10 年前
父节点 66cab50865
当前提交 e35caccf3b

@ -21,6 +21,7 @@ from os import path
import os
import time
from calculate.core.server.gen_pid import search_worked_process, ProcessStatus
from calculate.lib.cl_template import SystemIni
from calculate.lib.utils.tools import AddonError
from calculate.lib.utils.colortext.palette import TextState
@ -296,8 +297,8 @@ class Update:
"""
self.endTask()
_print = self.color_print
one = _print.bold("{0}", num)
two = _print.bold("{0}", max_num)
one = _print("{0}", num)
two = _print("{0}", max_num)
part = _(" ({current} of {maximum})").format(current=one,
maximum=two)
if self.is_binary_pkg(pkg,binary):
@ -336,15 +337,15 @@ class Update:
"""
self.endTask()
_print = self.color_print
one = _print.bold("{0}", num)
two = _print.bold("{0}", max_num)
one = _print("{0}", num)
two = _print("{0}", max_num)
part = _(" ({current} of {maximum})").format(current=one,
maximum=two)
_print = _print.foreground(Colors.RED)
_print = _print.foreground(Colors.LIGHT_RED)
self.startTask(
_("Unmerging{part} {package}").format(part=part,
package=_print.bold(str(pkg))))
package=_print(str(pkg))))
def emergelike(self, cmd, *params):
"""
@ -485,6 +486,7 @@ class Update:
if not packages:
self.printSUCCESS(_("Installed packages are up to date"))
self.set_need_update(False)
return True
with EmergeParser(EmergeCommand(list(packages),
extra_params=param)) as emerge:
@ -498,14 +500,19 @@ class Update:
self.updateCache(emerge.install_packages.list)
if not emerge.install_packages.list:
self.printSUCCESS(_("The system is up to date"))
self.set_need_update(False)
return True
self._display_install_package(emerge)
except EmergeError:
self.set_need_update(False)
self.emerge_cache.drop_cache("Emerge error")
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
if self.clVars.Get('cl_update_pretend_set') == 'on':
# установить кэш: есть обновления
self.set_need_update()
return True
self.set_need_update(False)
answer = self.askConfirm(
_("Would you like to merge these packages?"), "yes")
if answer == "no":
@ -513,6 +520,14 @@ class Update:
return "yes"
return True
def set_need_update(self, val=True):
"""
Установить флаг: есть обновления
"""
val = "on" if val else "off"
SystemIni().setVar('update', {'packages': val})
return True
def _emerge_translate(self, s):
"""
Перевести текст из emerge

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
# Copyright 2012-2013 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from itertools import ifilter
from calculate.core.datavars import DataVarsCore
from calculate.core.server.gen_pid import search_worked_process
from calculate.lib.cl_template import SystemIni
from calculate.lib.utils.content import getCfgFiles
from calculate.lib.utils.files import getRunCommands
class UpdateInfo(object):
"""
Информационный объект о процессе обновления
"""
def __init__(self, dv=None):
if dv is None:
self.dv = DataVarsCore()
self.dv.importCore()
else:
self.dv = dv
def need_update(self):
return self.update_ready() or self.check_for_dispatch()
def update_ready(self):
"""
Проверить есть ли обновления по ini.env
"""
return SystemIni().getVar('update', 'packages') == u'on'
def check_for_dispatch(self):
"""
Есть ли в системе не примененные файлы для dispatch-conf
"""
return bool(getCfgFiles(self.dv.Get('cl_config_protect'),
prefix=self.dv.Get('cl_chroot_path')))
def is_console_gui_run(self):
"""
Проверить есть ли уже запущенная копия console-gui
"""
return any(ifilter(lambda x: "cl-console-gui" in x, getRunCommands()))
def update_already_run(self):
"""
В системе уже есть работающий процесс обновления
"""
return search_worked_process("update", self.dv)

@ -266,17 +266,24 @@ class ClUpdateAction(Action):
{'name': 'revision',
'message': __("Fixing the settings"),
'method': 'Update.applyTemplates(install.cl_source,'
'cl_template_clt_set,True,None)',
'cl_template_clt_set,True,None,False)',
'condition': lambda Get: (Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on')
},
{'name': 'world',
'message': __("Updating the list of system packages"),
'method': 'Update.applyTemplates(install.cl_source,'
'cl_template_clt_set,True,None)',
'cl_template_clt_set,True,None,False)',
'condition': lambda Get: (Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on')
},
{'name': 'dispatch_conf',
'message': __("Updating configuration files"),
'method':'Update.dispatchConf()',
'condition': lambda Get: ((Get('cl_update_rev_set') == 'on' or
Get('cl_rebuild_world_set') == 'on') and
Get('cl_update_pretend_set') == 'off')
},
]
}
] + emerge_tasks + [

正在加载...
取消
保存