summaryrefslogtreecommitdiff
path: root/recipes-kernel/backports/backports_5.4.bb
blob: d16d6c1405e6e785aec2be30d89d3f6fd48a8451 (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
DESCRIPTION = "Linux Backports"
HOMEPAGE = "https://backports.wiki.kernel.org"
SECTION = "kernel/modules"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"

inherit module-base

DEPMOD_CONF = "99-backports.conf"

# To generate the backports tree yourself, so you can make modifications:
# Generate the backport tree using:
#    git clone git://git.toradex.com/backports-sources-toradex.git -b linux-5.4.y
# add/commit the generated tree
# Change SRCREV = to point to your generated tree
# Under SRC_URI point this at your generated tree as such:
#    git:///home/user/linux-backports-generated;protocol=file

SRCREV = "4cb81c29dde242744eccf9f37f2014ea3b37ade2"
SRCREV_use-head-next = "${AUTOREV}"
SRC_URI = " \
    git://git.toradex.com/backports-toradex.git;protocol=git;branch=toradex-${PV} \
    file://makefile.patch \
    file://config \
    file://${DEPMOD_CONF} \
"

# Depend on virtual/kernel to ensure that the kernel is built before we try to
# build the backports
DEPENDS += "virtual/kernel"
DEPENDS += "bison-native coreutils-native flex-native"

S = "${WORKDIR}/git"

EXTRA_OEMAKE = " \
    KLIB_BUILD=${STAGING_KERNEL_BUILDDIR} \
    KLIB=${STAGING_KERNEL_DIR} \
"

do_configure() {
    # Somehow lex does not automatically get linked to flex!
    ln -fs `which flex` ../recipe-sysroot-native/usr/bin/lex
    unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
    make CC="${BUILD_CC}" LD="${BUILD_LD}" AR="${BUILD_AR}" \
        -C ${S}/kconf O=${S}/kconf conf

    cp ${WORKDIR}/config ${S}/defconfig
    unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
    oe_runmake usedefconfig
}

# LDFLAGS are not suitable for direct ld use as with the kernel build system
do_compile() {
    unset LDFLAGS
    oe_runmake
}

do_install() {
    install -d ${D}${sysconfdir}/depmod.d/
    install -m 0644 ${WORKDIR}/${DEPMOD_CONF} ${D}${sysconfdir}/depmod.d/${DEPMOD_CONF}

    install -d ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/backports
    for ko in $(find ${S} -type f -name "*.ko")
    do
        install -m 0644 $ko ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/backports/
    done
}

pkg_postinst_${PN} () {
    if [ -z "$D" ]; then
        depmod -a ${KERNEL_VERSION}
    else
        # image.bbclass will call depmodwrapper after everything is installed,
        # no need to do it here as well
        :
    fi
}

pkg_postrm_${PN} () {
    if [ -z "$D" ]; then
        depmod -a ${KERNEL_VERSION}
    fi
}

FILES_${PN} = " \
    ${sysconfdir}/depmod.d/${DEPMOD_CONF} \
    ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/backports/ \
"