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