diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/contrib/convert-overrides.py | 103 |
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 | |||
22 | import tempfile | 22 | import tempfile |
23 | import shutil | 23 | import shutil |
24 | import mimetypes | 24 | import mimetypes |
25 | import argparse | ||
25 | 26 | ||
26 | if len(sys.argv) < 2: | 27 | parser = argparse.ArgumentParser(description="Convert override syntax") |
27 | print("Please specify a directory to run the conversion script against.") | 28 | parser.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) | 29 | parser.add_argument("--skip", "-s", action="append", default=[], help="Add additional string to skip and not consider an override") |
30 | parser.add_argument("--skip-ext", "-e", action="append", default=[], help="Additional file suffixes to skip when processing (e.g. '.foo')") | ||
31 | parser.add_argument("--package-vars", action="append", default=[], help="Additional variables to treat as package variables") | ||
32 | parser.add_argument("--image-vars", action="append", default=[], help="Additional variables to treat as image variables") | ||
33 | parser.add_argument("--short-override", action="append", default=[], help="Additional strings to treat as short overrides") | ||
34 | parser.add_argument("path", nargs="+", help="Paths to convert") | ||
35 | |||
36 | args = parser.parse_args() | ||
29 | 37 | ||
30 | # List of strings to treat as overrides | 38 | # List of strings to treat as overrides |
31 | vars = ["append", "prepend", "remove"] | 39 | vars = args.override |
32 | vars = vars + ["qemuarm", "qemux86", "qemumips", "qemuppc", "qemuriscv", "qemuall"] | 40 | vars += ["append", "prepend", "remove"] |
33 | vars = vars + ["genericx86", "edgerouter", "beaglebone-yocto"] | 41 | vars += ["qemuarm", "qemux86", "qemumips", "qemuppc", "qemuriscv", "qemuall"] |
34 | vars = vars + ["armeb", "arm", "armv5", "armv6", "armv4", "powerpc64", "aarch64", "riscv32", "riscv64", "x86", "mips64", "powerpc"] | 42 | vars += ["genericx86", "edgerouter", "beaglebone-yocto"] |
35 | vars = vars + ["mipsarch", "x86-x32", "mips16e", "microblaze", "e5500-64b", "mipsisa32", "mipsisa64"] | 43 | vars += ["armeb", "arm", "armv5", "armv6", "armv4", "powerpc64", "aarch64", "riscv32", "riscv64", "x86", "mips64", "powerpc"] |
36 | vars = vars + ["class-native", "class-target", "class-cross-canadian", "class-cross", "class-devupstream"] | 44 | vars += ["mipsarch", "x86-x32", "mips16e", "microblaze", "e5500-64b", "mipsisa32", "mipsisa64"] |
37 | vars = vars + ["tune-", "pn-", "forcevariable"] | 45 | vars += ["class-native", "class-target", "class-cross-canadian", "class-cross", "class-devupstream"] |
38 | vars = vars + ["libc-musl", "libc-glibc", "libc-newlib","libc-baremetal"] | 46 | vars += ["tune-", "pn-", "forcevariable"] |
39 | vars = vars + ["task-configure", "task-compile", "task-install", "task-clean", "task-image-qa", "task-rm_work", "task-image-complete", "task-populate-sdk"] | 47 | vars += ["libc-musl", "libc-glibc", "libc-newlib","libc-baremetal"] |
40 | vars = vars + ["toolchain-clang", "mydistro", "nios2", "sdkmingw32", "overrideone", "overridetwo"] | 48 | vars += ["task-configure", "task-compile", "task-install", "task-clean", "task-image-qa", "task-rm_work", "task-image-complete", "task-populate-sdk"] |
41 | vars = vars + ["linux-gnux32", "linux-muslx32", "linux-gnun32", "mingw32", "poky", "darwin", "linuxstdbase"] | 49 | vars += ["toolchain-clang", "mydistro", "nios2", "sdkmingw32", "overrideone", "overridetwo"] |
42 | vars = vars + ["linux-gnueabi", "eabi"] | 50 | vars += ["linux-gnux32", "linux-muslx32", "linux-gnun32", "mingw32", "poky", "darwin", "linuxstdbase"] |
43 | vars = vars + ["virtclass-multilib", "virtclass-mcextend"] | 51 | vars += ["linux-gnueabi", "eabi"] |
52 | vars += ["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. |
47 | shortvars = ["arc", "mips", "mipsel", "sh4"] | 56 | shortvars = ["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 |
50 | packagevars = ["FILES", "RDEPENDS", "RRECOMMENDS", "SUMMARY", "DESCRIPTION", "RSUGGESTS", "RPROVIDES", "RCONFLICTS", "PKG", "ALLOW_EMPTY", | 59 | packagevars = ["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 |
57 | skips = ["parser_append", "recipe_to_append", "extra_append", "to_remove", "show_appends", "applied_appends", "file_appends", "handle_remove"] | 66 | skips = args.skip |
58 | skips = skips + ["expanded_removes", "color_remove", "test_remove", "empty_remove", "toaster_prepend", "num_removed", "licfiles_append", "_write_append"] | 67 | skips += ["parser_append", "recipe_to_append", "extra_append", "to_remove", "show_appends", "applied_appends", "file_appends", "handle_remove"] |
59 | skips = skips + ["no_report_remove", "test_prepend", "test_append", "multiple_append", "test_remove", "shallow_remove", "do_remove_layer", "first_append"] | 68 | skips += ["expanded_removes", "color_remove", "test_remove", "empty_remove", "toaster_prepend", "num_removed", "licfiles_append", "_write_append"] |
60 | skips = skips + ["parser_remove", "to_append", "no_remove", "bblayers_add_remove", "bblayers_remove", "apply_append", "is_x86", "base_dep_prepend"] | 69 | skips += ["no_report_remove", "test_prepend", "test_append", "multiple_append", "test_remove", "shallow_remove", "do_remove_layer", "first_append"] |
61 | skips = skips + ["autotools_dep_prepend", "go_map_arm", "alt_remove_links", "systemd_append_file", "file_append", "process_file_darwin"] | 70 | skips += ["parser_remove", "to_append", "no_remove", "bblayers_add_remove", "bblayers_remove", "apply_append", "is_x86", "base_dep_prepend"] |
62 | skips = skips + ["run_loaddata_poky", "determine_if_poky_env", "do_populate_poky_src", "libc_cv_include_x86_isa_level", "test_rpm_remove", "do_install_armmultilib"] | 71 | skips += ["autotools_dep_prepend", "go_map_arm", "alt_remove_links", "systemd_append_file", "file_append", "process_file_darwin"] |
63 | skips = skips + ["get_appends_for_files", "test_doubleref_remove", "test_bitbakelayers_add_remove", "elf32_x86_64", "colour_remove", "revmap_remove"] | 72 | skips += ["run_loaddata_poky", "determine_if_poky_env", "do_populate_poky_src", "libc_cv_include_x86_isa_level", "test_rpm_remove", "do_install_armmultilib"] |
64 | skips = skips + ["test_rpm_remove", "test_bitbakelayers_add_remove", "recipe_append_file", "log_data_removed", "recipe_append", "systemd_machine_unit_append"] | 73 | skips += ["get_appends_for_files", "test_doubleref_remove", "test_bitbakelayers_add_remove", "elf32_x86_64", "colour_remove", "revmap_remove"] |
65 | skips = skips + ["recipetool_append", "changetype_remove", "try_appendfile_wc", "test_qemux86_directdisk", "test_layer_appends", "tgz_removed"] | 74 | skips += ["test_rpm_remove", "test_bitbakelayers_add_remove", "recipe_append_file", "log_data_removed", "recipe_append", "systemd_machine_unit_append"] |
66 | 75 | skips += ["recipetool_append", "changetype_remove", "try_appendfile_wc", "test_qemux86_directdisk", "test_layer_appends", "tgz_removed"] | |
67 | imagevars = ["IMAGE_CMD", "EXTRA_IMAGECMD", "IMAGE_TYPEDEP", "CONVERSION_CMD", "COMPRESS_CMD"] | 76 | |
68 | packagevars = packagevars + imagevars | 77 | imagevars = ["IMAGE_CMD", "EXTRA_IMAGECMD", "IMAGE_TYPEDEP", "CONVERSION_CMD", "COMPRESS_CMD"] + args.image_vars |
78 | packagevars += imagevars | ||
79 | |||
80 | skip_ext = [".html", ".patch", ".m4", ".diff"] + args.skip_ext | ||
69 | 81 | ||
70 | vars_re = {} | 82 | vars_re = {} |
71 | for exp in vars: | 83 | for exp in vars: |
@@ -124,21 +136,20 @@ def processfile(fn): | |||
124 | ourname = os.path.basename(sys.argv[0]) | 136 | ourname = os.path.basename(sys.argv[0]) |
125 | ourversion = "0.9.3" | 137 | ourversion = "0.9.3" |
126 | 138 | ||
127 | if os.path.isfile(sys.argv[1]): | 139 | for 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: | |
131 | for 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 | ||
144 | print("All files processed with version %s" % ourversion) | 155 | print("All files processed with version %s" % ourversion) |