blob: 7e016b51d61d12956dc1f3c8472dd7e835e676e5 [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"
4
5inherit obmc-phosphor-license
6inherit allarch
Matt Spinlerd7e55e42017-01-16 10:44:58 -06007
8DEPENDS += "mrw-perl-tools-native mrw-native"
9
10do_compile_append() {
11 ${STAGING_BINDIR_NATIVE}/perl-native/perl \
12 ${STAGING_BINDIR_NATIVE}/hwmon.pl \
Matt Spinler6825c162017-03-29 12:34:40 -050013 -x ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \
Brad Bishop1a6203f2017-06-07 23:30:32 -040014 -d ${WORKDIR}/mrw-config-files
Matt Spinlerd7e55e42017-01-16 10:44:58 -060015}
16
Matt Spinler6825c162017-03-29 12:34:40 -050017def find_conf_files(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060018 from fnmatch import fnmatch
19 myfiles = []
20
21 #These conf files generated by hwmon.pl are in
22 #subdirectories which we need to preserve the path to.
Matt Spinler6825c162017-03-29 12:34:40 -050023 for root, dirs, files in os.walk(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060024 for name in files:
25 if fnmatch(name, "*.conf"):
26 myfiles.append(os.path.join(root, name))
27
28 return myfiles
29
30python install_conf_files() {
31 from shutil import copy
32
Brad Bishop1a6203f2017-06-07 23:30:32 -040033 conf_file_dir = os.path.join(
34 d.getVar("WORKDIR", True),
35 'mrw-config-files')
36 files = find_conf_files(conf_file_dir)
Matt Spinlerd7e55e42017-01-16 10:44:58 -060037
38 install_dir = os.path.join(d.getVar("D", True),
39 "etc", "default", "obmc", "hwmon")
Matt Spinler6825c162017-03-29 12:34:40 -050040
Brad Bishop1a6203f2017-06-07 23:30:32 -040041 dir_len = len(conf_file_dir)
Matt Spinler6825c162017-03-29 12:34:40 -050042
Matt Spinlerd7e55e42017-01-16 10:44:58 -060043 for f in files:
Matt Spinler6825c162017-03-29 12:34:40 -050044 dest = os.path.join(install_dir, f[dir_len + 1:])
Matt Spinlerd7e55e42017-01-16 10:44:58 -060045 parent = os.path.dirname(dest)
46 if not os.path.exists(parent):
47 os.makedirs(parent)
48
49 copy(f, dest)
50}
51
52do_install[postfuncs] += "install_conf_files"