develop
Mike Khiretskiy hace 9 años
padre 9933d9cdc4
commit 66cd9596d7

@ -1,4 +1,4 @@
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright 2014 Calculate Ltd. http://www.calculate-linux.org
#
@ -22,6 +22,7 @@ import os
import time
from calculate.core.server.gen_pid import search_worked_process
from calculate.core.setup_cache import Cache as SetupCache
from calculate.core.server.func import MethodsInterface
from calculate.lib.cl_template import SystemIni
from calculate.lib.datavars import DataVarsError
@ -62,6 +63,7 @@ __ = getLazyLocalTranslate(_)
class UpdateError(AddonError):
"""Update Error"""
class OverlayOwnCache(MutableSet):
"""
Сет оверлеев с интегрированным кэшем
@ -120,7 +122,7 @@ def variable_module(var_env):
return variable_module_decor
class Update(object):
class Update(MethodsInterface):
"""Основной объект для выполнения действий связанных с обновлением системы
"""
@ -139,8 +141,9 @@ class Update(object):
self.update_map = {}
self.refresh_binhost = False
def get_prog_path(self, progname):
return getProgPath(progname)
@staticmethod
def get_prog_path(program_name):
return getProgPath(program_name)
def _syncRepository(self, name, url, rpath, revision,
cb_progress=None):
@ -149,16 +152,16 @@ class Update(object):
"""
dv = self.clVars
git = Git()
info_outdate = False
info_outdated = False
try:
self.stash_cache(rpath, name)
if not git.checkExistsRep(rpath):
git.cloneTagRepository(url, rpath, revision,
cb_progress=cb_progress)
info_outdate = True
info_outdated = True
else:
cr = ""
try:
cr = ""
need_update = False
tag_cr = git.getCommit(rpath, revision)
cr = git.getCurrentCommit(rpath)
@ -174,8 +177,8 @@ class Update(object):
cb_progress=cb_progress)
new_cr = git.getCurrentCommit(rpath)
if new_cr != cr:
info_outdate = True
if info_outdate:
info_outdated = True
if info_outdated:
self.raiseOutdate()
dv.Set('cl_update_outdate_set', 'on', force=True)
finally:
@ -279,8 +282,6 @@ class Update(object):
raise UpdateError(_("Configuration variables for repositories "
"are not setup"))
chroot_path = path.normpath(self.clVars.Get('cl_chroot_path'))
# TODO: DEBUG
# print "DEBUG", repname, revision
if chroot_path == '/':
rpath_orig = rpath
else:
@ -321,7 +322,7 @@ class Update(object):
if path.exists(rpath_new):
removeDir(rpath_new)
else:
if not self._syncRepository(repname, url, rpath, revision, branch):
if not self._syncRepository(repname, url, rpath, revision):
return "skip"
layman = Layman(dv.Get('cl_update_layman_installed'),
@ -329,8 +330,6 @@ class Update(object):
dv.Get('cl_update_layman_conf'),
prefix=chroot_path)
if repname != "portage":
# TODO: debug block
#print "EEEE",repname, url, rpath_orig
layman.add(repname, url, rpath_orig)
return True
@ -388,7 +387,6 @@ class Update(object):
if all(not path.exists(path.join(rpath, x)) for x in cachenames):
OverlayOwnCache(self.clVars).discard(name)
def syncLaymanRepository(self, repname):
"""
Обновить репозиторий через layman
@ -520,8 +518,7 @@ class Update(object):
_print = self.color_print
one = _print("{0}", num)
two = _print("{0}", max_num)
part = _("({current} of {maximum})").format(current=one,
maximum=two)
part = _("({current} of {maximum})").format(current=one, maximum=two)
_print = _print.foreground(Colors.DEFAULT)
if self.is_binary_pkg(pkg,binary):
_colorprint = _print.foreground(Colors.PURPLE)
@ -551,7 +548,6 @@ class Update(object):
_print = _print.foreground(Colors.PURPLE)
else:
_print = _print.foreground(Colors.GREEN)
#print listDirectory('/var/db/pkg/%s' % pkg['CATEGORY'])
pkg_key = "{CATEGORY}/{PF}".format(**pkg)
if pkg_key in self.update_map:
self.startTask(_("Installing {pkg} [{oldver}]").format(
@ -559,7 +555,6 @@ class Update(object):
else:
self.startTask(_("Installing %s") % (_print(str(pkg))))
def _printFetching(self, fn):
"""
Вывод сообщения о скачивании
@ -584,7 +579,7 @@ class Update(object):
self.startTask(
_("Unmerging{part} {package}").format(part=part,
package=_print(str(pkg))))
package=_print(str(pkg))))
def emergelike(self, cmd, *params):
"""
@ -977,23 +972,16 @@ class Update(object):
if not profile_dv:
raise UpdateError(
_("Failed to use the new profile. Try again."))
for var_name in (#'cl_update_rep_rev',
'cl_update_rep_path',
for var_name in ('cl_update_rep_path',
'cl_update_rep_url',
'cl_update_rep_name',
'cl_update_branch',
'cl_update_binhost_list',
'cl_update_branch_name',
'cl_profile_system',
'cl_update_rep'
):
# TODO: debug block
#print var_name, ":", profile_dv.Get(var_name)
'cl_update_rep'):
dv.Set(var_name, profile_dv.Get(var_name), force=True)
dv.Set('cl_chroot_path', chroot, force=True)
# TODO: debug block
#print ('cl_builder_branch_name',
# self.clVars.Get('cl_builder_branch_name'))
except DataVarsError as e:
print str(e)
raise UpdateError(_("Wrong profile"))

Cargando…
Cancelar
Guardar