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

Добавлена поддержка Packages.xz. Изменёны сообщения при синхронизации
репозиториев
master-3.5 3.5.1_beta3
parent 9358b1a4a5
commit 2fbafa7f68

@ -32,6 +32,7 @@ from calculate.lib.utils.colortext import get_color_print
from calculate.update.emerge_parser import RevdepPercentBlock from calculate.update.emerge_parser import RevdepPercentBlock
from calculate.update.datavars import DataVarsUpdate from calculate.update.datavars import DataVarsUpdate
from calculate.update.update_info import UpdateInfo from calculate.update.update_info import UpdateInfo
from calculate.lib.utils.binhosts import fetch_packages
from calculate.lib.cl_log import log from calculate.lib.cl_log import log
import re import re
import shutil import shutil
@ -154,7 +155,7 @@ class Update(MethodsInterface):
return getProgPath(program_name) return getProgPath(program_name)
def _syncRepository(self, name, url, rpath, revision, def _syncRepository(self, name, url, rpath, revision,
cb_progress=None, clean=False): cb_progress=None, clean=False, notask=False):
""" """
Синхронизировать репозитори Синхронизировать репозитори
""" """
@ -167,6 +168,10 @@ class Update(MethodsInterface):
try: try:
self.stash_cache(rpath, name) self.stash_cache(rpath, name)
if not git.checkExistsRep(rpath): if not git.checkExistsRep(rpath):
if not notask:
self.startTask(_("Syncing the {rep} repository").format(
rep=name.capitalize()))
self.addProgress()
git.cloneTagRepository(url, rpath, revision, git.cloneTagRepository(url, rpath, revision,
cb_progress=cb_progress) cb_progress=cb_progress)
info_outdated = True info_outdated = True
@ -177,10 +182,7 @@ class Update(MethodsInterface):
tag_cr = git.getCommit(rpath, revision) tag_cr = git.getCommit(rpath, revision)
cr = git.getCurrentCommit(rpath) cr = git.getCurrentCommit(rpath)
ref_type = git.reference_type(rpath, revision) ref_type = git.reference_type(rpath, revision)
if git.isNeedUnpack(rpath): if tag_cr != cr or ref_type == Git.Reference.Branch:
need_update = True
clean = True
elif tag_cr != cr or ref_type == Git.Reference.Branch:
need_update = True need_update = True
elif clean: elif clean:
status = git.getStatusInfo(rpath) status = git.getStatusInfo(rpath)
@ -189,6 +191,10 @@ class Update(MethodsInterface):
except GitError: except GitError:
need_update = True need_update = True
if need_update: if need_update:
if not notask:
self.startTask(_("Syncing the {rep} repository").format(
rep=name.capitalize()))
self.addProgress()
git.updateTagRepository(url, rpath, revision, git.updateTagRepository(url, rpath, revision,
cb_progress=cb_progress, cb_progress=cb_progress,
clean=clean) clean=clean)
@ -300,7 +306,8 @@ class Update(MethodsInterface):
return True return True
@variable_module("update") @variable_module("update")
def syncRepositories(self, repname, clean_on_error=True): def syncRepositories(self, repname, fallback_sync=False,
clean_on_error=True):
""" """
Синхронизировать репозитории Синхронизировать репозитории
""" """
@ -321,7 +328,6 @@ class Update(MethodsInterface):
rpath_orig = rpath rpath_orig = rpath
else: else:
rpath_orig = rpath[len(chroot_path):] rpath_orig = rpath[len(chroot_path):]
self.addProgress()
mtime = MTimeKeeper(path.join(rpath, "profiles/updates")) mtime = MTimeKeeper(path.join(rpath, "profiles/updates"))
mtime.save() mtime.save()
@ -336,7 +342,8 @@ class Update(MethodsInterface):
layman.add(repname, url, rpath_orig) layman.add(repname, url, rpath_orig)
if not self._syncRepository(repname, url, rpath, revision, if not self._syncRepository(repname, url, rpath, revision,
cb_progress=self.setProgress, cb_progress=self.setProgress,
clean=check_status): clean=check_status,
notask=fallback_sync):
return "skip" return "skip"
return True return True
except GitError as e: except GitError as e:
@ -353,7 +360,8 @@ class Update(MethodsInterface):
try: try:
self._syncRepository(repname, url, rpath_new, revision, self._syncRepository(repname, url, rpath_new, revision,
cb_progress=self.setProgress, cb_progress=self.setProgress,
clean=check_status) clean=check_status,
notask=fallback_sync)
removeDir(rpath) removeDir(rpath)
shutil.move(rpath_new, rpath) shutil.move(rpath_new, rpath)
except OSError as e: except OSError as e:
@ -1200,6 +1208,7 @@ class Update(MethodsInterface):
if write_binhost: if write_binhost:
if hosts[0] != self.clVars.Get('update.cl_update_binhost'): if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
self.refresh_binhost = True self.refresh_binhost = True
self.clVars.Set('cl_update_package_cache_set', 'on')
self.clVars.Write('cl_update_binhost', hosts[0], location="system") self.clVars.Write('cl_update_binhost', hosts[0], location="system")
new_ts = self.clVars.Get("update.cl_update_binhost_timestamp") new_ts = self.clVars.Get("update.cl_update_binhost_timestamp")
if new_ts: if new_ts:
@ -1266,3 +1275,9 @@ class Update(MethodsInterface):
dv.Set('update.cl_update_branch_name', revs) dv.Set('update.cl_update_branch_name', revs)
dv.Invalidate('update.cl_update_rep_rev') dv.Invalidate('update.cl_update_rep_rev')
return True return True
def download_packages(self, url_binhost, packages_fn):
fetch_packages(url_binhost, packages_fn)
return True

@ -18,6 +18,7 @@ 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 calculate.update.update import UpdateError from calculate.update.update import UpdateError
from calculate.update.emerge_parser import EmergeError from calculate.update.emerge_parser import EmergeError
@ -54,7 +55,7 @@ class ClUpdateAction(Action):
""" """
# ошибки, которые отображаются без подробностей # ошибки, которые отображаются без подробностей
native_error = (FilesError, UpdateError, native_error = (FilesError, UpdateError,
TemplatesError, TemplatesError, BinhostError,
GitError, EmergeError) GitError, EmergeError)
successMessage = None successMessage = None
@ -183,7 +184,7 @@ class ClUpdateAction(Action):
'foreach': 'cl_update_sync_rep', 'foreach': 'cl_update_sync_rep',
'message': 'message':
__("Fallback syncing the {eachvar:capitalize} repository"), __("Fallback syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncRepositories(eachvar)', 'method': 'Update.syncRepositories(eachvar,True)',
'condition': lambda Get: ("getbinpkg" in Get('cl_features') and 'condition': lambda Get: ("getbinpkg" in Get('cl_features') and
not Get('cl_update_binhost_data')[0]) not Get('cl_update_binhost_data')[0])
}, },
@ -195,7 +196,7 @@ class ClUpdateAction(Action):
}, },
{'name': 'sync_reps', {'name': 'sync_reps',
'foreach': 'cl_update_sync_rep', 'foreach': 'cl_update_sync_rep',
'message': __("Syncing the {eachvar:capitalize} repository"), 'message': __("Checking {eachvar:capitalize} updates"),
'method': 'Update.syncRepositories(eachvar)', 'method': 'Update.syncRepositories(eachvar)',
'condition': lambda Get: Get('cl_update_sync_rep') 'condition': lambda Get: Get('cl_update_sync_rep')
}, },
@ -257,10 +258,19 @@ class ClUpdateAction(Action):
{'name': 'sync_reps:cleanpkg', {'name': 'sync_reps:cleanpkg',
'message': __("Removing obsolete distfiles and binary packages"), 'message': __("Removing obsolete distfiles and binary packages"),
'method': 'Update.cleanpkg()', 'method': 'Update.cleanpkg()',
'condition': (lambda Get: Get('cl_update_cleanpkg_set') == 'on' and 'condition': (
Get('cl_update_outdate_set') == 'on'), lambda Get: Get('cl_update_cleanpkg_set') == 'on' and
Get('cl_update_outdate_set') == 'on'),
'essential': False 'essential': False
}, },
{'name': 'update_packages_cache',
'message': __("Update packages index"),
'method': 'Update.download_packages(cl_update_portage_binhost,'
'cl_update_package_cache)',
'condition': lambda Get: (
Get('cl_update_outdate_set') == 'on' or
Get('cl_update_package_cache_set') == 'on')
},
# сообщение удачного завершения при обновлении репозиториев # сообщение удачного завершения при обновлении репозиториев
{'name': 'success_syncrep', {'name': 'success_syncrep',
'message': __("Synchronization finished"), 'message': __("Synchronization finished"),
@ -268,7 +278,7 @@ class ClUpdateAction(Action):
"sync_other_reps", "sync_other_reps",
"emerge_metadata", "emerge_metadata",
"eix_update")), "eix_update")),
} }
] ]
}, },
{'name': 'reps_synchronization', {'name': 'reps_synchronization',
@ -278,13 +288,18 @@ class ClUpdateAction(Action):
'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: Get('cl_templates_locate') 'condition': lambda Get: (Get('cl_templates_locate') and
(Get('cl_update_outdate_set') == 'on' or
Get('cl_update_force_fix_set') == 'on'))
}, },
{'name': 'dispatch_conf', {'name': 'dispatch_conf',
'message': __("Updating configuration files"), 'message': __("Updating configuration files"),
'method':'Update.dispatchConf()', 'method': 'Update.dispatchConf()',
'condition': lambda Get: (Get('cl_dispatch_conf') != 'skip' and 'condition': lambda Get: (Get('cl_dispatch_conf') != 'skip' and
Get('cl_update_pretend_set') == 'off') Get('cl_update_pretend_set') == 'off' and
(Get('cl_update_outdate_set') == 'on' or
Get('cl_update_force_fix_set') == 'on'))
}, },
{'name': 'binhost_changed', {'name': 'binhost_changed',
'method': 'Update.message_binhost_changed()' 'method': 'Update.message_binhost_changed()'

@ -18,6 +18,7 @@ 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 calculate.update.update import UpdateError from calculate.update.update import UpdateError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
@ -33,7 +34,7 @@ class ClUpdateProfileAction(Action):
""" """
# ошибки, которые отображаются без подробностей # ошибки, которые отображаются без подробностей
native_error = (FilesError, native_error = (FilesError,
TemplatesError, TemplatesError, BinhostError,
UpdateError, GitError) UpdateError, GitError)
successMessage = __("The profile was successfully updated") successMessage = __("The profile was successfully updated")

@ -40,6 +40,7 @@ from calculate.lib.variables import linux as lib_linux
from calculate.lib.variables import env from calculate.lib.variables import env
from calculate.update.update_info import UpdateInfo from calculate.update.update_info import UpdateInfo
from itertools import chain from itertools import chain
from urlparse import urlparse
import time import time
_ = lambda x: x _ = lambda x: x
@ -1631,6 +1632,20 @@ class VariableClUpdateCheckRepSet(Variable):
self.help = _("check and fix the repositories integrity") self.help = _("check and fix the repositories integrity")
class VariableClUpdateForceFixSet(Variable):
"""
Удлять лишние файлы из репозиториев (например созданные пользователем)
"""
type = "bool"
value = "off"
opt = ["--force-fix"]
def init(self):
self.label = _("Force fix the settings")
self.help = _("force fix the settings")
class VariableClUpdateOnedepthSet(Variable): class VariableClUpdateOnedepthSet(Variable):
""" """
Удлять лишние файлы из репозиториев (например созданные пользователем) Удлять лишние файлы из репозиториев (например созданные пользователем)
@ -1655,3 +1670,45 @@ class VariableClUpdateEixRepositories(ReadonlyVariable):
x.capitalize() for x in chain( x.capitalize() for x in chain(
self.Get('update.cl_update_rep_name'), self.Get('update.cl_update_rep_name'),
self.Get('update.cl_update_other_rep_name'))) self.Get('update.cl_update_other_rep_name')))
class VariableClUpdatePortageBinhost(ReadonlyVariable):
"""
Прописываемый в /etc/portage/make.conf/binhost репозиторий
"""
value_format = "{update.cl_update_binhost}/grp/{os_arch_machine}"
class VariableClUpdatePackageCache(ReadonlyVariable):
"""
Путь кэшированного Packages
"""
def get(self):
cache_path = "var/cache/edb"
chroot_path = self.Get('cl_chroot_path')
base_url = self.Get('cl_update_portage_binhost')
parsed_url = urlparse(base_url)
host = parsed_url.netloc
port = parsed_url.port
user = None
passwd = None
user_passwd = ""
if "@" in host:
user, host = host.split("@", 1)
user_passwd = user + "@"
if ":" in user:
user, passwd = user.split(":", 1)
if port is not None:
port_str = ":%s" % (port,)
if host.endswith(port_str):
host = host[:-len(port_str)]
return os.path.join(chroot_path, cache_path, "binhost",
host, parsed_url.path.lstrip("/"),
"Packages")
class VariableClUpdatePackageCacheSet(Variable):
"""
Необходимость обновить Packages
"""
type = "bool"
value = "off"

@ -68,7 +68,6 @@ class Wsdl(WsdlBase):
'cl_update_binhost_stable_opt_set', 'cl_update_binhost_stable_opt_set',
'cl_update_binhost_recheck_set', 'cl_update_binhost_recheck_set',
), ),
expert=( expert=(
'cl_update_sync_only_set', 'cl_update_sync_only_set',
'cl_update_other_set', 'cl_update_other_set',
@ -76,6 +75,7 @@ class Wsdl(WsdlBase):
'cl_update_sync_rep', 'cl_update_sync_rep',
'cl_update_emergelist_set', 'cl_update_emergelist_set',
'cl_update_check_rep_set', 'cl_update_check_rep_set',
'cl_update_force_fix_set',
'cl_update_world', 'cl_update_world',
'cl_update_egencache_force', 'cl_update_egencache_force',
'cl_update_eixupdate_force', 'cl_update_eixupdate_force',

Loading…
Cancel
Save