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