blob: c6d0cba731ae3f1b6642d147ace32e5df7a38268 [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 Spinler3f6fcbe2017-12-14 13:31:55 -06007inherit mrw-xml
Matt Spinlerd7e55e42017-01-16 10:44:58 -06008
9DEPENDS += "mrw-perl-tools-native mrw-native"
10
11do_compile_append() {
12 ${STAGING_BINDIR_NATIVE}/perl-native/perl \
13 ${STAGING_BINDIR_NATIVE}/hwmon.pl \
Matt Spinler3f6fcbe2017-12-14 13:31:55 -060014 -x ${mrw_datadir}/${MRW_XML} \
Brad Bishop1a6203f2017-06-07 23:30:32 -040015 -d ${WORKDIR}/mrw-config-files
Matt Spinlerd7e55e42017-01-16 10:44:58 -060016}
17
Matt Spinler6825c162017-03-29 12:34:40 -050018def find_conf_files(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060019 from fnmatch import fnmatch
20 myfiles = []
21
22 #These conf files generated by hwmon.pl are in
23 #subdirectories which we need to preserve the path to.
Matt Spinler6825c162017-03-29 12:34:40 -050024 for root, dirs, files in os.walk(dir):
Matt Spinlerd7e55e42017-01-16 10:44:58 -060025 for name in files:
26 if fnmatch(name, "*.conf"):
27 myfiles.append(os.path.join(root, name))
28
29 return myfiles
30
31python install_conf_files() {
32 from shutil import copy
33
Brad Bishop1a6203f2017-06-07 23:30:32 -040034 conf_file_dir = os.path.join(
35 d.getVar("WORKDIR", True),
36 'mrw-config-files')
37 files = find_conf_files(conf_file_dir)
Matt Spinlerd7e55e42017-01-16 10:44:58 -060038
39 install_dir = os.path.join(d.getVar("D", True),
40 "etc", "default", "obmc", "hwmon")
Matt Spinler6825c162017-03-29 12:34:40 -050041
Brad Bishop1a6203f2017-06-07 23:30:32 -040042 dir_len = len(conf_file_dir)
Matt Spinler6825c162017-03-29 12:34:40 -050043
Matt Spinlerd7e55e42017-01-16 10:44:58 -060044 for f in files:
Matt Spinler6825c162017-03-29 12:34:40 -050045 dest = os.path.join(install_dir, f[dir_len + 1:])
Matt Spinlerd7e55e42017-01-16 10:44:58 -060046 parent = os.path.dirname(dest)
47 if not os.path.exists(parent):
48 os.makedirs(parent)
49
50 copy(f, dest)
51}
52
53do_install[postfuncs] += "install_conf_files"