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