From 7f2789a0d6130b029b43dfa818f4652a6c9f48ee Mon Sep 17 00:00:00 2001 From: Sergio Costas Rodriguez Date: Thu, 19 Sep 2024 13:55:01 +0200 Subject: [PATCH 1/3] Add missing dependency and tool for checking There is a missing dependency in DEBS part: webp-pixbuf-loader. This patch adds it and also adds a check to ensure that any push fulfills the dependencies, ensuring that DEBS is ran after all the previous parts. --- .github/workflows/check-dependencies.yml | 22 ++++++++++++ snapcraft.yaml | 2 +- tools/check_dependencies.py | 46 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-dependencies.yml create mode 100644 tools/check_dependencies.py diff --git a/.github/workflows/check-dependencies.yml b/.github/workflows/check-dependencies.yml new file mode 100644 index 0000000..7e48ed6 --- /dev/null +++ b/.github/workflows/check-dependencies.yml @@ -0,0 +1,22 @@ +name: test-dependencies +on: + pull_request: + push: + branches: + - gnome-42-2204-sdk + +jobs: + check-deps: + runs-on: ubuntu-latest + container: + image: ubuntu:rolling + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies (Ubuntu) + run: | + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3 python3-yaml + - name: Verify dependencies + run: | + tools/check_dependencies.py diff --git a/snapcraft.yaml b/snapcraft.yaml index 26a8a39..9e7fa51 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1522,7 +1522,7 @@ parts: fi debs: - after: [ libgnome-games-support, libadwaita, libgweather, poppler, libayatana-appindicator, intel-media-driver ] + after: [ libgnome-games-support, libadwaita, libgweather, poppler, libayatana-appindicator, intel-media-driver, webp-pixbuf-loader ] plugin: nil stage-packages: - appstream diff --git a/tools/check_dependencies.py b/tools/check_dependencies.py new file mode 100644 index 0000000..74580c4 --- /dev/null +++ b/tools/check_dependencies.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +import os +import sys +import yaml + +# Ensure that "deb" part depends on all previous parts + +config_file = "snapcraft.yaml" +if not os.path.exists(config_file): + config_file = os.path.join("snap", "snapcraft.yaml") + +data = yaml.safe_load(open(config_file, "r")) + +parts = {} +exceptions = ['buildenv'] + +for part in data['parts']: + if part == "debs": + break + if part in exceptions: + continue + parts[part] = False + +def filldeps(part): + global data + global parts + if 'after' not in data['parts'][part]: + return + + deps = data['parts'][part]['after'] + for dep in deps: + parts[dep] = True + filldeps(dep) + +filldeps("debs") +failed = False +for part in parts: + if parts[part]: + continue + print(f"DEBS must depend on {part}") + failed = True + +if failed: + sys.exit(1) +print("All dependencies are correct") From f847d196cae625a84f238bf04373caac383b1660 Mon Sep 17 00:00:00 2001 From: Sergio Costas Rodriguez Date: Thu, 19 Sep 2024 14:04:29 +0200 Subject: [PATCH 2/3] Fix permissions --- tools/check_dependencies.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/check_dependencies.py diff --git a/tools/check_dependencies.py b/tools/check_dependencies.py old mode 100644 new mode 100755 From 33c3510b76fb80653d28f8d77420e5e2f9551d95 Mon Sep 17 00:00:00 2001 From: Sergio Costas Rodriguez Date: Thu, 19 Sep 2024 15:12:00 +0200 Subject: [PATCH 3/3] YAML module doesn't guarantee order We must use a different way to ensure that all the dependencies are correct, because the python YAML module doesn't guarantee that the order is preserved, so, since the parts could be returned in a different order, we can't stop when we find "debs". --- tools/check_dependencies.py | 51 +++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/tools/check_dependencies.py b/tools/check_dependencies.py index 74580c4..6483f3c 100755 --- a/tools/check_dependencies.py +++ b/tools/check_dependencies.py @@ -12,34 +12,41 @@ data = yaml.safe_load(open(config_file, "r")) -parts = {} exceptions = ['buildenv'] -for part in data['parts']: - if part == "debs": - break - if part in exceptions: - continue - parts[part] = False - def filldeps(part): + """ Fill recursively the dependencies of each part """ global data - global parts - if 'after' not in data['parts'][part]: - return - - deps = data['parts'][part]['after'] - for dep in deps: - parts[dep] = True - filldeps(dep) + output = [] + if 'after' in data['parts'][part]: + for dep in data['parts'][part]['after']: + # it's not a problem to have duplicated dependencies + output += filldeps(dep) + output.append(dep) + return output + +dependencies = {} + +# get the dependencies for each part +for part in data["parts"]: + dependencies[part] = filldeps(part) + +deb_dependencies = [] +for part in data["parts"]: + if "debs" == part: + continue + if "debs" in dependencies[part]: + # if it depends on debs, it must be after, so don't take it into account + continue + if part in exceptions: + continue + deb_dependencies.append(part) -filldeps("debs") failed = False -for part in parts: - if parts[part]: - continue - print(f"DEBS must depend on {part}") - failed = True +for dependency in deb_dependencies: + if dependency not in dependencies["debs"]: + print(f"DEBS part must be after {dependency}") + failed = True if failed: sys.exit(1)