1SUMMARY = "Phosphor Debug Collector" 2DESCRIPTION = "Phosphor Debug Collector provides mechanisms \ 3to collect various log files and system parameters. \ 4This will be helpful for troubleshooting the problems in OpenBMC \ 5based systems." 6DEPENDS += " \ 7 phosphor-dbus-interfaces \ 8 phosphor-logging \ 9 sdbusplus \ 10 ${PYTHON_PN}-sdbus++-native \ 11 autoconf-archive-native \ 12 virtual/phosphor-debug-errors \ 13 ${PYTHON_PN}-native \ 14 ${PYTHON_PN}-pyyaml-native \ 15 ${PYTHON_PN}-setuptools-native \ 16 ${PYTHON_PN}-mako-native \ 17 fmt \ 18" 19PACKAGECONFIG ??= "${@bb.utils.contains_any('DISTRO_FEATURES', \ 20 'obmc-ubi-fs phosphor-mmc obmc-static-norootfs', '', 'jffs-workaround', d)}" 21PACKAGECONFIG[jffs-workaround] = "-Djffs-workaround=enabled, \ 22 -Djffs-workaround=disabled" 23PACKAGECONFIG[host-dump-transport-pldm] = " \ 24 -Dhost-transport=pldm,, \ 25 libpldm \ 26 " 27PACKAGECONFIG[openpower-dumps-extension] = " \ 28 -Dopenpower-dumps-extension=enabled, \ 29 -Dopenpower-dumps-extension=disabled \ 30" 31PV = "1.0+git${SRCPV}" 32PR = "r1" 33 34SRC_URI += "file://coretemp.conf" 35 36SYSTEMD_PACKAGES = "${PN}-monitor" 37SYSTEMD_SUBSTITUTIONS += "BMC_DUMP_PATH:${bmc_dump_path}:${MGR_SVC}" 38SYSTEMD_SERVICE:${PN}-monitor += "obmc-dump-monitor.service" 39SYSTEMD_SERVICE:${PN}-monitor += "ramoops-monitor.service" 40S = "${WORKDIR}/git" 41 42inherit pkgconfig meson \ 43 obmc-phosphor-dbus-service \ 44 python3native \ 45 phosphor-debug-collector 46 47EXTRA_OEMESON = " \ 48 -Dtests=disabled \ 49 -DBMC_DUMP_PATH=${bmc_dump_path} \ 50 -DERROR_MAP_YAML=${STAGING_DIR_NATIVE}/${datadir}/dump/errors_watch.yaml \ 51 " 52 53do_install:append() { 54 install -d ${D}${exec_prefix}/lib/tmpfiles.d 55 install -m 644 ${WORKDIR}/coretemp.conf ${D}${exec_prefix}/lib/tmpfiles.d/ 56} 57do_install[postfuncs] += "install_dreport" 58do_install[postfuncs] += "install_dreport_conf_file" 59do_install[postfuncs] += "install_dreport_plugins_scripts" 60do_install[postfuncs] += "install_dreport_include_scripts" 61do_install[postfuncs] += "install_dreport_user_scripts" 62 63RDEPENDS:${PN}-manager += " \ 64 ${PN}-dreport \ 65" 66RDEPENDS:${PN}-dreport += " \ 67 systemd \ 68 ${VIRTUAL-RUNTIME_base-utils} \ 69 bash \ 70 xz \ 71" 72RDEPENDS:${PN}-scripts += " \ 73 bash \ 74" 75 76FILES:${PN}-manager += " \ 77 ${bindir}/phosphor-dump-manager \ 78 ${bindir}/phosphor-offload-handler \ 79 ${exec_prefix}/lib/tmpfiles.d/coretemp.conf \ 80 ${datadir}/dump/ \ 81 " 82FILES:${PN}-monitor += "${bindir}/phosphor-dump-monitor" 83FILES:${PN}-monitor += "${bindir}/phosphor-ramoops-monitor" 84FILES:${PN}-dreport += "${bindir}/dreport" 85FILES:${PN}-scripts += "${dreport_dir}" 86 87require phosphor-debug-collector.inc 88 89ALLOW_EMPTY:${PN} = "1" 90 91DEBUG_COLLECTOR_PKGS = " \ 92 ${PN}-manager \ 93 ${PN}-monitor \ 94 ${PN}-dreport \ 95 ${PN}-scripts \ 96" 97PACKAGE_BEFORE_PN += "${DEBUG_COLLECTOR_PKGS}" 98DBUS_PACKAGES = "${PN}-manager" 99MGR_SVC ?= "xyz.openbmc_project.Dump.Manager.service" 100DBUS_SERVICE:${PN}-manager += "${MGR_SVC}" 101# Install dreport script 102# From tools/dreport.d/dreport to /usr/bin/dreport 103install_dreport() { 104 install -d ${D}${bindir} 105 install -m 0755 ${S}/tools/dreport.d/dreport \ 106 ${D}${bindir}/dreport 107} 108# Install dreport sample configuration file 109# From tools/dreport.d/sample.conf 110# to /usr/share/dreport.d/conf.d/dreport.conf 111install_dreport_conf_file() { 112 install -d ${D}${dreport_conf_dir} 113 install -m 0644 ${S}/tools/dreport.d/sample.conf \ 114 ${D}${dreport_conf_dir}/dreport.conf 115} 116# Install dreport plugins 117# From tools/dreport.d/plugins.d to /usr/share/dreport.d/plugins.d 118install_dreport_plugins_scripts() { 119 install -d ${D}${dreport_plugin_dir} 120 install -m 0755 ${S}/tools/dreport.d/plugins.d/* ${D}${dreport_plugin_dir}/ 121} 122# Install dreport utility functions 123# From tools/dreport.d/include.d to /usr/share/dreport.d/include.d 124install_dreport_include_scripts() { 125 install -d ${D}${dreport_include_dir} 126 install -m 0755 ${S}/tools/dreport.d/include.d/* \ 127 ${D}${dreport_include_dir}/ 128} 129# Make the links for a single user plugin script 130# Create user directories based on the dump type value in the config section 131# Create softlinks for the base scripts in the user directories 132def install_dreport_user_script(script_path, d): 133 import re 134 import configparser 135 #Read the user types from the dreport.conf file 136 configure = configparser.ConfigParser() 137 conf_dir = d.getVar('D', True) + d.getVar('dreport_conf_dir', True) 138 confsource = os.path.join(conf_dir, "dreport.conf") 139 configure.read(confsource) 140 config = ("config:") 141 section = "DumpType" 142 dreport_dir = d.getVar('D', True) + d.getVar('dreport_dir', True) 143 script = os.path.basename(script_path) 144 srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script) 145 file = open(script_path, "r") 146 for line in file: 147 if not config in line: 148 continue 149 revalue = re.search('[0-9]+.[0-9]+', line) 150 if not revalue: 151 bb.warn("Invalid format for config value =%s" % line) 152 continue 153 parse_value = revalue.group(0) 154 config_values = re.split(r'\W+', parse_value, 1) 155 if(len(config_values) != 2): 156 bb.warn("Invalid config value=%s" % parse_value) 157 break; 158 priority = config_values[1] 159 types = [int(d) for d in str(config_values[0])] 160 for type in types: 161 if not configure.has_option(section, str(type)): 162 bb.warn("Invalid dump type id =%s" % (str(type))) 163 continue 164 typestr = configure.get(section, str(type)) 165 destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d")) 166 if not os.path.exists(destdir): 167 os.makedirs(destdir) 168 linkname = "E" + priority + script 169 destlink = os.path.join(destdir, linkname) 170 os.symlink(srclink, destlink) 171 file.close() 172#Make the links for all the plugins 173python install_dreport_user_scripts() { 174 source = d.getVar('S', True) 175 source_path = os.path.join(source, "tools", "dreport.d", "plugins.d") 176 scripts = os.listdir(source_path) 177 for script in scripts: 178 srcname = os.path.join(source_path, script) 179 install_dreport_user_script(srcname, d) 180} 181