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] 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