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" 42 43RDEPENDS_${PN}-manager += " \ 44 ${PN}-dreport \ 45" 46RDEPENDS_${PN}-dreport += " \ 47 systemd \ 48 ${VIRTUAL-RUNTIME_base-utils} \ 49 bash \ 50 xz \ 51" 52RDEPENDS_${PN}-scripts += " \ 53 bash \ 54" 55 56MGR_SVC ?= "xyz.openbmc_project.Dump.Manager.service" 57 58SYSTEMD_SUBSTITUTIONS += "BMC_DUMP_PATH:${bmc_dump_path}:${MGR_SVC}" 59 60FILES_${PN}-manager += " \ 61 ${bindir}/phosphor-dump-manager \ 62 ${exec_prefix}/lib/tmpfiles.d/coretemp.conf \ 63 ${datadir}/dump/ \ 64 " 65FILES_${PN}-monitor += "${bindir}/phosphor-dump-monitor" 66FILES_${PN}-dreport += "${bindir}/dreport" 67FILES_${PN}-scripts += "${dreport_dir}" 68 69DBUS_SERVICE_${PN}-manager += "${MGR_SVC}" 70SYSTEMD_SERVICE_${PN}-monitor += "obmc-dump-monitor.service" 71 72EXTRA_OEMESON = " \ 73 -DBMC_DUMP_PATH=${bmc_dump_path} \ 74 -DERROR_MAP_YAML=${STAGING_DIR_NATIVE}/${datadir}/dump/errors_watch.yaml \ 75 " 76 77S = "${WORKDIR}/git" 78SRC_URI += "file://coretemp.conf" 79 80do_install_append() { 81 install -d ${D}${exec_prefix}/lib/tmpfiles.d 82 install -m 644 ${WORKDIR}/coretemp.conf ${D}${exec_prefix}/lib/tmpfiles.d/ 83} 84 85# Install dreport script 86# From tools/dreport.d/dreport to /usr/bin/dreport 87install_dreport() { 88 install -d ${D}${bindir} 89 install -m 0755 ${S}/tools/dreport.d/dreport \ 90 ${D}${bindir}/dreport 91} 92 93# Install dreport sample configuration file 94# From tools/dreport.d/sample.conf 95# to /usr/share/dreport.d/conf.d/dreport.conf 96install_dreport_conf_file() { 97 install -d ${D}${dreport_conf_dir} 98 install -m 0644 ${S}/tools/dreport.d/sample.conf \ 99 ${D}${dreport_conf_dir}/dreport.conf 100} 101 102# Install dreport plugins 103# From tools/dreport.d/plugins.d to /usr/share/dreport.d/plugins.d 104install_dreport_plugins_scripts() { 105 install -d ${D}${dreport_plugin_dir} 106 install -m 0755 ${S}/tools/dreport.d/plugins.d/* ${D}${dreport_plugin_dir}/ 107} 108 109# Install dreport utility functions 110# From tools/dreport.d/include.d to /usr/share/dreport.d/include.d 111install_dreport_include_scripts() { 112 install -d ${D}${dreport_include_dir} 113 install -m 0755 ${S}/tools/dreport.d/include.d/* \ 114 ${D}${dreport_include_dir}/ 115} 116 117# Make the links for a single user plugin script 118# Create user directories based on the dump type value in the config section 119# Create softlinks for the base scripts in the user directories 120def install_dreport_user_script(script_path, d): 121 import re 122 import configparser 123 124 #Read the user types from the dreport.conf file 125 configure = configparser.ConfigParser() 126 conf_dir = d.getVar('D', True) + d.getVar('dreport_conf_dir', True) 127 confsource = os.path.join(conf_dir, "dreport.conf") 128 configure.read(confsource) 129 130 config = ("config:") 131 section = "DumpType" 132 dreport_dir = d.getVar('D', True) + d.getVar('dreport_dir', True) 133 134 script = os.path.basename(script_path) 135 srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script) 136 137 file = open(script_path, "r") 138 139 for line in file: 140 if not config in line: 141 continue 142 revalue = re.search('[0-9]+.[0-9]+', line) 143 if not revalue: 144 bb.warn("Invalid format for config value =%s" % line) 145 continue 146 parse_value = revalue.group(0) 147 config_values = re.split('\W+', parse_value, 1) 148 if(len(config_values) != 2): 149 bb.warn("Invalid config value=%s" % parse_value) 150 break; 151 priority = config_values[1] 152 types = [int(d) for d in str(config_values[0])] 153 for type in types: 154 if not configure.has_option(section, str(type)): 155 bb.warn("Invalid dump type id =%s" % (str(type))) 156 continue 157 typestr = configure.get(section, str(type)) 158 destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d")) 159 if not os.path.exists(destdir): 160 os.makedirs(destdir) 161 linkname = "E" + priority + script 162 destlink = os.path.join(destdir, linkname) 163 os.symlink(srclink, destlink) 164 165#Make the links for all the plugins 166python install_dreport_user_scripts() { 167 168 source = d.getVar('S', True) 169 source_path = os.path.join(source, "tools", "dreport.d", "plugins.d") 170 scripts = os.listdir(source_path) 171 172 for script in scripts: 173 srcname = os.path.join(source_path, script) 174 install_dreport_user_script(srcname, d) 175} 176 177#Enable ubifs-workaround by DISTRO_FEATURE obmc-ubi-fs. 178PACKAGECONFIG_append_df-obmc-ubi-fs = " ubifs-workaround" 179PACKAGECONFIG[ubifs-workaround] = " \ 180 -Dubifs-workaround=enabled, \ 181 -Dubifs-workaround=disabled \ 182" 183 184PACKAGECONFIG[host-dump-offload-pldm] = " \ 185 -Dhost-dump-offload-transport=pldm,, \ 186 pldm \ 187 " 188 189do_install[postfuncs] += "install_dreport" 190do_install[postfuncs] += "install_dreport_conf_file" 191do_install[postfuncs] += "install_dreport_plugins_scripts" 192do_install[postfuncs] += "install_dreport_include_scripts" 193do_install[postfuncs] += "install_dreport_user_scripts" 194