Skip to content

Commit 1802a7e

Browse files
committed
Meta: Use vcpkg baseline as fallback for Flatpak linting
If there is no version specified in vcpkg overrides then the vcpkg baseline is queried for the version. The baseline is what ensures dependency compatibility.
1 parent 76683d9 commit 1802a7e

File tree

2 files changed

+60
-43
lines changed

2 files changed

+60
-43
lines changed

Meta/CMake/flatpak/org.ladybird.Ladybird.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
{
206206
"type": "git",
207207
"url": "https://github.com/GNOME/libxml2.git",
208-
"tag": "v2.13.8"
208+
"tag": "v2.15.0"
209209
}
210210
],
211211
"config-opts": [
@@ -253,7 +253,7 @@
253253
{
254254
"type": "git",
255255
"url": "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git",
256-
"tag": "v3.1.0"
256+
"tag": "v3.3.0"
257257
}
258258
],
259259
"config-opts": [
@@ -396,7 +396,7 @@
396396
{
397397
"type": "git",
398398
"url": "https://github.com/google/highway.git",
399-
"tag": "1.2.0",
399+
"tag": "1.3.0",
400400
"disable-submodules": true
401401
}
402402
],

Meta/check-flatpak.py

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,32 @@
66

77
import glob
88
import json
9+
import os
10+
import subprocess
911
import sys
1012

1113
from enum import Enum
1214

1315
VCPKG = "vcpkg.json"
1416
VCPKG_OVERLAYS_PORTS = "Meta/CMake/vcpkg/overlay-ports/*"
17+
VCPKG_URL = "https://github.com/microsoft/vcpkg.git"
18+
VCPKG_REPO = "Build/vcpkg"
1519
FLATPAK_MANIFEST = "Meta/CMake/flatpak/org.ladybird.Ladybird.json"
1620
SELF = "Ladybird"
1721

18-
# List of build tools that are not provided by the Flatpak SDK and therefor in the manifest
22+
# List of build tools that are not provided by the Flatpak SDK and therefore in the manifest
1923
# For a vcpkg build these are installed on the host system
2024
flatpak_build_tools = [
2125
"gn",
2226
]
2327

2428
# List of libraries that are dependencies of dependencies
25-
# These are in the manifest to fetch before the build but not explicitely versioned in vcpkg
29+
# These are in the manifest to fetch before building but not explicitely versioned
2630
flatpak_deps_of_deps = [
27-
"brotli",
28-
"dav1d",
29-
"highway",
30-
"libdwarf",
31-
"libxml2",
3231
"libyuv",
33-
"vulkan-memory-allocator",
34-
"zstd",
3532
]
3633

37-
# List of libraries that are in the Flatpak runtime and therefor not in the manifest
34+
# List of libraries that are in the Flatpak runtime and therefore not in the manifest
3835
# See: https://docs.flatpak.org/en/latest/available-runtimes.html#check-software-available-in-runtimes
3936
flatpak_runtime_libs = [
4037
"curl",
@@ -65,25 +62,69 @@ class DepMatch(Enum):
6562
Excluded = (3,)
6663

6764

68-
def check_for_match(vcpkg: dict, name: str, identifier: str) -> DepMatch:
65+
def get_baseline_version(baseline, name):
66+
if not os.path.isdir(VCPKG_REPO):
67+
cmd = f"git clone {VCPKG_URL} {VCPKG_REPO} && cd {VCPKG_REPO} && git reset --hard {baseline}"
68+
subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True)
69+
70+
# Query the current vcpkg baseline for its version of this package, this becomes the reference for linting
71+
cmd = f"cd {VCPKG_REPO} && git show {baseline}:versions/baseline.json | grep -E -A 3 -e '\"{name}\"'"
72+
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True)
73+
74+
if not result.returncode:
75+
json_string = result.stdout.decode("utf-8").replace("\n", "").removesuffix(",")
76+
result = json.loads(f"{{{json_string}}}")
77+
78+
if "baseline" in result[name]:
79+
return result[name]["baseline"]
80+
81+
82+
def check_for_match(vcpkg: dict, vcpkg_baseline, name: str, identifier: str) -> DepMatch:
83+
if name == SELF or name in flatpak_build_tools or name in flatpak_deps_of_deps:
84+
return DepMatch.Excluded
85+
86+
if name not in vcpkg:
87+
version = get_baseline_version(vcpkg_baseline, name)
88+
89+
if version:
90+
vcpkg[name] = version
91+
6992
if name in vcpkg:
7093
if vcpkg[name] not in identifier:
7194
return DepMatch.VersionMismatch
7295
else:
7396
return DepMatch.Match
74-
elif name == SELF or name in flatpak_build_tools or name in flatpak_deps_of_deps:
75-
return DepMatch.Excluded
7697
else:
7798
return DepMatch.NoMatch
7899

79100

80101
def check_vcpkg_vs_flatpak_versioning():
102+
def match_and_update(name: str, identifier: str) -> bool:
103+
dep_match = check_for_match(vcpkg, vcpkg_baseline, name, identifier)
104+
105+
if dep_match == DepMatch.Match or dep_match == DepMatch.Excluded:
106+
if name in vcpkg:
107+
del vcpkg[name]
108+
109+
return False
110+
else:
111+
if dep_match == DepMatch.VersionMismatch:
112+
print(f"{name} version mismatch. vcpkg: {vcpkg[name]}, Flatpak: {source['tag']}")
113+
del vcpkg[name]
114+
elif dep_match == DepMatch.NoMatch:
115+
flatpak.append(name)
116+
117+
return True
118+
81119
vcpkg = {}
82120
flatpak = []
83121
mismatch_found = False
84122

85123
with open(VCPKG) as input:
86-
for package in json.load(input)["overrides"]:
124+
vcpkg_json = json.load(input)
125+
vcpkg_baseline = vcpkg_json["builtin-baseline"]
126+
127+
for package in vcpkg_json["overrides"]:
87128
# Add name/version pair, strip any '#' postfix from the version
88129
vcpkg[package["name"]] = str(package["version"]).split("#")[0]
89130

@@ -105,38 +146,14 @@ def check_vcpkg_vs_flatpak_versioning():
105146
# Get the tag
106147
# Replace '-' with '.': 76-1 vs 76.1
107148
tag = str(source["tag"]).replace("-", ".")
108-
dep_match = check_for_match(vcpkg, name, tag)
109-
110-
if dep_match == DepMatch.Match or dep_match == DepMatch.Excluded:
111-
if name in vcpkg:
112-
del vcpkg[name]
113-
else:
114-
mismatch_found = True
115-
116-
if dep_match == DepMatch.VersionMismatch:
117-
print(f"{name} version mismatch. vcpkg: {vcpkg[name]}, Flatpak: {source['tag']}")
118-
del vcpkg[name]
119-
elif dep_match == DepMatch.NoMatch:
120-
flatpak.append(name)
149+
mismatch_found = match_and_update(name, tag)
121150

122151
break
123152
elif "branch" in source:
124153
# Get the branch
125154
# Strip '_' postfix, replace '/' with '_': chromium/7258_13 vs chromium_7258
126155
branch = str(source["branch"]).split("_")[0].replace("/", "_")
127-
dep_match = check_for_match(vcpkg, name, branch)
128-
129-
if dep_match == DepMatch.Match or dep_match == DepMatch.Excluded:
130-
if name in vcpkg:
131-
del vcpkg[name]
132-
else:
133-
mismatch_found = True
134-
135-
if dep_match == DepMatch.VersionMismatch:
136-
print(f"{name} version mismatch. vcpkg: {vcpkg[name]}, Flatpak: {source['branch']}")
137-
del vcpkg[name]
138-
elif DepMatch == DepMatch.NoMatch:
139-
flatpak.append(name)
156+
mismatch_found = match_and_update(name, branch)
140157

141158
break
142159
else:

0 commit comments

Comments
 (0)