pungi/pungi/wrappers/repoclosure.py
Lubomír Sedlář aefe9b186d repoclosure: Parse all fus logs
Originally the list of solvables for fus was growing with each iteration
and nothing was ever removed. That later changed so that fus iterations
are only done on newly added stuff. It's great for performance, but
means that the last log is not a superset of all others.

To get all dependency problems we need to look into all log files, not
just the last one.

JIRA: COMPOSE-3964
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
2019-12-02 11:08:55 +01:00

76 lines
2.6 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/>.
import os
from kobo.shortcuts import force_list
def get_repoclosure_cmd(backend='yum', arch=None, repos=None, lookaside=None):
cmds = {
'yum': {'cmd': ['/usr/bin/repoclosure', '--tempcache'], 'repoarg': '--repoid=%s', 'lookaside': '--lookaside=%s'},
'dnf': {'cmd': ['dnf', 'repoclosure'], 'repoarg': '--repo=%s', 'lookaside': '--repo=%s'},
}
try:
cmd = cmds[backend]['cmd']
except KeyError:
raise RuntimeError('Unknown repoclosure backend: %s' % backend)
# There are options that are not exposed here, because we don't need
# them.
for i in force_list(arch or []):
cmd.append("--arch=%s" % i)
repos = repos or {}
for repo_id, repo_path in repos.items():
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
cmd.append(cmds[backend]['repoarg'] % repo_id)
if backend == 'dnf':
# For dnf we want to add all repos with the --repo option (which
# enables only those and not any system repo), and the repos to
# check are also listed with the --check option.
cmd.append('--check=%s' % repo_id)
lookaside = lookaside or {}
for repo_id, repo_path in lookaside.items():
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
cmd.append(cmds[backend]['lookaside'] % repo_id)
return cmd
def _to_url(path):
if "://" not in path:
return "file://%s" % os.path.abspath(path)
return path
def extract_from_fus_logs(inputs, output):
"""Extract depsolver error messages from fus log and write them to output
file.
"""
has_error = False
with open(output, "w") as fout:
for input in inputs:
with open(input) as fin:
for line in fin:
if line.startswith("Problem ") or line.startswith(" "):
fout.write(line)
has_error = True
if has_error:
raise RuntimeError("Broken dependencies! See %s for details" % output)