summaryrefslogtreecommitdiffstats
path: root/meta-phosphor
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-03-29 16:18:02 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-04-10 13:51:38 +0000
commit26ffa12f8c1f452c31d94093f495bc92176b5d70 (patch)
treef8044de718e975cb979c044ab24791b3f3bfe19b /meta-phosphor
parent81e719f372269087d4941b91ef4abe1b26dd935b (diff)
downloadtalos-openbmc-26ffa12f8c1f452c31d94093f495bc92176b5d70.tar.gz
talos-openbmc-26ffa12f8c1f452c31d94093f495bc92176b5d70.zip
dreport: refactor install_dreport_user_scripts
Pull the code that makes the plugin links for a single script into its own function and then call it from install_dreport_user_scripts. This allows other layers to bbappend this recipe and call the new install_dreport_user_script function so they can link in their own dreport plugins. The bbappends would need to: * install their own plugins into ${D}${dreport_plugin_dir} * call the new install_dreport_user_script function for each of these plugins * add any new functions to do_install[postfuncs] Tested: Check that the bitbake output directory structure matches what it was before the change. Change-Id: Id0e97c2ed2f5233df70049a472c2a785f5efde71 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r--meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb76
1 files changed, 41 insertions, 35 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
index fcbe8ae5e..2aa5560ae 100644
--- a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
+++ b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
@@ -107,12 +107,10 @@ install_dreport_include_scripts() {
${D}${dreport_include_dir}/
}
-# Parse the scripts in base directory, read config value
+# Make the links for a single user plugin script
# Create user directories based on the dump type value in the config section
# Create softlinks for the base scripts in the user directories
-python install_dreport_user_scripts() {
- from shutil import copyfile
- import stat
+def install_dreport_user_script(script_path, d):
import re
import configparser
@@ -121,44 +119,52 @@ python install_dreport_user_scripts() {
conf_dir = d.getVar('D', True) + d.getVar('dreport_conf_dir', True)
confsource = os.path.join(conf_dir, "dreport.conf")
configure.read(confsource)
+
+ config = ("config:")
section = "DumpType"
- options = configure.options(section)
+ dreport_dir = d.getVar('D', True) + d.getVar('dreport_dir', True)
+
+ script = os.path.basename(script_path)
+ srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script)
+
+ file = open(script_path, "r")
+
+ for line in file:
+ if not config in line:
+ continue
+ revalue = re.search('[0-9]+.[0-9]+', line)
+ if not revalue:
+ bb.warn("Invalid format for config value =%s" % line)
+ continue
+ parse_value = revalue.group(0)
+ config_values = re.split('\W+', parse_value, 1)
+ if(len(config_values) != 2):
+ bb.warn("Invalid config value=%s" % parse_value)
+ break;
+ priority = config_values[1]
+ types = [int(d) for d in str(config_values[0])]
+ for type in types:
+ if not configure.has_option(section, str(type)):
+ bb.warn("Invalid dump type id =%s" % (str(type)))
+ continue
+ typestr = configure.get(section, str(type))
+ destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d"))
+ if not os.path.exists(destdir):
+ os.makedirs(destdir)
+ linkname = "E" + priority + script
+ destlink = os.path.join(destdir, linkname)
+ os.symlink(srclink, destlink)
+
+#Make the links for all the plugins
+python install_dreport_user_scripts() {
- #open the script from base dir and read the config value
source = d.getVar('S', True)
source_path = os.path.join(source, "tools", "dreport.d", "plugins.d")
scripts = os.listdir(source_path)
- dreport_dir= d.getVar('D', True) + d.getVar('dreport_dir', True)
- config = ("config:")
+
for script in scripts:
srcname = os.path.join(source_path, script)
- srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script)
- file = open(srcname, "r")
- for line in file:
- if not config in line:
- continue
- revalue = re.search('[0-9]+.[0-9]+', line)
- if not revalue:
- bb.warn("Invalid format for config value =%s" % line)
- continue
- parse_value = revalue.group(0)
- config_values = re.split('\W+', parse_value, 1)
- if(len(config_values) != 2):
- bb.warn("Invalid config value=%s" % parse_value)
- break;
- priority = config_values[1]
- types = [int(d) for d in str(config_values[0])]
- for type in types:
- if not configure.has_option(section, str(type)):
- bb.warn("Invalid dump type id =%s" % (str(type)))
- continue
- typestr = configure.get(section, str(type))
- destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d"))
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- linkname = "E" + priority + script
- destlink = os.path.join(destdir, linkname)
- os.symlink(srclink, destlink)
+ install_dreport_user_script(srcname, d)
}
#Enable ubifs-workaround by DISTRO_FEATURE obmc-ubi-fs.
OpenPOWER on IntegriCloud