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