blob: b4800645bb8bac3d0b106330c826598024bf0c6f [file] [log] [blame]
Jayanth Othayoth9963d172017-05-08 09:25:05 -05001SUMMARY = "Phosphor Debug Collector"
2DESCRIPTION = "Phosphor Debug Collector provides mechanisms \
Gunnar Mills2867a482017-08-08 10:53:28 -05003to collect various log files and system parameters. \
Jayanth Othayoth9963d172017-05-08 09:25:05 -05004This will be helpful for troubleshooting the problems in OpenBMC \
5based systems."
6
7PR = "r1"
8
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -05009DEBUG_COLLECTOR_PKGS = " \
10 ${PN}-manager \
11 ${PN}-monitor \
Jayanth Othayothd2592492017-07-29 22:28:44 -050012 ${PN}-dreport \
Marri Devender Rao33603922017-10-11 02:22:46 -050013 ${PN}-scripts \
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050014"
Brad Bishopbe45c3f2018-04-11 10:53:06 -040015PACKAGE_BEFORE_PN += "${DEBUG_COLLECTOR_PKGS}"
16ALLOW_EMPTY_${PN} = "1"
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050017
18DBUS_PACKAGES = "${PN}-manager"
19
20SYSTEMD_PACKAGES = "${PN}-monitor"
21
Jayanth Othayoth9963d172017-05-08 09:25:05 -050022inherit autotools \
23 pkgconfig \
Jayanth Othayothaae91e32017-06-05 03:10:00 -050024 obmc-phosphor-dbus-service \
Jayanth Othayoth5f6d8852017-07-05 10:31:16 -050025 pythonnative \
26 phosphor-debug-collector
Jayanth Othayoth9963d172017-05-08 09:25:05 -050027
28require phosphor-debug-collector.inc
29
30DEPENDS += " \
31 phosphor-dbus-interfaces \
32 phosphor-dbus-interfaces-native \
33 phosphor-logging \
34 sdbusplus \
35 sdbusplus-native \
36 autoconf-archive-native \
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050037"
Jayanth Othayoth9963d172017-05-08 09:25:05 -050038
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050039RDEPENDS_${PN}-manager += " \
Jayanth Othayoth9963d172017-05-08 09:25:05 -050040 sdbusplus \
41 phosphor-dbus-interfaces \
42 phosphor-logging \
Jayanth Othayothd2592492017-07-29 22:28:44 -050043 ${PN}-dreport \
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050044"
45RDEPENDS_${PN}-monitor += " \
46 sdbusplus \
47 phosphor-dbus-interfaces \
48 phosphor-logging \
49"
Jayanth Othayothd2592492017-07-29 22:28:44 -050050RDEPENDS_${PN}-dreport += " \
51 systemd \
52 ${VIRTUAL-RUNTIME_base-utils} \
53 bash \
Jayanth Othayoth947c07b2017-07-25 09:29:37 -050054 xz \
Jayanth Othayothd2592492017-07-29 22:28:44 -050055"
Marri Devender Rao33603922017-10-11 02:22:46 -050056RDEPENDS_${PN}-scripts += " \
57 bash \
58"
Jayanth Othayoth9963d172017-05-08 09:25:05 -050059
Jayanth Othayoth5f6d8852017-07-05 10:31:16 -050060MGR_SVC ?= "xyz.openbmc_project.Dump.Manager.service"
61
62SYSTEMD_SUBSTITUTIONS += "BMC_DUMP_PATH:${bmc_dump_path}:${MGR_SVC}"
63
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050064FILES_${PN}-manager += "${sbindir}/phosphor-dump-manager"
65FILES_${PN}-monitor += "${sbindir}/phosphor-dump-monitor"
Jayanth Othayothd2592492017-07-29 22:28:44 -050066FILES_${PN}-dreport += "${bindir}/dreport"
Marri Devender Rao33603922017-10-11 02:22:46 -050067FILES_${PN}-scripts += "${dreport_dir}"
Jayanth Othayoth9d21d6c2017-05-31 06:25:55 -050068
Jayanth Othayoth5f6d8852017-07-05 10:31:16 -050069DBUS_SERVICE_${PN}-manager += "${MGR_SVC}"
Jayanth Othayothce4dfa02017-09-15 10:55:35 -050070SYSTEMD_SERVICE_${PN}-monitor += "obmc-dump-monitor.service"
Jayanth Othayoth9963d172017-05-08 09:25:05 -050071
Jayanth Othayothf1b85172017-07-05 10:54:35 -050072EXTRA_OECONF = "BMC_DUMP_PATH=${bmc_dump_path}"
Jayanth Othayoth5f6d8852017-07-05 10:31:16 -050073
Jayanth Othayoth9963d172017-05-08 09:25:05 -050074S = "${WORKDIR}/git"
Jayanth Othayothd2592492017-07-29 22:28:44 -050075
Marri Devender Rao33603922017-10-11 02:22:46 -050076# Install dreport script
77# From tools/dreport.d/dreport to /usr/bin/dreport
78install_dreport() {
79 install -d ${D}${bindir}
80 install -m 0755 ${S}/tools/dreport.d/dreport \
81 ${D}${bindir}/dreport
82}
83
84# Install dreport sample configuration file
85# From tools/dreport.d/sample.conf
86# to /usr/share/dreport.d/conf.d/dreport.conf
87install_dreport_conf_file() {
88 install -d ${D}${dreport_conf_dir}
89 install -m 0644 ${S}/tools/dreport.d/sample.conf \
90 ${D}${dreport_conf_dir}/dreport.conf
91}
92
93# Install dreport plugins
94# From tools/dreport.d/plugins.d to /usr/share/dreport.d/plugins.d
95install_dreport_plugins_scripts() {
96 install -d ${D}${dreport_plugin_dir}
97 install -m 0755 ${S}/tools/dreport.d/plugins.d/* ${D}${dreport_plugin_dir}/
98}
99
100# Install dreport utility functions
101# From tools/dreport.d/include.d to /usr/share/dreport.d/include.d
102install_dreport_include_scripts() {
103 install -d ${D}${dreport_include_dir}
104 install -m 0755 ${S}/tools/dreport.d/include.d/* \
105 ${D}${dreport_include_dir}/
106}
107
Matt Spinler015f6b12018-03-29 16:18:02 -0500108# Make the links for a single user plugin script
Marri Devender Rao33603922017-10-11 02:22:46 -0500109# Create user directories based on the dump type value in the config section
110# Create softlinks for the base scripts in the user directories
Matt Spinler015f6b12018-03-29 16:18:02 -0500111def install_dreport_user_script(script_path, d):
Marri Devender Rao33603922017-10-11 02:22:46 -0500112 import re
113 import configparser
114
115 #Read the user types from the dreport.conf file
116 configure = configparser.ConfigParser()
117 conf_dir = d.getVar('D', True) + d.getVar('dreport_conf_dir', True)
118 confsource = os.path.join(conf_dir, "dreport.conf")
119 configure.read(confsource)
Marri Devender Rao33603922017-10-11 02:22:46 -0500120
Matt Spinler015f6b12018-03-29 16:18:02 -0500121 config = ("config:")
122 section = "DumpType"
123 dreport_dir = d.getVar('D', True) + d.getVar('dreport_dir', True)
124
125 script = os.path.basename(script_path)
126 srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script)
127
128 file = open(script_path, "r")
129
130 for line in file:
131 if not config in line:
132 continue
133 revalue = re.search('[0-9]+.[0-9]+', line)
134 if not revalue:
135 bb.warn("Invalid format for config value =%s" % line)
136 continue
137 parse_value = revalue.group(0)
138 config_values = re.split('\W+', parse_value, 1)
139 if(len(config_values) != 2):
140 bb.warn("Invalid config value=%s" % parse_value)
141 break;
142 priority = config_values[1]
143 types = [int(d) for d in str(config_values[0])]
144 for type in types:
145 if not configure.has_option(section, str(type)):
146 bb.warn("Invalid dump type id =%s" % (str(type)))
147 continue
148 typestr = configure.get(section, str(type))
149 destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d"))
150 if not os.path.exists(destdir):
151 os.makedirs(destdir)
152 linkname = "E" + priority + script
153 destlink = os.path.join(destdir, linkname)
154 os.symlink(srclink, destlink)
155
156#Make the links for all the plugins
157python install_dreport_user_scripts() {
158
Marri Devender Rao33603922017-10-11 02:22:46 -0500159 source = d.getVar('S', True)
160 source_path = os.path.join(source, "tools", "dreport.d", "plugins.d")
161 scripts = os.listdir(source_path)
Matt Spinler015f6b12018-03-29 16:18:02 -0500162
Marri Devender Rao33603922017-10-11 02:22:46 -0500163 for script in scripts:
164 srcname = os.path.join(source_path, script)
Matt Spinler015f6b12018-03-29 16:18:02 -0500165 install_dreport_user_script(srcname, d)
Jayanth Othayothd2592492017-07-29 22:28:44 -0500166}
Jayanth Othayothb6a69b52017-10-12 01:47:31 -0500167
Brad Bishop811eeec2018-03-09 00:04:00 -0500168#Enable ubifs-workaround by DISTRO_FEATURE obmc-ubi-fs.
169PACKAGECONFIG_append_df-obmc-ubi-fs = " ubifs-workaround"
Jayanth Othayothb6a69b52017-10-12 01:47:31 -0500170PACKAGECONFIG[ubifs-workaround] = " \
171 --enable-ubifs-workaround, \
172 --disable-ubifs-workaround \
173"
Marri Devender Rao33603922017-10-11 02:22:46 -0500174
175do_install[postfuncs] += "install_dreport"
176do_install[postfuncs] += "install_dreport_conf_file"
177do_install[postfuncs] += "install_dreport_plugins_scripts"
178do_install[postfuncs] += "install_dreport_include_scripts"
179do_install[postfuncs] += "install_dreport_user_scripts"