blob: fffadc1c31dc02b1a24280dc8cdc61af75165e2b [file] [log] [blame]
Ratan Gupta3aa591f2017-03-06 17:05:11 +05301SUMMARY = "sensor config for phosphor-host-ipmid"
2PR = "r1"
Brad Bishop75f03872018-11-03 09:41:57 -07003LICENSE = "Apache-2.0"
Brad Bishop6f3f0aa2019-09-13 12:14:05 -04004LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
Ratan Gupta3aa591f2017-03-06 17:05:11 +05305
Ratan Gupta3aa591f2017-03-06 17:05:11 +05306inherit phosphor-ipmi-host
Andrew Geissler04b85e92020-03-30 14:31:19 +00007inherit python3native
Matt Spinler0a8ea632017-12-14 13:31:55 -06008inherit mrw-xml
Joseph Reynolds79809ea2021-02-26 15:37:31 -06009inherit native
Ratan Gupta3aa591f2017-03-06 17:05:11 +053010
11DEPENDS += " \
12 mrw-native \
13 mrw-perl-tools-native \
Brad Bishop4851f412018-02-14 21:55:54 -050014 phosphor-ipmi-sensor-config-native \
Dhruvaraj Subhashchandrane251ef92017-07-12 06:45:14 -050015 phosphor-ipmi-sensor-inventory-mrw-config-native \
Andrew Geissler04b85e92020-03-30 14:31:19 +000016 ${PYTHON_PN}-pyyaml-native \
Ratan Gupta3aa591f2017-03-06 17:05:11 +053017 "
18
19PROVIDES += "virtual/phosphor-ipmi-sensor-inventory"
20
21S = "${WORKDIR}"
Dhruvaraj Subhashchandrane251ef92017-07-12 06:45:14 -050022SRC_URI += "file://merge_sensor_config.py"
Ratan Gupta3aa591f2017-03-06 17:05:11 +053023
24do_install() {
Ratan Gupta65e6e472017-03-17 19:37:28 +053025 DEST=${D}${sensor_datadir}
Ratan Gupta3aa591f2017-03-06 17:05:11 +053026 install -d ${DEST}
27
28 ${bindir}/perl-native/perl \
29 ${bindir}/gen_ipmi_sensor.pl \
Matt Spinler0a8ea632017-12-14 13:31:55 -060030 -i ${mrw_datadir}/${MRW_XML} \
Dhruvaraj Subhashchandrane251ef92017-07-12 06:45:14 -050031 -m ${sensor_yamldir}/config.yaml \
Ratan Gupta3aa591f2017-03-06 17:05:11 +053032 -o ${DEST}/sensor.yaml
33}
Dhruvaraj Subhashchandrane251ef92017-07-12 06:45:14 -050034
35python do_merge_sensor_config () {
36 import subprocess
37
38 # TODO: Perform the merge in a temporary directory?
39 workdir = d.getVar('WORKDIR', True)
40 nativedir = d.getVar('STAGING_DIR_NATIVE', True)
41 sensoryamldir = d.getVar('sensor_yamldir', True)
42 cmd = []
43 cmd.append(os.path.join(workdir, 'merge_sensor_config.py'))
44 cmd.append(os.path.join(sensoryamldir, 'config.yaml'))
45
46 fetch = os.listdir(sensoryamldir)
Kun Yicdc3b232017-10-09 23:17:08 -070047 override_urls = [url for url in fetch if url.endswith('-config.yaml')]
Dhruvaraj Subhashchandrane251ef92017-07-12 06:45:14 -050048 for url in override_urls:
49 bb.debug(2, 'Merging extra configurations: ' + url)
50 filename = os.path.join(sensoryamldir, url)
51 cmd.append(filename)
52
53 # Invoke the script and don't catch any resulting exception.
54 subprocess.check_call(cmd)
55}
56# python-pyyaml-native is installed by do_configure, so put this task after
57addtask merge_sensor_config after do_configure before do_compile