Brad Bishop | fe7871c | 2017-02-22 20:50:13 -0500 | [diff] [blame] | 1 | SUMMARY = "Phosphor hwmon configuration generator" |
| 2 | DESCRIPTION = "Generate phosphor-hwmon configuration from an MRW." |
| 3 | PR = "r1" |
Patrick Venture | 57c7a6f | 2018-11-04 08:16:50 -0800 | [diff] [blame] | 4 | LICENSE = "Apache-2.0" |
Brad Bishop | a1cee09 | 2019-09-13 12:14:05 -0400 | [diff] [blame] | 5 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" |
Brad Bishop | fe7871c | 2017-02-22 20:50:13 -0500 | [diff] [blame] | 6 | |
Brad Bishop | fe7871c | 2017-02-22 20:50:13 -0500 | [diff] [blame] | 7 | inherit allarch |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 8 | inherit mrw-xml |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 9 | |
| 10 | DEPENDS += "mrw-perl-tools-native mrw-native" |
| 11 | |
| 12 | do_compile_append() { |
| 13 | ${STAGING_BINDIR_NATIVE}/perl-native/perl \ |
| 14 | ${STAGING_BINDIR_NATIVE}/hwmon.pl \ |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 15 | -x ${mrw_datadir}/${MRW_XML} \ |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 16 | -d ${WORKDIR}/mrw-config-files |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 17 | } |
| 18 | |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 19 | def find_conf_files(dir): |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 20 | from fnmatch import fnmatch |
| 21 | myfiles = [] |
| 22 | |
| 23 | #These conf files generated by hwmon.pl are in |
| 24 | #subdirectories which we need to preserve the path to. |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 25 | for root, dirs, files in os.walk(dir): |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 26 | for name in files: |
| 27 | if fnmatch(name, "*.conf"): |
| 28 | myfiles.append(os.path.join(root, name)) |
| 29 | |
| 30 | return myfiles |
| 31 | |
| 32 | python install_conf_files() { |
| 33 | from shutil import copy |
| 34 | |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 35 | conf_file_dir = os.path.join( |
| 36 | d.getVar("WORKDIR", True), |
| 37 | 'mrw-config-files') |
| 38 | files = find_conf_files(conf_file_dir) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 39 | |
| 40 | install_dir = os.path.join(d.getVar("D", True), |
| 41 | "etc", "default", "obmc", "hwmon") |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 42 | |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 43 | dir_len = len(conf_file_dir) |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 44 | |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 45 | for f in files: |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 46 | dest = os.path.join(install_dir, f[dir_len + 1:]) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 47 | parent = os.path.dirname(dest) |
| 48 | if not os.path.exists(parent): |
| 49 | os.makedirs(parent) |
| 50 | |
| 51 | copy(f, dest) |
| 52 | } |
| 53 | |
| 54 | do_install[postfuncs] += "install_conf_files" |