Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Meta/CMake/flatpak/org.ladybird.Ladybird.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{
"type": "git",
"url": "https://github.com/pnggroup/libpng.git",
"tag": "v1.6.49"
"tag": "v1.6.50"
},
{
"type": "file",
Expand Down Expand Up @@ -112,7 +112,8 @@
{
"type": "git",
"url": "https://chromium.googlesource.com/angle/angle",
"commit": "7ab02e1d49a649adaba62b8a7fdfabf8144b313f",
"commit": "79ac1a8cd767a32cce6401203e20c4bd4ca4d539",
"branch": "chromium/7258_13",
"dest": "angle",
"disable-submodules": true
},
Expand Down Expand Up @@ -204,7 +205,7 @@
{
"type": "git",
"url": "https://github.com/GNOME/libxml2.git",
"tag": "v2.13.8"
"tag": "v2.15.0"
}
],
"config-opts": [
Expand Down Expand Up @@ -252,7 +253,7 @@
{
"type": "git",
"url": "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git",
"tag": "v3.1.0"
"tag": "v3.3.0"
}
],
"config-opts": [
Expand Down Expand Up @@ -283,7 +284,7 @@
]
},
{
"name": "libwoff2",
"name": "woff2",
"buildsystem": "cmake-ninja",
"sources": [
{
Expand Down Expand Up @@ -363,7 +364,7 @@
{
"type": "git",
"url": "https://github.com/webmproject/libwebp.git",
"tag": "v1.5.0"
"tag": "v1.6.0"
}
],
"config-opts": [
Expand Down Expand Up @@ -395,7 +396,7 @@
{
"type": "git",
"url": "https://github.com/google/highway.git",
"tag": "1.2.0",
"tag": "1.3.0",
"disable-submodules": true
}
],
Expand Down Expand Up @@ -453,7 +454,8 @@
{
"type": "git",
"url": "https://skia.googlesource.com/skia.git",
"commit": "chrome/m129"
"commit": "f406b708b8c0d31e1bfad101fc3d1ff00e7fb19e",
"branch": "chrome/m129"
},
{
"type": "file",
Expand Down Expand Up @@ -492,7 +494,7 @@
]
},
{
"name": "fast_float",
"name": "fast-float",
"buildsystem": "cmake-ninja",
"sources": [
{
Expand All @@ -514,7 +516,7 @@
{
"type": "git",
"url": "https://github.com/libsdl-org/SDL.git",
"tag": "release-3.2.20"
"tag": "release-3.2.22"
}
],
"config-opts": [
Expand Down Expand Up @@ -566,7 +568,7 @@
{
"type": "git",
"url": "https://github.com/jeremy-rifkin/cpptrace.git",
"tag": "v1.0.4"
"tag": "v1.0.2"
}
],
"config-opts": [
Expand Down
200 changes: 200 additions & 0 deletions Meta/check-flatpak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#!/usr/bin/env python3

# Copyright (c) 2025, The Ladybird contributors
#
# SPDX-License-Identifier: BSD-2-Clause

import glob
import json
import os
import subprocess
import sys

from enum import Enum

VCPKG = "vcpkg.json"
VCPKG_OVERLAYS_PORTS = "Meta/CMake/vcpkg/overlay-ports/*"
VCPKG_URL = "https://github.com/microsoft/vcpkg.git"
VCPKG_REPO = "Build/vcpkg"
FLATPAK_MANIFEST = "Meta/CMake/flatpak/org.ladybird.Ladybird.json"
SELF = "Ladybird"

# List of build tools that are not provided by the Flatpak SDK and therefore in the manifest
# For a vcpkg build these are installed on the host system
flatpak_build_tools = [
"gn",
]

# List of libraries that are dependencies of dependencies
# These are in the manifest to fetch before building but not explicitely versioned
flatpak_deps_of_deps = [
"libyuv",
]

# List of libraries that are in the Flatpak runtime and therefore not in the manifest
# See: https://docs.flatpak.org/en/latest/available-runtimes.html#check-software-available-in-runtimes
flatpak_runtime_libs = [
"curl",
"dbus",
"ffmpeg",
"fontconfig",
"harfbuzz",
"libjpeg-turbo",
"libproxy",
"openssl",
"qtbase",
"qtmultimedia",
"sqlite3",
"zlib",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that we're linking against whatever the kde runtime gives us for these libraries in terms of their versions? These are all pretty critical, wouldn't it be safer to build against the exact same versions as those in vcpkg.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this can be done, but anticipating a future Flathub submission, I'm not sure about this. In Flathub submission PRs you see the reviewers often report that some library is in the runtime and should be used from that. They seem pretty strict in their policies.

]

# List of libraries that are in vcpkg but not needed for the Linux platform
vcpkg_not_linux = [
"dirent",
"mman",
]


class DepMatch(Enum):
Match = (0,)
NoMatch = (1,)
VersionMismatch = (2,)
Excluded = (3,)


def get_baseline_version(baseline, name):
if not os.path.isdir(VCPKG_REPO):
cmd = f"git clone --revision {baseline} --depth 1 {VCPKG_URL} {VCPKG_REPO}"
subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True)

# Query the current vcpkg baseline for its version of this package, this becomes the reference for linting
cmd = f"cd {VCPKG_REPO} && git show {baseline}:versions/baseline.json | grep -E -A 3 -e '\"{name}\"'"
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True)

if not result.returncode:
json_string = result.stdout.decode("utf-8").replace("\n", "").removesuffix(",")
result = json.loads(f"{{{json_string}}}")

if "baseline" in result[name]:
return result[name]["baseline"]


def check_for_match(vcpkg: dict, vcpkg_baseline, name: str, identifier: str) -> DepMatch:
if name == SELF or name in flatpak_build_tools or name in flatpak_deps_of_deps:
return DepMatch.Excluded

if name not in vcpkg:
version = get_baseline_version(vcpkg_baseline, name)

if version:
vcpkg[name] = version

if name in vcpkg:
if vcpkg[name] not in identifier:
return DepMatch.VersionMismatch
else:
return DepMatch.Match
else:
return DepMatch.NoMatch


def check_vcpkg_vs_flatpak_versioning():
def match_and_update(name: str, identifier: str) -> bool:
dep_match = check_for_match(vcpkg, vcpkg_baseline, name, identifier)

if dep_match == DepMatch.Match or dep_match == DepMatch.Excluded:
if name in vcpkg:
del vcpkg[name]

return False
else:
if dep_match == DepMatch.VersionMismatch:
print(f"{name} version mismatch. vcpkg: {vcpkg[name]}, Flatpak: {source['tag']}")
del vcpkg[name]
elif dep_match == DepMatch.NoMatch:
flatpak.append(name)

return True

vcpkg = {}
flatpak = []
mismatch_found = False

with open(VCPKG) as input:
vcpkg_json = json.load(input)
vcpkg_baseline = vcpkg_json["builtin-baseline"]

for package in vcpkg_json["overrides"]:
# Add name/version pair, strip any '#' postfix from the version
vcpkg[package["name"]] = str(package["version"]).split("#")[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We read all the vcpkg versions, but we don't report packages that are only mentioned in vcpkg but not the flatpak. This is a common mistake (we add a new dependency but forgot to add it to flatpak, e.g. see cpptrace). Can this script spot those as well?

Copy link
Contributor Author

@JanKoudijs JanKoudijs Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current script is indeed limited to finding mismatches in dependencies that are found in both vcpkg and the flatpak. What complicates a full version check is that Flatpak uses runtimes. The org.kde.Platform runtime we use includes commonly used libraries to reduce the size of the application Flatpak itself. Such runtime libraries are not explicitly listed in the flatpak.

I saw that today the flatpak label has been added, to trigger Flatpak builds in CI. Applying this label to PRs will also add in detecting partial version updates early.

Besides the flatpak label there is also a dependencies label, this might also be a good candidate to trigger Flatpak builds in CI.

Would these 3 together give an acceptable detection?

Btw. can this PR get the flatpak label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't report packages that are only mentioned in vcpkg but not the flatpak.

The other way around also happens. Not all vcpkg dependencies have a pinned version in [overrides], preventing comparison against the flatpak. The newly added cpptrace is an example of this. I don't know if it would be good practice to pin more dependency versions in vcpkg.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flatpak label is just for the actual build. Regular CI linting runs the script you're introducing here, that's not related to that.

cpptrace should definitely have a pinned version in vcpkg.json.

Maybe start off assuming everything must have identical versions, and keep a list of exceptions in your script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flatpak label is just for the actual build. Regular CI linting runs the script you're introducing here, that's not related to that.

I'm not sure I understand, does this mean that this was done after the merge and not as part of the PR checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We read all the vcpkg versions, but we don't report packages that are only mentioned in vcpkg but not the flatpak.

The updated script checks for dependencies that are unique for vcpkg or the flatpak if they have a listed exclusion, if not then linting fails.

Reasons for exclusion are:

  • Flatpak build dependencies
  • Flatpak dependencies of dependencies, these are not versioned in vcpkg
  • Flatpak runtime libraries
  • vcpkg dependencies specific for the non-Linux platforms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpptrace should definitely have a pinned version in vcpkg.json.

done


# Check the vcpkg overlay ports for packages not listed in overrides
for path in glob.glob(VCPKG_OVERLAYS_PORTS):
with open(f"{path}/vcpkg.json") as input:
overlay = json.load(input)

if "name" in overlay and overlay["name"] not in vcpkg and "version" in overlay:
vcpkg[overlay["name"]] = overlay["version"]

with open(FLATPAK_MANIFEST) as input:
for module in json.load(input)["modules"]:
name = module["name"]

for source in module["sources"]:
if "type" in source and source["type"] == "git":
if "tag" in source:
# Get the tag
# Replace '-' with '.': 76-1 vs 76.1
tag = str(source["tag"]).replace("-", ".")
mismatch_found = match_and_update(name, tag)

break
elif "branch" in source:
# Get the branch
# Strip '_' postfix, replace '/' with '_': chromium/7258_13 vs chromium_7258
branch = str(source["branch"]).split("_")[0].replace("/", "_")
mismatch_found = match_and_update(name, branch)

break
else:
if not (name == SELF or name in flatpak_build_tools or name in flatpak_deps_of_deps):
flatpak.append(name)

# Remove excluded dependencies from the vcpkg list
for name in flatpak_runtime_libs + vcpkg_not_linux:
if name in vcpkg:
del vcpkg[name]

if len(vcpkg):
mismatch_found = True
print(f"There are {len(vcpkg)} vcpkg dependencies that have no match in flatpak")

for name in vcpkg.keys():
print(f"- {name}")

if len(flatpak):
mismatch_found = True
print(f"There are {len(flatpak)} flatpak dependencies that have no match in vcpkg")

for name in flatpak:
print(f"- {name}")

return mismatch_found


def main():
file_list = sys.argv[1:] if len(sys.argv) > 1 else [VCPKG]
did_fail = False

if VCPKG in file_list or FLATPAK_MANIFEST in file_list:
did_fail = check_vcpkg_vs_flatpak_versioning()

# TODO: Add linting of Flatpak and AppStream manifest
# See #5594, bullet point "Missing lint job in CI to ensure Flatpak and AppStream manifests are up to snuff"

if did_fail:
sys.exit(1)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions Meta/lint-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set +e

for cmd in \
Meta/check-debug-flags.sh \
Meta/check-flatpak.py \
Meta/check-html-doctype.py \
Meta/check-idl-files.py \
Meta/check-newlines-at-eof.py \
Expand Down
4 changes: 4 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"name": "angle",
"version": "chromium_7258#0"
},
{
"name": "cpptrace",
"version": "1.0.2"
},
{
"name": "curl",
"version": "8.16.0#0"
Expand Down
Loading