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 | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 7 | |
| 8 | DEPENDS += "mrw-perl-tools-native mrw-native" |
| 9 | |
| 10 | do_compile_append() { |
| 11 | ${STAGING_BINDIR_NATIVE}/perl-native/perl \ |
| 12 | ${STAGING_BINDIR_NATIVE}/hwmon.pl \ |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 13 | -x ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \ |
| 14 | -d ${WORKDIR} |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 15 | } |
| 16 | |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 17 | def find_conf_files(dir): |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 18 | 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 Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 23 | for root, dirs, files in os.walk(dir): |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 24 | for name in files: |
| 25 | if fnmatch(name, "*.conf"): |
| 26 | myfiles.append(os.path.join(root, name)) |
| 27 | |
| 28 | return myfiles |
| 29 | |
| 30 | python install_conf_files() { |
| 31 | from shutil import copy |
| 32 | |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 33 | files = find_conf_files(d.getVar("WORKDIR", True)) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 34 | |
| 35 | install_dir = os.path.join(d.getVar("D", True), |
| 36 | "etc", "default", "obmc", "hwmon") |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 37 | |
| 38 | dir_len = len(d.getVar("WORKDIR", True)) |
| 39 | |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 40 | for f in files: |
Matt Spinler | 6825c16 | 2017-03-29 12:34:40 -0500 | [diff] [blame] | 41 | dest = os.path.join(install_dir, f[dir_len + 1:]) |
Matt Spinler | d7e55e4 | 2017-01-16 10:44:58 -0600 | [diff] [blame] | 42 | parent = os.path.dirname(dest) |
| 43 | if not os.path.exists(parent): |
| 44 | os.makedirs(parent) |
| 45 | |
| 46 | copy(f, dest) |
| 47 | } |
| 48 | |
| 49 | do_install[postfuncs] += "install_conf_files" |