|
|
@ -24,10 +24,14 @@ from calculate.lib.utils.files import (
|
|
|
|
makeDirectory, writeFile, readLinesFile, chmod, chown, FilePermission,
|
|
|
|
makeDirectory, writeFile, readLinesFile, chmod, chown, FilePermission,
|
|
|
|
find, FindFileType, removeFileWithEmptyDirectory,
|
|
|
|
find, FindFileType, removeFileWithEmptyDirectory,
|
|
|
|
copyWithPath)
|
|
|
|
copyWithPath)
|
|
|
|
|
|
|
|
from calculate.lib.utils.git import Git
|
|
|
|
from calculate.lib.utils.portage import Layman, EmergeLog, EmergeLogNamedTask, \
|
|
|
|
from calculate.lib.utils.portage import Layman, EmergeLog, EmergeLogNamedTask, \
|
|
|
|
InstalledPackageInfo, EbuildInfoError, EbuildInfo, ChrootEix
|
|
|
|
InstalledPackageInfo, EbuildInfoError, EbuildInfo, ChrootEix, \
|
|
|
|
|
|
|
|
get_packages_files_directory, get_manifest_files_directory
|
|
|
|
from calculate.update.emerge_parser import EmergeParser, \
|
|
|
|
from calculate.update.emerge_parser import EmergeParser, \
|
|
|
|
EmergeError, ChrootEmergeCommand, ChrootCommandExecutor
|
|
|
|
EmergeError, ChrootEmergeCommand, ChrootCommandExecutor, RevdepPercentBlock, \
|
|
|
|
|
|
|
|
EmergeCache
|
|
|
|
|
|
|
|
from calculate.lib.cl_log import log
|
|
|
|
from .build_storage import Build
|
|
|
|
from .build_storage import Build
|
|
|
|
from calculate.update.update import Update
|
|
|
|
from calculate.update.update import Update
|
|
|
|
from calculate.install.distr import Distributive
|
|
|
|
from calculate.install.distr import Distributive
|
|
|
@ -49,6 +53,7 @@ class Builder(Update):
|
|
|
|
self.pretend_package_list = {}
|
|
|
|
self.pretend_package_list = {}
|
|
|
|
self.update_map = {}
|
|
|
|
self.update_map = {}
|
|
|
|
self.color_print = get_color_print()
|
|
|
|
self.color_print = get_color_print()
|
|
|
|
|
|
|
|
self.emerge_cache = EmergeCache()
|
|
|
|
|
|
|
|
|
|
|
|
def mount_target(self, target):
|
|
|
|
def mount_target(self, target):
|
|
|
|
dir_distro = target.convertToDirectory()
|
|
|
|
dir_distro = target.convertToDirectory()
|
|
|
@ -185,10 +190,10 @@ class Builder(Update):
|
|
|
|
clTempl = None
|
|
|
|
clTempl = None
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
clVars.importData()
|
|
|
|
clVars.importData()
|
|
|
|
# TODO: использование параметра -T
|
|
|
|
|
|
|
|
if distro_dv:
|
|
|
|
if distro_dv:
|
|
|
|
clVars.Set('cl_template_path_use',
|
|
|
|
clVars.Set('cl_template_path_use',
|
|
|
|
[pathJoin(chroot, x) for x in distro_dv.Get('cl_template_path')],
|
|
|
|
[pathJoin(chroot, x)
|
|
|
|
|
|
|
|
for x in distro_dv.Get('cl_template_path')],
|
|
|
|
force=True)
|
|
|
|
force=True)
|
|
|
|
clVars.Set('cl_env_path',
|
|
|
|
clVars.Set('cl_env_path',
|
|
|
|
[pathJoin(chroot, x) for x in clVars.Get('cl_env_path')],
|
|
|
|
[pathJoin(chroot, x) for x in clVars.Get('cl_env_path')],
|
|
|
@ -196,10 +201,10 @@ class Builder(Update):
|
|
|
|
clVars.Set('cl_make_profile', path.join(chroot,
|
|
|
|
clVars.Set('cl_make_profile', path.join(chroot,
|
|
|
|
'etc/portage/make.profile'), force=True)
|
|
|
|
'etc/portage/make.profile'), force=True)
|
|
|
|
clVars.Set('cl_action', action, force=True)
|
|
|
|
clVars.Set('cl_action', action, force=True)
|
|
|
|
clVars.Set('cl_verbose_set', self.clVars.Get('cl_verbose_set'))
|
|
|
|
|
|
|
|
clVars.Set('cl_chroot_status', 'on', force=True)
|
|
|
|
clVars.Set('cl_chroot_status', 'on', force=True)
|
|
|
|
#clVars.Set("cl_dispatch_conf", self.clVars.Get('cl_dispatch_conf'),
|
|
|
|
for copyvar in ("cl_dispatch_conf", "cl_verbose_set",
|
|
|
|
# force=True)
|
|
|
|
"update.cl_update_world"):
|
|
|
|
|
|
|
|
clVars.Set(copyvar, self.clVars.Get(copyvar), force=True)
|
|
|
|
clVars.flIniFile()
|
|
|
|
clVars.flIniFile()
|
|
|
|
cltFilter=True if cltFilter in (True,"on") else False
|
|
|
|
cltFilter=True if cltFilter in (True,"on") else False
|
|
|
|
clVars.Set("cl_chroot_path", chroot, True)
|
|
|
|
clVars.Set("cl_chroot_path", chroot, True)
|
|
|
@ -263,8 +268,8 @@ class Builder(Update):
|
|
|
|
progname, "--repo=%s" % repname, "--update",
|
|
|
|
progname, "--repo=%s" % repname, "--update",
|
|
|
|
"--jobs=%s" % cpu_num, stderr=STDOUT)
|
|
|
|
"--jobs=%s" % cpu_num, stderr=STDOUT)
|
|
|
|
|
|
|
|
|
|
|
|
def clear_log(self, builder_id):
|
|
|
|
def clear_log(self, builder_id_path):
|
|
|
|
logname = "build-%s" % builder_id
|
|
|
|
logname = "build-%s" % builder_id_path
|
|
|
|
mainlog = self.clVars.Get('core.cl_log_path')
|
|
|
|
mainlog = self.clVars.Get('core.cl_log_path')
|
|
|
|
logpath = path.join(mainlog, logname)
|
|
|
|
logpath = path.join(mainlog, logname)
|
|
|
|
if path.exists(logpath):
|
|
|
|
if path.exists(logpath):
|
|
|
@ -273,25 +278,25 @@ class Builder(Update):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def _get_log_file(self):
|
|
|
|
def _get_log_file(self):
|
|
|
|
logname = "build-%s/%s" % (self.clVars.Get('cl_builder_id'),
|
|
|
|
logname = "build-%s/%s" % (self.clVars.Get('cl_builder_id_path'),
|
|
|
|
self.clVars.Get('cl_task_name'))
|
|
|
|
self.clVars.Get('cl_task_name'))
|
|
|
|
mainlog = self.clVars.Get('core.cl_log_path')
|
|
|
|
mainlog = self.clVars.Get('core.cl_log_path')
|
|
|
|
return path.join(mainlog, logname)
|
|
|
|
return path.join(mainlog, logname)
|
|
|
|
|
|
|
|
|
|
|
|
def emerge_ask(self, param, *packages):
|
|
|
|
def emerge_ask(self, pretend, *params):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Вывести информацию об обновлении
|
|
|
|
Вывести информацию об обновлении
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
deo = self.clVars.Get('cl_emerge_default_opts')
|
|
|
|
deo = self.clVars.Get('cl_emerge_default_opts')
|
|
|
|
param = [param]
|
|
|
|
param = [x for x in params if x.startswith("-")]
|
|
|
|
|
|
|
|
packages = [x for x in params if not x.startswith("-")]
|
|
|
|
chroot_path = self.clVars.Get('cl_builder_path')
|
|
|
|
chroot_path = self.clVars.Get('cl_builder_path')
|
|
|
|
logfile = self._get_log_file()
|
|
|
|
logfile = self._get_log_file()
|
|
|
|
with EmergeParser(ChrootEmergeCommand(chroot_path,
|
|
|
|
with EmergeParser(ChrootEmergeCommand(chroot_path,
|
|
|
|
list(packages),
|
|
|
|
list(packages),
|
|
|
|
emerge_default_opts=deo,
|
|
|
|
emerge_default_opts=deo,
|
|
|
|
extra_params=param,
|
|
|
|
extra_params=param,
|
|
|
|
logfile=logfile
|
|
|
|
logfile=logfile)) as emerge:
|
|
|
|
)) as emerge:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
emerge.question.action = lambda x: False
|
|
|
|
emerge.question.action = lambda x: False
|
|
|
|
emerge.run()
|
|
|
|
emerge.run()
|
|
|
@ -299,11 +304,14 @@ class Builder(Update):
|
|
|
|
emergelike = self.clVars.Get(
|
|
|
|
emergelike = self.clVars.Get(
|
|
|
|
'update.cl_update_emergelist_set') == 'on'
|
|
|
|
'update.cl_update_emergelist_set') == 'on'
|
|
|
|
self._display_install_package(emerge, emergelike)
|
|
|
|
self._display_install_package(emerge, emergelike)
|
|
|
|
|
|
|
|
if not pretend:
|
|
|
|
answer = self.askConfirm(
|
|
|
|
answer = self.askConfirm(
|
|
|
|
_("Would you like to merge these packages?"), "yes")
|
|
|
|
_("Would you like to merge these packages?"), "yes")
|
|
|
|
if answer == "no":
|
|
|
|
if answer == "no":
|
|
|
|
emerge.command.send("no\n")
|
|
|
|
emerge.command.send("no\n")
|
|
|
|
raise KeyboardInterrupt
|
|
|
|
raise KeyboardInterrupt
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printSUCCESS("Nothing to merge")
|
|
|
|
self.printSUCCESS("Nothing to merge")
|
|
|
|
except EmergeError as e:
|
|
|
|
except EmergeError as e:
|
|
|
@ -401,11 +409,11 @@ class Builder(Update):
|
|
|
|
map_rep[pkg['repository']]):
|
|
|
|
map_rep[pkg['repository']]):
|
|
|
|
yield pkg.atom
|
|
|
|
yield pkg.atom
|
|
|
|
except EbuildInfoError:
|
|
|
|
except EbuildInfoError:
|
|
|
|
yield pkg.atom
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
rebuild_list = map(lambda x: "=%s" % x, rebuild_generator())
|
|
|
|
rebuild_list = map(lambda x: "=%s" % x, rebuild_generator())
|
|
|
|
if rebuild_list:
|
|
|
|
if rebuild_list:
|
|
|
|
return self.emerge_ask("-1", *rebuild_list)
|
|
|
|
return self.emerge_ask(False, "-1", *rebuild_list)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class Driver(object):
|
|
|
|
class Driver(object):
|
|
|
@ -533,26 +541,35 @@ class Builder(Update):
|
|
|
|
|
|
|
|
|
|
|
|
ef = EmergeFetcher(ChrootEmergeCommand(
|
|
|
|
ef = EmergeFetcher(ChrootEmergeCommand(
|
|
|
|
builder_path, ["=%s" % x for x in package_list],
|
|
|
|
builder_path, ["=%s" % x for x in package_list],
|
|
|
|
extra_params=["-Of", "--ask=n"]))
|
|
|
|
extra_params=["-Of", "--ask=n"], logfile="%s.2" % logfile))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
for package in ef:
|
|
|
|
for package in ef:
|
|
|
|
pkg_name = str(package)
|
|
|
|
pkg_name = str(package)
|
|
|
|
if binary_map.get(pkg_name, False):
|
|
|
|
if binary_map.get(pkg_name, False):
|
|
|
|
for fn in package.files:
|
|
|
|
for fn in package.files:
|
|
|
|
pkgdir_files.append("%s/%s"%(package['CATEGORY'],
|
|
|
|
pkgdir_files.append("%s/%s" % (package['CATEGORY'],
|
|
|
|
fn))
|
|
|
|
fn))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for fn in package.files:
|
|
|
|
for fn in package.files:
|
|
|
|
distdir_files.append(fn)
|
|
|
|
distdir_files.append(fn)
|
|
|
|
except EmergeFetcherError:
|
|
|
|
if ef.failed():
|
|
|
|
|
|
|
|
raise BuilderError(_("Failed to get %s") % drv_name)
|
|
|
|
|
|
|
|
except EmergeFetcherError as e:
|
|
|
|
|
|
|
|
if e.extension:
|
|
|
|
|
|
|
|
self.printPre("\n%s\n"%e.extension)
|
|
|
|
|
|
|
|
if e.errno == EmergeFetcherError.FetchErrno.NeedManually:
|
|
|
|
|
|
|
|
raise BuilderError(
|
|
|
|
|
|
|
|
_("Failed to fetch files for %s") % drv_name)
|
|
|
|
repeat_driver_list.append([drv_name, drv_mask, drv_atom])
|
|
|
|
repeat_driver_list.append([drv_name, drv_mask, drv_atom])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not driver_list and repeat_driver_list:
|
|
|
|
if not driver_list and repeat_driver_list:
|
|
|
|
driver_list = repeat_driver_list
|
|
|
|
driver_list = repeat_driver_list
|
|
|
|
repeat_driver_list = []
|
|
|
|
repeat_driver_list = []
|
|
|
|
self.printWARNING(_("Waiting for unlock %s")
|
|
|
|
self.printWARNING(_("Waiting for unlock %s")
|
|
|
|
% driver_list[0][0])
|
|
|
|
% driver_list[0][0])
|
|
|
|
time.sleep(10)
|
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
|
|
|
|
self.startTask(_("Cleaning and copying driver files"))
|
|
|
|
self.startTask(_("Cleaning and copying driver files"))
|
|
|
|
for source_dn, source, target_dn, target in [
|
|
|
|
for source_dn, source, target_dn, target in [
|
|
|
|
(builder_distdir, distdir_files,
|
|
|
|
(builder_distdir, distdir_files,
|
|
|
@ -648,6 +665,11 @@ class Builder(Update):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def check_obsolete(self, builder_path):
|
|
|
|
def check_obsolete(self, builder_path):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Проверка на устаревшие установленные пакеты
|
|
|
|
|
|
|
|
:param builder_path:
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
chroot_eix = ChrootEix(builder_path, [], ChrootEix.Option.TestObsolete)
|
|
|
|
chroot_eix = ChrootEix(builder_path, [], ChrootEix.Option.TestObsolete)
|
|
|
|
l = chroot_eix.get_packages()
|
|
|
|
l = chroot_eix.get_packages()
|
|
|
|
if l:
|
|
|
|
if l:
|
|
|
@ -673,3 +695,104 @@ class Builder(Update):
|
|
|
|
logfile=logfile)) as emerge:
|
|
|
|
logfile=logfile)) as emerge:
|
|
|
|
self._startEmerging(emerge)
|
|
|
|
self._startEmerging(emerge)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def revdep_rebuild(self, builder_path, cmd, *params):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Запуск revdep-rebulid
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
cmd_path = self.get_prog_path(cmd)
|
|
|
|
|
|
|
|
logfile = self._get_log_file()
|
|
|
|
|
|
|
|
if not cmd_path:
|
|
|
|
|
|
|
|
raise BuilderError(_("Failed to find the %s command") % cmd)
|
|
|
|
|
|
|
|
with EmergeParser(ChrootCommandExecutor(
|
|
|
|
|
|
|
|
builder_path, cmd_path, params, logfile=logfile)) as emerge:
|
|
|
|
|
|
|
|
revdep = RevdepPercentBlock(emerge)
|
|
|
|
|
|
|
|
self.addProgress()
|
|
|
|
|
|
|
|
revdep.add_observer(self.setProgress)
|
|
|
|
|
|
|
|
revdep.action = lambda x: (
|
|
|
|
|
|
|
|
self.endTask(), self.startTask(_("Assigning files to packages"))
|
|
|
|
|
|
|
|
if "Assign" in revdep else None)
|
|
|
|
|
|
|
|
self._startEmerging(emerge)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def syncLaymanRepository(self, repname):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Обновить репозиторий через layman
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
chroot_path = self.clVars.Get('cl_builder_path')
|
|
|
|
|
|
|
|
layman = self.get_prog_path('/usr/bin/layman')
|
|
|
|
|
|
|
|
if not layman:
|
|
|
|
|
|
|
|
raise BuilderError(_("The Layman tool is not found"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rpath = self.clVars.Select('cl_builder_other_rep_path',
|
|
|
|
|
|
|
|
where='cl_builder_other_rep_name',
|
|
|
|
|
|
|
|
eq=repname, limit=1)
|
|
|
|
|
|
|
|
laymanname = path.basename(rpath)
|
|
|
|
|
|
|
|
self.stash_cache(rpath, laymanname)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if Git.is_git(rpath):
|
|
|
|
|
|
|
|
self.addProgress()
|
|
|
|
|
|
|
|
p = PercentProgress(
|
|
|
|
|
|
|
|
"/usr/bin/chroot", chroot_path,
|
|
|
|
|
|
|
|
layman, "-s", laymanname, part=1, atty=True)
|
|
|
|
|
|
|
|
for perc in p.progress():
|
|
|
|
|
|
|
|
self.setProgress(perc)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
p = process(
|
|
|
|
|
|
|
|
"/usr/bin/chroot", chroot_path,
|
|
|
|
|
|
|
|
layman, "-s", repname, stderr=STDOUT)
|
|
|
|
|
|
|
|
if p.failed():
|
|
|
|
|
|
|
|
raise BuilderError(
|
|
|
|
|
|
|
|
_("Failed to update the {rname} repository").format(
|
|
|
|
|
|
|
|
rname=repname),
|
|
|
|
|
|
|
|
addon=p.read())
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
self.unstash_cache(rpath, laymanname)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _update_binhost_packages(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Выполнить команду обновления файла binhost (Packages.gz)
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
chroot_path = self.clVars.Get('cl_builder_path')
|
|
|
|
|
|
|
|
os.system('/usr/bin/chroot %s /usr/sbin/emaint binhost -f &>/dev/null'%
|
|
|
|
|
|
|
|
chroot_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanpkg(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Очистка системы от устаревших distfiles и packages
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
builder_path = self.clVars.Get('cl_builder_path')
|
|
|
|
|
|
|
|
portdirs = [
|
|
|
|
|
|
|
|
pathJoin(builder_path, x)
|
|
|
|
|
|
|
|
for x in self.clVars.Get("builder.cl_builder_repository_location")]
|
|
|
|
|
|
|
|
pkgfiles = get_packages_files_directory(*portdirs)
|
|
|
|
|
|
|
|
distdirfiles = get_manifest_files_directory(*portdirs)
|
|
|
|
|
|
|
|
distdir = self.clVars.Get('builder.cl_builder_linux_distdir')
|
|
|
|
|
|
|
|
pkgdir = self.clVars.Get('builder.cl_builder_linux_pkgdir')
|
|
|
|
|
|
|
|
logfile = self._get_log_file()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = log("update_cleanpkg.log", filename=logfile,
|
|
|
|
|
|
|
|
formatter="%(asctime)s - %(clean)s - %(message)s")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self._cleanpkg(
|
|
|
|
|
|
|
|
distdir, pkgdir, distdirfiles, pkgfiles, logger)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def raiseOutdate(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Установить флаг данные о репозиториях устарели (необходим для выполнения
|
|
|
|
|
|
|
|
eix-update и прочих команд обновляющих кэш
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.clVars.Set('cl_builder_outdate_set', 'on', force=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_branch_variables(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Применить значение переменной для выбора веток репозиториев
|
|
|
|
|
|
|
|
при обновлении
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.clVars.Set('update.cl_update_branch_name',
|
|
|
|
|
|
|
|
self.clVars.Get('builder.cl_builder_branch_name'))
|
|
|
|
|
|
|
|
return True
|
|
|
|