fix(ci): use archive sources instead of git clones for flatpak

This commit is contained in:
Jonathan Steffan authored and xytovl committed 2026-11-04 09:46:36 +01:00
1 parent bae0cc3326
commit 6adb188c15
9 files changed
+197 -71

No files matched your search

+32 -10
View File
@@ -199,6 +199,16 @@ jobs:
with:
fetch-depth: 0
- uses: actions/cache/restore@v5
id: cache
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
restore-keys: flatpak-build-
- name: Create the flatpak manifest
run: |
git config --global --add safe.directory $(pwd)
@@ -206,15 +216,30 @@ jobs:
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
cat flatpak/io.github.wivrn.wivrn.yml
- uses: flatpak/flatpak-github-actions/[email protected]
- name: Update flatpak runtimes
run: |
for i in 1 2 3; do
flatpak update -y --noninteractive && exit 0
echo "flatpak update failed (attempt $i), retrying"
sleep 20
done
exit 1
- uses: flatpak/flatpak-github-actions/[email protected]
with:
manifest-path: flatpak/io.github.wivrn.wivrn.yml
bundle: wivrn-server.flatpak
# The manifest is regenerated on every commit with the git hash embedded,
# so its default (manifest-hash) cache key never hits. Key on the files
# that actually define the dependency set instead, so the toolchain
# downloads and build cache persist across commits.
cache-key: flatpak-builder-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
restore-cache: false
save-cache: false
- uses: actions/cache/save@v5
if: success() && steps.cache.outputs.cache-hit != 'true'
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
- name: Debug bundle
uses: actions/upload-artifact@v7
@@ -429,10 +454,7 @@ jobs:
- name: Patch monado
working-directory: wivrn/monado-src
run: >
for p in ../patches/monado/*; do
patch -p1 --fuzz=0 --forward < "$p"
done
run: ../patches/apply.sh ../patches/monado/*
- name: Download stb
run: |
+5
View File
@@ -22,3 +22,8 @@ gradle.properties
local.properties
compile_commands.json
!libopenxr_loader.so
# Generated by tools/gen_flatpak_manifest.py
flatpak/io.github.wivrn.wivrn.yml
flatpak/xrizer-gen-src-*.json
flatpak/monado-*.tar.gz
+2
View File
@@ -33,6 +33,8 @@ For a few dependencies it is possible to select system or embedded versions, che
For more advanced options, check [CMakeLists.txt](../CMakeLists.txt).
For the Flatpak, see [flatpak](flatpak.md).
## Profiling / tracing build
To build the server with Perfetto tracing for local profiling, use the `server-tracing` preset (it is the `server` preset plus `WIVRN_USE_PERFETTO=ON`):
+11
View File
@@ -0,0 +1,11 @@
# Flatpak maintenance
The manifest template is `flatpak/io.github.wivrn.wivrn.yml.in`. All remote sources are archives pinned with a sha256, downloaded from the project's official host: a release tarball, or an archive of the official repository. Do not use third-party mirrors or `type: git` sources. Get a sha256 with `curl -L <url> | sha256sum`.
| When | Do |
|---|---|
| Updating monado | Update `monado-rev`. Nothing else. |
| Updating xrizer | Update the commit in its archive URL and its sha256. The cargo sources are regenerated by `tools/gen_flatpak_manifest.py`. |
| Updating OpenComposite | Also update the `libs/openxr-sdk`, `libs/glm` and `libs/libunwind` archives to its submodule commits: `curl "https://gitlab.com/api/v4/projects/znixian%2FOpenOVR/repository/tree?path=libs&ref=<commit>"` (entries of type `commit`). |
| Updating the KDE runtime | Update the `flatpak-github-actions:kde-<version>` container tag in [Build.yml](../.github/workflows/Build.yml) to match `runtime-version`. |
| Updating any other dependency | Update its URL and sha256. |
+1 -2
View File
@@ -210,8 +210,7 @@ CT_SYSROOT_DIR_PREFIX=""
CT_WANTS_STATIC_LINK=y
CT_WANTS_STATIC_LINK_CXX=y
# CT_STATIC_TOOLCHAIN is not set
CT_SHOW_CT_VERSION=y
CT_TOOLCHAIN_PKGVERSION=""
# CT_SHOW_CT_VERSION is not set
CT_TOOLCHAIN_BUGURL=""
#
+1 -2
View File
@@ -189,8 +189,7 @@ CT_SYSROOT_DIR_PREFIX=""
CT_WANTS_STATIC_LINK=y
CT_WANTS_STATIC_LINK_CXX=y
# CT_STATIC_TOOLCHAIN is not set
CT_SHOW_CT_VERSION=y
CT_TOOLCHAIN_PKGVERSION=""
# CT_SHOW_CT_VERSION is not set
CT_TOOLCHAIN_BUGURL=""
#
+54 -41
View File
@@ -67,13 +67,16 @@ cleanup:
- '*.la'
- '*.cmake'
# Sources are sha256-pinned archives, not git, so flatpak-builder reuses
# downloads and unchanged module builds from .flatpak-builder. CI caches that
# directory plus the monado archive, keyed on this file, ct-ng configs and monado-rev.
modules:
- name: crosstool
buildsystem: autotools
sources:
- type: git
url: https://github.com/crosstool-ng/crosstool-ng.git
commit: 620b909cd0713f68084378b63cf61b5232757b90
- type: archive
url: https://github.com/crosstool-ng/crosstool-ng/archive/620b909cd0713f68084378b63cf61b5232757b90.tar.gz
sha256: d109c9315c0ae0cbb7622d540b1f395b663243371413bbecba03e800c5caa18b
- type: shell
commands:
# Make the build lighter:
@@ -94,9 +97,11 @@ modules:
config-opts:
- --disable-md2man
sources:
- type: git
url: https://github.com/RsyncProject/rsync.git
commit: 3305a7a063ab0167cab5bf7029da53abaa9fdb6e
- type: archive
url: https://github.com/RsyncProject/rsync/releases/download/v3.4.1/rsync-3.4.1.tar.gz
mirror-urls:
- https://download.samba.org/pub/rsync/src/rsync-3.4.1.tar.gz
sha256: 2924bcb3a1ed8b551fc101f740b9f0fe0a202b115027647cf69850d65fd88c52
cleanup:
- '*'
@@ -209,10 +214,9 @@ modules:
- --disable-manpages
- --disable-static
sources:
- type: git
url: https://github.com/avahi/avahi.git
tag: v0.8
commit: f060abee2807c943821d88839c013ce15db17b58
- type: archive
url: https://github.com/avahi/avahi/releases/download/v0.8/avahi-0.8.tar.gz
sha256: 060309d7a333d38d951bc27598c677af1796934dbd98e1024e7ad8de798fedda
cleanup:
- /share/locale
- /share/runtime/locale
@@ -223,9 +227,9 @@ modules:
config-opts:
- --enable-shared
sources:
- type: git
url: https://code.videolan.org/videolan/x264.git
commit: 31e19f92f00c7003fa115047ce50978bc98c3a0d
- type: archive
url: https://code.videolan.org/videolan/x264/-/archive/31e19f92f00c7003fa115047ce50978bc98c3a0d/x264-31e19f92f00c7003fa115047ce50978bc98c3a0d.tar.gz
sha256: d053c9d86988d6bc78237ca5205865c5ddf99c98ef4cd9927eec8f6d388f6dd9
cleanup:
- /bin/x264
@@ -251,10 +255,9 @@ modules:
- /bin/ffplay
- /bin/ffprobe
sources:
- type: git
url: https://gitlab.com/freedesktop-sdk/mirrors/ffmpeg/ffmpeg.git
tag: n7.1.4
commit: 9abe92e3af7fa7becc8f7f742b1457b4c28220a6
- type: archive
url: https://ffmpeg.org/releases/ffmpeg-7.1.4.tar.xz
sha256: 71f4aac3573ed9060489cb62526a6c7dda815ae10993789611acd7be9fa9fbf4
- name: eigen3
buildsystem: cmake-ninja
@@ -262,10 +265,9 @@ modules:
- -DBUILD_TESTING=OFF
builddir: true
sources:
- type: git
url: https://gitlab.com/libeigen/eigen.git
tag: 5.0.1
commit: bc3b39870ecb690a623a3f49149a358b95c5781d
- type: archive
url: https://gitlab.com/libeigen/eigen/-/archive/5.0.1/eigen-5.0.1.tar.gz
sha256: e9c326dc8c05cd1e044c71f30f1b2e34a6161a3b6ecf445d56b53ff1669e3dec
cleanup:
- '*'
@@ -274,10 +276,9 @@ modules:
config-opts:
- -DJSON_BuildTests=OFF
sources:
- type: git
url: https://github.com/nlohmann/json.git
tag: v3.12.0
commit: 55f93686c01528224f448c19128836e7df245f72
- type: archive
url: https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz
sha256: 42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa
- name: cli11
buildsystem: cmake-ninja
@@ -287,10 +288,9 @@ modules:
- -DCLI11_BUILD_TESTS=OFF
- -DCLI11_BUILD_EXAMPLES=OFF
sources:
- type: git
url: https://github.com/CLIUtils/CLI11
tag: v2.6.2
commit: 37bb6edc5317e99af72ef48405e65d9ca5218861
- type: archive
url: https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.6.2.tar.gz
sha256: c6ea6b2e5608b3ea8617999bd5f47420c71b2ebdb8dc4767c1034d1da5785711
cleanup:
- '*'
@@ -314,9 +314,22 @@ modules:
- -DUSE_SYSTEM_OPENXR=OFF
- -DUSE_SYSTEM_GLM=OFF
sources:
- type: git
url: https://gitlab.com/znixian/OpenOVR.git
commit: cff07db75c4823afe93ed7027b03d5f7bc86f164
- type: archive
url: https://gitlab.com/znixian/OpenOVR/-/archive/cff07db75c4823afe93ed7027b03d5f7bc86f164/OpenOVR-cff07db75c4823afe93ed7027b03d5f7bc86f164.tar.gz
sha256: d7ac1b9b12b3681414370be301909789ccdbb948412689780b2dec8cd47070bf
# git submodules of OpenOVR at the commit above
- type: archive
url: https://github.com/KhronosGroup/OpenXR-SDK/archive/91a8a8d9d70f4b469bca0726122c3b5a6096010e.tar.gz
dest: libs/openxr-sdk
sha256: 3b615f994adfa6184c6ff3b1b6af24965048ea1ddd3c3cf15c2b042282e74c05
- type: archive
url: https://github.com/g-truc/glm/archive/bf71a834948186f4097caa076cd2663c69a10e1e.tar.gz
dest: libs/glm
sha256: 70ad78e872c145f0164d54da833b651914c184edc65958906937b9739fb8fb1b
- type: archive
url: https://github.com/libunwind/libunwind/archive/f27f6a860335fc6c8107702dbde4b215ea74b164.tar.gz
dest: libs/libunwind
sha256: 3beb15d894759234dcb568f9d2be8b6ddc04c5d112836772e99884c58a07a285
- name: xrizer
buildsystem: simple
@@ -345,9 +358,9 @@ modules:
- mkdir /app/xrizer
- cp -rL target/release/bin/ /app/xrizer/
sources:
- type: git
url: https://github.com/Supreeeme/xrizer.git
commit: a1216c7b53fb562a5bc4de473163e97a483042af
- type: archive
url: https://github.com/Supreeeme/xrizer/archive/a1216c7b53fb562a5bc4de473163e97a483042af.tar.gz
sha256: d75bb0a301bcafb57e94ca56b9ea6ccbe847f3db9181d7fb61bffccb26a40c88
- xrizer-gen-src.json
- name: wivrn-library
@@ -389,9 +402,9 @@ modules:
- WIVRN_SRC1
WIVRN_SRC2
WIVRN_SRC3
- type: git
url: https://gitlab.freedesktop.org/monado/monado
commit: MONADO_COMMIT
- type: archive
url: MONADO_URL
sha256: MONADO_SHA256
dest: deps/monado-src
- type: shell
commands:
@@ -429,9 +442,9 @@ modules:
url: BOOST_URL
dest: deps/boost-src
sha256: BOOST_SHA256
- type: git
url: https://gitlab.freedesktop.org/monado/monado
commit: MONADO_COMMIT
- type: archive
url: MONADO_URL
sha256: MONADO_SHA256
dest: deps/monado-src
- type: shell
commands:
+6 -3
View File
@@ -14,10 +14,13 @@ if ! type patch 2> /dev/null ; then
exit 1
fi
# There is no reliable way to apply a patch and succeed if it was
# already applied. Just ignore errors...
# Skip patches that are already applied, fail on any other error.
for f in "$@" ; do
patch -p1 --forward < "$f"
if patch -p1 --reverse --force --dry-run --fuzz=0 < "$f" > /dev/null 2>&1 ; then
echo "already applied: $f"
continue
fi
patch -p1 --forward --batch --fuzz=0 < "$f" || exit 1
done
exit 0
+85 -13
View File
@@ -2,17 +2,81 @@
import argparse
import asyncio
import hashlib
import json
import os
import re
import shutil
import subprocess
import sys
import time
from urllib.request import urlopen
import flatpakcargogenerator
import toml
TEMPLATE = "flatpak/io.github.wivrn.wivrn.yml.in"
# Local caches, regenerated or downloaded only when the xrizer commit or
# monado-rev changes. The xrizer commit is part of the cache filename, so
# its presence alone tells us whether it's still valid.
CARGO_SOURCES = "flatpak/xrizer-gen-src-{0}.json"
CARGO_SOURCES_OUT_NAME = "xrizer-gen-src.json"
MONADO_ARCHIVE = "flatpak/monado-{0}.tar.gz"
XRIZER_REPO = "https://github.com/Supreeeme/xrizer"
MONADO_URL = "https://gitlab.freedesktop.org/monado/monado/-/archive/{0}/monado-{0}.tar.gz"
def read_file(path: str) -> str:
try:
with open(path) as f:
return f.read().strip()
except FileNotFoundError:
return ""
def fetch(url: str, attempts: int = 4) -> bytes:
for attempt in range(1, attempts + 1):
try:
with urlopen(url, timeout=120) as response:
return response.read()
except OSError as e:
if attempt == attempts:
raise
print(f"Downloading {url} failed ({e}), retrying", file=sys.stderr)
time.sleep(30 * attempt)
def write_cargo_sources(path: str, gen_src) -> None:
with open(path, "w") as f:
json.dump(gen_src, f, indent=4, sort_keys=False)
f.write("\n")
def generate_cargo_sources(xrizer_commit: str):
try:
import flatpakcargogenerator
import toml
except ImportError as e:
print(
f"Generating {CARGO_SOURCES_OUT_NAME} requires python modules toml and aiohttp: {e}",
file=sys.stderr,
)
sys.exit(2)
print(f"Generating cargo sources for xrizer {xrizer_commit}", file=sys.stderr)
lock = fetch(f"{XRIZER_REPO}/raw/{xrizer_commit}/Cargo.lock")
return asyncio.run(flatpakcargogenerator.generate_sources(toml.loads(lock.decode())))
def monado_sha256(root: str, monado_commit: str) -> str:
archive = os.path.join(root, MONADO_ARCHIVE.format(monado_commit))
if not os.path.exists(archive):
print(f"Downloading monado archive for {monado_commit}", file=sys.stderr)
with open(archive + ".part", "wb") as f:
f.write(fetch(MONADO_URL.format(monado_commit)))
os.replace(archive + ".part", archive)
with open(archive, "rb") as f:
return hashlib.sha256(f.read()).hexdigest()
class CMakeFile:
def __init__(self, filename: str):
@@ -48,16 +112,23 @@ if __name__ == "__main__":
with open(os.path.join(root, TEMPLATE)) as f:
template = f.read()
# Get dependencies for xrizer
xrizer_repo = "https://github.com/Supreeeme/xrizer"
xrizer_commit = re.findall(f"url: {xrizer_repo}.git[ \n]*commit: ([a-f0-9]*)", template)[0]
lock = urlopen(f"{xrizer_repo}/raw/{xrizer_commit}/Cargo.lock")
gen_src = asyncio.run(flatpakcargogenerator.generate_sources(toml.loads(lock.read().decode())))
with open(os.path.join(args.out, "xrizer-gen-src.json"), "w") as f:
json.dump(gen_src, f, indent=4, sort_keys=False)
# Cargo dependencies for xrizer
xrizer_commit = re.findall(f"url: {XRIZER_REPO}/archive/([a-f0-9]{{40}})\\.tar\\.gz", template)[
0
]
cargo_sources = os.path.join(root, CARGO_SOURCES.format(xrizer_commit))
out_cargo_sources = os.path.join(args.out, CARGO_SOURCES_OUT_NAME)
if os.path.exists(cargo_sources):
if not os.path.exists(out_cargo_sources) or not os.path.samefile(
cargo_sources, out_cargo_sources
):
shutil.copyfile(cargo_sources, out_cargo_sources)
else:
gen_src = generate_cargo_sources(xrizer_commit)
write_cargo_sources(cargo_sources, gen_src)
write_cargo_sources(out_cargo_sources, gen_src)
with open(os.path.join(root, "monado-rev")) as f:
monado_commit = f.read()
monado_commit = read_file(os.path.join(root, "monado-rev"))
boost_url = cmake.get("boost", "URL")
boost_sha256 = cmake.get("boost", "URL_HASH").split("=")[-1]
@@ -102,7 +173,8 @@ if __name__ == "__main__":
template = template.replace("BOOST_URL", boost_url)
template = template.replace("BOOST_SHA256", boost_sha256)
template = template.replace("MONADO_COMMIT", monado_commit)
template = template.replace("MONADO_URL", MONADO_URL.format(monado_commit))
template = template.replace("MONADO_SHA256", monado_sha256(root, monado_commit))
with open(os.path.join(args.out, "io.github.wivrn.wivrn.yml"), "w") as f:
f.write(template)