diff --git a/debian/changelog b/debian/changelog index 7e4b9b64402539742fff9172b0afdf0f47df4922..d1ed623819733e4996314dce2948368445919c57 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +apertis-dev-tools (0.2024.19) apertis; urgency=medium + + * ci-license-scan: Add proposed whitelist. + While working with license scan is very common to add whitelist for + files and folders. To make this job easier, allow ci-license-scan to + propose a whitelist based on known patterns. + This feature is only meant to help developers to reduce the overheard + of the manual work, hence, the proposed changed need to be carefully + reviewed. + * apertis-pkg-merge-local: Add support for scan. + It is common to need locally check for license scan issues, so add initial + support for it to the tooling. + * apertis-pkg-merge-local: Support different types of release commits. + Depending on the type of changes, upstream or donwstream, it is better to + use different settings while generation the changelog, in order to provide + or not the full set of changes. + + -- Walter Lozano <walter.lozano@collabora.com> Fri, 17 Jan 2025 15:07:58 -0300 + apertis-dev-tools (0.2024.18) apertis; urgency=medium * ci-buildpackage: drop the use of wrap-and-sort. diff --git a/tools/apertis-pkg-merge-local b/tools/apertis-pkg-merge-local index 5e84ae4c5f5de92127c2b199adec46d8d1a6ab34..10916b4abf171fff6dd6bf1f87c636ed08c8d10f 100755 --- a/tools/apertis-pkg-merge-local +++ b/tools/apertis-pkg-merge-local @@ -67,8 +67,22 @@ diff_old() { git diff $EXTRA_ARGS origin/$UPSTREAM_BRANCH_OLD origin/$DOWNSTREAM_BRANCH_OLD ':(exclude)debian/apertis' ':(exclude)debian/changelog' } -commit() { - dch --force-distribution --distribution apertis --local +apertis --upstream Rebase on top of $UPSTREAM_BRANCH +scan() { + if grep -q target debian/apertis/component + then + ci-license-scan --blacklist-licenses "GPL-3 GPL-3+ AGPL-3 AGPL-3+ AGPL-1 AGPL-1+ LGPL-3 LGPL-3+ BSD-4-Clause MPL-1.1" --fail-on-unknown --propose-whitelist + else + echo "Package does no belong to target, skipping" + fi +} + +commit-whitelist() { + git add debian/apertis/copyright.whitelist + + git commit -s -e -m 'copyright.whitelist: Update configuration' +} + +release() { git add debian/changelog git diff --cached DIR=`pwd` @@ -78,6 +92,16 @@ commit() { git commit -sm "Release $PACKAGE version $VERSION" } +release-down() { + GBP_CONF_FILES=/dev/null gbp dch --release --force-distribution -D apertis --local +apertis --ignore-branch --dch-opt=--upstream --full + release +} + +release-up() { + dch --force-distribution --distribution apertis --local +apertis --upstream Merge changes from $UPSTREAM_BRANCH + release +} + COMMAND=$1 shift EXTRA_ARGS=$@ @@ -92,11 +116,20 @@ diff) diff_old) diff_old ;; -commit) - commit +scan) + scan + ;; +commit-whitelist) + commit-whitelist + ;; +release-down) + release-down + ;; +release-up) + release-up ;; *) echo Unknown command - echo Usage `basename $0` '[merge|diff|diff_old|commit]' + echo Usage `basename $0` '[merge|diff|diff_old|scan|commit-whitelist|release-down|release-up]' ;; esac diff --git a/tools/ci-license-scan b/tools/ci-license-scan index 29b92504a420664cafb541d1d904770e0f627ab2..453ecd5d179f206ea3c3434c92c5ebcdf0433a1e 100755 --- a/tools/ci-license-scan +++ b/tools/ci-license-scan @@ -388,6 +388,36 @@ def get_pattern_broadness(pattern): return pattern.count("*") + pattern.count("?") +def propose_whitelist(license): + reason = None + if license.file.startswith("debian/"): + reason = "# debian metadata is not part of build artifacts\n" + elif license.file.startswith(("doc/", "docs/")): + reason = "# docs are not meant to be installed in target\n" + elif license.file.startswith(("test/", "tests/", "testsuite/")): + reason = "# tests are not meant to be installed in target\n" + elif license.file.startswith(("example/", "examples/")): + reason = "# examples are not meant to be installed in target\n" + elif license.file.startswith("m4/") or license.file.endswith(".m4"): + reason = "# preprocesor files are not meant to be installed in target\n" + elif license.file.startswith(("build/", "build-aux")) or license.file.endswith( + (".am", ".in", ".make") + ): + reason = "# build scripts are not meant to be installed in target\n" + else: + reason = "# PLEASE FILL THE REASON TO WHITELIST\n" + if reason: + with open("debian/apertis/copyright.whitelist", "a+") as f: + f.seek(0) + buf = f.read() + data = "" + if len(buf) and buf[-1] != "\n": + data += "\n" + data += reason + data += license.file + "\n" + f.write(data) + + def main(): parser = argparse.ArgumentParser() parser.add_argument( @@ -434,6 +464,11 @@ def main(): default=["debian/apertis/copyright.whitelist"], help="extra file whitelist", ) + parser.add_argument( + "--propose-whitelist", + action="store_true", + help="propose a whitelist in case of failure", + ) args = parser.parse_args() print("%s fail on change" % ("Will" if args.fail_on_change else "Will not")) print( @@ -599,9 +634,18 @@ def main(): for license in sorted(unknown_licensed): print(f" UNKNOWN license entry found: {license}", file=sys.stderr) should_fail = args.fail_on_unknown + if args.propose_whitelist: + propose_whitelist(license) for license in sorted(bad_licenses): print(f" Blacklisted license entry found: {license}", file=sys.stderr) + if args.propose_whitelist: + propose_whitelist(license) should_fail = True + if args.propose_whitelist: + print( + "\nPROPOSED WHITELIST HAVE BEEN ADDED, PLEASE REVIEW THEM!!!\n", + file=sys.stderr, + ) if should_fail: sys.exit(1)