summaryrefslogtreecommitdiffstats
path: root/recipes-bsp/rmc/rmc-db.bb
blob: 7ec824a8c4534cc9ab937f6784d3d7b9aa518f59 (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
SUMMARY = "Central RMC Database"
DESCRIPTION = "Generate a centralized RMC database for RMC feature. \
Fingerprints and data for all boards supported are specified by variable \
RMC_BOARD_DATA_DIRS which is a list of top directories that contains \
subdirectories for boards. Developers can add their top directories by appending \
them to this variable in a rmc-db.bbappend.Refer to rmc-db bbclass for more \
information."

LICENSE = "MIT"

LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

S = "${WORKDIR}"

inherit rmc-db

RMC_BOARD_DATA_DIRS ?= "${THISDIR}/boards/"
RMC_DB_DIR = "${WORKDIR}/db"

FILES_${PN} = "/boot/rmc.db"

# Let sstate be aware of change in any added board directories
do_generate_rmc_db[file-checksums] = "${@get_rmc_top_dirs_list(d)}"

# derived from get_lic_checksum_file_list(d) in base.bbclass in OE
def get_rmc_top_dirs_list(d):
    dirlist = []
    dirs = d.getVar("RMC_BOARD_DATA_DIRS", True) or ''
    topdirs = dirs.split()
    for each in topdirs:
        dirlist.append(each + ":" + str(os.path.exists(each)))
    return " ".join(dirlist)

do_generate_rmc_db () {
	rmc_generate_db "${RMC_BOARD_DATA_DIRS}" "${RMC_DB_DIR}"/rmc.db
}

addtask generate_rmc_db  after do_compile

inherit deploy

do_deploy () {
	if [ -f ${RMC_DB_DIR}/rmc.db ]; then
		install -m 0400 ${RMC_DB_DIR}/rmc.db ${DEPLOYDIR}
	else
		rm -f ${DEPLOYDIR}/rmc.db
		echo "Warning: no RMC central database found, skip deployment."
	fi
}

do_install () {
	install -d ${D}/boot
	if [ -f ${RMC_DB_DIR}/rmc.db ]; then
		install -m 0400 ${RMC_DB_DIR}/rmc.db ${D}/boot/
	else
		rm -f ${D}/rmc.db
		echo "Warning: no RMC central database found, skip installation."
	fi
}
do_install[depends] += "${PN}:do_generate_rmc_db"

addtask deploy after do_generate_rmc_db