diff options
Diffstat (limited to 'poky/scripts/contrib')
-rwxr-xr-x | poky/scripts/contrib/convert-spdx-licenses.py | 145 | ||||
-rwxr-xr-x | poky/scripts/contrib/convert-variable-renames.py | 116 | ||||
-rwxr-xr-x | poky/scripts/contrib/documentation-audit.sh | 4 | ||||
-rwxr-xr-x | poky/scripts/contrib/test_build_time.sh | 2 |
4 files changed, 264 insertions, 3 deletions
diff --git a/poky/scripts/contrib/convert-spdx-licenses.py b/poky/scripts/contrib/convert-spdx-licenses.py new file mode 100755 index 0000000000..4e194dee3f --- /dev/null +++ b/poky/scripts/contrib/convert-spdx-licenses.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python3 +# +# Conversion script to change LICENSE entries to SPDX identifiers +# +# Copyright (C) 2021-2022 Richard Purdie +# +# SPDX-License-Identifier: GPL-2.0-only +# + +import re +import os +import sys +import tempfile +import shutil +import mimetypes + +if len(sys.argv) < 2: + print("Please specify a directory to run the conversion script against.") + sys.exit(1) + +license_map = { +"AGPL-3" : "AGPL-3.0-only", +"AGPL-3+" : "AGPL-3.0-or-later", +"AGPLv3" : "AGPL-3.0-only", +"AGPLv3+" : "AGPL-3.0-or-later", +"AGPLv3.0" : "AGPL-3.0-only", +"AGPLv3.0+" : "AGPL-3.0-or-later", +"AGPL-3.0" : "AGPL-3.0-only", +"AGPL-3.0+" : "AGPL-3.0-or-later", +"BSD-0-Clause" : "0BSD", +"GPL-1" : "GPL-1.0-only", +"GPL-1+" : "GPL-1.0-or-later", +"GPLv1" : "GPL-1.0-only", +"GPLv1+" : "GPL-1.0-or-later", +"GPLv1.0" : "GPL-1.0-only", +"GPLv1.0+" : "GPL-1.0-or-later", +"GPL-1.0" : "GPL-1.0-only", +"GPL-1.0+" : "GPL-1.0-or-later", +"GPL-2" : "GPL-2.0-only", +"GPL-2+" : "GPL-2.0-or-later", +"GPLv2" : "GPL-2.0-only", +"GPLv2+" : "GPL-2.0-or-later", +"GPLv2.0" : "GPL-2.0-only", +"GPLv2.0+" : "GPL-2.0-or-later", +"GPL-2.0" : "GPL-2.0-only", +"GPL-2.0+" : "GPL-2.0-or-later", +"GPL-3" : "GPL-3.0-only", +"GPL-3+" : "GPL-3.0-or-later", +"GPLv3" : "GPL-3.0-only", +"GPLv3+" : "GPL-3.0-or-later", +"GPLv3.0" : "GPL-3.0-only", +"GPLv3.0+" : "GPL-3.0-or-later", +"GPL-3.0" : "GPL-3.0-only", +"GPL-3.0+" : "GPL-3.0-or-later", +"LGPLv2" : "LGPL-2.0-only", +"LGPLv2+" : "LGPL-2.0-or-later", +"LGPLv2.0" : "LGPL-2.0-only", +"LGPLv2.0+" : "LGPL-2.0-or-later", +"LGPL-2.0" : "LGPL-2.0-only", +"LGPL-2.0+" : "LGPL-2.0-or-later", +"LGPL2.1" : "LGPL-2.1-only", +"LGPL2.1+" : "LGPL-2.1-or-later", +"LGPLv2.1" : "LGPL-2.1-only", +"LGPLv2.1+" : "LGPL-2.1-or-later", +"LGPL-2.1" : "LGPL-2.1-only", +"LGPL-2.1+" : "LGPL-2.1-or-later", +"LGPLv3" : "LGPL-3.0-only", +"LGPLv3+" : "LGPL-3.0-or-later", +"LGPL-3.0" : "LGPL-3.0-only", +"LGPL-3.0+" : "LGPL-3.0-or-later", +"MPL-1" : "MPL-1.0", +"MPLv1" : "MPL-1.0", +"MPLv1.1" : "MPL-1.1", +"MPLv2" : "MPL-2.0", +"MIT-X" : "MIT", +"MIT-style" : "MIT", +"openssl" : "OpenSSL", +"PSF" : "PSF-2.0", +"PSFv2" : "PSF-2.0", +"Python-2" : "Python-2.0", +"Apachev2" : "Apache-2.0", +"Apache-2" : "Apache-2.0", +"Artisticv1" : "Artistic-1.0", +"Artistic-1" : "Artistic-1.0", +"AFL-2" : "AFL-2.0", +"AFL-1" : "AFL-1.2", +"AFLv2" : "AFL-2.0", +"AFLv1" : "AFL-1.2", +"CDDLv1" : "CDDL-1.0", +"CDDL-1" : "CDDL-1.0", +"EPLv1.0" : "EPL-1.0", +"FreeType" : "FTL", +"Nauman" : "Naumen", +"tcl" : "TCL", +"vim" : "Vim", +"SGIv1" : "SGI-1", +} + +def processfile(fn): + print("processing file '%s'" % fn) + try: + fh, abs_path = tempfile.mkstemp() + modified = False + with os.fdopen(fh, 'w') as new_file: + with open(fn, "r") as old_file: + for line in old_file: + if not line.startswith("LICENSE"): + new_file.write(line) + continue + orig = line + for license in sorted(license_map, key=len, reverse=True): + for ending in ['"', "'", " ", ")"]: + line = line.replace(license + ending, license_map[license] + ending) + if orig != line: + modified = True + new_file.write(line) + new_file.close() + if modified: + shutil.copymode(fn, abs_path) + os.remove(fn) + shutil.move(abs_path, fn) + except UnicodeDecodeError: + pass + +ourname = os.path.basename(sys.argv[0]) +ourversion = "0.01" + +if os.path.isfile(sys.argv[1]): + processfile(sys.argv[1]) + sys.exit(0) + +for targetdir in sys.argv[1:]: + print("processing directory '%s'" % targetdir) + for root, dirs, files in os.walk(targetdir): + for name in files: + if name == ourname: + continue + fn = os.path.join(root, name) + if os.path.islink(fn): + continue + if "/.git/" in fn or fn.endswith(".html") or fn.endswith(".patch") or fn.endswith(".m4") or fn.endswith(".diff") or fn.endswith(".orig"): + continue + processfile(fn) + +print("All files processed with version %s" % ourversion) diff --git a/poky/scripts/contrib/convert-variable-renames.py b/poky/scripts/contrib/convert-variable-renames.py new file mode 100755 index 0000000000..ed012610db --- /dev/null +++ b/poky/scripts/contrib/convert-variable-renames.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +# +# Conversion script to rename variables to versions with improved terminology. +# Also highlights potentially problematic langage and removed variables. +# +# Copyright (C) 2021 Richard Purdie +# Copyright (C) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: GPL-2.0-only +# + +import re +import os +import sys +import tempfile +import shutil +import mimetypes + +if len(sys.argv) < 2: + print("Please specify a directory to run the conversion script against.") + sys.exit(1) + +renames = { +"BB_ENV_WHITELIST" : "BB_ENV_PASSTHROUGH", +"BB_ENV_EXTRAWHITE" : "BB_ENV_PASSTHROUGH_ADDITIONS", +"BB_HASHCONFIG_WHITELIST" : "BB_HASHCONFIG_IGNORE_VARS", +"BB_SETSCENE_ENFORCE_WHITELIST" : "BB_SETSCENE_ENFORCE_IGNORE_TASKS", +"BB_HASHBASE_WHITELIST" : "BB_BASEHASH_IGNORE_VARS", +"BB_HASHTASK_WHITELIST" : "BB_TASKHASH_IGNORE_TASKS", +"CVE_CHECK_PN_WHITELIST" : "CVE_CHECK_SKIP_RECIPE", +"CVE_CHECK_WHITELIST" : "CVE_CHECK_IGNORE", +"MULTI_PROVIDER_WHITELIST" : "BB_MULTI_PROVIDER_ALLOWED", +"PNBLACKLIST" : "SKIP_RECIPE", +"SDK_LOCAL_CONF_BLACKLIST" : "ESDK_LOCALCONF_REMOVE", +"SDK_LOCAL_CONF_WHITELIST" : "ESDK_LOCALCONF_ALLOW", +"SDK_INHERIT_BLACKLIST" : "ESDK_CLASS_INHERIT_DISABLE", +"SSTATE_DUPWHITELIST" : "SSTATE_ALLOW_OVERLAP_FILES", +"SYSROOT_DIRS_BLACKLIST" : "SYSROOT_DIRS_IGNORE", +"UNKNOWN_CONFIGURE_WHITELIST" : "UNKNOWN_CONFIGURE_OPT_IGNORE", +"ICECC_USER_CLASS_BL" : "ICECC_CLASS_DISABLE", +"ICECC_SYSTEM_CLASS_BL" : "ICECC_CLASS_DISABLE", +"ICECC_USER_PACKAGE_WL" : "ICECC_RECIPE_ENABLE", +"ICECC_USER_PACKAGE_BL" : "ICECC_RECIPE_DISABLE", +"ICECC_SYSTEM_PACKAGE_BL" : "ICECC_RECIPE_DISABLE", +"LICENSE_FLAGS_WHITELIST" : "LICENSE_FLAGS_ACCEPTED", +} + +removed_list = [ +"BB_STAMP_WHITELIST", +"BB_STAMP_POLICY", +"INHERIT_BLACKLIST", +"TUNEABI_WHITELIST", +] + +context_check_list = [ +"blacklist", +"whitelist", +"abort", +] + +def processfile(fn): + + print("processing file '%s'" % fn) + try: + fh, abs_path = tempfile.mkstemp() + modified = False + with os.fdopen(fh, 'w') as new_file: + with open(fn, "r") as old_file: + lineno = 0 + for line in old_file: + lineno += 1 + if not line or "BB_RENAMED_VARIABLE" in line: + continue + # Do the renames + for old_name, new_name in renames.items(): + if old_name in line: + line = line.replace(old_name, new_name) + modified = True + # Find removed names + for removed_name in removed_list: + if removed_name in line: + print("%s needs further work at line %s because has been deprecated" % (fn, lineno, remove_name)) + for check_word in context_check_list: + if re.search(check_word, line, re.IGNORECASE): + print("%s needs further work at line %s since it contains %s"% (fn, lineno, check_word)) + new_file.write(line) + new_file.close() + if modified: + print("*** Modified file '%s'" % (fn)) + shutil.copymode(fn, abs_path) + os.remove(fn) + shutil.move(abs_path, fn) + except UnicodeDecodeError: + pass + +ourname = os.path.basename(sys.argv[0]) +ourversion = "0.1" + +if os.path.isfile(sys.argv[1]): + processfile(sys.argv[1]) + sys.exit(0) + +for targetdir in sys.argv[1:]: + print("processing directory '%s'" % targetdir) + for root, dirs, files in os.walk(targetdir): + for name in files: + if name == ourname: + continue + fn = os.path.join(root, name) + if os.path.islink(fn): + continue + if "ChangeLog" in fn or "/.git/" in fn or fn.endswith(".html") or fn.endswith(".patch") or fn.endswith(".m4") or fn.endswith(".diff") or fn.endswith(".orig"): + continue + processfile(fn) + +print("All files processed with version %s" % ourversion) diff --git a/poky/scripts/contrib/documentation-audit.sh b/poky/scripts/contrib/documentation-audit.sh index f436f9bae0..36f7f3287c 100755 --- a/poky/scripts/contrib/documentation-audit.sh +++ b/poky/scripts/contrib/documentation-audit.sh @@ -26,8 +26,8 @@ if [ -z "$BITBAKE" ]; then fi echo "REMINDER: you need to build for MACHINE=qemux86 or you won't get useful results" -echo "REMINDER: you need to set LICENSE_FLAGS_WHITELIST appropriately in local.conf or " -echo " you'll get false positives. For example, LICENSE_FLAGS_WHITELIST = \"commercial\"" +echo "REMINDER: you need to set LICENSE_FLAGS_ACCEPTED appropriately in local.conf or " +echo " you'll get false positives. For example, LICENSE_FLAGS_ACCEPTED = \"commercial\"" for pkg in `bitbake -s | awk '{ print \$1 }'`; do if [[ "$pkg" == "Loading" || "$pkg" == "Loaded" || diff --git a/poky/scripts/contrib/test_build_time.sh b/poky/scripts/contrib/test_build_time.sh index 23f238adf6..4012ac7ba7 100755 --- a/poky/scripts/contrib/test_build_time.sh +++ b/poky/scripts/contrib/test_build_time.sh @@ -97,7 +97,7 @@ if [ $? != 0 ] ; then exit 251 fi -if [ "$BB_ENV_EXTRAWHITE" != "" ] ; then +if [ "BB_ENV_PASSTHROUGH_ADDITIONS" != "" ] ; then echo "WARNING: you are running after sourcing the build environment script, this is not recommended" fi |