blob: 6cc04ac622813b30caf527d152f9bf8a897e8ad6 [file] [log] [blame]
Brad Bishop3217b272017-02-22 20:50:13 -05001SUMMARY = "Phosphor hwmon configuration generator"
2DESCRIPTION = "Generate phosphor-hwmon configuration from an MRW."
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"
Ed Tanous9936f862022-09-19 09:13:20 -07005DEPENDS += "mrw-perl-tools-native mrw-native"
6PR = "r1"
Brad Bishop3217b272017-02-22 20:50:13 -05007
Brad Bishop3217b272017-02-22 20:50:13 -05008inherit allarch
Matt Spinler0a8ea632017-12-14 13:31:55 -06009inherit mrw-xml
Matt Spinler6d2fda52017-01-16 10:44:58 -060010
Patrick Williams12fc9392021-08-06 09:16:53 -050011do_compile:append() {
Matt Spinler6d2fda52017-01-16 10:44:58 -060012 ${STAGING_BINDIR_NATIVE}/perl-native/perl \
13 ${STAGING_BINDIR_NATIVE}/hwmon.pl \
Matt Spinler0a8ea632017-12-14 13:31:55 -060014 -x ${mrw_datadir}/${MRW_XML} \
Brad Bishop096d8182017-06-07 23:30:32 -040015 -d ${WORKDIR}/mrw-config-files
Matt Spinler6d2fda52017-01-16 10:44:58 -060016}
Ed Tanous9936f862022-09-19 09:13:20 -070017do_install[postfuncs] += "install_conf_files"
Matt Spinler6d2fda52017-01-16 10:44:58 -060018
Matt Spinler6fb9ddb2017-03-29 12:34:40 -050019def find_conf_files(dir):
Matt Spinler6d2fda52017-01-16 10:44:58 -060020 from fnmatch import fnmatch
21 myfiles = []
Matt Spinler6d2fda52017-01-16 10:44:58 -060022 #These conf files generated by hwmon.pl are in
23 #subdirectories which we need to preserve the path to.
Matt Spinler6fb9ddb2017-03-29 12:34:40 -050024 for root, dirs, files in os.walk(dir):
Matt Spinler6d2fda52017-01-16 10:44:58 -060025 for name in files:
26 if fnmatch(name, "*.conf"):
27 myfiles.append(os.path.join(root, name))
Matt Spinler6d2fda52017-01-16 10:44:58 -060028 return myfiles
Matt Spinler6d2fda52017-01-16 10:44:58 -060029python install_conf_files() {
30 from shutil import copy
Brad Bishop096d8182017-06-07 23:30:32 -040031 conf_file_dir = os.path.join(
32 d.getVar("WORKDIR", True),
33 'mrw-config-files')
34 files = find_conf_files(conf_file_dir)
Matt Spinler6d2fda52017-01-16 10:44:58 -060035 install_dir = os.path.join(d.getVar("D", True),
36 "etc", "default", "obmc", "hwmon")
Brad Bishop096d8182017-06-07 23:30:32 -040037 dir_len = len(conf_file_dir)
Matt Spinler6d2fda52017-01-16 10:44:58 -060038 for f in files:
Matt Spinler6fb9ddb2017-03-29 12:34:40 -050039 dest = os.path.join(install_dir, f[dir_len + 1:])
Matt Spinler6d2fda52017-01-16 10:44:58 -060040 parent = os.path.dirname(dest)
41 if not os.path.exists(parent):
42 os.makedirs(parent)
Matt Spinler6d2fda52017-01-16 10:44:58 -060043 copy(f, dest)
44}