Browse Source

Добавлен вызов depclean при cl-update если в предыдущий раз

оставалось неудаленное ядро
master3.3
Mike Khiretskiy 7 years ago
parent
commit
cbe42e3d52
  1. 7
      pym/update/update.py
  2. 29
      pym/update/update_info.py
  3. 9
      pym/update/utils/cl_update.py
  4. 17
      pym/update/variables/update.py

7
pym/update/update.py

@ -833,10 +833,12 @@ class Update(object):
try:
emerge = EmergeParser(EmergeCommand(["--depclean"],
emerge_default_opts=deo))
outdated_kernel = False
try:
emerge.question.action = lambda x: False
emerge.run()
if not emerge.uninstall_packages.list:
UpdateInfo(self.clVars).outdated_kernel = False
return True
kernel_pkg = self.clVars.Get('cl_update_kernel_pkg')
if any(("%s-%s" % (x['CATEGORY/PN'], x['PVR'])) == kernel_pkg
@ -850,6 +852,7 @@ class Update(object):
emerge.close()
emerge = None
if not pkglist:
UpdateInfo(self.clVars).outdated_kernel = True
return True
emerge = EmergeParser(
EmergeCommand(pkglist,
@ -857,6 +860,9 @@ class Update(object):
emerge_default_opts=deo))
emerge.question.action = lambda x: False
emerge.run()
outdated_kernel = True
else:
outdated_kernel = False
self._display_remove_list(emerge)
except EmergeError:
self._display_error(emerge.prepare_error)
@ -864,6 +870,7 @@ class Update(object):
if (self.askConfirm(
_("Would you like to unmerge these packages?")) != 'yes'):
return False
UpdateInfo(self.clVars).outdated_kernel = outdated_kernel
self._startEmerging(emerge)
finally:
if emerge:

29
pym/update/update_info.py

@ -14,12 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from os import path
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
from calculate.lib.utils.files import getRunCommands, readFile
import time
class UpdateInfo(object):
@ -72,3 +75,27 @@ class UpdateInfo(object):
В системе уже есть работающий процесс обновления
"""
return search_worked_process("update", self.dv)
@property
def outdated_kernel(self):
flag_path = self.dv.Get('cl_update_outdated_kernel_path')
if path.exists(flag_path):
try:
flag_kernel = readFile(flag_path).strip()
current_kernel = self.dv.Get('update.cl_update_kernel_version')
if flag_kernel != current_kernel:
return True
except ValueError:
pass
return False
@outdated_kernel.setter
def outdated_kernel(self, value):
flag_path = self.dv.Get('cl_update_outdated_kernel_path')
if value:
with open(flag_path, 'w') as f:
f.write(self.dv.Get('update.cl_update_kernel_version'))
else:
if path.exists(flag_path):
os.unlink(flag_path)

9
pym/update/utils/cl_update.py

@ -45,6 +45,13 @@ class ClUpdateAction(Action):
return bool(PackageList(task.list)[pkg])
return func
def need_depclean(pkg, task_name):
def func(Get):
task = EmergeLog(EmergeLogNamedTask(task_name))
return (bool(PackageList(task.list)[pkg])
or Get('cl_update_outdated_kernel_set') == 'on')
return func
def need_upgrade(pkg):
def func():
return bool(Eix(pkg, Eix.Option.Upgrade).get_packages())
@ -124,7 +131,7 @@ class ClUpdateAction(Action):
{'name': 'update_other:update_depclean',
'message': __("Calculating dependencies"),
'method': 'Update.depclean()',
'condition': was_installed('.*', log_names['depclean']),
'condition': need_depclean('.*', log_names['depclean']),
'decoration': 'Update.update_task("%s")' % log_names['depclean']
},
]

17
pym/update/variables/update.py

@ -33,6 +33,7 @@ from calculate.update.profile import RepositoryStorageSet, DEFAULT_BRANCH
from calculate.lib.variables.linux import VariableOsLinuxName, \
VariableOsLinuxSubname, VariableOsLinuxVer, VariableOsLinuxShortname
from calculate.lib.variables.env import VariableClTemplateLocation
from calculate.update.update_info import UpdateInfo
setLocalTranslate('cl_update3', sys.modules[__name__])
@ -1087,3 +1088,19 @@ class VariableClUpdateCleanpkgSet(Variable):
def init(self):
self.label = _("Clean obsolete programs archives")
self.help = _("clean obsolete programs archives")
class VariableClUpdateOutdatedKernelPath(Variable):
"""
Файл-флаг наличия устаревшего, неудаленного ядра
"""
value = "/var/lib/calculate/calculate-update/outdated_kernel"
class VariableClUpdateOutdatedKernelSet(ReadonlyVariable):
"""
Есть наличие устаревшего ядра
"""
type = "bool"
def get(self):
ui = UpdateInfo(self.parent)
return "on" if ui.outdated_kernel else "off"
Loading…
Cancel
Save