aboutsummaryrefslogtreecommitdiff
blob: 310b21e9ecdc74d0677e628b6ceb4a351ee4c290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright 2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

import textwrap

import portage
from portage.dep import _repo_separator
from portage.elog import elog_process
from portage.elog.messages import eerror


def eapi_invalid(self, cpv, repo_name, settings, eapi_var, eapi_parsed, eapi_lineno):
    msg = []
    msg.extend(
        textwrap.wrap(
            (
                "EAPI assignment in ebuild '%s%s%s' does not"
                " conform with PMS section 7.3.1 (see bug #402167):"
            )
            % (cpv, _repo_separator, repo_name),
            70,
        )
    )

    if not eapi_parsed:
        # None means the assignment was not found, while an
        # empty string indicates an (invalid) empty assignment.
        msg.append(
            f"\tvalid EAPI assignment must occur on or before line: {eapi_lineno}"
        )
    else:
        msg.append(
            ("\tbash returned EAPI '%s' which does not match " "assignment on line: %s")
            % (eapi_var, eapi_lineno)
        )

    if portage.data.secpass >= 2:
        # TODO: improve elog permission error handling (bug #416231)
        for line in msg:
            eerror(line, phase="other", key=cpv)
        elog_process(cpv, settings, phasefilter=("other",))

    else:
        out = portage.output.EOutput()
        for line in msg:
            out.eerror(line)