blob: 91e4fa59b2e250088cc04e786e4b4d9ea24eac85 [file] [log] [blame]
Brad Bishopfe7871c2017-02-22 20:50:13 -05001SUMMARY = "Phosphor hwmon configuration generator"
2DESCRIPTION = "Generate phosphor-hwmon configuration from an MRW."
3PR = "r1"
Patrick Venture57c7a6f2018-11-04 08:16:50 -08004LICENSE = "Apache-2.0"
5LIC_FILES_CHKSUM = "file://${PHOSPHORBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658"
Brad Bishopfe7871c2017-02-22 20:50:13 -05006
Brad Bishopfe7871c2017-02-22 20:50:13 -05007inherit allarch
Matt Spinler3f6fcbe2017-12-14 13:31:55 -06008inherit mrw-xml
Matt Spinlerd7e55e42017-01-16 10:44:58 -06009
10DEPENDS += "mrw-perl-tools-native mrw-native"
11
12do_compile_append() {
13 ${STAGING_BINDIR_NATIVE}/perl-native/perl \
14 ${STAGING_BINDIR_NATIVE}/hwmon.pl \
Matt Spinler3f6fcbe2017-12-14 13:31:55 -060015 -x ${mrw_datadir}/${MRW_XML} \
Brad Bishop1a6203f2017-06-07 23:30:32 -040016 -d ${WORKDIR}/mrw-config-files
Matt Spinlerd7e55e42017-01-16 10:44:58 -060017}
18
Matt Spinler6825c162017-03-29 12:34:40 -050019def find_conf_files(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060020 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 Spinler6825c162017-03-29 12:34:40 -050025 for root, dirs, files in os.walk(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060026 for name in files:
27 if fnmatch(name, "*.conf"):
28 myfiles.append(os.path.join(root, name))
29
30 return myfiles
31
32python install_conf_files() {
33 from shutil import copy
34
Brad Bishop1a6203f2017-06-07 23:30:32 -040035 conf_file_dir = os.path.join(
36 d.getVar("WORKDIR", True),
37 'mrw-config-files')
38 files = find_conf_files(conf_file_dir)
Matt Spinlerd7e55e42017-01-16 10:44:58 -060039
40 install_dir = os.path.join(d.getVar("D", True),
41 "etc", "default", "obmc", "hwmon")
Matt Spinler6825c162017-03-29 12:34:40 -050042
Brad Bishop1a6203f2017-06-07 23:30:32 -040043 dir_len = len(conf_file_dir)
Matt Spinler6825c162017-03-29 12:34:40 -050044
Matt Spinlerd7e55e42017-01-16 10:44:58 -060045 for f in files:
Matt Spinler6825c162017-03-29 12:34:40 -050046 dest = os.path.join(install_dir, f[dir_len + 1:])
Matt Spinlerd7e55e42017-01-16 10:44:58 -060047 parent = os.path.dirname(dest)
48 if not os.path.exists(parent):
49 os.makedirs(parent)
50
51 copy(f, dest)
52}
53
54do_install[postfuncs] += "install_conf_files"