aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srpm_utils.py
blob: ebd8bffdc407e78f1535adff0a4afeae0fba4d18 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import bb

# Clean up a d for inclusion in spec
def clean_data(d):
    srpm_autotools_do_configure = """\
    if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
    if [ x"${acpaths}" = xdefault ]; then
        acpaths=
        for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \\
             grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\\1,'|sort -u`; do
                 acpaths="$acpaths -I $i"
             done
    else
        acpaths="${acpaths}"
    fi

        autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
    fi
    if [ -e ${S}/configure ]; then
        %configure ${EXTRA_OECONF}
    fi
"""


    ld = bb.data.createCopy(d)
    ld.prependVar("OVERRIDES", "srpm:")
    bb.data.update_data(ld)

    for s in ("prefix", "exec_prefix", "bindir", "sbindir", "libexecdir",
              "datadir", "sysconfdir", "sharedstatedir", "localstatedir",
              "libdir", "includedir", "infordir", "mandir"):
        ld.setVar(s, "%%{_%s}" % s)
    ld.setVar("systemd_unitdir", "%{_unitdir}/..")

    ld.setVar("STAGING_DIR_NATIVE", "")
    ld.setVar("STAGING_DIR_HOST", "")

    ld.setVar("base_do_compile", "make %{?_smp_mflags} ${EXTRA_OEMAKE}")
    ld.setVar("oe_runmake", '%{__make} ${EXTRA_OEMAKE} "$@"')
    ld.setVar("oe_multilib_header", ":")

    ld.setVar("WORKDIR", "%{_builddir}")
    ld.setVar("B", "${S}")
    ld.setVar("D", "%{buildroot}")
    ld.setVar("BUILD_SYS", "%{_build}")
    ld.setVar("HOST_ALIAS", "%{_host_alias}")
    ld.setVar("HOST_ARCH", "%{_host_cpu}")
    ld.setVar("HOST_OS", "%{_host_os}")
    ld.setVar("HOST_SYS", "%{_host}")
    ld.setVar("HOST_VENDOR", "%{_host_vendor}")
    ld.setVar("PACKAGE_ARCH", "%{_target_cpu}")
    ld.setVar("TARGET_ALIAS", "%{_target_alias}")
    ld.setVar("TARGET_ARCH", "%{_target_cpu}")
    ld.setVar("TARGET_OS", "%{_target_os}")
    ld.setVar("TARGET_SYS", "%{_target}")
    ld.setVar("TARGET_VENDOR", "%{_target_vendor}")
    ld.setVar("CC", "%{__cc}")
    ld.setVar("CCLD", "%{__cc}")
    ld.setVar("CPP", "%{__cpp}")
    ld.setVar("CXX", "%{__cxx}")
    ld.setVar("LD", "%{__ld}")

    if bb.data.inherits_class('autotools', ld):
        # This simplifies the .spec file, but it also removes workarounds
        # embedded into autotools_do_configure which are relevant for some
        # recipes. For example, iconv.patch in ubsutils depends on the
        # gettextize workaround and needs to be removed before the conversion.
        ld.setVar("autotools_do_configure", srpm_autotools_do_configure)
        ld.setVar("autotools_do_install", "%make_install")
    elif bb.data.inherits_class('distutils', ld):
        ld.setVar("distutils_do_compile", "python setup.py build")
        ld.setVar("distutils_do_install", "python setup.py install --root=%{buildroot}")

    # Unexport any variables in SRPM_NO_EXPORT
    no_exp = ld.getVar('SRPM_NO_EXPORT', True) or ""
    for k in no_exp.split():
        ld.delVarFlag(k, "export")
        ld.delVarFlag(k, "unexport")

    # Unexport any variables with no value set
    maybe_exp = ld.getVar('SRPM_MAYBE_EXPORT', True) or ""
    for k in maybe_exp.split():
        if (ld.getVar(k, True) or "").strip() == "":
            ld.delVarFlag(k, "export")
            ld.delVarFlag(k, "unexport")

    return ld