Brad Bishop | fe7871c | 2017-02-22 20:50:13 -0500 | [diff] [blame] | 1 | SUMMARY = "Phosphor hwmon configuration generator" |
| 2 | DESCRIPTION = "Generate phosphor-hwmon configuration from an MRW." |
| 3 | PR = "r1" |
| 4 | |
| 5 | inherit obmc-phosphor-license |
| 6 | inherit allarch |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 7 | inherit mrw-xml |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 8 | |
| 9 | DEPENDS += "mrw-perl-tools-native mrw-native" |
| 10 | |
| 11 | do_compile_append() { |
| 12 | ${STAGING_BINDIR_NATIVE}/perl-native/perl \ |
| 13 | ${STAGING_BINDIR_NATIVE}/hwmon.pl \ |
Matt Spinler | 3f6fcbe | 2017-12-14 13:31:55 -0600 | [diff] [blame] | 14 | -x ${mrw_datadir}/${MRW_XML} \ |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 15 | -d ${WORKDIR}/mrw-config-files |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 16 | } |
| 17 | |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 18 | def find_conf_files(dir): |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 19 | 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 Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 24 | for root, dirs, files in os.walk(dir): |
Matt Spinler | d7e55e4 | 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)) |
| 28 | |
| 29 | return myfiles |
| 30 | |
| 31 | python install_conf_files() { |
| 32 | from shutil import copy |
| 33 | |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 34 | conf_file_dir = os.path.join( |
| 35 | d.getVar("WORKDIR", True), |
| 36 | 'mrw-config-files') |
| 37 | files = find_conf_files(conf_file_dir) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 38 | |
| 39 | install_dir = os.path.join(d.getVar("D", True), |
| 40 | "etc", "default", "obmc", "hwmon") |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 41 | |
Brad Bishop | 1a6203f | 2017-06-07 23:30:32 -0400 | [diff] [blame] | 42 | dir_len = len(conf_file_dir) |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 43 | |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 44 | for f in files: |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 45 | dest = os.path.join(install_dir, f[dir_len + 1:]) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 46 | parent = os.path.dirname(dest) |
| 47 | if not os.path.exists(parent): |
| 48 | os.makedirs(parent) |
| 49 | |
| 50 | copy(f, dest) |
| 51 | } |
| 52 | |
| 53 | do_install[postfuncs] += "install_conf_files" |