Добавлена возможность использования базового хоста бинарных обновлений

parent 84def60ebd
commit f7b1421697

@ -34,7 +34,8 @@ from calculate.lib.utils.files import (
makeDirectory, writeFile, readLinesFile, chmod, chown, FilePermission,
find, FindFileType, removeFileWithEmptyDirectory, check_rw,
tar_xz_directory, sha256sum,
copyWithPath, countFiles, listDirectory, getRunCommands, isMount, readFile)
copyWithPath, countFiles, listDirectory, getRunCommands, isMount, readFile,
DirectoryRCS, RCSError)
from calculate.lib.utils.git import Git
from calculate.builder.variables.action import Actions
from calculate.lib.utils.portage import (Layman, EmergeLog, EmergeLogNamedTask,
@ -1220,12 +1221,18 @@ class Builder(Update):
Выполнить сборку пакета
"""
deo = self.get_default_emerge_opts()
if "features-getbinpkg" in params:
env_update = {"FEATURES": "-getbinpkg"}
params = [x for x in params if x != "features-getbinpkg"]
else:
env_update = None
extra_params = [x for x in params if x.startswith("-")]
packages = [x for x in params if not x.startswith("-")]
logfile = self._get_log_file()
with EmergeParser(self.chrootize(builder_path, EmergeCommand(
packages, emerge_default_opts=deo,
extra_params=extra_params, use=use,
env_update=env_update,
logfile=logfile))) as emerge:
try:
emerge.question.action = lambda x: False
@ -1544,9 +1551,21 @@ class Builder(Update):
"""
deo = self.get_default_emerge_opts()
logfile = self._get_log_file()
# в случае использования base binhost
env_update = {}
if self.clVars.GetBool('cl_builder_binhost_base_set'):
env_update = {"PKGDIR": self.clVars.Get('cl_builder_pkgdir_stable'),
"FEATURES": "-getbinpkg"}
# удалить Packages файл, для того, чтобы он переформировался при
# следующем вызове emerge
index_fn = path.join(env_update['PKGDIR'], "Packages")
if path.exists(index_fn):
os.unlink(index_fn)
with EmergeParser(self.chrootize(builder_path, EmergeCommand(
["=%s" % x for x in packages] + ["@system"],
emerge_default_opts=deo,
env_update=env_update,
extra_params=["-pKve"], logfile=logfile))) as emerge:
try:
emerge.question.action = lambda x: False
@ -1700,8 +1719,9 @@ class Builder(Update):
if clear_req_pkgs:
try:
hide_packages(*clear_req_pkgs, prefix=builder_path)
self.emerge(builder_path, "-O", "=%s" % pkg)
# собрать пакет из исходников
self.emerge(builder_path, "features-getbinpkg",
"-O", "=%s" % pkg)
except EmergeError:
old_logfile = self._get_log_file()
pkg_path = str(pkg).replace("/", "_")
@ -1770,3 +1790,53 @@ class Builder(Update):
logfile=logfile))
dracut.execute()
return dracut.success()
def set_base_binhost(self, binhost):
"""
Использовать базовый бинарный хост
:param binhost:
:return:
"""
self.clVars.Write('cl_update_binhost', binhost)
self.clVars.Set('cl_update_package_cache_set', 'on')
return True
def index_pkgdir(self, pkgdir, trunkdir, stabledir):
"""
Спрять pkgdir при использование base binhost, для корректного вычисления
зависимостей
:param pkgdir:
:param trunkdir:
:param stabledir:
:return:
"""
drcs = DirectoryRCS(pkgdir, trunkdir, stabledir)
if drcs.not_prepared():
try:
drcs.fixing()
except RCSError as e:
raise BuilderError(
_("Failed to update trunk binaries: %s") % str(e))
else:
try:
drcs.indexing()
except RCSError as e:
raise BuilderError(
_("Failed to prepare stable binaries: %s") % str(e))
return True
def fix_pkgdir(self, pkgdir, trunkdir, stabledir):
"""
Зафиксировать изменения по собранным бинарным пакетам
:param pkgdir:
:param trunkdir:
:param stabledir:
:return:
"""
try:
drcs = DirectoryRCS(pkgdir, trunkdir, stabledir)
drcs.fixing()
except RCSError as e:
raise BuilderError(
_("Failed to merge prepared binaries: %s") % str(e))
return True

@ -18,6 +18,7 @@ import sys
from calculate.core.server.func import Action, Tasks
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from calculate.lib.cl_template import TemplatesError
from calculate.lib.utils.binhosts import BinhostError
from calculate.lib.utils.files import FilesError, isEmptyFile, readFile
from calculate.update.emerge_parser import EmergeError
from calculate.update.update import UpdateError
@ -75,7 +76,7 @@ class ClBuilderUpdateAction(Action):
"""
# ошибки, которые отображаются без подробностей
native_error = (DistributiveError, FilesError, UpdateError,
TemplatesError,
TemplatesError, BinhostError,
BuilderError, GitError, EmergeError)
successMessage = None
@ -152,6 +153,13 @@ class ClBuilderUpdateAction(Action):
'condition': lambda Get: Get(
'cl_builder_usetag_set') == "on"
},
{'name': 'use_base_binhost',
'method': 'Builder.set_base_binhost('
'builder.cl_builder_binhost_base)',
'condition': lambda Get, GetBool: (
GetBool("builder.cl_builder_binhost_base_set") and
Get("builder.cl_builder_binhost_base"))
},
{'name': 'update_layman',
'message': __("Updating layman cache"),
'method': "Builder.update_layman(cl_builder_path)",
@ -240,6 +248,12 @@ class ClBuilderUpdateAction(Action):
},
]
},
{'name': 'use_base_binhost:index_pkgdir',
'message': _("Prepare binary package directory"),
'method': 'Builder.index_pkgdir(cl_builder_pkgdir,'
'cl_builder_pkgdir_trunk,'
'cl_builder_pkgdir_stable)'
},
{'name': 'emerge_update_world',
'group': __("Updating packages"),
'tasks': [
@ -353,6 +367,12 @@ class ClBuilderUpdateAction(Action):
],
'depend': Tasks.has("update_other")
},
{'name': 'use_base_binhost:fix_pkgdir',
'message': _("Update binary package directory"),
'method': 'Builder.index_pkgdir(cl_builder_pkgdir,'
'cl_builder_pkgdir_trunk,'
'cl_builder_pkgdir_stable)'
},
{'name': 'update_other:check_automagic_group',
'group': __("Check for auto depends"),
'tasks': [

@ -819,6 +819,19 @@ class VariableClBuilderPkgdir(Variable):
else:
return ""
class VariableClBuilderPkgdirStable(Variable):
"""
Директория со стабильным набором бинарных пакетов
"""
value_format = "{cl_builder_pkgdir}.stable"
class VariableClBuilderPkgdirTrunk(Variable):
"""
Директория со набором бинарных пакетов, осавшихся в результате
прерывания сборки
"""
value_format = "{cl_builder_pkgdir}.trunk"
class VariableClBuilderAction(ReadonlyVariable):
"""
@ -1933,3 +1946,4 @@ class VariableClBuilderContainerDataPath(ImagePathHelper, Variable):
return self.Get('cl_builder_container_base_path')
prefix = "lxc-"

@ -21,7 +21,7 @@ from calculate.install import distr
from calculate.install.distr import DistributiveError
from calculate.lib.datavars import (ReadonlyVariable, VariableError,
ReadonlyTableVariable, FieldValue,
HumanReadable)
HumanReadable, Variable)
from calculate.lib.utils.files import pathJoin
from calculate.lib.utils.tools import ignore
from calculate.lib.variables import env
@ -77,6 +77,8 @@ class DataVarsBuilderLinux(linux.LinuxDataVars):
env.VariableClEnvPath(),
env.VariableClEbuildPhase(),
update.VariableClUpdateUsetagSet(section="update"),
update.VariableClUpdateBinhostBase(section="update"),
update.VariableClUpdateBinhostBaseSet(section="update"),
update.VariableClUpdateWithBdepsSet(section="update"),
update.VariableClUpdateRepData(section="update"),
update.VariableClUpdateRepPath(section="update"),
@ -438,3 +440,31 @@ class VariableClBuilderLinuxPkgdir(ReadonlyVariable):
if dv:
return pathJoin(builder_path, dv.Get('cl_pkgdir'))
return pathJoin(builder_path, fallback_pkgdir)
class VariableClBuilderBinhostBaseSet(ReadonlyVariable):
"""
Сборка использует базовый бинарный хост
"""
type = Variable.Types.Boolean
def get(self):
dv = self.Get('cl_builder_linux_datavars')
if dv:
return dv.Get('cl_update_binhost_base_set')
return Variable.Off
class VariableClBuilderBinhostBase(ReadonlyVariable):
"""
Адрес базового бинарного хоста в приоритете берётся базовый хост собирающей
системы, если не получилось, то из собираемой системы
"""
def get(self):
host_binhost_base = self.Get('update.cl_update_binhost_base')
if host_binhost_base:
return host_binhost_base
dv = self.Get('cl_builder_linux_datavars')
if dv:
return dv.Get('cl_update_binhost_base')
return ""

Loading…
Cancel
Save