Доработана функция проверка автоматических зависимостей

parent dba4ec8d89
commit e801ed6c8e

@ -1348,7 +1348,7 @@ class Builder(Update):
for pkg in emerge.install_packages.list:
yield pkg
except EmergeError:
print emerge.prepare_error
self._display_error(emerge.prepare_error)
def check_automagic(self, builder_path):
"""
@ -1366,34 +1366,42 @@ class Builder(Update):
except (IOError, OSError):
raise BuilderError(_("Failed to hide package database"))
lp = LibraryProviders(vdb_path="var/db/.pkg", prefix=builder_path)
automagic = {}
# task_list = task.list
task_list = []
for i in glob.glob(path.join(builder_path, vdb_path, "*/*")):
pf = path.basename(i)
category = path.basename(path.dirname(i))
task_list.append(EmergePackage("%s/%s" % (category, pf)))
task_list = task.list
#task_list = []
#for i in sorted(glob.glob(path.join(builder_path, vdb_path, "*/*"))):
# pf = path.basename(i)
# category = path.basename(path.dirname(i))
# task_list.append(EmergePackage("%s/%s" % (category, pf)))
try:
check_data = [(x,
list(set(filter(
None,
[lp.get(y) for y in
getRequires(x, vdb_path=vdb_path,
prefix=builder_path)]))))
for x in PackageList(task_list)]
check_data = {x: y for x, y in check_data if y}
lp = LibraryProviders(vdb_path="var/db/.pkg", prefix=builder_path)
def get_check_data():
for pkg in PackageList(task_list):
def get_all_reqs(pkg):
for arch, lib in getRequires(pkg, vdb_path=vdb_path,
prefix=builder_path):
if arch in lp and lib in lp[arch]:
yield tuple(lp[arch][lib])
yield pkg, list(set(get_all_reqs(pkg)))
check_data = {x:y for x,y in get_check_data() if y}
for i, data in enumerate(check_data.items()):
package, required_pkgs = data
self.startTask("Check (%d of %d) %s" % (
i + 1, len(check_data), package))
for pkg in self.pretend_emerge_list(builder_path, package):
if pkg in required_pkgs:
required_pkgs.remove(pkg)
if required_pkgs:
automagic[package] = required_pkgs
pretend = list(self.pretend_emerge_list(builder_path, package))
if not pretend:
self.endTask(False)
self.printERROR("Failed to receive package list")
else:
required_pkgs = [x for x in required_pkgs
if all(y not in pretend for y in x)]
if required_pkgs:
automagic[package] = required_pkgs
self.endTask(False)
finally:
try:
shutil.move(hide_vdb_path, real_vdb_path)
@ -1401,6 +1409,7 @@ class Builder(Update):
raise BuilderError(_("Failed to unhide package database"))
if automagic:
for pkg, reqs in automagic.items():
reqs = list(set(str(x) for x in chain(reqs)))
self.printWARNING("Detect auto depends for %s package by %s" % (
pkg, ",".join(str(x) for x in reqs)))
pkg, ",".join(reqs)))
return True

@ -324,12 +324,10 @@ class ClBuilderUpdateAction(Action):
'tasks': [
{'name': 'check_automagic',
'method': 'Builder.check_automagic(cl_builder_path)',
'condition': lambda Get:
Get('builder.cl_builder_check_automagic_set') == 'on',
# TODO: emerge.log check
# and
#BuilderConditions.was_installed(
# '.*', EmergeMark.Automagic)(Get)),
'condition': lambda Get: (
Get('builder.cl_builder_check_automagic_set') == 'on' and
BuilderConditions.was_installed(
'.*', EmergeMark.Automagic)(Get)),
'decoration': 'Builder.update_task("%s")' %
EmergeMark.Automagic
},

@ -1698,3 +1698,9 @@ class VariableClBuilderCheckAutomagicSet(Variable):
def init(self):
self.label = _("Check for auto depends")
self.help = _("check for auto depends")
def get(self):
if self.GetBool('cl_builder_binary_set'):
return "off"
else:
return "on"

Loading…
Cancel
Save