aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-mfgtool.inc
blob: d6a2fa50b073a5ab0d7d8afc846dbe609acaf71c (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
89
90
91
92
93
94
# Produces a Manufacturing Tool compatible Linux Kernel
#
# This makes a separated binary set for Manufacturing Tool use
# without clobbering the Linux Kernel used for normal use.
#
# This file must be included after the original linux-imx.inc file
# as it overrides the needed values.
#
# Copyright (C) 2014, 2015 O.S. Systems Software LTDA.

# Adjust provides
PROVIDES = "linux-mfgtool"

# Avoid coliding files
LOCALVERSION_append = "-mfgtool"
KERNEL_SRC_PATH = "/usr/src/kernel-mfgtool"
KERNEL_IMAGE_BASE_NAME = "${KERNEL_IMAGETYPE}-mfgtool-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
KERNEL_IMAGE_SYMLINK_NAME = "${KERNEL_IMAGETYPE}-mfgtool-${MACHINE}"
MODULE_IMAGE_BASE_NAME = "modules-mfgtool-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
MODULE_TARBALL_SYMLINK_NAME = "modules-mfgtool-${MACHINE}.tgz"
STAGING_KERNEL_DIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-mfgtool-source"
STAGING_KERNEL_BUILDDIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-mfgtool-build-artifacts"

# Ensures we prefer our mfgtool specific files
FILESEXTRAPATHS_prepend := "${THISDIR}/${ORIG_PN}-${PV}:${THISDIR}/${ORIG_PN}:"

python mfgtool_recipe_handler () {
    pn = e.data.getVar("PN", True)
    if not (pn.endswith("-mfgtool") or pn.startswith("mfgtool-")):
        return

    e.data.setVar("MLPREFIX", "mfgtool-")
    e.data.setVar("ORIG_PN", e.data.getVar("PN", True))
    e.data.setVar("PN", "mfgtool-" + e.data.getVar("PN", True).replace("-mfgtool", "").replace("mfgtool-", ""))
}

python () {
    pn = d.getVar("PN", True)
    if not pn.startswith("mfgtool-"):
        return

    from oe.classextend import ClassExtender

    # We need to expand KERNEL_VERSION at runtime, not at parse time
    # The class extension code can expand variables early so remove
    # the variable from the datastore temporarily and then restore
    kernver = d.getVar("KERNEL_VERSION", False)
    kernverpkgname = d.getVar("KERNEL_VERSION_PKG_NAME", False)
    d.delVar("KERNEL_VERSION")
    d.delVar("KERNEL_VERSION_PKG_NAME")

    class LinuxMfgToolExtender(ClassExtender):
        def extend_name(self, name):
            if name.startswith("rtld"):
                return name
            if name.endswith("-" + self.extname):
                name = name.replace("-" + self.extname, "")
            if name.startswith("virtual/"):
                subs = name.split("/", 1)[1]
                if not subs.startswith(self.extname):
                    return "virtual/" + self.extname + "-" + subs
                return name
            if not name.startswith(self.extname):
                return self.extname + "-" + name
            return name

    clsextend = LinuxMfgToolExtender("mfgtool", d)
    clsextend.rename_packages()
    clsextend.rename_package_variables((d.getVar("PACKAGEVARS", True) or "").split())

    clsextend.map_packagevars()
    clsextend.map_regexp_variable("PACKAGES_DYNAMIC")

    d.setVar("KERNEL_VERSION", kernver)
    d.setVar("KERNEL_VERSION_PKG_NAME", kernverpkgname)
}

addhandler mfgtool_recipe_handler
mfgtool_recipe_handler[eventmask] = "bb.event.RecipePreFinalise"

# FIXME: Avoid depmod data emiting as kernel-abiversion path is
#        hardcoded.
emit_depmod_pkgdata() {
    :
}

# FIXME: We need to remove the STAGING_KERNEL_BUILDDIR contents as
#        kernel.bbclass has no way to skip its installation.
# FIXME: It is not possible to have external modules against
#        this kernel variant.
do_install_append() {
    rm -r ${STAGING_KERNEL_BUILDDIR}
}