Include groups in depsolving.
This adds a new argument to projects_depsolve and projects_depsolve_with_size that contains the group list, unfortunately. I would have prefered adding a function that just returns a list of all the contents of a group and then add that to what was being passed into projects_depsolve. However, there does not appear to be any good way to do that in yum aside from a lot of grubbing around in the comps object, which I am unwilling to do.
This commit is contained in:
parent
0f69d2084c
commit
5fe4b47072
@ -264,7 +264,7 @@ def start_build(cfg, yumlock, gitlock, branch, recipe_name, compose_type, test_m
|
|||||||
deps = []
|
deps = []
|
||||||
try:
|
try:
|
||||||
with yumlock.lock:
|
with yumlock.lock:
|
||||||
(installed_size, deps) = projects_depsolve_with_size(yumlock.yb, projects, with_core=False)
|
(installed_size, deps) = projects_depsolve_with_size(yumlock.yb, projects, recipe.group_names, with_core=False)
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
log.error("start_build depsolve: %s", str(e))
|
log.error("start_build depsolve: %s", str(e))
|
||||||
raise RuntimeError("Problem depsolving %s: %s" % (recipe["name"], str(e)))
|
raise RuntimeError("Problem depsolving %s: %s" % (recipe["name"], str(e)))
|
||||||
@ -280,7 +280,7 @@ def start_build(cfg, yumlock, gitlock, branch, recipe_name, compose_type, test_m
|
|||||||
pkgs = [(name, "*") for name in ks.handler.packages.packageList]
|
pkgs = [(name, "*") for name in ks.handler.packages.packageList]
|
||||||
try:
|
try:
|
||||||
with yumlock.lock:
|
with yumlock.lock:
|
||||||
(template_size, _) = projects_depsolve_with_size(yumlock.yb, pkgs,
|
(template_size, _) = projects_depsolve_with_size(yumlock.yb, pkgs, [],
|
||||||
with_core=not ks.handler.packages.nocore)
|
with_core=not ks.handler.packages.nocore)
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
log.error("start_build depsolve: %s", str(e))
|
log.error("start_build depsolve: %s", str(e))
|
||||||
|
@ -189,13 +189,15 @@ def projects_info(yb, project_names):
|
|||||||
return sorted(map(yaps_to_project_info, ybl.available), key=lambda p: p["name"].lower())
|
return sorted(map(yaps_to_project_info, ybl.available), key=lambda p: p["name"].lower())
|
||||||
|
|
||||||
|
|
||||||
def projects_depsolve(yb, projects):
|
def projects_depsolve(yb, projects, groups):
|
||||||
"""Return the dependencies for a list of projects
|
"""Return the dependencies for a list of projects
|
||||||
|
|
||||||
:param yb: yum base object
|
:param yb: yum base object
|
||||||
:type yb: YumBase
|
:type yb: YumBase
|
||||||
:param projects: The projects and version globs to find the dependencies for
|
:param projects: The projects and version globs to find the dependencies for
|
||||||
:type projects: List of tuples
|
:type projects: List of tuples
|
||||||
|
:param groups: The groups to include in dependency solving
|
||||||
|
:type groups: List of str
|
||||||
:returns: NEVRA's of the project and its dependencies
|
:returns: NEVRA's of the project and its dependencies
|
||||||
:rtype: list of dicts
|
:rtype: list of dicts
|
||||||
:raises: ProjectsError if there was a problem installing something
|
:raises: ProjectsError if there was a problem installing something
|
||||||
@ -204,6 +206,9 @@ def projects_depsolve(yb, projects):
|
|||||||
# This resets the transaction
|
# This resets the transaction
|
||||||
yb.closeRpmDB()
|
yb.closeRpmDB()
|
||||||
install_errors = []
|
install_errors = []
|
||||||
|
for name in groups:
|
||||||
|
yb.selectGroup(name, ["mandatory", "default"])
|
||||||
|
|
||||||
for name, version in projects:
|
for name, version in projects:
|
||||||
if not version:
|
if not version:
|
||||||
version = "*"
|
version = "*"
|
||||||
@ -248,13 +253,15 @@ def estimate_size(packages, block_size=4096):
|
|||||||
installed_size += p.po.installedsize
|
installed_size += p.po.installedsize
|
||||||
return installed_size
|
return installed_size
|
||||||
|
|
||||||
def projects_depsolve_with_size(yb, projects, with_core=True):
|
def projects_depsolve_with_size(yb, projects, groups, with_core=True):
|
||||||
"""Return the dependencies and installed size for a list of projects
|
"""Return the dependencies and installed size for a list of projects
|
||||||
|
|
||||||
:param yb: yum base object
|
:param yb: yum base object
|
||||||
:type yb: YumBase
|
:type yb: YumBase
|
||||||
:param projects: The projects and version globs to find the dependencies for
|
:param projects: The projects and version globs to find the dependencies for
|
||||||
:type projects: List of tuples
|
:type projects: List of tuples
|
||||||
|
:param groups: The groups to include in dependency solving
|
||||||
|
:type groups: List of str
|
||||||
:returns: installed size and a list of NEVRA's of the project and its dependencies
|
:returns: installed size and a list of NEVRA's of the project and its dependencies
|
||||||
:rtype: tuple of (int, list of dicts)
|
:rtype: tuple of (int, list of dicts)
|
||||||
:raises: ProjectsError if there was a problem installing something
|
:raises: ProjectsError if there was a problem installing something
|
||||||
@ -263,6 +270,9 @@ def projects_depsolve_with_size(yb, projects, with_core=True):
|
|||||||
# This resets the transaction
|
# This resets the transaction
|
||||||
yb.closeRpmDB()
|
yb.closeRpmDB()
|
||||||
install_errors = []
|
install_errors = []
|
||||||
|
for name in groups:
|
||||||
|
yb.selectGroup(name, ["mandatory", "default"])
|
||||||
|
|
||||||
for name, version in projects:
|
for name, version in projects:
|
||||||
if not version:
|
if not version:
|
||||||
version = "*"
|
version = "*"
|
||||||
@ -335,7 +345,7 @@ def modules_info(yb, module_names):
|
|||||||
modules = sorted(map(yaps_to_project, ybl.available), key=lambda p: p["name"].lower())
|
modules = sorted(map(yaps_to_project, ybl.available), key=lambda p: p["name"].lower())
|
||||||
# Add the dependency info to each one
|
# Add the dependency info to each one
|
||||||
for module in modules:
|
for module in modules:
|
||||||
module["dependencies"] = projects_depsolve(yb, [(module["name"], "*")])
|
module["dependencies"] = projects_depsolve(yb, [(module["name"], "*")], [])
|
||||||
|
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ def v0_api(api):
|
|||||||
deps = []
|
deps = []
|
||||||
try:
|
try:
|
||||||
with api.config["YUMLOCK"].lock:
|
with api.config["YUMLOCK"].lock:
|
||||||
deps = projects_depsolve(api.config["YUMLOCK"].yb, projects)
|
deps = projects_depsolve(api.config["YUMLOCK"].yb, projects, blueprint.group_names)
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
errors.append("%s: %s" % (blueprint_name, str(e)))
|
errors.append("%s: %s" % (blueprint_name, str(e)))
|
||||||
log.error("(v0_blueprints_freeze) %s", str(e))
|
log.error("(v0_blueprints_freeze) %s", str(e))
|
||||||
@ -1330,7 +1330,7 @@ def v0_api(api):
|
|||||||
deps = []
|
deps = []
|
||||||
try:
|
try:
|
||||||
with api.config["YUMLOCK"].lock:
|
with api.config["YUMLOCK"].lock:
|
||||||
deps = projects_depsolve(api.config["YUMLOCK"].yb, projects)
|
deps = projects_depsolve(api.config["YUMLOCK"].yb, projects, blueprint.group_names)
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
errors.append("%s: %s" % (blueprint_name, str(e)))
|
errors.append("%s: %s" % (blueprint_name, str(e)))
|
||||||
log.error("(v0_blueprints_depsolve) %s", str(e))
|
log.error("(v0_blueprints_depsolve) %s", str(e))
|
||||||
@ -1385,7 +1385,7 @@ def v0_api(api):
|
|||||||
"""Return detailed information about the listed projects"""
|
"""Return detailed information about the listed projects"""
|
||||||
try:
|
try:
|
||||||
with api.config["YUMLOCK"].lock:
|
with api.config["YUMLOCK"].lock:
|
||||||
deps = projects_depsolve(api.config["YUMLOCK"].yb, [(n, "*") for n in project_names.split(",")])
|
deps = projects_depsolve(api.config["YUMLOCK"].yb, [(n, "*") for n in project_names.split(",")], [])
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
log.error("(v0_projects_depsolve) %s", str(e))
|
log.error("(v0_projects_depsolve) %s", str(e))
|
||||||
return jsonify(status=False, errors=[str(e)]), 400
|
return jsonify(status=False, errors=[str(e)]), 400
|
||||||
|
@ -182,27 +182,27 @@ class ProjectsTest(unittest.TestCase):
|
|||||||
projects_info(self.yb, ["bash"])
|
projects_info(self.yb, ["bash"])
|
||||||
|
|
||||||
def test_projects_depsolve(self):
|
def test_projects_depsolve(self):
|
||||||
deps = projects_depsolve(self.yb, [("bash", "*.*")])
|
deps = projects_depsolve(self.yb, [("bash", "*.*")], [])
|
||||||
self.assertTrue(len(deps) > 3)
|
self.assertTrue(len(deps) > 3)
|
||||||
self.assertEqual(deps[2]["name"], "basesystem")
|
self.assertEqual(deps[2]["name"], "basesystem")
|
||||||
|
|
||||||
def test_projects_depsolve_version(self):
|
def test_projects_depsolve_version(self):
|
||||||
"""Test that depsolving with a partial wildcard version works"""
|
"""Test that depsolving with a partial wildcard version works"""
|
||||||
deps = projects_depsolve(self.yb, [("bash", "4.*")])
|
deps = projects_depsolve(self.yb, [("bash", "4.*")], [])
|
||||||
self.assertEqual(deps[1]["name"], "bash")
|
self.assertEqual(deps[1]["name"], "bash")
|
||||||
|
|
||||||
deps = projects_depsolve(self.yb, [("bash", "4.2.*")])
|
deps = projects_depsolve(self.yb, [("bash", "4.2.*")], [])
|
||||||
self.assertEqual(deps[1]["name"], "bash")
|
self.assertEqual(deps[1]["name"], "bash")
|
||||||
|
|
||||||
def test_projects_depsolve_oldversion(self):
|
def test_projects_depsolve_oldversion(self):
|
||||||
"""Test that depsolving a specific non-existant version fails"""
|
"""Test that depsolving a specific non-existant version fails"""
|
||||||
with self.assertRaises(ProjectsError):
|
with self.assertRaises(ProjectsError):
|
||||||
deps = projects_depsolve(self.yb, [("bash", "1.0.0")])
|
deps = projects_depsolve(self.yb, [("bash", "1.0.0")], [])
|
||||||
self.assertEqual(deps[1]["name"], "bash")
|
self.assertEqual(deps[1]["name"], "bash")
|
||||||
|
|
||||||
def test_projects_depsolve_fail(self):
|
def test_projects_depsolve_fail(self):
|
||||||
with self.assertRaises(ProjectsError):
|
with self.assertRaises(ProjectsError):
|
||||||
projects_depsolve(self.yb, [("nada-package", "*.*")])
|
projects_depsolve(self.yb, [("nada-package", "*.*")], [])
|
||||||
|
|
||||||
def test_modules_list(self):
|
def test_modules_list(self):
|
||||||
modules = modules_list(self.yb, None)
|
modules = modules_list(self.yb, None)
|
||||||
|
Loading…
Reference in New Issue
Block a user