summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2022-11-11 08:55:51 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-14 16:19:42 +0000
commit3e5ce0275a43202cfe9fc5e3e1bdf8c3e7998a62 (patch)
tree5a2016310020b8ed7a791431ad39f4fc4cf8a1f6 /scripts
parent744cea3bfeebcde151499a424fea6bf98d226c9b (diff)
downloadpoky-3e5ce0275a43202cfe9fc5e3e1bdf8c3e7998a62.tar.gz
scripts: convert-overrides: Allow command-line customizations
Adds argument parsing to the conversion script so that the fields that the script uses to do conversions can be customized on the command line. The intention is to allows easier customization without having to fork the script, and allow automated checking on 3rd party layers via CI without false positives (From OE-Core rev: b9551f9180bf9f13fb1c480b5b7892fdc831ffcd) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/contrib/convert-overrides.py103
1 files changed, 57 insertions, 46 deletions
diff --git a/scripts/contrib/convert-overrides.py b/scripts/contrib/convert-overrides.py
index 4d41a4c475..1939757f1b 100755
--- a/scripts/contrib/convert-overrides.py
+++ b/scripts/contrib/convert-overrides.py
@@ -22,50 +22,62 @@ import sys
22import tempfile 22import tempfile
23import shutil 23import shutil
24import mimetypes 24import mimetypes
25import argparse
25 26
26if len(sys.argv) < 2: 27parser = argparse.ArgumentParser(description="Convert override syntax")
27 print("Please specify a directory to run the conversion script against.") 28parser.add_argument("--override", "-o", action="append", default=[], help="Add additional strings to consider as an override (e.g. custom machines/distros")
28 sys.exit(1) 29parser.add_argument("--skip", "-s", action="append", default=[], help="Add additional string to skip and not consider an override")
30parser.add_argument("--skip-ext", "-e", action="append", default=[], help="Additional file suffixes to skip when processing (e.g. '.foo')")
31parser.add_argument("--package-vars", action="append", default=[], help="Additional variables to treat as package variables")
32parser.add_argument("--image-vars", action="append", default=[], help="Additional variables to treat as image variables")
33parser.add_argument("--short-override", action="append", default=[], help="Additional strings to treat as short overrides")
34parser.add_argument("path", nargs="+", help="Paths to convert")
35
36args = parser.parse_args()
29 37
30# List of strings to treat as overrides 38# List of strings to treat as overrides
31vars = ["append", "prepend", "remove"] 39vars = args.override
32vars = vars + ["qemuarm", "qemux86", "qemumips", "qemuppc", "qemuriscv", "qemuall"] 40vars += ["append", "prepend", "remove"]
33vars = vars + ["genericx86", "edgerouter", "beaglebone-yocto"] 41vars += ["qemuarm", "qemux86", "qemumips", "qemuppc", "qemuriscv", "qemuall"]
34vars = vars + ["armeb", "arm", "armv5", "armv6", "armv4", "powerpc64", "aarch64", "riscv32", "riscv64", "x86", "mips64", "powerpc"] 42vars += ["genericx86", "edgerouter", "beaglebone-yocto"]
35vars = vars + ["mipsarch", "x86-x32", "mips16e", "microblaze", "e5500-64b", "mipsisa32", "mipsisa64"] 43vars += ["armeb", "arm", "armv5", "armv6", "armv4", "powerpc64", "aarch64", "riscv32", "riscv64", "x86", "mips64", "powerpc"]
36vars = vars + ["class-native", "class-target", "class-cross-canadian", "class-cross", "class-devupstream"] 44vars += ["mipsarch", "x86-x32", "mips16e", "microblaze", "e5500-64b", "mipsisa32", "mipsisa64"]
37vars = vars + ["tune-", "pn-", "forcevariable"] 45vars += ["class-native", "class-target", "class-cross-canadian", "class-cross", "class-devupstream"]
38vars = vars + ["libc-musl", "libc-glibc", "libc-newlib","libc-baremetal"] 46vars += ["tune-", "pn-", "forcevariable"]
39vars = vars + ["task-configure", "task-compile", "task-install", "task-clean", "task-image-qa", "task-rm_work", "task-image-complete", "task-populate-sdk"] 47vars += ["libc-musl", "libc-glibc", "libc-newlib","libc-baremetal"]
40vars = vars + ["toolchain-clang", "mydistro", "nios2", "sdkmingw32", "overrideone", "overridetwo"] 48vars += ["task-configure", "task-compile", "task-install", "task-clean", "task-image-qa", "task-rm_work", "task-image-complete", "task-populate-sdk"]
41vars = vars + ["linux-gnux32", "linux-muslx32", "linux-gnun32", "mingw32", "poky", "darwin", "linuxstdbase"] 49vars += ["toolchain-clang", "mydistro", "nios2", "sdkmingw32", "overrideone", "overridetwo"]
42vars = vars + ["linux-gnueabi", "eabi"] 50vars += ["linux-gnux32", "linux-muslx32", "linux-gnun32", "mingw32", "poky", "darwin", "linuxstdbase"]
43vars = vars + ["virtclass-multilib", "virtclass-mcextend"] 51vars += ["linux-gnueabi", "eabi"]
52vars += ["virtclass-multilib", "virtclass-mcextend"]
44 53
45# List of strings to treat as overrides but only with whitespace following or another override (more restricted matching). 54# List of strings to treat as overrides but only with whitespace following or another override (more restricted matching).
46# Handles issues with arc matching arch. 55# Handles issues with arc matching arch.
47shortvars = ["arc", "mips", "mipsel", "sh4"] 56shortvars = ["arc", "mips", "mipsel", "sh4"] + args.short_override
48 57
49# Variables which take packagenames as an override 58# Variables which take packagenames as an override
50packagevars = ["FILES", "RDEPENDS", "RRECOMMENDS", "SUMMARY", "DESCRIPTION", "RSUGGESTS", "RPROVIDES", "RCONFLICTS", "PKG", "ALLOW_EMPTY", 59packagevars = ["FILES", "RDEPENDS", "RRECOMMENDS", "SUMMARY", "DESCRIPTION", "RSUGGESTS", "RPROVIDES", "RCONFLICTS", "PKG", "ALLOW_EMPTY",
51 "pkg_postrm", "pkg_postinst_ontarget", "pkg_postinst", "INITSCRIPT_NAME", "INITSCRIPT_PARAMS", "DEBIAN_NOAUTONAME", "ALTERNATIVE", 60 "pkg_postrm", "pkg_postinst_ontarget", "pkg_postinst", "INITSCRIPT_NAME", "INITSCRIPT_PARAMS", "DEBIAN_NOAUTONAME", "ALTERNATIVE",
52 "PKGE", "PKGV", "PKGR", "USERADD_PARAM", "GROUPADD_PARAM", "CONFFILES", "SYSTEMD_SERVICE", "LICENSE", "SECTION", "pkg_preinst", 61 "PKGE", "PKGV", "PKGR", "USERADD_PARAM", "GROUPADD_PARAM", "CONFFILES", "SYSTEMD_SERVICE", "LICENSE", "SECTION", "pkg_preinst",
53 "pkg_prerm", "RREPLACES", "GROUPMEMS_PARAM", "SYSTEMD_AUTO_ENABLE", "SKIP_FILEDEPS", "PRIVATE_LIBS", "PACKAGE_ADD_METADATA", 62 "pkg_prerm", "RREPLACES", "GROUPMEMS_PARAM", "SYSTEMD_AUTO_ENABLE", "SKIP_FILEDEPS", "PRIVATE_LIBS", "PACKAGE_ADD_METADATA",
54 "INSANE_SKIP", "DEBIANNAME", "SYSTEMD_SERVICE_ESCAPED"] 63 "INSANE_SKIP", "DEBIANNAME", "SYSTEMD_SERVICE_ESCAPED"] + args.package_vars
55 64
56# Expressions to skip if encountered, these are not overrides 65# Expressions to skip if encountered, these are not overrides
57skips = ["parser_append", "recipe_to_append", "extra_append", "to_remove", "show_appends", "applied_appends", "file_appends", "handle_remove"] 66skips = args.skip
58skips = skips + ["expanded_removes", "color_remove", "test_remove", "empty_remove", "toaster_prepend", "num_removed", "licfiles_append", "_write_append"] 67skips += ["parser_append", "recipe_to_append", "extra_append", "to_remove", "show_appends", "applied_appends", "file_appends", "handle_remove"]
59skips = skips + ["no_report_remove", "test_prepend", "test_append", "multiple_append", "test_remove", "shallow_remove", "do_remove_layer", "first_append"] 68skips += ["expanded_removes", "color_remove", "test_remove", "empty_remove", "toaster_prepend", "num_removed", "licfiles_append", "_write_append"]
60skips = skips + ["parser_remove", "to_append", "no_remove", "bblayers_add_remove", "bblayers_remove", "apply_append", "is_x86", "base_dep_prepend"] 69skips += ["no_report_remove", "test_prepend", "test_append", "multiple_append", "test_remove", "shallow_remove", "do_remove_layer", "first_append"]
61skips = skips + ["autotools_dep_prepend", "go_map_arm", "alt_remove_links", "systemd_append_file", "file_append", "process_file_darwin"] 70skips += ["parser_remove", "to_append", "no_remove", "bblayers_add_remove", "bblayers_remove", "apply_append", "is_x86", "base_dep_prepend"]
62skips = skips + ["run_loaddata_poky", "determine_if_poky_env", "do_populate_poky_src", "libc_cv_include_x86_isa_level", "test_rpm_remove", "do_install_armmultilib"] 71skips += ["autotools_dep_prepend", "go_map_arm", "alt_remove_links", "systemd_append_file", "file_append", "process_file_darwin"]
63skips = skips + ["get_appends_for_files", "test_doubleref_remove", "test_bitbakelayers_add_remove", "elf32_x86_64", "colour_remove", "revmap_remove"] 72skips += ["run_loaddata_poky", "determine_if_poky_env", "do_populate_poky_src", "libc_cv_include_x86_isa_level", "test_rpm_remove", "do_install_armmultilib"]
64skips = skips + ["test_rpm_remove", "test_bitbakelayers_add_remove", "recipe_append_file", "log_data_removed", "recipe_append", "systemd_machine_unit_append"] 73skips += ["get_appends_for_files", "test_doubleref_remove", "test_bitbakelayers_add_remove", "elf32_x86_64", "colour_remove", "revmap_remove"]
65skips = skips + ["recipetool_append", "changetype_remove", "try_appendfile_wc", "test_qemux86_directdisk", "test_layer_appends", "tgz_removed"] 74skips += ["test_rpm_remove", "test_bitbakelayers_add_remove", "recipe_append_file", "log_data_removed", "recipe_append", "systemd_machine_unit_append"]
66 75skips += ["recipetool_append", "changetype_remove", "try_appendfile_wc", "test_qemux86_directdisk", "test_layer_appends", "tgz_removed"]
67imagevars = ["IMAGE_CMD", "EXTRA_IMAGECMD", "IMAGE_TYPEDEP", "CONVERSION_CMD", "COMPRESS_CMD"] 76
68packagevars = packagevars + imagevars 77imagevars = ["IMAGE_CMD", "EXTRA_IMAGECMD", "IMAGE_TYPEDEP", "CONVERSION_CMD", "COMPRESS_CMD"] + args.image_vars
78packagevars += imagevars
79
80skip_ext = [".html", ".patch", ".m4", ".diff"] + args.skip_ext
69 81
70vars_re = {} 82vars_re = {}
71for exp in vars: 83for exp in vars:
@@ -124,21 +136,20 @@ def processfile(fn):
124ourname = os.path.basename(sys.argv[0]) 136ourname = os.path.basename(sys.argv[0])
125ourversion = "0.9.3" 137ourversion = "0.9.3"
126 138
127if os.path.isfile(sys.argv[1]): 139for p in args.path:
128 processfile(sys.argv[1]) 140 if os.path.isfile(p):
129 sys.exit(0) 141 processfile(p)
130 142 else:
131for targetdir in sys.argv[1:]: 143 print("processing directory '%s'" % p)
132 print("processing directory '%s'" % targetdir) 144 for root, dirs, files in os.walk(p):
133 for root, dirs, files in os.walk(targetdir): 145 for name in files:
134 for name in files: 146 if name == ourname:
135 if name == ourname: 147 continue
136 continue 148 fn = os.path.join(root, name)
137 fn = os.path.join(root, name) 149 if os.path.islink(fn):
138 if os.path.islink(fn): 150 continue
139 continue 151 if "/.git/" in fn or any(fn.endswith(ext) for ext in skip_ext):
140 if "/.git/" in fn or fn.endswith(".html") or fn.endswith(".patch") or fn.endswith(".m4") or fn.endswith(".diff"): 152 continue
141 continue 153 processfile(fn)
142 processfile(fn)
143 154
144print("All files processed with version %s" % ourversion) 155print("All files processed with version %s" % ourversion)