From 32b9e3f0252977b789433693d2cf71ebf8be6f7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Mon, 21 Nov 2022 15:11:11 +0100
Subject: [PATCH 1/3] Add Bullseye-backports, Bookworm and Sid in
 data/sources.yaml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages are imported from bullseye-backports, bookworm (testing)
or sid (unstable). In order to keep Apertis packages in sync with
the source channel, we need to fetch data from these different sources.

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 data/sources.yaml | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/data/sources.yaml b/data/sources.yaml
index caf9632..c91a742 100644
--- a/data/sources.yaml
+++ b/data/sources.yaml
@@ -52,3 +52,25 @@ sources:
     suite: bullseye-updates
     <<: *bullseye
     components: *DEBIAN_COMPONENTS
+  debian/bullseye-backports:
+    <<: *bullseye
+    suite: bullseye-backports
+    base: debian/bullseye-backports
+    url_template: *DEBIAN_SUITE_URL_TEMPLATE
+    components: *DEBIAN_COMPONENTS
+  debian/bookworm:
+    <<: &bookworm
+      distribution: debian
+      release: bookworm
+      suite: bookworm
+      base: debian/bookworm
+      url_template: *DEBIAN_SUITE_URL_TEMPLATE
+      components: *DEBIAN_COMPONENTS_NONFREE
+  debian/sid:
+    <<: &sid
+      distribution: debian
+      release: sid
+      suite: sid
+      base: debian/sid
+      url_template: *DEBIAN_SUITE_URL_TEMPLATE
+      components: *DEBIAN_COMPONENTS_NONFREE
-- 
GitLab


From b44af864ee5ce1cbbe41c3e1cccbde49c2139c06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Wed, 23 Nov 2022 10:07:54 +0100
Subject: [PATCH 2/3] Report outdated packages imported from a different
 channel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some Apertis packages come from a different Debian release. In order keep
them in sync, active descendant branches are analyzed to determine in which
apertis versions they landed. Then, this information is used to report on the
dashboard which apertis releases need to be updated.

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 bin/packaging-updates       | 20 ++++++++++++++++++++
 templates/index.html.jinja2 |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/bin/packaging-updates b/bin/packaging-updates
index 446f527..044fd1a 100755
--- a/bin/packaging-updates
+++ b/bin/packaging-updates
@@ -30,6 +30,19 @@ def sources_for_branches(data, branchnames):
 def compute_updates(data):
     ret = {"packages": {}}
 
+    def channel_is_active(channel):
+        return channel.get("status") == "active"
+
+    def get_channel_base(channel):
+        return channel.get("base")
+
+    channels = data["channels"]
+    channels_keys = set(channels.keys())
+    base_channels = {get_channel_base(channels[name]) for name in channels_keys}
+    active_channels = {
+        name for name in base_channels if channel_is_active(channels[name])
+    }
+
     def updatable(package, base, branch, upstream):
         msg = f"Branch {package.git['path_with_namespace']}:{branch.name}/{branch.version}"
         if base and base != branch:
@@ -45,6 +58,13 @@ def compute_updates(data):
             "upstream": upstream,
         }
 
+        if hasattr(branch, "descendant_branches"):
+            descendant_channels = set(b for b in branch.descendant_branches)
+            active_descendant_channels = descendant_channels.intersection(
+                active_channels
+            )
+            update["downstreams"] = list(active_descendant_channels)
+
         if base:
             update["base"] = {"name": base.name, "version": base.version}
         p = ret["packages"].setdefault(package.name, {})
diff --git a/templates/index.html.jinja2 b/templates/index.html.jinja2
index 816fac9..f7eec82 100644
--- a/templates/index.html.jinja2
+++ b/templates/index.html.jinja2
@@ -234,6 +234,9 @@
           {%- for channel in channels.values() if channel.source.distribution+"/"+channel.source.release == sources[report.upstream.source].base -%}
             {{- report_channels.append(channel.base) or "" -}}
           {%- endfor -%}
+          {%- for downstream in report.downstreams -%}
+            {{- report_channels.append(channels[downstream].base) or "" -}}
+          {%- endfor -%}
         {%- elif report.branch in sources -%}
           {%- for channel in channels.values() if channel.source.distribution+"/"+channel.source.release == sources[report.branch].base -%}
             {{- report_channels.append(channel.base) or "" -}}
-- 
GitLab


From 697eb1e3e007ec7e5547a199e55c2541c095f1c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Thu, 5 Jan 2023 09:54:06 +0100
Subject: [PATCH 3/3] Check git debian branches to ensure they correspond to a
 tracked Debian release
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some packages are fetched from untracked Debian releases, we need a way to
list them in order to check if they require an update or to be sync against
a tracked Debian release.

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 bin/classes.py                 |  1 +
 bin/packaging-check-invariants | 22 ++++++++++++++++++++++
 templates/index.html.jinja2    |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/bin/classes.py b/bin/classes.py
index 27f96fb..ba28c98 100644
--- a/bin/classes.py
+++ b/bin/classes.py
@@ -49,6 +49,7 @@ class Report(enum.Enum):
     GIT_PROJECT_MISSING = enum.auto()
     GIT_UPSTREAM_BRANCH_DROPPED = enum.auto()
     GIT_UPSTREAM_BRANCH_NOT_MERGED = enum.auto()
+    GIT_UPSTREAM_BRANCH_UNTRACKED = enum.auto()
     GIT_WRONG_SETTINGS = enum.auto()
     OBS_PACKAGE_AMBIGUOUS = enum.auto()
     OBS_PACKAGE_MISSING_BUT_IN_GIT = enum.auto()
diff --git a/bin/packaging-check-invariants b/bin/packaging-check-invariants
index 72cfdcc..1dca171 100755
--- a/bin/packaging-check-invariants
+++ b/bin/packaging-check-invariants
@@ -1194,6 +1194,27 @@ class InvariantChecker:
                 branch=package.git.default_branch,
             )
 
+    def check_upstream_branches(self, package):
+        """Compare upstream branches to tracked Debian releases
+
+        Check upstream branches to ensure they correspond to a tracked Debian
+        release, and thus don't miss a new package version from an untracked
+        Debian release.
+        """
+        if "git" not in package:
+            return
+        sources = self.data.sources
+        for branch in package.git.branches.values():
+            for descendant_branches in branch.descendant_branches:
+                if descendant_branches.startswith("debian"):
+                    if descendant_branches not in sources:
+                        self.warning(
+                            package.name,
+                            Report.GIT_UPSTREAM_BRANCH_UNTRACKED,
+                            branch=branch.name,
+                            branch_untracked=descendant_branches,
+                        )
+
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(
@@ -1255,6 +1276,7 @@ if __name__ == "__main__":
             checker.check_published_packages(package)
             checker.check_license_problems(package)
             checker.check_git_settings(package)
+            checker.check_upstream_branches(package)
         except Exception as e:
             raise Error(package.name) from e
 
diff --git a/templates/index.html.jinja2 b/templates/index.html.jinja2
index f7eec82..6e1fc7f 100644
--- a/templates/index.html.jinja2
+++ b/templates/index.html.jinja2
@@ -336,6 +336,8 @@
             Version in {{ branch(package, report.branch) }} is higher than version <code>{{ report.upstream }}</code> in upstream <code>{{ report.branch }}</code>
             {%- elif report.kind == "wrong-settings" -%}
             Git repository has wrong settings {{ branch(package) }}
+            {%- elif report.kind == "upstream-branch-untracked" -%}
+            Git repository contains an untracked debian branch {{ report.branch_untracked }}
             {%- else -%}
               Unknown report: {{ report }}
             {%- endif -%}
-- 
GitLab