gather: Make additional_packages accept debuginfo packages
Now debuginfo packages defined in additional_packages option could be handled correctly. JIRA: COMPOSE-4085 Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
parent
3a31d47c83
commit
ff269a8675
@ -706,6 +706,11 @@ Options
|
|||||||
used, so wildcards are possible. The package can be specified as name only
|
used, so wildcards are possible. The package can be specified as name only
|
||||||
or ``name.arch``.
|
or ``name.arch``.
|
||||||
|
|
||||||
|
With ``dnf`` gathering backend, you can specify a debuginfo package to be
|
||||||
|
included. This is meant to include a package if autodetection does not get
|
||||||
|
it. If you add a debuginfo package that does not have anything else from
|
||||||
|
the same build included in the compose, the sources will not be pulled in.
|
||||||
|
|
||||||
**filter_packages**
|
**filter_packages**
|
||||||
(*list*) -- packages to be excluded from a variant and architecture;
|
(*list*) -- packages to be excluded from a variant and architecture;
|
||||||
format: ``[(variant_uid_regex, {arch|*: [package_globs]})]``
|
format: ``[(variant_uid_regex, {arch|*: [package_globs]})]``
|
||||||
|
@ -18,6 +18,7 @@ from enum import Enum
|
|||||||
from itertools import count
|
from itertools import count
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from kobo.rpmlib import parse_nvra
|
from kobo.rpmlib import parse_nvra
|
||||||
|
|
||||||
@ -325,7 +326,7 @@ class Gather(GatherBase):
|
|||||||
return pkg in pkgs
|
return pkg in pkgs
|
||||||
|
|
||||||
def _add_packages(self, packages, pulled_by=None, req=None, reason=None, dest=None):
|
def _add_packages(self, packages, pulled_by=None, req=None, reason=None, dest=None):
|
||||||
dest = dest or self.result_binary_packages
|
dest = dest if dest is not None else self.result_binary_packages
|
||||||
for i in packages:
|
for i in packages:
|
||||||
assert i is not None
|
assert i is not None
|
||||||
if i not in dest:
|
if i not in dest:
|
||||||
@ -458,6 +459,7 @@ class Gather(GatherBase):
|
|||||||
@Profiler("Gather.add_initial_packages()")
|
@Profiler("Gather.add_initial_packages()")
|
||||||
def add_initial_packages(self, pattern_list):
|
def add_initial_packages(self, pattern_list):
|
||||||
added = set()
|
added = set()
|
||||||
|
added_debuginfo = set()
|
||||||
|
|
||||||
excludes = []
|
excludes = []
|
||||||
includes = []
|
includes = []
|
||||||
@ -472,17 +474,35 @@ class Gather(GatherBase):
|
|||||||
|
|
||||||
for pattern in includes:
|
for pattern in includes:
|
||||||
with Profiler("Gather.add_initial_packages():include"):
|
with Profiler("Gather.add_initial_packages():include"):
|
||||||
|
debuginfo = False
|
||||||
if pattern == "system-release" and self.opts.greedy_method == "all":
|
if pattern == "system-release" and self.opts.greedy_method == "all":
|
||||||
pkgs = self.q_binary_packages.filter(
|
pkgs = self.q_binary_packages.filter(
|
||||||
provides="system-release"
|
provides="system-release"
|
||||||
).apply()
|
).apply()
|
||||||
else:
|
else:
|
||||||
if pattern.endswith(".+"):
|
for p in DEBUG_PATTERNS:
|
||||||
pkgs = self.q_multilib_binary_packages.filter(
|
p = p.replace("*", ".+")
|
||||||
name__glob=pattern[:-2]
|
if re.match(p, pattern):
|
||||||
).apply()
|
debuginfo = True
|
||||||
|
break
|
||||||
|
if debuginfo:
|
||||||
|
if pattern.endswith(".+"):
|
||||||
|
pkgs = self.q_multilib_debug_packages.filter(
|
||||||
|
name__glob=pattern[:-2]
|
||||||
|
).apply()
|
||||||
|
else:
|
||||||
|
pkgs = self.q_debug_packages.filter(
|
||||||
|
name__glob=pattern
|
||||||
|
).apply()
|
||||||
else:
|
else:
|
||||||
pkgs = self.q_binary_packages.filter(name__glob=pattern).apply()
|
if pattern.endswith(".+"):
|
||||||
|
pkgs = self.q_multilib_binary_packages.filter(
|
||||||
|
name__glob=pattern[:-2]
|
||||||
|
).apply()
|
||||||
|
else:
|
||||||
|
pkgs = self.q_binary_packages.filter(
|
||||||
|
name__glob=pattern
|
||||||
|
).apply()
|
||||||
|
|
||||||
if not pkgs:
|
if not pkgs:
|
||||||
self.logger.error("No package matches pattern %s" % pattern)
|
self.logger.error("No package matches pattern %s" % pattern)
|
||||||
@ -495,14 +515,17 @@ class Gather(GatherBase):
|
|||||||
packages_by_name.setdefault(po.name, []).append(po)
|
packages_by_name.setdefault(po.name, []).append(po)
|
||||||
|
|
||||||
for name, packages in packages_by_name.items():
|
for name, packages in packages_by_name.items():
|
||||||
pkgs = self._get_best_package(packages)
|
pkgs = self._get_best_package(packages, debuginfo=debuginfo)
|
||||||
if pkgs:
|
if pkgs:
|
||||||
added.update(pkgs)
|
if debuginfo:
|
||||||
|
added_debuginfo.update(pkgs)
|
||||||
|
else:
|
||||||
|
added.update(pkgs)
|
||||||
|
|
||||||
for pkg in added:
|
for pkg in added | added_debuginfo:
|
||||||
self._set_flag(pkg, PkgFlag.input)
|
self._set_flag(pkg, PkgFlag.input)
|
||||||
|
|
||||||
return added
|
return added, added_debuginfo
|
||||||
|
|
||||||
@Profiler("Gather.init_query_cache()")
|
@Profiler("Gather.init_query_cache()")
|
||||||
def init_query_cache(self):
|
def init_query_cache(self):
|
||||||
@ -947,8 +970,10 @@ class Gather(GatherBase):
|
|||||||
self.conditional_packages = conditional_packages or []
|
self.conditional_packages = conditional_packages or []
|
||||||
|
|
||||||
self.logger.debug("INITIAL PACKAGES")
|
self.logger.debug("INITIAL PACKAGES")
|
||||||
added = self.add_initial_packages(pattern_list)
|
added, added_debuginfo = self.add_initial_packages(pattern_list)
|
||||||
self._add_packages(added)
|
self._add_packages(added)
|
||||||
|
if added_debuginfo:
|
||||||
|
self._add_packages(added_debuginfo, dest=self.result_debug_packages)
|
||||||
|
|
||||||
added = self.log_count("PREPOPULATE", self.add_prepopulate_packages)
|
added = self.log_count("PREPOPULATE", self.add_prepopulate_packages)
|
||||||
self._add_packages(added, reason="prepopulate")
|
self._add_packages(added, reason="prepopulate")
|
||||||
|
@ -2613,3 +2613,12 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
six.assertCountEqual(self, pkg_map["debuginfo"], [])
|
six.assertCountEqual(self, pkg_map["debuginfo"], [])
|
||||||
|
|
||||||
|
def test_explicit_debug(self):
|
||||||
|
pkg_map = self.go(["dummy-bash-debuginfo"], None)
|
||||||
|
|
||||||
|
six.assertCountEqual(self, pkg_map["rpm"], [])
|
||||||
|
six.assertCountEqual(self, pkg_map["srpm"], [])
|
||||||
|
six.assertCountEqual(
|
||||||
|
self, pkg_map["debuginfo"], ["dummy-bash-debuginfo-4.2.37-6.x86_64.rpm"],
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user