pungi/pungi/wrappers/fus.py
Lubomír Sedlář ba0193ca28 gather: Add a hybrid depsolver backend
This patch adds a new gather method called `hybrid`, which uses a `fus`
binary, which must exist somewhere on the `$PATH`. It will call it
multiple times to add multilib packages.

The solver can handle packages, modules and comps groups as input.
However comps groups are never passed in. Pungi will expand it to a list
of packages to avoid issues with comps handling in fus. It ignores
optional packages, and if the group mentions a package that does not
exist, nothing else from the group is included.

Multilib is also handled outside of fus. Pungi will run it, parse the
packages from output, determines multilib packages and adds them as
input. Then it runs the solver again. This is done until nothing new is
added. Usually two passes should be enough.

Source packages and debuginfo are added as a final step. All debuginfo
packages from any included source are added. If the source or debuginfo
package is included in any lookaside repo, it will be skipped.

The tool expects to get a platform stream that should be provided for
modules to depend on. Pungi looks into the modules and gets the platform
from there. If there are more requests, an error is raised.

There is some missing functionality and options that are ignored.
Particularly these are:

 * gather_fulltree
 * gather_selfhosting
 * greedy_method

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
2018-07-16 10:21:41 +02:00

71 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://gnu.org/licenses/>.
"""
This is a wrapper for a hybrid depsolver that understands how module
dependencies work. It's Funny Solver, because it does funny things.
https://github.com/fedora-modularity/fus
The executable basically provides one iteration of the traditional DNF based
depsolver. It has to be run multiple times to explicitly add multilib packages,
or source packages to include build dependencies (which is not yet supported in
Pungi).
"""
def get_cmd(
arch,
repos,
lookasides,
packages,
modules,
platform=None,
filter_packages=None, # TODO not supported yet
):
cmd = ["fus", "--verbose", "--arch", arch]
for idx, repo in enumerate(repos):
cmd.append("--repo=repo-%s,repo,%s" % (idx, repo))
for idx, repo in enumerate(lookasides):
cmd.append("--repo=lookaside-%s,lookaside,%s" % (idx, repo))
if platform:
cmd.append("--platform=%s" % platform)
for module in modules:
cmd.append("module(%s)" % module)
cmd.extend(packages)
return cmd
def parse_output(output):
"""Read output of fus from the given filepath, and return a set of tuples
(NVR, arch) and a set of module NSVCs.
"""
packages = set()
modules = set()
with open(output) as f:
for line in f:
if " " in line or "@" not in line:
continue
nevra, _ = line.strip().rsplit("@", 1)
if nevra.startswith("module:"):
modules.add(nevra[7:].rsplit(".", 1)[0])
else:
packages.add(tuple(nevra.rsplit(".", 1)))
return packages, modules