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