|
|
@ -38,7 +38,7 @@ import shutil
|
|
|
|
from collections import MutableSet
|
|
|
|
from collections import MutableSet
|
|
|
|
from update_tasks import EmergeMark
|
|
|
|
from update_tasks import EmergeMark
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.utils.git import Git, GitError
|
|
|
|
from calculate.lib.utils.git import Git, GitError, MTimeKeeper
|
|
|
|
from calculate.lib.utils.portage import (Layman, EmergeLog,
|
|
|
|
from calculate.lib.utils.portage import (Layman, EmergeLog,
|
|
|
|
EmergeLogNamedTask, PackageList,
|
|
|
|
EmergeLogNamedTask, PackageList,
|
|
|
|
PackageInformation,
|
|
|
|
PackageInformation,
|
|
|
@ -57,6 +57,7 @@ from emerge_parser import (EmergeParser, EmergeCommand, EmergeError,
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate,
|
|
|
|
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate,
|
|
|
|
RegexpLocalization, _)
|
|
|
|
RegexpLocalization, _)
|
|
|
|
|
|
|
|
|
|
|
|
setLocalTranslate('cl_update3', sys.modules[__name__])
|
|
|
|
setLocalTranslate('cl_update3', sys.modules[__name__])
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
|
|
|
|
|
|
|
@ -69,6 +70,7 @@ class OverlayOwnCache(MutableSet):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Сет оверлеев с интегрированным кэшем
|
|
|
|
Сет оверлеев с интегрированным кэшем
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, dv=None):
|
|
|
|
def __init__(self, dv=None):
|
|
|
|
self.dv = dv
|
|
|
|
self.dv = dv
|
|
|
|
|
|
|
|
|
|
|
@ -118,6 +120,7 @@ def variable_module(var_env):
|
|
|
|
return f(self, *args, **kw)
|
|
|
|
return f(self, *args, **kw)
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
self.clVars.defaultModule = old_env
|
|
|
|
self.clVars.defaultModule = old_env
|
|
|
|
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
return variable_module_decor
|
|
|
|
return variable_module_decor
|
|
|
@ -127,6 +130,7 @@ class Update(MethodsInterface):
|
|
|
|
"""Основной объект для выполнения действий связанных с обновлением системы
|
|
|
|
"""Основной объект для выполнения действий связанных с обновлением системы
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
def init(self):
|
|
|
|
commandLog = path.join(self.clVars.Get('core.cl_log_path'),
|
|
|
|
commandLog = path.join(self.clVars.Get('core.cl_log_path'),
|
|
|
|
'lastcommand.log')
|
|
|
|
'lastcommand.log')
|
|
|
@ -146,13 +150,16 @@ 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):
|
|
|
|
cb_progress=None, clean=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Синхронизировать репозитори
|
|
|
|
Синхронизировать репозитори
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
dv = self.clVars
|
|
|
|
dv = self.clVars
|
|
|
|
git = Git()
|
|
|
|
git = Git()
|
|
|
|
info_outdated = False
|
|
|
|
info_outdated = False
|
|
|
|
|
|
|
|
old_dir = "%s.old" % git._gitDir(rpath)
|
|
|
|
|
|
|
|
if path.exists(old_dir):
|
|
|
|
|
|
|
|
clean = True
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.stash_cache(rpath, name)
|
|
|
|
self.stash_cache(rpath, name)
|
|
|
|
if not git.checkExistsRep(rpath):
|
|
|
|
if not git.checkExistsRep(rpath):
|
|
|
@ -166,15 +173,20 @@ 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):
|
|
|
|
|
|
|
|
need_update = True
|
|
|
|
|
|
|
|
elif tag_cr != cr or ref_type == Git.Reference.Branch:
|
|
|
|
|
|
|
|
need_update = True
|
|
|
|
|
|
|
|
elif clean:
|
|
|
|
status = git.getStatusInfo(rpath)
|
|
|
|
status = git.getStatusInfo(rpath)
|
|
|
|
if (tag_cr != cr or ref_type == Git.Reference.Branch or
|
|
|
|
if not status or status['files']:
|
|
|
|
not status or status['files']):
|
|
|
|
|
|
|
|
need_update = True
|
|
|
|
need_update = True
|
|
|
|
except GitError:
|
|
|
|
except GitError:
|
|
|
|
need_update = True
|
|
|
|
need_update = True
|
|
|
|
if need_update:
|
|
|
|
if need_update:
|
|
|
|
git.updateTagRepository(url, rpath, revision,
|
|
|
|
git.updateTagRepository(url, rpath, revision,
|
|
|
|
cb_progress=cb_progress)
|
|
|
|
cb_progress=cb_progress,
|
|
|
|
|
|
|
|
clean=clean)
|
|
|
|
new_cr = git.getCurrentCommit(rpath)
|
|
|
|
new_cr = git.getCurrentCommit(rpath)
|
|
|
|
if new_cr != cr:
|
|
|
|
if new_cr != cr:
|
|
|
|
info_outdated = True
|
|
|
|
info_outdated = True
|
|
|
@ -237,7 +249,8 @@ class Update(MethodsInterface):
|
|
|
|
Проверить повторный запуск
|
|
|
|
Проверить повторный запуск
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
update_running = lambda: any(os.getpid() != x
|
|
|
|
update_running = lambda: any(os.getpid() != x
|
|
|
|
for x in search_worked_process('update', dv))
|
|
|
|
for x in
|
|
|
|
|
|
|
|
search_worked_process('update', dv))
|
|
|
|
dv = self.clVars
|
|
|
|
dv = self.clVars
|
|
|
|
if update_running():
|
|
|
|
if update_running():
|
|
|
|
if not wait_update:
|
|
|
|
if not wait_update:
|
|
|
@ -268,12 +281,26 @@ class Update(MethodsInterface):
|
|
|
|
self.endTask()
|
|
|
|
self.endTask()
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@variable_module("update")
|
|
|
|
|
|
|
|
def trimRepositories(self, repname):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Синхронизировать репозитории
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
|
|
|
rpath = \
|
|
|
|
|
|
|
|
dv.select('cl_update_rep_path', cl_update_rep_name=repname, limit=1)
|
|
|
|
|
|
|
|
git = Git()
|
|
|
|
|
|
|
|
self.addProgress()
|
|
|
|
|
|
|
|
git.trimRepository(rpath, cb_progress=self.setProgress)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@variable_module("update")
|
|
|
|
@variable_module("update")
|
|
|
|
def syncRepositories(self, repname, clean_on_error=True):
|
|
|
|
def syncRepositories(self, repname, clean_on_error=True):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Синхронизировать репозитории
|
|
|
|
Синхронизировать репозитории
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
dv = self.clVars
|
|
|
|
dv = self.clVars
|
|
|
|
|
|
|
|
check_status = dv.GetBool('update.cl_update_check_rep_set')
|
|
|
|
url, rpath, revision = (
|
|
|
|
url, rpath, revision = (
|
|
|
|
dv.Select(["cl_update_rep_url", "cl_update_rep_path",
|
|
|
|
dv.Select(["cl_update_rep_url", "cl_update_rep_path",
|
|
|
|
"cl_update_rep_rev"],
|
|
|
|
"cl_update_rep_rev"],
|
|
|
@ -281,6 +308,9 @@ class Update(MethodsInterface):
|
|
|
|
if not url or not rpath:
|
|
|
|
if not url or not rpath:
|
|
|
|
raise UpdateError(_("Configuration variables for repositories "
|
|
|
|
raise UpdateError(_("Configuration variables for repositories "
|
|
|
|
"are not setup"))
|
|
|
|
"are not setup"))
|
|
|
|
|
|
|
|
git = Git()
|
|
|
|
|
|
|
|
if not git.checkUrl(url):
|
|
|
|
|
|
|
|
raise UpdateError(_("Git %s is unavailable") % url)
|
|
|
|
chroot_path = path.normpath(self.clVars.Get('cl_chroot_path'))
|
|
|
|
chroot_path = path.normpath(self.clVars.Get('cl_chroot_path'))
|
|
|
|
if chroot_path == '/':
|
|
|
|
if chroot_path == '/':
|
|
|
|
rpath_orig = rpath
|
|
|
|
rpath_orig = rpath
|
|
|
@ -288,6 +318,9 @@ class Update(MethodsInterface):
|
|
|
|
rpath_orig = rpath[len(chroot_path):]
|
|
|
|
rpath_orig = rpath[len(chroot_path):]
|
|
|
|
self.addProgress()
|
|
|
|
self.addProgress()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mtime = MTimeKeeper(path.join(rpath, "profiles/updates"))
|
|
|
|
|
|
|
|
mtime.save()
|
|
|
|
|
|
|
|
try:
|
|
|
|
if clean_on_error:
|
|
|
|
if clean_on_error:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
layman = Layman(dv.Get('cl_update_layman_installed'),
|
|
|
|
layman = Layman(dv.Get('cl_update_layman_installed'),
|
|
|
@ -297,7 +330,8 @@ class Update(MethodsInterface):
|
|
|
|
if repname != "portage":
|
|
|
|
if repname != "portage":
|
|
|
|
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):
|
|
|
|
return "skip"
|
|
|
|
return "skip"
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
except GitError as e:
|
|
|
|
except GitError as e:
|
|
|
@ -306,12 +340,14 @@ class Update(MethodsInterface):
|
|
|
|
self.printWARNING(str(e))
|
|
|
|
self.printWARNING(str(e))
|
|
|
|
self.endTask(False)
|
|
|
|
self.endTask(False)
|
|
|
|
self.startTask(
|
|
|
|
self.startTask(
|
|
|
|
_("Re-fetching the {name} repository").format(name=repname))
|
|
|
|
_("Re-fetching the {name} repository").format(
|
|
|
|
|
|
|
|
name=repname))
|
|
|
|
self.addProgress()
|
|
|
|
self.addProgress()
|
|
|
|
rpath_new = "%s_new" % rpath
|
|
|
|
rpath_new = "%s_new" % rpath
|
|
|
|
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)
|
|
|
|
removeDir(rpath)
|
|
|
|
removeDir(rpath)
|
|
|
|
shutil.move(rpath_new, rpath)
|
|
|
|
shutil.move(rpath_new, rpath)
|
|
|
|
except OSError as e:
|
|
|
|
except OSError as e:
|
|
|
@ -322,7 +358,8 @@ class Update(MethodsInterface):
|
|
|
|
if path.exists(rpath_new):
|
|
|
|
if path.exists(rpath_new):
|
|
|
|
removeDir(rpath_new)
|
|
|
|
removeDir(rpath_new)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not self._syncRepository(repname, url, rpath, revision):
|
|
|
|
if not self._syncRepository(repname, url, rpath, revision,
|
|
|
|
|
|
|
|
clean=check_status):
|
|
|
|
return "skip"
|
|
|
|
return "skip"
|
|
|
|
|
|
|
|
|
|
|
|
layman = Layman(dv.Get('cl_update_layman_installed'),
|
|
|
|
layman = Layman(dv.Get('cl_update_layman_installed'),
|
|
|
@ -331,6 +368,8 @@ class Update(MethodsInterface):
|
|
|
|
prefix=chroot_path)
|
|
|
|
prefix=chroot_path)
|
|
|
|
if repname != "portage":
|
|
|
|
if repname != "portage":
|
|
|
|
layman.add(repname, url, rpath_orig)
|
|
|
|
layman.add(repname, url, rpath_orig)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
mtime.restore()
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
metadata_cache_names = ("metadata/md5-cache", "metadata/cache")
|
|
|
|
metadata_cache_names = ("metadata/md5-cache", "metadata/cache")
|
|
|
@ -410,7 +449,8 @@ class Update(MethodsInterface):
|
|
|
|
p = process(layman, "-s", repname, stderr=STDOUT)
|
|
|
|
p = process(layman, "-s", repname, stderr=STDOUT)
|
|
|
|
if p.failed():
|
|
|
|
if p.failed():
|
|
|
|
raise UpdateError(
|
|
|
|
raise UpdateError(
|
|
|
|
_("Failed to update the {rname} repository").format(rname=repname),
|
|
|
|
_("Failed to update the {rname} repository").format(
|
|
|
|
|
|
|
|
rname=repname),
|
|
|
|
addon=p.read())
|
|
|
|
addon=p.read())
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
self.unstash_cache(rpath, laymanname)
|
|
|
|
self.unstash_cache(rpath, laymanname)
|
|
|
@ -660,7 +700,8 @@ class Update(MethodsInterface):
|
|
|
|
mult = _print.bold("*")
|
|
|
|
mult = _print.bold("*")
|
|
|
|
self.printDefault(
|
|
|
|
self.printDefault(
|
|
|
|
" {mult} {fullname}{flag}{shortname}{size}".format(
|
|
|
|
" {mult} {fullname}{flag}{shortname}{size}".format(
|
|
|
|
mult=mult, fullname=fullname, shortname=shortname, size=size,
|
|
|
|
mult=mult, fullname=fullname, shortname=shortname,
|
|
|
|
|
|
|
|
size=size,
|
|
|
|
flag=install_flag))
|
|
|
|
flag=install_flag))
|
|
|
|
|
|
|
|
|
|
|
|
def _display_install_package(self, emerge, emergelike=False):
|
|
|
|
def _display_install_package(self, emerge, emergelike=False):
|
|
|
@ -829,8 +870,10 @@ class Update(MethodsInterface):
|
|
|
|
emerge.installing.add_observer(self._printInstallPackage)
|
|
|
|
emerge.installing.add_observer(self._printInstallPackage)
|
|
|
|
emerge.uninstalling.add_observer(self._printUninstallPackage)
|
|
|
|
emerge.uninstalling.add_observer(self._printUninstallPackage)
|
|
|
|
emerge.fetching.add_observer(self._printFetching)
|
|
|
|
emerge.fetching.add_observer(self._printFetching)
|
|
|
|
|
|
|
|
|
|
|
|
def cancel_observing_fetch(fn):
|
|
|
|
def cancel_observing_fetch(fn):
|
|
|
|
emerge.fetching.clear_observers()
|
|
|
|
emerge.fetching.clear_observers()
|
|
|
|
|
|
|
|
|
|
|
|
emerge.fetching.add_observer(cancel_observing_fetch)
|
|
|
|
emerge.fetching.add_observer(cancel_observing_fetch)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
emerge.run()
|
|
|
|
emerge.run()
|
|
|
@ -962,7 +1005,6 @@ class Update(MethodsInterface):
|
|
|
|
self.clVars.Invalidate('cl_update_profile_storage')
|
|
|
|
self.clVars.Invalidate('cl_update_profile_storage')
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reconfigureProfileVars(self, profile_dv, chroot):
|
|
|
|
def reconfigureProfileVars(self, profile_dv, chroot):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Синхронизировать репозитории
|
|
|
|
Синхронизировать репозитории
|
|
|
@ -1003,7 +1045,8 @@ class Update(MethodsInterface):
|
|
|
|
raise UpdateError(
|
|
|
|
raise UpdateError(
|
|
|
|
_("Failed to set the profile: %s") % _("Profile not found"))
|
|
|
|
_("Failed to set the profile: %s") % _("Profile not found"))
|
|
|
|
for rm_fn in filter(path.lexists,
|
|
|
|
for rm_fn in filter(path.lexists,
|
|
|
|
('/etc/make.profile', '/etc/portage/make.profile')):
|
|
|
|
('/etc/make.profile',
|
|
|
|
|
|
|
|
'/etc/portage/make.profile')):
|
|
|
|
os.unlink(rm_fn)
|
|
|
|
os.unlink(rm_fn)
|
|
|
|
os.symlink(profile_path, profile_file)
|
|
|
|
os.symlink(profile_path, profile_file)
|
|
|
|
except (OSError, IOError) as e:
|
|
|
|
except (OSError, IOError) as e:
|
|
|
@ -1016,6 +1059,7 @@ class Update(MethodsInterface):
|
|
|
|
Наложить шаблоны из профиля
|
|
|
|
Наложить шаблоны из профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from calculate.lib.cl_template import TemplatesError, ProgressTemplate
|
|
|
|
from calculate.lib.cl_template import TemplatesError, ProgressTemplate
|
|
|
|
|
|
|
|
|
|
|
|
dv = DataVarsUpdate()
|
|
|
|
dv = DataVarsUpdate()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
dv.importUpdate()
|
|
|
|
dv.importUpdate()
|
|
|
|