Compare commits

..

No commits in common. 'master' and 'develop' have entirely different histories.

6
.gitignore vendored

@ -1,6 +0,0 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# если выполняется обновление уже полученного репозитория # если выполняется обновление уже полученного репозитория
if [[ $1 == "pull" ]] || [[ $1 == "remote" ]] if [[ $1 == "pull" ]]
then then
# получить название репозитория # получить название репозитория
if [[ -f profiles/repo_name ]] if [[ -f profiles/repo_name ]]
@ -20,11 +20,8 @@ native_reps=,$(/usr/libexec/calculate/cl-variable --value update.cl_update_rep_
# если обновляемый репозиторий от дистрибутива # если обновляемый репозиторий от дистрибутива
if echo $native_reps | grep -q ,${repo_name}, if echo $native_reps | grep -q ,${repo_name},
then then
if [[ $1 == "pull" ]] # отбновить репозиторий через утилиты Calculate
then /usr/sbin/cl-core --method update --rep $repo_name --sync-only on --skip-eix-update -T none
# отбновить репозиторий через утилиты Calculate
/usr/sbin/cl-core --method update --rep $repo_name --sync-only on --skip-eix-update -T none
fi
else else
# выполнить обновление через git # выполнить обновление через git
/usr/bin/git $* /usr/bin/git $*

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2012-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -55,7 +55,7 @@ class EmergeNeedRootError(EmergeError):
pass pass
class CommandExecutor(): class CommandExecutor(object):
""" """
Запуск программы для объекта Emerge Запуск программы для объекта Emerge
""" """
@ -75,28 +75,21 @@ class CommandExecutor():
def get_command(self): def get_command(self):
return [self.cmd] + list(self.params) return [self.cmd] + list(self.params)
#TODO make sure pexpect encoding doesn't mess up anything
#if it does, instead put log file as binary maybe?
def execute(self): def execute(self):
if self.child is None: if self.child is None:
command_data = self.get_command() command_data = self.get_command()
self.child = pexpect.spawn(command_data[0], command_data[1:], self.child = pexpect.spawn(command_data[0], command_data[1:],
logfile=open(self.logfile, 'w'), logfile=open(self.logfile, 'w'),
env=self.env, cwd=self.cwd, timeout=None, env=self.env, cwd=self.cwd, timeout=None)
encoding="UTF-8", codec_errors='ignore')
return self.child return self.child
def close(self): def close(self):
if self.child is not None: if self.child is not None:
try: self.child.close()
self.child.close()
except pexpect.ExceptionPexpect:
self.child.close(force=True)
self.child = None self.child = None
def success(self): def success(self):
if self.child: if self.child:
self.child.read()
if self.child.isalive(): if self.child.isalive():
self.child.wait() self.child.wait()
return self.child.exitstatus == 0 return self.child.exitstatus == 0
@ -119,8 +112,7 @@ class EmergeCommand(CommandExecutor):
emerge_cmd = getProgPath("/usr/bin/emerge") emerge_cmd = getProgPath("/usr/bin/emerge")
def __init__(self, packages, extra_params=None, env=None, cwd=None, def __init__(self, packages, extra_params=None, env=None, cwd=None,
logfile=None, emerge_default_opts=None, env_update=None, logfile=None, emerge_default_opts=None, use=""):
use=""):
extra_params = extra_params or [] extra_params = extra_params or []
if env is None: if env is None:
if emerge_default_opts is None: if emerge_default_opts is None:
@ -135,11 +127,9 @@ class EmergeCommand(CommandExecutor):
if use: if use:
env["USE"] = use env["USE"] = use
env.update(os.environ) env.update(os.environ)
if env_update is not None:
env.update(env_update)
params = self.default_params + extra_params + packages params = self.default_params + extra_params + packages
super().__init__(self.emerge_cmd, params=params, super(EmergeCommand, self).__init__(self.emerge_cmd, params=params,
env=env, cwd=cwd, logfile=logfile) env=env, cwd=cwd, logfile=logfile)
@ -178,7 +168,7 @@ def Linux32(obj):
return obj return obj
class InfoBlockInterface(): class InfoBlockInterface(object):
""" """
Интерфейс для информационного блока Интерфейс для информационного блока
""" """
@ -287,7 +277,7 @@ class InstallPackagesBlock(EmergeInformationBlock):
re_blocks = re.compile(r"\[{c}blocks{c} {c}b".format(c=_color_block)) re_blocks = re.compile(r"\[{c}blocks{c} {c}b".format(c=_color_block))
def get_data(self, match): def get_data(self, match):
super().get_data(match) super(InstallPackagesBlock, self).get_data(match)
list_block = XmlConverter().transform(self.result).split('\n') list_block = XmlConverter().transform(self.result).split('\n')
self.list = PackageList(map(EmergeUpdateInfo, list_block)) self.list = PackageList(map(EmergeUpdateInfo, list_block))
self.remove_list = PackageList(map(EmergeRemoveInfo, list_block)) self.remove_list = PackageList(map(EmergeRemoveInfo, list_block))
@ -517,7 +507,7 @@ class NotifierInformationBlock(EmergeInformationBlock):
Информационный блок поддерживающий observing Информационный блок поддерживающий observing
""" """
def __init__(self, parent): def __init__(self, parent):
super().__init__(parent) super(NotifierInformationBlock, self).__init__(parent)
self.observers = [] self.observers = []
def get_data(self, match): def get_data(self, match):
@ -722,7 +712,7 @@ class EmergeParser(InfoBlockInterface):
while True: while True:
index = child.expect_exact(self.elements.keys()) index = child.expect_exact(self.elements.keys())
element = list(self.elements.values())[index] element = self.elements.values()[index]
element.get_block(child) element.get_block(child)
if element.action: if element.action:
if element.action(child) is False: if element.action(child) is False:
@ -738,7 +728,7 @@ class EmergeParser(InfoBlockInterface):
self.close() self.close()
class MtimeCheckvalue(): class MtimeCheckvalue(object):
def __init__(self, *fname): def __init__(self, *fname):
self.fname = fname self.fname = fname
@ -760,21 +750,21 @@ class MtimeCheckvalue():
class Md5Checkvalue(MtimeCheckvalue): class Md5Checkvalue(MtimeCheckvalue):
def value_func(self, fn): def value_func(self, fn):
return hashlib.md5(readFile(fn, binary=True)).hexdigest() return hashlib.md5(readFile(fn)).hexdigest()
class GitCheckvalue(): class GitCheckvalue(object):
def __init__(self, git, rpath): def __init__(self, rpath):
self.rpath = rpath self.rpath = rpath
self.git = git self.git = Git()
def checkvalues(self): def checkvalues(self):
with ignore(GitError): with ignore(GitError):
if self.git.is_git(self.rpath): if self.git.is_git(self.rpath):
yield self.rpath, self.git.getCurrentCommit(self.rpath) yield self.rpath, Git().getCurrentCommit(self.rpath)
class EmergeCache(): class EmergeCache(object):
""" """
Кэш пакетов Кэш пакетов
""" """

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2014-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2014-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -15,20 +15,19 @@
# limitations under the License. # limitations under the License.
import sys import sys
import os
from os import path from os import path
import shutil import shutil
from calculate.lib.utils.files import (listDirectory, readFile, readLinesFile, from calculate.lib.utils.files import (listDirectory, readFile, readLinesFile,
makeDirectory, removeDir) makeDirectory, removeDir)
from calculate.lib.utils.git import Git from calculate.lib.utils.git import Git
from .update import UpdateError from update import UpdateError
from calculate.lib.cl_lang import setLocalTranslate, _ from calculate.lib.cl_lang import setLocalTranslate, _
setLocalTranslate('cl_update3', sys.modules[__name__]) setLocalTranslate('cl_update3', sys.modules[__name__])
DEFAULT_BRANCH = Git.Reference.Master DEFAULT_BRANCH = Git.Reference.Master
class RepositoryStorageInterface(): class RepositoryStorageInterface(object):
def __iter__(self): def __iter__(self):
raise StopIteration raise StopIteration
@ -41,15 +40,15 @@ class RepositoryStorageInterface():
class RepositoryStorage(RepositoryStorageInterface): class RepositoryStorage(RepositoryStorageInterface):
directory = '/tmp' directory = '/tmp'
def __init__(self, git, directory): def __init__(self, directory):
self.directory = directory self.directory = directory
self.git = git
makeDirectory(directory) makeDirectory(directory)
def __iter__(self): def __iter__(self):
git = Git()
for dn in listDirectory(self.directory, onlyDir=True, fullPath=True): for dn in listDirectory(self.directory, onlyDir=True, fullPath=True):
if self.git.is_git(dn): if git.is_git(dn):
yield ProfileRepository(self.git, path.basename(dn), self) yield ProfileRepository(path.basename(dn), self)
def get_profiles(self, url, branch=DEFAULT_BRANCH): def get_profiles(self, url, branch=DEFAULT_BRANCH):
return [] return []
@ -90,8 +89,7 @@ class CacheStorage(ProfileStorage):
if rep.is_like(url, branch): if rep.is_like(url, branch):
return rep return rep
else: else:
return ProfileRepository.clone(self.git, url, self, return ProfileRepository.clone(url, self, branch)
branch or DEFAULT_BRANCH)
class RepositoryStorageSet(RepositoryStorageInterface): class RepositoryStorageSet(RepositoryStorageInterface):
""" """
@ -122,10 +120,6 @@ class RepositoryStorageSet(RepositoryStorageInterface):
for rep in self: for rep in self:
if rep.is_like(url, branch): if rep.is_like(url, branch):
return rep return rep
for storage in self.storages:
rep = storage.get_repository(url, branch)
if rep:
return rep
return None return None
def is_local(self, url, branch=DEFAULT_BRANCH): def is_local(self, url, branch=DEFAULT_BRANCH):
@ -141,7 +135,7 @@ class RepositoryStorageSet(RepositoryStorageInterface):
def __repr__(self): def __repr__(self):
return "Repository set" return "Repository set"
class Profile(): class Profile(object):
""" """
Профиль репозитория Профиль репозитория
""" """
@ -151,22 +145,14 @@ class Profile():
self.repository = repository self.repository = repository
self.profile = profile self.profile = profile
self.arch = arch self.arch = arch
self._path = None
@property @property
def path(self): def path(self):
if self._path:
return self._path
return path.join(self.repository.directory,"profiles", self.profile) return path.join(self.repository.directory,"profiles", self.profile)
@path.setter
def path(self, value):
self._path = value
return value
@classmethod @classmethod
def from_string(cls, repository, s): def from_string(cls, repository, s):
parts = [x for x in s.split() if x] parts = filter(None, s.split())
if len(parts) == 3 and parts[0] in cls.available_arch: if len(parts) == 3 and parts[0] in cls.available_arch:
return Profile(repository, parts[1], parts[0]) return Profile(repository, parts[1], parts[0])
return None return None
@ -178,14 +164,13 @@ class Profile():
self.repository.directory) self.repository.directory)
class ProfileRepository(): class ProfileRepository(object):
""" """
Репозиторий либо скачивается, либо берется из кэша Репозиторий либо скачивается, либо берется из кэша
""" """
def __init__(self, git, name, storage): def __init__(self, name, storage):
self._storage = storage self._storage = storage
self.name = name self.name = name
self.git = git
@property @property
def storage(self): def storage(self):
@ -207,28 +192,23 @@ class ProfileRepository():
str(e)) str(e))
@classmethod @classmethod
def clone(cls, git, url, storage, branch=DEFAULT_BRANCH): def clone(cls, url, storage, branch=DEFAULT_BRANCH):
name = path.basename(url) name = path.basename(url)
if name.endswith(".git"): if name.endswith(".git"):
name = name[:-4] name = name[:-4]
git = Git()
rpath = path.join(storage.directory, name) rpath = path.join(storage.directory, name)
if path.exists(rpath): if path.exists(rpath):
removeDir(rpath) removeDir(rpath)
if git.is_private_url(url):
try:
makeDirectory(rpath)
os.chmod(rpath, 0o700)
except OSError:
pass
git.cloneRepository(url, rpath, branch) git.cloneRepository(url, rpath, branch)
pr = cls(git, name, storage) pr = cls(name, storage)
repo_name = pr.repo_name repo_name = pr.repo_name
if name != repo_name: if name != repo_name:
rpath_new = path.join(storage.directory, repo_name) rpath_new = path.join(storage.directory, repo_name)
if path.exists(rpath_new): if path.exists(rpath_new):
removeDir(rpath_new) removeDir(rpath_new)
shutil.move(rpath, rpath_new) shutil.move(rpath, rpath_new)
pr = cls(git, repo_name, storage) pr = cls(repo_name, storage)
return pr return pr
@property @property
@ -250,32 +230,30 @@ class ProfileRepository():
@property @property
def url(self): def url(self):
return self.git.get_url(self.directory, "origin") git = Git()
return git.get_url(self.directory, "origin")
@property @property
def branch(self): def branch(self):
return self.git.getBranch(self.directory) git = Git()
return git.getBranch(self.directory)
def sync(self): def sync(self):
""" """
Синхронизировать репозиторий Синхронизировать репозиторий
""" """
if not self.git.pullRepository(self.directory, quiet_error=True): git = Git()
self.git.resetRepository(self.directory, to_origin=True) if not git.pullRepository(self.directory, quiet_error=True):
self.git.pullRepository(self.directory, quiet_error=True) git.resetRepository(self.directory, to_origin=True)
git.pullRepository(self.directory, quiet_error=True)
def get_profiles(self): def get_profiles(self):
""" """
Получить список профилей репозитория Получить список профилей репозитория
""" """
profiles_desc = path.join(self.directory, "profiles/profiles.desc") profiles_desc = path.join(self.directory, "profiles/profiles.desc")
return list(filter(None, (Profile.from_string(self, line) return filter(None, (Profile.from_string(self, line)
for line in readLinesFile(profiles_desc)))) for line in readLinesFile(profiles_desc)))
@staticmethod
def get_local_profiles(directory):
profiles_desc = path.join(directory, "profiles/profiles.desc")
return list(filter(None, (Profile.from_string(Profile, line)
for line in readLinesFile(profiles_desc))))
def __repr__(self): def __repr__(self):
return "<ProfileRepository %s url=%s>" % (self.directory, self.url) return "<ProfileRepository %s url=%s>" % (self.directory, self.url)

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2012-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
import os import os
from os import path from os import path
from itertools import ifilter
from calculate.core.datavars import DataVarsCore from calculate.core.datavars import DataVarsCore
from calculate.core.server.gen_pid import search_worked_process from calculate.core.server.gen_pid import search_worked_process
from calculate.lib.cl_template import SystemIni from calculate.lib.cl_template import SystemIni
@ -23,11 +24,12 @@ from calculate.lib.utils.content import getCfgFiles
from calculate.lib.utils.files import getRunCommands, readFile, writeFile from calculate.lib.utils.files import getRunCommands, readFile, writeFile
class UpdateInfo(): class UpdateInfo(object):
""" """
Информационный объект о процессе обновления Информационный объект о процессе обновления
""" """
update_file = "/var/lib/calculate/calculate-update/updates.available" section = "update"
varname = "updates"
def __init__(self, dv=None): def __init__(self, dv=None):
if dv is None: if dv is None:
@ -44,20 +46,15 @@ class UpdateInfo():
""" """
Проверить есть ли обновления по ini.env Проверить есть ли обновления по ini.env
""" """
return path.exists(cls.update_file) return SystemIni().getVar(cls.section, cls.varname) == u'on'
@classmethod @classmethod
def set_update_ready(cls, value): def set_update_ready(cls, value):
""" """
Установить статус обновления Установить статус обновления
""" """
try: SystemIni().setVar(cls.section,
if value: {cls.varname:"on" if value else "off"})
writeFile(cls.update_file).close()
else:
os.unlink(cls.update_file)
except OSError:
pass
def check_for_dispatch(self): def check_for_dispatch(self):
""" """
@ -70,7 +67,7 @@ class UpdateInfo():
""" """
Проверить есть ли уже запущенная копия console-gui Проверить есть ли уже запущенная копия console-gui
""" """
return any([x for x in getRunCommands() if "cl-console-gui" in x]) return any(ifilter(lambda x: "cl-console-gui" in x, getRunCommands()))
def update_already_run(self): def update_already_run(self):
""" """

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -25,5 +25,3 @@ class EmergeMark:
PreservedLibs = "update preserved libs" PreservedLibs = "update preserved libs"
RevdepRebuild = "revdep rebuild" RevdepRebuild = "revdep rebuild"
Prelink = "prelink" Prelink = "prelink"
Automagic = "check for auto depends"
SaveTag = "save latest calculate update tag"

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2010-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2010-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ import sys
from calculate.core.server.func import Action from calculate.core.server.func import Action
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from calculate.lib.utils.files import FilesError from calculate.lib.utils.files import FilesError
from ..update import UpdateError from calculate.update.update import UpdateError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
_ = lambda x: x _ = lambda x: x

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2010-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2010-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -15,251 +15,23 @@
# limitations under the License. # limitations under the License.
import sys import sys
from calculate.core.server.func import Action, Tasks, AllTasks from calculate.core.server.func import Action, Tasks
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from calculate.lib.cl_template import TemplatesError from calculate.lib.cl_template import TemplatesError
from calculate.lib.utils.binhosts import BinhostError from calculate.lib.utils.files import FilesError
from calculate.lib.utils.files import FilesError, readFile from calculate.update.update import UpdateError
from ..update import UpdateError from calculate.update.emerge_parser import EmergeError
from ..emerge_parser import EmergeError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
from calculate.lib.utils.portage import (EmergeLog, isPkgInstalled, from calculate.lib.utils.portage import (EmergeLog,
EmergeLogNamedTask, PackageList) EmergeLogNamedTask, PackageList)
from ..update_tasks import EmergeMark from calculate.update.update_tasks import EmergeMark
_ = lambda x: x _ = lambda x: x
setLocalTranslate('cl_update3', sys.modules[__name__]) setLocalTranslate('cl_update3', sys.modules[__name__])
__ = getLazyLocalTranslate(_) __ = getLazyLocalTranslate(_)
def get_synchronization_tasks(object_name): class UpdateConditions(object):
Object = lambda s: "%s.%s"%(object_name, s)
return [
{'name': 'reps_synchronization',
'group': __("Repositories synchronization"),
'tasks': [
# создать объект проверки PGP
{'name': 'prepare_gpg',
'method': Object("prepare_gpg()"),
},
# создать объект хранилище серверов обновлений
{'name': 'create_binhost_data',
'method': Object('create_binhost_data()')
},
{
'name': 'perform_migration_system_pre_check',
'method': Object('perform_migration_system_pre_check()'),
'condition': lambda Get, GetBool: (Get('cl_update_ignore_level') == 'off')
},
# проверить валиден ли текущий хост
{'name': 'check_current_binhost',
'message': __("Checking current binhost"),
'essential': False,
'method': Object('check_current_binhost(update.cl_update_binhost)'),
'condition': lambda GetBool, Get: (
not GetBool('update.cl_update_binhost_recheck_set') and
not Get('update.cl_update_binhost_choice') and
Get('update.cl_update_binhost_choice') != 'auto' and
Get('update.cl_update_sync_rep') and
Get('update.cl_update_binhost') and
Get('update.cl_update_use_migration_host') == 'off')
},
{'name': 'drop_packeges_cache',
'method': 'Update.drop_packages_cache()',
'depend': AllTasks.failed_all("check_current_binhost")
},
{'name': 'not_use_search:failed_base_binhost',
'error': __("Failed to use base binhost"),
'method': Object("delete_binhost()"),
'depend': AllTasks.failed_all("check_current_binhost")
},
{'name': 'check_chosen_binhost',
'message': _("Checking chosen binhost"),
'method': Object('check_chosen_binhost(update.cl_update_binhost_choice)'),
'essential': False,
'condition': lambda GetBool, Get: (
not GetBool('update.cl_update_binhost_recheck_set') and
Get('update.cl_update_binhost_choice') and
Get('update.cl_update_binhost_choice') != 'auto'),
'depend': AllTasks.hasnot("check_current_binhost")},
{'name': 'failed_check_chosen_binhost',
'method': Object('check_if_migration()'),
'depend': AllTasks.failed_all("check_chosen_binhost")},
{'name': 'group_find_binhost',
'group': '',
'while': (~AllTasks.has_any("detect_best_binhost") &
((AllTasks.failed_all("update_packages_cache")
& ~AllTasks.has_any("not_use_search")) |
~AllTasks.has_any("sync_reps"))) & Tasks.success(),
'condition': lambda GetBool, Get: (GetBool('update.cl_update_usetag_set') and
Get('update.cl_update_sync_rep')),
'tasks': [
# найти лучший сервер обновлений
{'name': 'detect_best_binhost',
'method': Object(f'detect_best_binhost({object_name.lower()}.cl_update_ignore_level)'),
'essential': False,
'depend': (Tasks.success() & ~AllTasks.has_any("not_use_search") &
(AllTasks.failed_one_of("check_current_binhost") |
AllTasks.failed_one_of("check_chosen_binhost") |
(AllTasks.hasnot("check_current_binhost") &
AllTasks.hasnot("check_chosen_binhost")) |
AllTasks.success_all("sync_reps"))),
'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'off',
},
{'name': 'interrupt_on_no_leveled_binhost',
'method': Object("interrupt_on_no_leveled_binhost()"),
'essential': True,
'depend': (Tasks.success() & ~AllTasks.has_any("not_use_search") &
(~AllTasks.success_one_of("check_current_binhost")) &
AllTasks.failed_all("detect_best_binhost")),
'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'off'
},
{'name': 'set_migration_binhost',
'method': Object('set_migration_host()'),
'depend': (Tasks.success() & ~AllTasks.has_any("not_use_search")|
AllTasks.success_all("sync_reps")),
'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'on'
},
# запасная синхронизация, в ходе которой ветки обновляются до
# master
# {'name': 'sync_reps_fallback',
# 'foreach': 'update.cl_update_sync_rep',
# 'message':
# __("Fallback syncing the {eachvar:capitalize} repository"),
# 'method': Object('syncRepositories(eachvar,True)'),
# 'depend': Tasks.success() & AllTasks.failed_one_of("detect_best_binhost"),
# },
# # обновление переменных информации из binhost
# {'name': 'sync_reps_fallback:update_binhost_list',
# 'method': Object('update_binhost_list()'),
# 'depend': Tasks.success() & AllTasks.failed_one_of("detect_best_binhost"),
# },
# # найти лучший сервер обновлений
# {'name': 'sync_reps_fallback:detect_best_binhost',
# 'method': Object('detect_best_binhost()'),
# 'depend': Tasks.success() & AllTasks.failed_one_of("detect_best_binhost"),
# },
{'name': 'sync_reps',
'foreach': 'update.cl_update_sync_rep',
'message': __("Checking {eachvar:capitalize} updates"),
'method': Object('syncRepositories(eachvar)'),
'condition': lambda Get: Get('update.cl_update_sync_rep'),
'depend': Tasks.success() & ~AllTasks.success_all("update_packages_cache")
},
{'name': 'sync_reps:update_local_info_binhost',
'method': Object('update_local_info_binhost()'),
'condition': lambda Get: Get("update.cl_update_binhost_choice") == 'auto'
or not Get("update.cl_update_binhost_choice")
or Get("update.cl_update_binhost_recheck_set"),
'depend': AllTasks.hasnot('check_chosen_binhost')
},
{'name': 'sync_reps:update_binhost_list',
'essential': False,
'method': Object('update_binhost_list()'),
'condition': lambda GetBool: GetBool('update.cl_update_outdate_set')
},
{'name': 'sync_reps:update_packages_cache',
'message': __("Update packages index"),
'method': Object('download_packages(update.cl_update_portage_binhost,'
'update.cl_update_package_cache, update.cl_update_package_cache_sign,'
'update.cl_update_gpg)'),
'condition': lambda Get, GetBool: (
Get('update.cl_update_package_cache') and (
Get('update.cl_update_outdate_set') == 'on' or
Get('update.cl_update_package_cache_set') == 'on'))
},
],
},
{'name': 'no_server',
'error': __("Failed to find the binary updates server"),
'method': Object("delete_binhost()"),
# method: который должен удалить текущую информацию о сервере обновлений
'depend': (~Tasks.has_any("failed_base_binhost") & (Tasks.failed() |
Tasks.success() & AllTasks.failed_one_of("update_packages_cache"))),
'condition': lambda GetBool, Get: (GetBool('update.cl_update_usetag_set') and
Get('update.cl_update_sync_rep')),
},
{'name': 'sync_reps',
'foreach': 'update.cl_update_sync_rep',
'message': __("Checking {eachvar:capitalize} updates"),
'method': Object('syncRepositories(eachvar)'),
'condition': lambda Get, GetBool: (Get('update.cl_update_sync_rep') and
not GetBool('update.cl_update_usetag_set')),
},
{'name': 'update_rep_list',
'message': __("Repository cache update"),
'method': Object('update_rep_list()'),
'condition': lambda Get: (isPkgInstalled(
"app-eselect/eselect-repository", prefix=Get('cl_chroot_path')) and
Get('cl_chroot_path') != "/"),
'essential': False,
},
{'name': 'sync_other_reps',
'foreach': 'update.cl_update_other_rep_name',
'message': __("Syncing the {eachvar:capitalize} repository"),
'method': Object('syncOtherRepository(eachvar)'),
'condition': lambda GetBool: (GetBool('update.cl_update_other_set') or
not GetBool('update.cl_update_other_git_exists'))
},
{'name': 'trim_reps',
'foreach': 'update.cl_update_sync_rep',
'message': __("Cleaning the history of the "
"{eachvar:capitalize} repository"),
'method': Object('trimRepositories(eachvar)'),
'condition': lambda Get: (Get('update.cl_update_sync_rep') and
Get('update.cl_update_onedepth_set') == 'on')
},
{'name': 'sync_reps:regen_cache',
'foreach': 'update.cl_update_sync_overlay_rep',
'essential': False,
'method': Object('regenCache(eachvar)'),
'condition': (
lambda Get: (Get('update.cl_update_outdate_set') == 'on' and
Get('update.cl_update_egencache_force') != 'skip' or
Get('update.cl_update_egencache_force') == 'force'))
},
{'name': 'sync_other_reps:regen_other_cache',
'foreach': 'update.cl_update_other_rep_name',
'method': Object('regenCache(eachvar)'),
'essential': False,
},
{'name': 'eix_update',
'message': __("Updating the eix cache for "
"{update.cl_update_eix_repositories}"),
'method': Object('eixUpdate(cl_repository_name)'),
'condition': (
lambda Get: (Get('update.cl_update_outdate_set') == 'on' and
Get('update.cl_update_eixupdate_force') != 'skip' or
Get('update.cl_update_eixupdate_force') == 'force'))
},
{'name': 'update_setup_cache',
'message': __("Updating the cache of configurable packages"),
'method': Object('updateSetupCache()'),
'essential': False,
'condition': lambda Get: Get('update.cl_update_outdate_set') == 'on'
},
{'name': 'sync_reps:cleanpkg',
'message': __("Removing obsolete distfiles and binary packages"),
'method': Object('cleanpkg()'),
'condition': (
lambda Get: Get('update.cl_update_cleanpkg_set') == 'on' and
Get('update.cl_update_outdate_set') == 'on'),
'essential': False
},
# сообщение удачного завершения при обновлении репозиториев
{'name': 'success_syncrep',
'message': __("Synchronization finished"),
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
"sync_other_reps",
"emerge_metadata",
"eix_update")),
}
]
},
]
class UpdateConditions():
@staticmethod @staticmethod
def was_installed(pkg, task_name): def was_installed(pkg, task_name):
def func(): def func():
@ -272,26 +44,9 @@ class UpdateConditions():
def func(Get): def func(Get):
task = EmergeLog(EmergeLogNamedTask(task_name)) task = EmergeLog(EmergeLogNamedTask(task_name))
return (bool(PackageList(task.list)[pkg]) return (bool(PackageList(task.list)[pkg])
or Get('cl_update_force_depclean_set') == 'on' or Get('cl_update_outdated_kernel_set') == 'on')
or Get('cl_update_outdated_kernel_set') == 'on'
or Get('cl_update_world_hash_set') == 'on')
return func return func
@staticmethod
def force_preserved(Get):
pfile = "/var/lib/portage/preserved_libs_registry"
content = readFile(pfile).strip()
if not content or content[1:-1].strip() == '':
return False
else:
return True
@staticmethod
def check_world_updated_after_tag_save():
def func():
task = EmergeLog(EmergeLogNamedTask(EmergeMark.SaveTag))
return task.did_update_world_happen()
return func
class ClUpdateAction(Action): class ClUpdateAction(Action):
""" """
@ -299,7 +54,7 @@ class ClUpdateAction(Action):
""" """
# ошибки, которые отображаются без подробностей # ошибки, которые отображаются без подробностей
native_error = (FilesError, UpdateError, native_error = (FilesError, UpdateError,
TemplatesError, BinhostError, TemplatesError,
GitError, EmergeError) GitError, EmergeError)
successMessage = None successMessage = None
@ -307,44 +62,19 @@ class ClUpdateAction(Action):
interruptMessage = __("Update manually interrupted") interruptMessage = __("Update manually interrupted")
emerge_tasks = [ emerge_tasks = [
{'name': 'save_bdeps_val',
'method': 'Update.save_with_bdeps()',
'essential': False
},
{'name': 'update_fastlogin_domain',
'method': "Update.update_fastlogin_domain_path()"
},
{'name': 'drop_portage_hash_on_sync',
'method': 'Update.drop_portage_state_hash()',
'condition': lambda Get: Get('cl_update_outdate_set') == 'on'
},
{'name': 'premerge_group', {'name': 'premerge_group',
'group': __("Checking for updates"), 'group': __("Checking for updates"),
'tasks': [ 'tasks': [
{'name': 'premerge', {'name': 'premerge',
'message': __("Calculating dependencies"), 'message': __("Calculating dependencies"),
'method': 'Update.premerge("-uDN","@world")', 'method': 'Update.premerge("-uDN","--with-bdeps=y","@world")',
'condition': lambda Get: ( 'condition': lambda Get:Get('cl_update_sync_only_set') == 'off'
Get('cl_update_sync_only_set') == 'off' and
Get('cl_update_pretend_set') == 'on') and \
(Get('cl_update_world') != "update" or
Get('cl_update_outdate_set') == 'on' or
Get('cl_update_settings_changes_set') == 'on' or
Get('cl_update_binhost_recheck_set') == 'on' or
Get('cl_update_force_fix_set') == 'on' or
Get('update.cl_update_package_cache_set') == 'on')
}], }],
}, },
{'name': 'update', {'name': 'premerge:update',
'condition': lambda Get:Get('cl_update_pretend_set') == 'off' and \ 'condition': lambda Get:Get('cl_update_pretend_set') == 'off',
(Get('cl_update_world') != "update" or 'depend': Tasks.result("premerge", eq='yes')
Get('cl_update_outdate_set') == 'on' or },
Get('cl_update_settings_changes_set') == 'on' or
Get('cl_update_binhost_recheck_set') == 'on' or
Get('cl_update_force_fix_set') == 'on' or
Get('cl_update_available_set') == 'on' or
Get('update.cl_update_package_cache_set') == 'on')
},
{'name': 'update_other', {'name': 'update_other',
'condition': lambda Get: ( Get('cl_update_pretend_set') == 'off' and 'condition': lambda Get: ( Get('cl_update_pretend_set') == 'off' and
Get('cl_update_sync_only_set') == 'off') Get('cl_update_sync_only_set') == 'off')
@ -352,20 +82,30 @@ class ClUpdateAction(Action):
{'name': 'update:update_world', {'name': 'update:update_world',
'group': __("Updating packages"), 'group': __("Updating packages"),
'tasks': [ 'tasks': [
{'name': 'update_world', {'name': 'update:update_world',
'message': __("Calculating dependencies"), 'message': __("Calculating dependencies"),
'method': 'Update.emerge_ask(cl_update_pretend_set,' 'method': 'Update.emerge("","-uDN","--with-bdeps=y","@world")',
'"-uDN","@world")',
} }
], ]
'condition': lambda Get: (Get('cl_update_sync_only_set') == 'off' and
(Get('update.cl_update_outdate_set') == 'on' or
Get('cl_update_settings_changes_set') == 'on'))
}, },
{'name': 'update_other:update_perl', {'name': 'update:update_python',
'group': __("Updating Perl modules"), 'group': __("Updating Python"),
'tasks': [ 'tasks': [
{'name': 'update_other:perl_cleaner', {'name': 'update:python_updater',
'message': __('Find & rebuild packages broken due '
'to a Python upgrade'),
'method': 'Update.emergelike("python-updater")',
'condition': UpdateConditions.was_installed(
'dev-lang/python$', EmergeMark.PythonUpdater),
'decoration': 'Update.update_task("%s")' %
EmergeMark.PythonUpdater
},
]
},
{'name': 'update:update_perl',
'group': __("Updating Perl"),
'tasks': [
{'name': 'update:perl_cleaner',
'message': __('Find & rebuild packages and Perl header files ' 'message': __('Find & rebuild packages and Perl header files '
'broken due to a perl upgrade'), 'broken due to a perl upgrade'),
'method': 'Update.emergelike("perl-cleaner", "all")', 'method': 'Update.emergelike("perl-cleaner", "all")',
@ -394,7 +134,7 @@ class ClUpdateAction(Action):
'message': __('Updating Kernel modules'), 'message': __('Updating Kernel modules'),
'method': 'Update.emerge("","@module-rebuild")', 'method': 'Update.emerge("","@module-rebuild")',
'condition': UpdateConditions.was_installed( 'condition': UpdateConditions.was_installed(
'sys-kernel/(calculate-sources|gentoo-kernel|vanilla-kernel)', EmergeMark.KernelModules), 'sys-kernel/.*source', EmergeMark.KernelModules),
'decoration': 'Update.update_task("%s")' % 'decoration': 'Update.update_task("%s")' %
EmergeMark.KernelModules EmergeMark.KernelModules
}, },
@ -409,17 +149,16 @@ class ClUpdateAction(Action):
{'name': 'update_other:preserved_rebuild', {'name': 'update_other:preserved_rebuild',
'message': __('Updating preserved libraries'), 'message': __('Updating preserved libraries'),
'method': 'Update.emerge("","@preserved-rebuild")', 'method': 'Update.emerge("","@preserved-rebuild")',
'condition': lambda Get: (UpdateConditions.was_installed( 'condition': UpdateConditions.was_installed(
'.*', EmergeMark.PreservedLibs)() or '.*', EmergeMark.PreservedLibs),
UpdateConditions.force_preserved(Get)),
'decoration': 'Update.update_task("%s")' % 'decoration': 'Update.update_task("%s")' %
EmergeMark.PreservedLibs EmergeMark.PreservedLibs
}, },
{'name': 'update_other:revdev_rebuild', {'name': 'update_other:revdev_rebuild',
'message': __('Checking reverse dependencies'), 'message': __('Checking reverse dependencies'),
'method': 'Update.revdep_rebuild("revdep-rebuild")', 'method': 'Update.revdep_rebuild("revdep-rebuild")',
'condition': lambda Get: (Get( 'condition': lambda Get: (Get(
'cl_update_revdep_rebuild_set') == 'on' and 'cl_update_skip_rb_set') == 'off' and
UpdateConditions.was_installed( UpdateConditions.was_installed(
'.*', EmergeMark.RevdepRebuild)()), '.*', EmergeMark.RevdepRebuild)()),
'decoration': 'Update.update_task("%s")' % 'decoration': 'Update.update_task("%s")' %
@ -433,10 +172,8 @@ class ClUpdateAction(Action):
}, },
] ]
}, },
{'name': 'set_upto_date_cache', {'name': 'update:set_upto_date_cache',
'method': 'Update.setUpToDateCache()', 'method': 'Update.setUpToDateCache()'
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off' and \
Get('cl_update_pretend_set') == 'off'
} }
] ]
@ -451,47 +188,115 @@ class ClUpdateAction(Action):
{'name': 'check_run', {'name': 'check_run',
'method': 'Update.checkRun(cl_update_wait_another_set)' 'method': 'Update.checkRun(cl_update_wait_another_set)'
}, },
{'name': 'check_if_world_was_updated', {'name': 'reps_synchronization',
'method': 'Update.update_set_current_saved_tag()', 'group': __("Repositories synchronization"),
'essential': False, 'tasks': [
'condition': lambda Get: (Get('cl_update_sync_only_set') == 'off' and \ # запасная синхронизация, в ходе которой ветки обновляются до
Get('cl_update_pretend_set') == 'off' and \ # master
UpdateConditions.check_world_updated_after_tag_save()()) {'name': 'sync_reps_fallback',
'foreach': 'cl_update_sync_rep',
'message':
__("Fallback syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncRepositories(eachvar)',
'condition': lambda Get: ("getbinpkg" in Get('cl_features') and
not Get('cl_update_binhost_data')[0])
},
# обновление переменных информации из binhost
{'name': 'update_binhost_list',
'method': 'Update.update_binhost_list()',
'condition': lambda Get: ("getbinpkg" in Get('cl_features') and
not Get('cl_update_binhost_data')[0])
},
{'name': 'sync_reps',
'foreach': 'cl_update_sync_rep',
'message': __("Syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncRepositories(eachvar)',
'condition': lambda Get: Get('cl_update_sync_rep')
},
{'name': 'check_binhost',
'method': 'Update.check_binhost()',
'condition': lambda Get: "getbinpkg" in Get('cl_features')
},
{'name': 'sync_other_reps',
'foreach': 'cl_update_other_rep_name',
'message': __("Syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncLaymanRepository(eachvar)',
'condition': lambda Get: Get('cl_update_other_set') == 'on'
},
{'name': 'sync_reps:regen_cache',
'foreach': 'cl_update_sync_overlay_rep',
'essential': False,
'method': 'Update.regenCache(eachvar)',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_egencache_force') != 'skip' or
Get('cl_update_egencache_force') == 'force'))
},
{'name': 'sync_other_reps:regen_other_cache',
'foreach': 'cl_update_other_rep_name',
'method': 'Update.regenCache(eachvar)',
'essential': False,
},
{'name': 'emerge_metadata',
'message': __("Metadata transfer"),
'method': 'Update.emergeMetadata()',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_metadata_force') != 'skip' or
Get('cl_update_metadata_force') == 'force'))
},
{'name': 'eix_update',
'message': __("Updating the eix cache"),
'method': 'Update.eixUpdate(cl_repository_name)',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_eixupdate_force') != 'skip' or
Get('cl_update_eixupdate_force') == 'force'))
},
{'name': 'update_setup_cache',
'message': __("Updating the cache of configurable packages"),
'method': 'Update.updateSetupCache()',
'essential': False,
'condition': lambda Get: Get('cl_update_outdate_set') == 'on'
},
{'name': 'sync_reps:cleanpkg',
'message': __("Removing obsolete distfiles and binary packages"),
'method': 'Update.cleanpkg()',
'condition': (lambda Get: Get('cl_update_cleanpkg_set') == 'on' and
Get('cl_update_outdate_set') == 'on'),
'essential': False
},
# сообщение удачного завершения при обновлении репозиториев
{'name': 'success_syncrep',
'message': __("Synchronization finished"),
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
"sync_other_reps",
"emerge_metadata",
"eix_update")),
}
]
}, },
] + get_synchronization_tasks("Update") + [ {'name': 'reps_synchronization',
{'name': 'system_configuration',
'group': __("System configuration"), 'group': __("System configuration"),
'tasks': [ 'tasks': [
{'name': 'binhost_changed',
'method': 'Update.message_binhost_changed()'
},
{'name': 'revision', {'name': 'revision',
'message': __("Fixing the settings"), 'message': __("Fixing the settings"),
'method': 'Update.applyTemplates(install.cl_source,' 'method': 'Update.applyTemplates(install.cl_source,'
'cl_template_clt_set,True,None,False)', 'cl_template_clt_set,True,None,False)',
'condition': lambda Get, GetBool: (Get('cl_templates_locate') and 'condition': lambda Get: Get('cl_templates_locate')
(Get('cl_update_world') != "update" or },
GetBool('cl_update_outdate_set') or
GetBool('cl_update_binhost_recheck_set') or
GetBool('cl_update_force_fix_set') or
GetBool('update.cl_update_package_cache_set')))
},
{'name': 'dispatch_conf', {'name': 'dispatch_conf',
'message': __("Updating configuration files"), 'message': __("Updating configuration files"),
'method': 'Update.dispatchConf()', 'method':'Update.dispatchConf()',
'condition': lambda Get, GetBool: (Get('cl_dispatch_conf') != 'skip' and 'condition': lambda Get: (Get('cl_dispatch_conf') != 'skip' and
Get('cl_update_pretend_set') == 'off' and Get('cl_update_pretend_set') == 'off')
(GetBool('cl_update_outdate_set') or },
GetBool('cl_update_binhost_recheck_set') or {'name': 'binhost_changed',
GetBool('cl_update_force_fix_set') or 'method': 'Update.message_binhost_changed()'
GetBool('update.cl_update_package_cache_set'))) },
},
] ]
} }
] + emerge_tasks + [ ] + emerge_tasks + [
{'name': 'check success configure',
'method': 'Update.check_success_configure()',
},
{'name': 'failed', {'name': 'failed',
'error': __("Update failed"), 'error': __("Update failed"),
'depend': (Tasks.failed() & Tasks.hasnot("interrupt") & 'depend': (Tasks.failed() & Tasks.hasnot("interrupt") &
@ -501,56 +306,10 @@ class ClUpdateAction(Action):
'depend': Tasks.failed_all("check_schedule") 'depend': Tasks.failed_all("check_schedule")
}, },
# сообщение удачного завершения при обновлении ревизии # сообщение удачного завершения при обновлении ревизии
{'name': 'drop_portage_hash',
'method': 'Update.drop_portage_state_hash()',
'depend': Tasks.failed()
},
{'name': 'drop_world_hash',
'method': 'Update.drop_world_state_hash()',
'depend': Tasks.failed()},
{'name': 'update:set_current_level',
'method': 'Update.update_increment_current_level()',
'depend': (Tasks.success() & Tasks.hasnot("interrupt") &
Tasks.success_all("update") & Tasks.hasnot("check_schedule")),
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off' and
Get('cl_update_pretend_set') == 'off' and
Get('update.cl_update_use_migration_host') == 'on'
},
{'name': 'update_world:set_latest_tag',
'method': 'Update.update_set_current_saved_tag()',
'depend': (Tasks.success() & Tasks.hasnot("interrupt") &
Tasks.success_all("update") & Tasks.hasnot("check_schedule")),
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off' and
Get('cl_update_pretend_set') == 'off',
'decoration': 'Update.update_task("%s")' % EmergeMark.SaveTag
},
{'name': 'update:save_portage_hash',
'method': 'Update.save_portage_state_hash()',
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off'
},
{'name': 'update:save_world_hash',
'method': 'Update.save_world_state_hash()',
'condition': lambda Get: Get('cl_update_sync_only_set') == 'off'
},
{'name': 'clear_migration_host',
'method': 'Update.delete_binhost()',
'depend': (Tasks.hasnot("check_schedule")),
'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'on'
},
# сообщение удачного завершения при обновлении ревизии
{'name': 'success_rev', {'name': 'success_rev',
'message': __("System update finished!"), 'message': __("System update finished!"),
'condition': lambda Get: (Get('cl_update_rev_set') == 'on' and 'condition': lambda Get: (Get('cl_update_rev_set') == 'on' and
Get('cl_update_pretend_set') == 'off' and Get('cl_update_pretend_set') == 'off')
Get('cl_update_sync_only_set') == 'off')
},
# сообщение удачного завершения при обновлении ревизии
{'name': 'success_sync_only',
'message': __("System sync finished!"),
'condition': lambda Get: (Get('cl_update_rev_set') == 'on' and
Get('cl_update_pretend_set') == 'off' and
Get('cl_update_sync_only_set') == 'on')
}, },
# сообщение удачного завершения при пересоздании world # сообщение удачного завершения при пересоздании world
{'name': 'success_world', {'name': 'success_world',

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2010-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2010-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -18,9 +18,8 @@ import sys
from calculate.core.server.func import Action, Tasks from calculate.core.server.func import Action, Tasks
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from calculate.lib.cl_template import TemplatesError from calculate.lib.cl_template import TemplatesError
from calculate.lib.utils.binhosts import BinhostError
from calculate.lib.utils.files import FilesError from calculate.lib.utils.files import FilesError
from ..update import UpdateError from calculate.update.update import UpdateError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
_ = lambda x: x _ = lambda x: x
@ -34,7 +33,7 @@ class ClUpdateProfileAction(Action):
""" """
# ошибки, которые отображаются без подробностей # ошибки, которые отображаются без подробностей
native_error = (FilesError, native_error = (FilesError,
TemplatesError, BinhostError, TemplatesError,
UpdateError, GitError) UpdateError, GitError)
successMessage = __("The profile was successfully updated") successMessage = __("The profile was successfully updated")
@ -47,33 +46,69 @@ class ClUpdateProfileAction(Action):
'method': 'Update.migrateCacheRepository(' 'method': 'Update.migrateCacheRepository('
'cl_update_profile_url,cl_update_profile_branch,' 'cl_update_profile_url,cl_update_profile_branch,'
'cl_update_profile_storage)', 'cl_update_profile_storage)',
'condition': lambda Get: Get('cl_update_profile_url')}, 'message': __("Repository transfer"),
{'name': 'profile_from_url', 'condition': lambda Get: not (
'group': __('setting up from url'), Get('cl_update_profile_storage').is_local(
'tasks': [ Get('cl_update_profile_url'),
{'message': __("Repository transfer"), Get('cl_update_profile_branch')))
'condition': lambda Get: not ( },
Get('cl_update_profile_storage').is_local( {'name': 'reconfigure_vars1',
Get('cl_update_profile_url'), 'method': 'Update.invalidateVariables("cl_update_profile_storage")',
Get('cl_update_profile_branch'))) and Get('cl_update_profile_check_sync_allowed'),
},
{'name': 'reconfigure_vars1',
'method': 'Update.invalidateVariables("cl_update_profile_storage")',
},
{'name': 'check_datavars',
'error': _("Profile not found in master"),
'condition': lambda Get: not Get('update.cl_update_profile_datavars'),
},
{'name': 'drop_binhosts',
'method': 'Update.drop_binhosts(update.cl_update_profile_datavars)',
},
{'name': 'reconfigure_vars',
'method': 'Update.reconfigureProfileVars(cl_update_profile_datavars,'
'cl_chroot_path)',
},
],
'depend': Tasks.has('migrate_repository') 'depend': Tasks.has('migrate_repository')
}, },
{'name': 'drop_binhosts',
'method': 'Update.drop_binhosts(update.cl_update_profile_datavars)'
},
{'name': 'reconfigure_vars',
'method': 'Update.reconfigureProfileVars(cl_update_profile_datavars,'
'cl_chroot_path)'
},
{'name': 'reps_synchronization',
'group': __("Repositories synchronization"),
'tasks': [
{'name': 'sync_reps',
'foreach': 'cl_update_profile_sync_rep',
'message': __("Syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncRepositories(eachvar)',
# TODO: неиспользуемое условие
# 'condition': lambda Get: Get('cl_update_profile_sync_rep')
},
{'name': 'sync_reps:regen_cache',
'foreach': 'cl_update_sync_overlay_rep',
'message': __("Updating the {eachvar:capitalize} repository cache"),
'essential': False,
'method': 'Update.regenCache(eachvar)',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_metadata_force') != 'skip' or
Get('cl_update_metadata_force') == 'force'))
},
{'name': 'emerge_metadata',
'message': __("Metadata transfer"),
'method': 'Update.emergeMetadata()',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_metadata_force') != 'skip' or
Get('cl_update_metadata_force') == 'force'))
},
{'name': 'eix_update',
'message': __("Updating the eix cache"),
'method': 'Update.eixUpdate(cl_repository_name)',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_eixupdate_force') != 'skip' or
Get('cl_update_eixupdate_force') == 'force'))
},
# сообщение удачного завершения при обновлении репозиториев
{'name': 'success_syncrep',
'message': __("Synchronization finished"),
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
"sync_other_reps",
"emerge_metadata",
"eix_update")),
}
]
},
{'name': 'reps_synchronization', {'name': 'reps_synchronization',
'group': __("Setting up the profile"), 'group': __("Setting up the profile"),
'tasks': [ 'tasks': [
@ -81,9 +116,6 @@ class ClUpdateProfileAction(Action):
'message': __("Switching to profile {cl_update_profile_system}"), 'message': __("Switching to profile {cl_update_profile_system}"),
'method': 'Update.setProfile(cl_update_profile_system)' 'method': 'Update.setProfile(cl_update_profile_system)'
}, },
{'name': 'rename_custom',
'method': 'Update.rename_custom_files()',
},
{'name': 'revision', {'name': 'revision',
'message': __("Fixing the settings"), 'message': __("Fixing the settings"),
'method': 'Update.applyProfileTemplates(cl_template_clt_set,' 'method': 'Update.applyProfileTemplates(cl_template_clt_set,'

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*- #-*- coding: utf-8 -*-
# Copyright 2008-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2008-2013 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from . import action import action
from . import update import update
section = "update" section = "update"

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2013-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2013-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ class VariableAcUpdateSync(ReadonlyVariable):
""" """
def get(self): def get(self):
action = self.Get("cl_action") action = self.Get("cl_action")
if action in ("sync", 'update_profile') and \ if action in ("sync", 'update_profile'):
not self.Get('cl_merge_pkg'):
return "on" return "on"
return "off" return "off"

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2010-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2010-2015 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -20,18 +20,17 @@ from calculate.lib.datavars import VariableError,DataVarsError
from calculate.core.server.func import WsdlBase from calculate.core.server.func import WsdlBase
from calculate.install.install import InstallError from calculate.install.install import InstallError
from .update import Update, UpdateError from calculate.update.update import Update, UpdateError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
from .utils.cl_update import ClUpdateAction from utils.cl_update import ClUpdateAction
from .utils.cl_update_profile import ClUpdateProfileAction from utils.cl_update_profile import ClUpdateProfileAction
from .utils.cl_setup_update import ClSetupUpdateAction from utils.cl_setup_update import ClSetupUpdateAction
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate, _ from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate, _
setLocalTranslate('cl_update3', sys.modules[__name__]) setLocalTranslate('cl_update3', sys.modules[__name__])
__ = getLazyLocalTranslate(_) __ = getLazyLocalTranslate(_)
class Wsdl(WsdlBase): class Wsdl(WsdlBase):
methods = [ methods = [
# #
@ -65,36 +64,25 @@ class Wsdl(WsdlBase):
# описание груп (список лямбда функций) # описание груп (список лямбда функций)
'groups': [ 'groups': [
lambda group: group(_("Update the system"), lambda group: group(_("Update the system"),
normal=( normal=(),
'cl_update_binhost_stable_opt_set',
'cl_update_binhost_recheck_set',
'cl_update_with_bdeps_opt_set',
'cl_update_binhost_choice',
'cl_update_rep_hosting_choice',
),
expert=( expert=(
'cl_update_other_set', 'cl_update_sync_only_set',
'cl_update_sync_only_set', 'cl_update_other_set',
'cl_update_pretend_set', 'cl_update_pretend_set',
'cl_update_sync_rep', 'cl_update_sync_rep',
'cl_update_emergelist_set', 'cl_update_emergelist_set',
'cl_update_check_rep_set', 'cl_update_world',
'cl_update_force_fix_set', 'cl_update_egencache_force',
'cl_update_ignore_level', 'cl_update_eixupdate_force',
'cl_update_force_level', 'cl_update_skip_rb_set',
'cl_update_world', 'cl_update_wait_another_set',
'cl_update_gpg_force', 'cl_update_autocheck_schedule_set',
'cl_update_egencache_force', 'cl_update_binhost_recheck_set',
'cl_update_eixupdate_force', 'cl_update_cleanpkg_set',
'cl_update_revdep_rebuild_set', 'cl_update_branch_data',
'cl_update_wait_another_set', 'cl_templates_locate',
'cl_update_autocheck_schedule_set', 'cl_verbose_set', 'cl_dispatch_conf'),
'cl_update_onedepth_set', next_label=_("Perform"))]},
'cl_update_cleanpkg_set',
'cl_update_branch_data',
'cl_templates_locate',
'cl_verbose_set', 'cl_dispatch_conf'),
next_label=_("Run"))]},
# #
# Сменить профиль # Сменить профиль
# #
@ -106,8 +94,7 @@ class Wsdl(WsdlBase):
# заголовок метода # заголовок метода
'title': __("Change the Profile"), 'title': __("Change the Profile"),
# иконка для графической консоли # иконка для графической консоли
'image': 'calculate-update-profile,' 'image': 'notification-display-brightness-full,gtk-dialog-info,'
'notification-display-brightness-full,gtk-dialog-info,'
'help-hint', 'help-hint',
# метод присутствует в графической консоли # метод присутствует в графической консоли
'gui': True, 'gui': True,
@ -124,7 +111,7 @@ class Wsdl(WsdlBase):
'native_error': (VariableError, DataVarsError, 'native_error': (VariableError, DataVarsError,
InstallError, UpdateError, GitError), InstallError, UpdateError, GitError),
# значения по умолчанию для переменных этого метода # значения по умолчанию для переменных этого метода
'setvars': {'cl_action!': 'update_profile', 'cl_update_world_default': "rebuild"}, 'setvars': {'cl_action!': 'update_profile'},
# описание груп (список лямбда функций) # описание груп (список лямбда функций)
'groups': [ 'groups': [
lambda group: group(_("Repository"), lambda group: group(_("Repository"),
@ -147,7 +134,7 @@ class Wsdl(WsdlBase):
'cl_update_profile_linux_fullname', 'cl_update_profile_linux_fullname',
'cl_update_profile_depend_data') 'cl_update_profile_depend_data')
)], )],
'brief': {'next': __("Run"), 'brief': {'next': __("Perform"),
'name': __("Set the profile")}}, 'name': __("Set the profile")}},
# #
# Настроить автопроверку обновлений # Настроить автопроверку обновлений
@ -160,13 +147,13 @@ class Wsdl(WsdlBase):
# заголовок метода # заголовок метода
'title': __("Update Check"), 'title': __("Update Check"),
# иконка для графической консоли # иконка для графической консоли
'image': 'calculate-setup-update,software-properties,preferences-desktop', 'image': 'software-properties,preferences-desktop',
# метод присутствует в графической консоли # метод присутствует в графической консоли
'gui': True, 'gui': True,
# консольная команда # консольная команда
'command': 'cl-setup-update', 'command': 'cl-setup-update',
# права для запуска метода # права для запуска метода
'rights': ['setup_update'], 'rights': ['update'],
# объект содержащий модули для действия # объект содержащий модули для действия
'logic': {'Update': Update}, 'logic': {'Update': Update},
# описание действия # описание действия

@ -3,7 +3,7 @@
# setup.py --- Setup script for calculate-update # setup.py --- Setup script for calculate-update
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org # Copyright 2012 Calculate Ltd. http://www.calculate-linux.org
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
__app__ = "calculate-update" __app__ = "calculate-update"
__version__ = "3.7.3" #TODO bump version __version__ = "3.2.2"
import os import os
from glob import glob from glob import glob
@ -67,7 +67,7 @@ class install_data(module_install_data.install_data):
os.chmod(out,chmod) os.chmod(out,chmod)
self.outfiles.append(out) self.outfiles.append(out)
data_files = [('/usr/libexec/calculate', [('data/cl-git-wrapper', 0o755)])] data_files = [('/usr/libexec/calculate', [('data/cl-git-wrapper', 0755)])]
packages = [ packages = [
"calculate."+str('.'.join(root.split(os.sep)[1:])) "calculate."+str('.'.join(root.split(os.sep)[1:]))

Loading…
Cancel
Save