2015-02-10 13:19:34 +00:00
|
|
|
# -*- 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
|
2016-09-21 12:49:13 +00:00
|
|
|
# along with this program; if not, see <https://gnu.org/licenses/>.
|
2015-02-10 13:19:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from kobo.shortcuts import force_list
|
|
|
|
|
|
|
|
|
2017-01-30 09:16:03 +00:00
|
|
|
def get_repoclosure_cmd(backend='yum', arch=None, repos=None, lookaside=None):
|
2017-01-26 08:19:12 +00:00
|
|
|
cmds = {
|
|
|
|
'yum': {'cmd': ['/usr/bin/repoclosure'], '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)
|
2017-01-26 07:59:47 +00:00
|
|
|
|
|
|
|
# There are options that are not exposed here, because we don't need
|
2017-01-26 08:19:12 +00:00
|
|
|
# them.
|
2017-01-26 07:59:47 +00:00
|
|
|
|
|
|
|
for i in force_list(arch or []):
|
|
|
|
cmd.append("--arch=%s" % i)
|
|
|
|
|
|
|
|
repos = repos or {}
|
2017-09-05 08:01:21 +00:00
|
|
|
for repo_id, repo_path in repos.items():
|
2017-01-26 08:01:44 +00:00
|
|
|
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
2017-01-26 08:19:12 +00:00
|
|
|
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)
|
2017-01-26 07:59:47 +00:00
|
|
|
|
|
|
|
lookaside = lookaside or {}
|
2017-09-05 08:01:21 +00:00
|
|
|
for repo_id, repo_path in lookaside.items():
|
2017-01-26 08:01:44 +00:00
|
|
|
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
2017-01-26 08:19:12 +00:00
|
|
|
cmd.append(cmds[backend]['lookaside'] % repo_id)
|
2017-01-26 07:59:47 +00:00
|
|
|
|
|
|
|
return cmd
|
2017-01-26 08:01:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _to_url(path):
|
|
|
|
if "://" not in path:
|
|
|
|
return "file://%s" % os.path.abspath(path)
|
|
|
|
return path
|
2018-10-22 12:14:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
def extract_from_fus_log(input, output):
|
|
|
|
"""Extract depsolver error messages from fus log and write them to output
|
|
|
|
file.
|
|
|
|
"""
|
|
|
|
has_error = False
|
|
|
|
with open(input) as fin:
|
|
|
|
with open(output, "w") as fout:
|
|
|
|
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)
|