Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 1 | SUMMARY = "sensor config for phosphor-host-ipmid" |
| 2 | PR = "r1" |
| 3 | |
| 4 | inherit native |
| 5 | inherit obmc-phosphor-license |
| 6 | inherit phosphor-ipmi-host |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 7 | inherit pythonnative |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 8 | inherit mrw-xml |
Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 9 | |
| 10 | DEPENDS += " \ |
| 11 | mrw-native \ |
| 12 | mrw-perl-tools-native \ |
Brad Bishop | 96c3b13 | 2018-02-14 21:55:54 -0500 | [diff] [blame] | 13 | phosphor-ipmi-sensor-config-native \ |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 14 | phosphor-ipmi-sensor-inventory-mrw-config-native \ |
Brad Bishop | 9c37a68 | 2018-03-09 11:06:11 -0500 | [diff] [blame] | 15 | python-pyyaml-native \ |
Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 16 | " |
| 17 | |
| 18 | PROVIDES += "virtual/phosphor-ipmi-sensor-inventory" |
| 19 | |
| 20 | S = "${WORKDIR}" |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 21 | SRC_URI += "file://merge_sensor_config.py" |
Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 22 | |
| 23 | do_install() { |
Ratan Gupta | b76fa56 | 2017-03-17 19:37:28 +0530 | [diff] [blame] | 24 | DEST=${D}${sensor_datadir} |
Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 25 | install -d ${DEST} |
| 26 | |
| 27 | ${bindir}/perl-native/perl \ |
| 28 | ${bindir}/gen_ipmi_sensor.pl \ |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 29 | -i ${mrw_datadir}/${MRW_XML} \ |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 30 | -m ${sensor_yamldir}/config.yaml \ |
Ratan Gupta | b92d0ec | 2017-03-06 17:05:11 +0530 | [diff] [blame] | 31 | -o ${DEST}/sensor.yaml |
| 32 | } |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 33 | |
| 34 | python do_merge_sensor_config () { |
| 35 | import subprocess |
| 36 | |
| 37 | # TODO: Perform the merge in a temporary directory? |
| 38 | workdir = d.getVar('WORKDIR', True) |
| 39 | nativedir = d.getVar('STAGING_DIR_NATIVE', True) |
| 40 | sensoryamldir = d.getVar('sensor_yamldir', True) |
| 41 | cmd = [] |
| 42 | cmd.append(os.path.join(workdir, 'merge_sensor_config.py')) |
| 43 | cmd.append(os.path.join(sensoryamldir, 'config.yaml')) |
| 44 | |
| 45 | fetch = os.listdir(sensoryamldir) |
Kun Yi | e6bd58c | 2017-10-09 23:17:08 -0700 | [diff] [blame] | 46 | override_urls = [url for url in fetch if url.endswith('-config.yaml')] |
Dhruvaraj Subhashchandran | a03c56d | 2017-07-12 06:45:14 -0500 | [diff] [blame] | 47 | for url in override_urls: |
| 48 | bb.debug(2, 'Merging extra configurations: ' + url) |
| 49 | filename = os.path.join(sensoryamldir, url) |
| 50 | cmd.append(filename) |
| 51 | |
| 52 | # Invoke the script and don't catch any resulting exception. |
| 53 | subprocess.check_call(cmd) |
| 54 | } |
| 55 | # python-pyyaml-native is installed by do_configure, so put this task after |
| 56 | addtask merge_sensor_config after do_configure before do_compile |