From 2bac485c4bf65d997b2e0cb6175be121a49cf938 Mon Sep 17 00:00:00 2001 From: Walter Lozano <walter.lozano@collabora.com> Date: Thu, 16 Jan 2025 17:30:45 -0300 Subject: [PATCH 1/5] 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. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> --- tools/ci-license-scan | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/ci-license-scan b/tools/ci-license-scan index 29b9250..453ecd5 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) -- GitLab From 5451267a4e10864c393d14aef7f83697b9d078e1 Mon Sep 17 00:00:00 2001 From: Walter Lozano <walter.lozano@collabora.com> Date: Fri, 17 Jan 2025 15:47:09 -0300 Subject: [PATCH 2/5] apertis-pkg-merge-local: Rename commit to release The commit command is intended to update the changelog and commit the changes, to make the use of the command clearer rename it to release. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> --- tools/apertis-pkg-merge-local | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/apertis-pkg-merge-local b/tools/apertis-pkg-merge-local index 5e84ae4..e615b71 100755 --- a/tools/apertis-pkg-merge-local +++ b/tools/apertis-pkg-merge-local @@ -67,7 +67,7 @@ diff_old() { git diff $EXTRA_ARGS origin/$UPSTREAM_BRANCH_OLD origin/$DOWNSTREAM_BRANCH_OLD ':(exclude)debian/apertis' ':(exclude)debian/changelog' } -commit() { +release() { dch --force-distribution --distribution apertis --local +apertis --upstream Rebase on top of $UPSTREAM_BRANCH git add debian/changelog git diff --cached @@ -92,11 +92,11 @@ diff) diff_old) diff_old ;; -commit) - commit +release) + release ;; *) echo Unknown command - echo Usage `basename $0` '[merge|diff|diff_old|commit]' + echo Usage `basename $0` '[merge|diff|diff_old|release]' ;; esac -- GitLab From 2bdea3f026c6329952f5985b5ce101394f515752 Mon Sep 17 00:00:00 2001 From: Walter Lozano <walter.lozano@collabora.com> Date: Thu, 16 Jan 2025 17:50:40 -0300 Subject: [PATCH 3/5] 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. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> --- tools/apertis-pkg-merge-local | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/apertis-pkg-merge-local b/tools/apertis-pkg-merge-local index e615b71..ef3ac1d 100755 --- a/tools/apertis-pkg-merge-local +++ b/tools/apertis-pkg-merge-local @@ -67,6 +67,21 @@ diff_old() { git diff $EXTRA_ARGS origin/$UPSTREAM_BRANCH_OLD origin/$DOWNSTREAM_BRANCH_OLD ':(exclude)debian/apertis' ':(exclude)debian/changelog' } +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() { dch --force-distribution --distribution apertis --local +apertis --upstream Rebase on top of $UPSTREAM_BRANCH git add debian/changelog @@ -92,11 +107,17 @@ diff) diff_old) diff_old ;; +scan) + scan + ;; +commit-whitelist) + commit-whitelist + ;; release) release ;; *) echo Unknown command - echo Usage `basename $0` '[merge|diff|diff_old|release]' + echo Usage `basename $0` '[merge|diff|diff_old|scan|commit-whitelist|release]' ;; esac -- GitLab From c6a9a5aa0cd8ec45a9bfa8863e7d295a14e51d58 Mon Sep 17 00:00:00 2001 From: Walter Lozano <walter.lozano@collabora.com> Date: Fri, 17 Jan 2025 14:57:54 -0300 Subject: [PATCH 4/5] 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. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> --- tools/apertis-pkg-merge-local | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/apertis-pkg-merge-local b/tools/apertis-pkg-merge-local index ef3ac1d..10916b4 100755 --- a/tools/apertis-pkg-merge-local +++ b/tools/apertis-pkg-merge-local @@ -83,7 +83,6 @@ commit-whitelist() { } release() { - dch --force-distribution --distribution apertis --local +apertis --upstream Rebase on top of $UPSTREAM_BRANCH git add debian/changelog git diff --cached DIR=`pwd` @@ -93,6 +92,16 @@ release() { 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=$@ @@ -113,11 +122,14 @@ scan) commit-whitelist) commit-whitelist ;; -release) - release +release-down) + release-down + ;; +release-up) + release-up ;; *) echo Unknown command - echo Usage `basename $0` '[merge|diff|diff_old|scan|commit-whitelist|release]' + echo Usage `basename $0` '[merge|diff|diff_old|scan|commit-whitelist|release-down|release-up]' ;; esac -- GitLab From 4b2577e2409f58b93b6a763e26b4e60d16bbbc55 Mon Sep 17 00:00:00 2001 From: Walter Lozano <walter.lozano@collabora.com> Date: Fri, 17 Jan 2025 15:08:08 -0300 Subject: [PATCH 5/5] Release apertis-dev-tools version 0.2024.19 Signed-off-by: Walter Lozano <walter.lozano@collabora.com> --- debian/changelog | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/debian/changelog b/debian/changelog index 7e4b9b6..d1ed623 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. -- GitLab