diff options
| author | Mark Hatle <mark.hatle@amd.com> | 2025-02-07 16:30:25 -0700 |
|---|---|---|
| committer | Mark Hatle <mark.hatle@amd.com> | 2025-03-30 14:16:15 -0600 |
| commit | 5cbced74e7850da51e60908b70426144aaa329cc (patch) | |
| tree | c902a1a210319fa405f934e90a51adff5d68acc1 | |
| parent | 7d88c043fb3019d3dca0b4d02c8640eb78c8c7ff (diff) | |
| download | meta-xilinx-5cbced74e7850da51e60908b70426144aaa329cc.tar.gz | |
meta-xilinx-core: Add qemuboot-tool to help process qemuboot.conf files
Used to combine multiple qemuboot.conf files, non-blank values replace prior values.
./qemuboot-tool: <command> <argument> ...
load <file> - load a new file
merge <file> - load and fill any new/empty variables
remove <var> - Remove a variable
Commands can be chained, such as:
load file1 remove val1 merge file2
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
| -rw-r--r-- | meta-xilinx-core/conf/layer.conf | 2 | ||||
| -rw-r--r-- | meta-xilinx-core/recipes-devtools/qemuboot-tool/nativesdk-qemuboot-tool_1.0.bb | 20 | ||||
| -rwxr-xr-x | meta-xilinx-core/scripts/qemuboot-tool | 87 |
3 files changed, 109 insertions, 0 deletions
diff --git a/meta-xilinx-core/conf/layer.conf b/meta-xilinx-core/conf/layer.conf index 329bb29d..3d20a0a4 100644 --- a/meta-xilinx-core/conf/layer.conf +++ b/meta-xilinx-core/conf/layer.conf | |||
| @@ -27,6 +27,8 @@ xilinx-tools:${LAYERDIR}/dynamic-layers/meta-xilinx-tools/recipes-*/*/*.bbappend | |||
| 27 | LAYERDEPENDS_xilinx = "core meta-arm" | 27 | LAYERDEPENDS_xilinx = "core meta-arm" |
| 28 | LAYERRECOMMENDS_xilinx = "openembedded-layer" | 28 | LAYERRECOMMENDS_xilinx = "openembedded-layer" |
| 29 | 29 | ||
| 30 | LAYERPATH_xilinx = "${LAYERDIR}" | ||
| 31 | |||
| 30 | LAYERSERIES_COMPAT_xilinx = "scarthgap" | 32 | LAYERSERIES_COMPAT_xilinx = "scarthgap" |
| 31 | 33 | ||
| 32 | SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \ | 34 | SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \ |
diff --git a/meta-xilinx-core/recipes-devtools/qemuboot-tool/nativesdk-qemuboot-tool_1.0.bb b/meta-xilinx-core/recipes-devtools/qemuboot-tool/nativesdk-qemuboot-tool_1.0.bb new file mode 100644 index 00000000..ff6af9d0 --- /dev/null +++ b/meta-xilinx-core/recipes-devtools/qemuboot-tool/nativesdk-qemuboot-tool_1.0.bb | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | SUMMARY = "helper script to adjust and merge multiple qemuboot.conf files" | ||
| 2 | LICENSE = "MIT" | ||
| 3 | RDEPENDS:${PN} = "nativesdk-python3-core" | ||
| 4 | |||
| 5 | LIC_FILES_CHKSUM = "file://${LAYERPATH_xilinx}/scripts/qemuboot-tool;beginline=5;endline=21;md5=4b89903784b8d154cd8b631388da4f0d" | ||
| 6 | |||
| 7 | SRC_URI = "file://${LAYERPATH_xilinx}/scripts/qemuboot-tool" | ||
| 8 | |||
| 9 | S = "${WORKDIR}" | ||
| 10 | |||
| 11 | inherit nativesdk | ||
| 12 | |||
| 13 | do_compile() { | ||
| 14 | : | ||
| 15 | } | ||
| 16 | |||
| 17 | do_install() { | ||
| 18 | install -d ${D}${bindir} | ||
| 19 | install -m 0755 ${WORKDIR}${LAYERPATH_xilinx}/scripts/* ${D}${bindir}/ | ||
| 20 | } | ||
diff --git a/meta-xilinx-core/scripts/qemuboot-tool b/meta-xilinx-core/scripts/qemuboot-tool new file mode 100755 index 00000000..14cc71b1 --- /dev/null +++ b/meta-xilinx-core/scripts/qemuboot-tool | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | #! /usr/bin/env python3 | ||
| 2 | # | ||
| 3 | # SPDX-License-Identifier: MIT | ||
| 4 | # | ||
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | # of this software and associated documentation files (the "Software"), to deal | ||
| 7 | # in the Software without restriction, including without limitation the rights | ||
| 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | # copies of the Software, and to permit persons to whom the Software is | ||
| 10 | # furnished to do so, subject to the following conditions: | ||
| 11 | # | ||
| 12 | # The above copyright notice and this permission notice shall be included in | ||
| 13 | # all copies or substantial portions of the Software. | ||
| 14 | # | ||
| 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 21 | # THE SOFTWARE. | ||
| 22 | |||
| 23 | import os | ||
| 24 | import sys | ||
| 25 | import configparser | ||
| 26 | |||
| 27 | def getVars(file, vars = {}): | ||
| 28 | if not os.path.exists(file): | ||
| 29 | sys.exit(f"{file} does not exist!") | ||
| 30 | |||
| 31 | cf = configparser.ConfigParser() | ||
| 32 | cf.read(file) | ||
| 33 | |||
| 34 | for k, v in cf.items('config_bsp'): | ||
| 35 | if k in vars and vars[k] != "": | ||
| 36 | continue | ||
| 37 | vars[k] = v | ||
| 38 | |||
| 39 | return vars | ||
| 40 | |||
| 41 | |||
| 42 | def usage(): | ||
| 43 | print("Used to combine multiple qemuboot.conf files, non-blank values replace prior values.\n") | ||
| 44 | print("%s: <command> <argument> ...\n" % sys.argv[0]) | ||
| 45 | print(" load <file> - load a new file") | ||
| 46 | print(" merge <file> - load and fill any new/empty variables") | ||
| 47 | print(" remove <var> - Remove a variable\n") | ||
| 48 | print(" Commands can be chained, such as:") | ||
| 49 | print(" load file1 remove val1 merge file2") | ||
| 50 | print() | ||
| 51 | |||
| 52 | def main(): | ||
| 53 | if "help" in sys.argv or '-h' in sys.argv or '--help' in sys.argv: | ||
| 54 | usage() | ||
| 55 | return 0 | ||
| 56 | |||
| 57 | vars = {} | ||
| 58 | |||
| 59 | idx = 1 | ||
| 60 | while(idx < len(sys.argv)): | ||
| 61 | arg = sys.argv[idx] | ||
| 62 | if arg == "load": | ||
| 63 | idx += 1 | ||
| 64 | vars = getVars(sys.argv[idx], {}) | ||
| 65 | elif arg == "merge": | ||
| 66 | idx += 1 | ||
| 67 | vars = getVars(sys.argv[idx], vars) | ||
| 68 | elif arg == "remove": | ||
| 69 | idx += 1 | ||
| 70 | key = sys.argv[idx] | ||
| 71 | if key not in vars: | ||
| 72 | print(f"remove: Variable {key} not found") | ||
| 73 | sys.exit(-1) | ||
| 74 | del vars[key] | ||
| 75 | else: | ||
| 76 | print(f"Unknown command {arg}") | ||
| 77 | sys.exit(-1) | ||
| 78 | |||
| 79 | idx += 1 | ||
| 80 | |||
| 81 | print('[config_bsp]') | ||
| 82 | for var in sorted(vars.items()): | ||
| 83 | print('%s = %s' % (var[0], var[1])) | ||
| 84 | |||
| 85 | |||
| 86 | if __name__ == "__main__": | ||
| 87 | sys.exit(main()) | ||
