mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix(desktop): address KDE feedback and keep local builds in sync with CI (#488)
This commit is contained in:
1 parent
c761b83112
commit
d99ed8e00b
41 files changed
+1252
-191
No files matched your search
+46
-91
@@ -13,7 +13,7 @@ else
|
||||
fi
|
||||
sdk_dir=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-"${HOME}/Library/Android/sdk"}}
|
||||
java_dir=${JAVA_HOME:-"/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"}
|
||||
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v2}
|
||||
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
|
||||
build_variant=${DROIDDECK_BUILD_VARIANT:-release}
|
||||
case "$build_variant" in
|
||||
debug) gradle_task=assembleDebug ;;
|
||||
@@ -33,7 +33,7 @@ if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "Docker is required to cross-compile the glibc ARM64 preload libraries." >&2
|
||||
exit 1
|
||||
fi
|
||||
for tool in curl tar zstd shasum unzip; do
|
||||
for tool in curl tar zstd shasum unzip python3; do
|
||||
if ! command -v "${tool}" >/dev/null 2>&1; then
|
||||
echo "${tool} is required to build the CI-equivalent APK." >&2
|
||||
exit 1
|
||||
@@ -62,24 +62,10 @@ export NDK="${sdk_dir}/ndk/${ndk_version}"
|
||||
|
||||
staging_dir=$(mktemp -d "${TMPDIR:-/tmp}/droiddeck-build.XXXXXX")
|
||||
bundle_asset="${repo_root}/app/src/main/assets/pulseaudio.tzst"
|
||||
bundle_backup="${staging_dir}/pulseaudio.original.tzst"
|
||||
bundle_replaced=0
|
||||
linuxfs_dir="${repo_root}/app/src/main/assets/linuxfs"
|
||||
linuxfs_backup="${staging_dir}/linuxfs.original"
|
||||
linuxfs_preexisting=0
|
||||
linuxfs_replaced=0
|
||||
cleanup() {
|
||||
local exit_code=$?
|
||||
trap - EXIT
|
||||
if [[ "${bundle_replaced}" == 1 ]]; then
|
||||
cp -p "${bundle_backup}" "${bundle_asset}" || exit_code=1
|
||||
fi
|
||||
if [[ "${linuxfs_replaced}" == 1 ]]; then
|
||||
rm -rf -- "${linuxfs_dir}" || exit_code=1
|
||||
if [[ "${linuxfs_preexisting}" == 1 ]]; then
|
||||
mv "${linuxfs_backup}" "${linuxfs_dir}" || exit_code=1
|
||||
fi
|
||||
fi
|
||||
rm -rf -- "${staging_dir}" || exit_code=1
|
||||
exit "${exit_code}"
|
||||
}
|
||||
@@ -87,29 +73,11 @@ trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
if [[ -d "${linuxfs_dir}" ]]; then
|
||||
cp -a "${linuxfs_dir}" "${linuxfs_backup}"
|
||||
linuxfs_preexisting=1
|
||||
fi
|
||||
linuxfs_replaced=1
|
||||
# A wedged daemon used to hang indefinitely and then trigger an unnecessary image rebuild.
|
||||
python3 "${repo_root}/tools/docker_preflight.py" "${image_name}"
|
||||
rm -rf -- "${linuxfs_dir}"
|
||||
mkdir -p "${linuxfs_dir}"
|
||||
|
||||
# Docker Desktop's VM restarts now and then, and until its engine has loaded its image store it
|
||||
# answers "No such image" for images it has. The rebuild that follows hangs on the registry
|
||||
# (the base image's credentials go through docker-credential-desktop), so give a restarting daemon
|
||||
# up to a minute before deciding the image is really missing.
|
||||
image_present=0
|
||||
for _ in $(seq 1 30); do
|
||||
if inspect_error=$(docker image inspect "${image_name}" 2>&1 >/dev/null); then image_present=1; break; fi
|
||||
sleep 2
|
||||
done
|
||||
if [[ "${image_present}" = 0 ]]; then
|
||||
echo "Build image ${image_name} not found (${inspect_error:-no error}); building it." >&2
|
||||
docker build --platform linux/amd64 -t "${image_name}" \
|
||||
-f "${repo_root}/tools/local-cross.Dockerfile" "${repo_root}"
|
||||
fi
|
||||
|
||||
docker run --rm --platform linux/amd64 \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "${repo_root}:/src" -w /src "${image_name}" bash -lc '
|
||||
@@ -126,6 +94,9 @@ docker run --rm --platform linux/amd64 \
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
|
||||
-o "$d/libblfastpath.so" tools/proot/fastpath/fastpath.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/libblfastpath.so"
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
|
||||
-o "$d/libssbs.so" tools/linuxfs/ssbs/ssbs_adapter.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/libssbs.so"
|
||||
mkdir -p "$d/usr/local/bin"
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -Wextra -o "$d/usr/local/bin/droiddeck-clipboard" tools/linuxfs/clipboard/clipboard.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-clipboard"
|
||||
@@ -142,34 +113,11 @@ docker run --rm --platform linux/amd64 \
|
||||
install -Dm644 tools/linuxfs/desktop/firefox-droiddeck.js \
|
||||
"$d/usr/lib/firefox/defaults/pref/droiddeck.js"
|
||||
|
||||
need=$(aarch64-linux-gnu-readelf -d "$d/libfakeinput.so" | sed -n "s/.*NEEDED.*\\[\\(.*\\)\\]/\\1/p")
|
||||
for bad in libstdc++.so.6 libgcc_s.so.1; do
|
||||
if printf "%s\\n" "$need" | grep -qx "$bad"; then
|
||||
echo "libfakeinput.so links $bad; the C++ runtime must stay static" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
syms() { aarch64-linux-gnu-readelf -Ws "$1" | awk '\''$4 == "FUNC" && $5 == "GLOBAL" {sub(/@.*/, "", $8); print $8}'\''; }
|
||||
fake=$(syms "$d/libfakeinput.so")
|
||||
for sym in open openat ioctl read close poll ppoll select stat fstat access scandir; do
|
||||
printf "%s\\n" "$fake" | grep -qx "$sym" || {
|
||||
echo "libfakeinput.so does not export $sym" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
session=$(syms "$d/libblsession.so")
|
||||
for sym in socket bind getsockname setsockopt statfs statvfs; do
|
||||
printf "%s\\n" "$session" | grep -qx "$sym" || {
|
||||
echo "libblsession.so does not export $sym" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
test -f "$d/usr/local/bin/droiddeck-session"
|
||||
test -f "$d/usr/local/bin/droiddeck-proton-extra"
|
||||
READELF=aarch64-linux-gnu-readelf bash tools/linuxfs/check-preloads.sh "$d"
|
||||
'
|
||||
|
||||
docker run --rm --platform linux/amd64 \
|
||||
-v "${repo_root}:/src" -w /src debian:bullseye bash -c '
|
||||
-v "${repo_root}:/src" -w /src public.ecr.aws/docker/library/debian:bullseye bash -c '
|
||||
set -euo pipefail
|
||||
printf "deb http://archive.debian.org/debian bullseye main\ndeb http://archive.debian.org/debian-security bullseye-security main\n" > /etc/apt/sources.list
|
||||
apt-get -o Acquire::Check-Valid-Until=false update -qq
|
||||
@@ -253,6 +201,26 @@ elif [[ -d "${sync_assets}" ]]; then
|
||||
echo "No tools/droiddeck-esync/release.env: the APK bundles the droiddeck-esync packs already in ${sync_assets}." >&2
|
||||
fi
|
||||
|
||||
msi_pkgs="${staging_dir}/msi-pkgs"
|
||||
msi_dir="${linuxfs_dir}/usr/local/lib/droiddeck-msitools"
|
||||
mkdir -p "${msi_pkgs}" "${msi_dir}"
|
||||
while read -r package_sha256 package_url; do
|
||||
[[ -n "${package_url}" ]] || continue
|
||||
package_archive=$(cached "${package_sha256}" "$(basename "${package_url}")" \
|
||||
bash -c 'curl -fsSL --retry 3 -o "$out" "$0"' "${package_url}")
|
||||
tar -xJf "${package_archive}" -C "${msi_pkgs}"
|
||||
done < <(grep -v '^#' "${repo_root}/tools/msitools/packages.txt")
|
||||
for tool in msiinfo cabextract; do install -m644 "${msi_pkgs}/usr/bin/${tool}" "${msi_dir}/${tool}"; done
|
||||
for tool in 7z 7z.so; do install -m644 "${msi_pkgs}/usr/lib/7zip/${tool}" "${msi_dir}/${tool}"; done
|
||||
for library in libmsi-1.0.so.0 libgsf-1.so.114 libgcab-1.0.so.0; do
|
||||
cp -L "${msi_pkgs}/usr/lib/${library}" "${msi_dir}/${library}"
|
||||
done
|
||||
mkdir -p "${linuxfs_dir}/usr/local/share/licenses/droiddeck-msitools"
|
||||
for license in NOTICE GPL-2 GPL-3 LGPL-2.1 7zip-License 7zip-unRarLicense; do
|
||||
install -m644 "${repo_root}/tools/msitools/licenses/${license}" \
|
||||
"${linuxfs_dir}/usr/local/share/licenses/droiddeck-msitools/${license}"
|
||||
done
|
||||
|
||||
mango_dir="${linuxfs_dir}/usr/local/lib/mangoapp"
|
||||
mango_pkgs="${staging_dir}/mango-pkgs"
|
||||
mkdir -p "${mango_dir}" "${mango_pkgs}"
|
||||
@@ -295,16 +263,18 @@ sink_output="${staging_dir}/sink-out"
|
||||
# proot is rebuilt only when its sources (source.env, the patches, the build script) changed since
|
||||
# the libraries in jniLibs were built.
|
||||
proot_out="${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
proot_inputs=$(cd "${repo_root}/tools/proot" && find . -type f ! -name '*.pyc' | LC_ALL=C sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
|
||||
proot_sources=$(cd "${repo_root}/tools/proot" && find . -type f ! -name '*.pyc' | LC_ALL=C sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
|
||||
proot_inputs=$(printf '%s\n' "${proot_sources}" "${ndk_version}" | shasum -a 256 | cut -d' ' -f1)
|
||||
if [[ -f "${proot_out}/libproot.so" && -f "${proot_out}/libproot-loader.so" \
|
||||
&& "$(cat "${proot_out}/.proot-inputs" 2>/dev/null)" = "${proot_inputs}" ]]; then
|
||||
&& "$(cat "${proot_out}/.proot-inputs" 2>/dev/null)" = "${proot_inputs}" ]] \
|
||||
&& (cd "${proot_out}" && shasum -a 256 -c .proot-outputs >/dev/null 2>&1); then
|
||||
echo "proot: sources unchanged, keeping ${proot_out}/libproot.so"
|
||||
else
|
||||
"${repo_root}/tools/proot/build.sh" "${proot_out}"
|
||||
echo "${proot_inputs}" > "${proot_out}/.proot-inputs"
|
||||
(cd "${proot_out}" && shasum -a 256 libproot.so libproot-loader.so > .proot-outputs)
|
||||
fi
|
||||
|
||||
cp -p "${bundle_asset}" "${bundle_backup}"
|
||||
bundle_dir="${staging_dir}/pulseaudio-bundle"
|
||||
mkdir -p "${bundle_dir}"
|
||||
zstd -dc "${bundle_asset}" | tar -xf - -C "${bundle_dir}"
|
||||
@@ -318,8 +288,8 @@ install -m755 "${sink_output}/module-aaudio-sink.so" \
|
||||
install -m755 "${sink_output}/module-directaudio-native-sink.so" \
|
||||
"${bundle_dir}/modules/arm64/module-directaudio-native-sink.so"
|
||||
tar -cf - -C "${bundle_dir}" . | zstd -19 -T0 -c > "${staging_dir}/pulseaudio.tzst"
|
||||
bundle_replaced=1
|
||||
mv "${staging_dir}/pulseaudio.tzst" "${bundle_asset}"
|
||||
mkdir -p "${repo_root}/app/build/prepared-assets"
|
||||
mv "${staging_dir}/pulseaudio.tzst" "${repo_root}/app/build/prepared-assets/pulseaudio.tzst"
|
||||
|
||||
# The GOG / Epic / Amazon download engines are Rust (app/src/main/rust/stores); Gradle's
|
||||
# buildRustStores task cross-compiles them with cargo-ndk, which needs the Android target and the
|
||||
@@ -336,17 +306,17 @@ else
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
rustup target add aarch64-linux-android
|
||||
rustup target add --toolchain stable aarch64-linux-android
|
||||
if ! command -v cargo-ndk >/dev/null 2>&1; then
|
||||
cargo install cargo-ndk --locked
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "${repo_root}"
|
||||
python3 tools/release/runtime_inputs.py record
|
||||
./gradlew "${gradle_task}" --console=plain -PndkVersion="${ndk_version}" ${gradle_rust_arg}
|
||||
python3 tools/release/check_session_assets.py "app/build/outputs/apk/${build_variant}/app-${build_variant}.apk"
|
||||
cp -p "${bundle_backup}" "${bundle_asset}"
|
||||
bundle_replaced=0
|
||||
python3 tools/release/runtime_inputs.py apk "app/build/outputs/apk/${build_variant}/app-${build_variant}.apk"
|
||||
|
||||
apk="${repo_root}/app/build/outputs/apk/${build_variant}/app-${build_variant}.apk"
|
||||
audio_check="${staging_dir}/audio-check"
|
||||
@@ -362,28 +332,12 @@ for audio_file in \
|
||||
fi
|
||||
done
|
||||
|
||||
docker run --rm --platform linux/amd64 -e build_variant="${build_variant}" -v "${repo_root}:/src:ro" -w /src "${image_name}" \
|
||||
bash -lc '
|
||||
set -euo pipefail
|
||||
apk=app/build/outputs/apk/${build_variant}/app-${build_variant}.apk
|
||||
work=$(mktemp -d)
|
||||
unzip -q "$apk" "lib/arm64-v8a/*" -d "$work"
|
||||
cd "$work/lib/arm64-v8a"
|
||||
system="libc.so libm.so libdl.so liblog.so libandroid.so libz.so libvulkan.so libstdc++.so
|
||||
libGLESv2.so libEGL.so libnativewindow.so libjnigraphics.so libaaudio.so
|
||||
libOpenSLES.so libmediandk.so libcamera2ndk.so libsync.so libneuralnetworks.so"
|
||||
fail=0
|
||||
for so in *.so; do
|
||||
for need in $(readelf -d "$so" | sed -n "s/.*NEEDED.*\\[\\(.*\\)\\]/\\1/p"); do
|
||||
[ -f "$need" ] && continue
|
||||
case " $(echo $system) " in *" $need "*) continue ;; esac
|
||||
echo "missing: $so -> $need"
|
||||
fail=1
|
||||
done
|
||||
done
|
||||
[ "$fail" -eq 0 ]
|
||||
echo "every NEEDED resolves"
|
||||
'
|
||||
readelf_path=$(find "${NDK}/toolchains/llvm/prebuilt" -name llvm-readelf | head -1)
|
||||
[[ -x "${readelf_path}" ]] || { echo "NDK llvm-readelf is missing" >&2; exit 1; }
|
||||
stores_check=()
|
||||
[[ "${DROIDDECK_SKIP_RUST:-0}" != 1 ]] || stores_check+=(--without-stores)
|
||||
python3 tools/release/check_android_libraries.py "${apk}" --readelf "${readelf_path}" "${stores_check[@]}"
|
||||
git diff --exit-code -- app/src/main/rust/stores/Cargo.lock
|
||||
|
||||
build_tools=$(find "${sdk_dir}/build-tools" -mindepth 1 -maxdepth 1 -type d -print | sort -V | tail -1)
|
||||
if [[ ! -x "${build_tools}/zipalign" || ! -x "${build_tools}/apksigner" ]]; then
|
||||
@@ -435,6 +389,7 @@ if [[ -n "${signing_env}" ]]; then
|
||||
(
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
cd "$(dirname "${signing_env}")"
|
||||
. "${signing_env}"
|
||||
set +a
|
||||
BUILD_TOOLS="${build_tools}" "${repo_root}/tools/release/sign-apk.sh" "${apk}" standard "${apk}.release"
|
||||
|
||||
@@ -21,3 +21,15 @@ at every session): Plasma's own `startplasma-wayland`, with KWin nested in the a
|
||||
through `kwin_wayland_wrapper`. KWin composites in software (QPainter) - the Adreno node is not a
|
||||
DRM device - so games and emulators from the menu go through `droiddeck-gpu`, and Steam goes back
|
||||
to the app as a Steam session.
|
||||
|
||||
`build-kwin.sh` builds KWin 6.7.5's Wayland executable and library on a native ARM64 runner, using a disposable
|
||||
Arch Linux ARM chroot with every build package signature-checked. The KDE source tarball is pinned
|
||||
by SHA-256 (the same digest in Arch's KWin PKGBUILD); `patches/0001-respect-nested-desktop-scale.patch`
|
||||
lets Display Settings control the inner desktop scale independently of the outer window size.
|
||||
It keeps layer sizes, pointer/touch coordinates and the cursor in the same physical pixels.
|
||||
The behavior is enabled only with `DROIDDECK_NESTED_SCALE`, which the desktop script supplies.
|
||||
|
||||
The desktop workflow replaces the same-version `kwin_wayland` executable and `libkwin.so`; the rest
|
||||
comes from the signature-checked Arch packages. `desktop-kde.kwin.txt` records the source, patch,
|
||||
executable, library and build package hashes. Corresponding source is
|
||||
https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz plus the patch in this repository.
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Build the pinned KWin executable with the nested-scale patch on native aarch64 Linux.
|
||||
# Its dependencies come from signature-checked Arch Linux ARM packages in a disposable chroot.
|
||||
set -euo pipefail
|
||||
out=$(realpath -m "${1:?out dir}")
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
[ "$(uname -m)" = aarch64 ] || { echo 'KWin needs a native aarch64 runner' >&2; exit 1; }
|
||||
version=6.7.5
|
||||
source_sha=6baa910b732d93c48c90f9c1cc685cc93d0b8de0cdf138c24192c045bc3a48e2
|
||||
mirror=https://fl.us.mirror.archlinuxarm.org/aarch64
|
||||
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
|
||||
work=$(mktemp -d)
|
||||
trap 'sudo umount "$work/root/proc" 2>/dev/null || true; sudo rm -rf "$work"' EXIT
|
||||
mkdir -p "$work/db" "$work/root" "$work/pkgs" "$out"
|
||||
fetch() { curl -fsSL --proto '=https' --proto-redir '=https' --retry 6 --retry-all-errors -o "$1" "$2"; }
|
||||
for repo in core extra alarm; do
|
||||
fetch "$work/db/$repo.db" "$mirror/$repo/$repo.db"
|
||||
mkdir -p "$work/db/x_$repo"
|
||||
tar -xzf "$work/db/$repo.db" -C "$work/db/x_$repo"
|
||||
done
|
||||
touch "$work/runtime.txt"
|
||||
python3 "$here/closure.py" "$work/db" "$work/runtime.txt" "$here/kwin-build-seeds.txt" > "$work/packages.txt"
|
||||
# Refuse a repository whose KWin headers/libraries have moved beyond the pinned source.
|
||||
grep -Eq '^extra/kwin-6\.7\.5-[0-9]+-aarch64\.pkg\.tar\.' "$work/packages.txt"
|
||||
export work mirror builder here
|
||||
download() {
|
||||
local entry=$1 sum=$2 file=${1#*/}
|
||||
fetch "$work/pkgs/$file" "$mirror/$entry"
|
||||
fetch "$work/pkgs/$file.sig" "$mirror/$entry.sig"
|
||||
gpgv --status-fd 1 --keyring "$here/archlinuxarm-builder.gpg" "$work/pkgs/$file.sig" "$work/pkgs/$file" 2>/dev/null \
|
||||
| grep -Eq "^\[GNUPG:\] VALIDSIG .* $builder\$"
|
||||
echo "$sum $work/pkgs/$file" | sha256sum -c - >/dev/null
|
||||
}
|
||||
export -f fetch download
|
||||
xargs -P 8 -n 2 bash -c 'set -euo pipefail; download "$@"' _ < "$work/packages.txt"
|
||||
while read -r entry sum; do
|
||||
sudo tar -xf "$work/pkgs/${entry#*/}" -C "$work/root" --no-same-owner \
|
||||
--exclude=.PKGINFO --exclude=.MTREE --exclude=.INSTALL --exclude=.BUILDINFO --exclude=.CHANGELOG
|
||||
done < "$work/packages.txt"
|
||||
fetch "$work/kwin.tar.xz" "https://download.kde.org/stable/plasma/$version/kwin-$version.tar.xz"
|
||||
echo "$source_sha $work/kwin.tar.xz" | sha256sum -c -
|
||||
sudo mkdir -p "$work/root/build" "$work/root/proc" "$work/root/dev"
|
||||
sudo mknod -m 666 "$work/root/dev/null" c 1 3
|
||||
sudo mknod -m 666 "$work/root/dev/zero" c 1 5
|
||||
sudo mknod -m 666 "$work/root/dev/random" c 1 8
|
||||
sudo mknod -m 666 "$work/root/dev/urandom" c 1 9
|
||||
sudo mount -t proc proc "$work/root/proc"
|
||||
sudo tar -xf "$work/kwin.tar.xz" -C "$work/root/build"
|
||||
sudo patch -d "$work/root/build/kwin-$version" -p1 < "$here/patches/0001-respect-nested-desktop-scale.patch"
|
||||
sudo chroot "$work/root" /usr/bin/env PATH=/usr/bin:/bin HOME=/root LC_ALL=C.UTF-8 \
|
||||
/usr/bin/cmake -S "/build/kwin-$version" -B /build/out -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBEXECDIR=lib -DBUILD_TESTING=OFF
|
||||
sudo chroot "$work/root" /usr/bin/env PATH=/usr/bin:/bin HOME=/root LC_ALL=C.UTF-8 \
|
||||
/usr/bin/cmake --build /build/out --target kwin_wayland --parallel 4
|
||||
sudo cp "$work/root/build/out/bin/kwin_wayland" "$out/kwin_wayland"
|
||||
sudo cp "$work/root/build/out/bin/libkwin.so.$version" "$out/libkwin.so.$version"
|
||||
sudo chown "$(id -u):$(id -g)" "$out/kwin_wayland" "$out/libkwin.so.$version"
|
||||
strip --strip-unneeded "$out/kwin_wayland" "$out/libkwin.so.$version"
|
||||
# The backend lives in libkwin, not the small launcher. Catch accidentally shipping only the
|
||||
# executable, which boots successfully but still loads the distribution's unpatched backend.
|
||||
grep -aq DROIDDECK_NESTED_SCALE "$out/libkwin.so.$version"
|
||||
{
|
||||
echo "KWin $version source sha256 $source_sha"
|
||||
echo "Patch sha256 $(sha256sum "$here/patches/0001-respect-nested-desktop-scale.patch" | cut -d' ' -f1)"
|
||||
echo "Executable sha256 $(sha256sum "$out/kwin_wayland" | cut -d' ' -f1)"
|
||||
echo "Library sha256 $(sha256sum "$out/libkwin.so.$version" | cut -d' ' -f1)"
|
||||
echo 'Build packages (Arch Linux ARM signatures verified):'
|
||||
cat "$work/packages.txt"
|
||||
} > "$out/desktop-kde.kwin.txt"
|
||||
@@ -56,6 +56,12 @@ done < "$work/pkglist.txt"
|
||||
|
||||
cp -a "$here/overlay/." "$work/root/"
|
||||
|
||||
# Same-version KWin, built by build-kwin.sh with the nested desktop scale patch.
|
||||
if [ -n "${KDE_KWIN_OVERRIDE:-}" ]; then
|
||||
install -m 755 "$KDE_KWIN_OVERRIDE/kwin_wayland" "$work/root/usr/bin/kwin_wayland"
|
||||
install -m 755 "$KDE_KWIN_OVERRIDE/libkwin.so.6.7.5" "$work/root/usr/lib/libkwin.so.6.7.5"
|
||||
fi
|
||||
|
||||
# Weight that no desktop on a phone reads.
|
||||
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/man" "$work/root/usr/share/info" \
|
||||
"$work/root/usr/share/gtk-doc" "$work/root/usr/include" "$work/root/usr/lib/pkgconfig" \
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Native build tools and KWin's Arch makedepends; dependencies are resolved and signature-checked.
|
||||
kwin
|
||||
base-devel
|
||||
cmake
|
||||
ninja
|
||||
gcc
|
||||
make
|
||||
pkgconf
|
||||
extra-cmake-modules
|
||||
kdoctools
|
||||
krunner
|
||||
plasma-wayland-protocols
|
||||
python
|
||||
vulkan-headers
|
||||
wayland-protocols
|
||||
xorg-xwayland
|
||||
@@ -8,5 +8,10 @@ Third-party files in DroidDeck's KDE desktop package (tools/desktop-kde/overlay)
|
||||
- steam.svg: Papirus icon theme (https://github.com/PapirusDevelopmentTeam/papirus-icon-theme),
|
||||
GPL-3.0.
|
||||
|
||||
- kwin_wayland: KWin 6.7.5, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
|
||||
Corresponding source: https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz and
|
||||
https://github.com/Droid-Deck/DroidDeck/tree/fix/kde-desktop-followups/tools/desktop-kde/patches
|
||||
(the source and patch hashes are recorded in desktop-kde.kwin.txt beside the package).
|
||||
|
||||
Everything else in the package is Arch Linux ARM's own packages, under their own licenses
|
||||
(/usr/share/licenses).
|
||||
@@ -0,0 +1,158 @@
|
||||
--- a/src/backends/wayland/wayland_output.cpp
|
||||
+++ b/src/backends/wayland/wayland_output.cpp
|
||||
@@ -294,6 +294,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
+qreal WaylandOutput::presentationScale() const
|
||||
+{
|
||||
+ return qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE") ? m_pendingScale : scale();
|
||||
+}
|
||||
+
|
||||
bool WaylandOutput::present(const QList<OutputLayer *> &layersToUpdate, const std::shared_ptr<OutputFrame> &frame)
|
||||
{
|
||||
auto cursorLayers = layersToUpdate | std::views::filter([](OutputLayer *layer) {
|
||||
@@ -312,7 +317,7 @@
|
||||
m_surface->attachBuffer(buffer);
|
||||
m_mapped = true;
|
||||
}
|
||||
- m_viewport->setDestination(QSize(std::round(modeSize().width() / scale()), std::round(modeSize().height() / scale())));
|
||||
+ m_viewport->setDestination(QSize(std::round(modeSize().width() / presentationScale()), std::round(modeSize().height() / presentationScale())));
|
||||
m_surface->setScale(1);
|
||||
// commit the subsurfaces before the main surface
|
||||
for (OutputLayer *layer : layersToUpdate) {
|
||||
@@ -375,9 +380,11 @@
|
||||
next.enabled = props->enabled.value_or(m_state.enabled);
|
||||
next.transform = props->transform.value_or(m_state.transform);
|
||||
next.position = props->pos.value_or(m_state.position);
|
||||
- // intentionally ignored, as it would get overwritten
|
||||
- // with the fractional scale protocol anyways
|
||||
- // next.scale = props->scale.value_or(m_state.scale);
|
||||
+ // DroidDeck owns the outer window size; Display Settings owns the inner UI scale.
|
||||
+ if (qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
|
||||
+ next.scale = props->scale.value_or(m_state.scale);
|
||||
+ next.scaleSetting = props->scaleSetting.value_or(m_state.scaleSetting);
|
||||
+ }
|
||||
next.desiredMode = props->desiredMode.value_or(m_state.desiredMode);
|
||||
next.uuid = props->uuid.value_or(m_state.uuid);
|
||||
next.replicationSource = props->replicationSource.value_or(m_state.replicationSource);
|
||||
@@ -466,7 +473,9 @@
|
||||
State next = m_state;
|
||||
next.modes = {mode};
|
||||
next.currentMode = mode;
|
||||
- next.scale = m_pendingScale;
|
||||
+ if (!qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
|
||||
+ next.scale = m_pendingScale;
|
||||
+ }
|
||||
setState(next);
|
||||
|
||||
Q_EMIT m_backend->outputsQueried();
|
||||
--- a/src/backends/wayland/wayland_output.h
|
||||
+++ b/src/backends/wayland/wayland_output.h
|
||||
@@ -93,6 +93,8 @@
|
||||
|
||||
void init(const QSize &pixelSize, qreal scale, bool fullscreen);
|
||||
|
||||
+ // The outer window scale, independent of the desktop UI scale in DroidDeck.
|
||||
+ qreal presentationScale() const;
|
||||
bool isReady() const;
|
||||
KWayland::Client::Surface *surface() const;
|
||||
WaylandCursor *cursor() const;
|
||||
--- a/src/backends/wayland/wayland_backend.cpp
|
||||
+++ b/src/backends/wayland/wayland_backend.cpp
|
||||
@@ -107,8 +107,9 @@
|
||||
WaylandOutput *output = m_seat->backend()->findOutput(m_pointer->enteredSurface());
|
||||
Q_ASSERT(output);
|
||||
const auto subsurface = m_seat->backend()->findSubSurface(m_pointer->enteredSurface());
|
||||
- const QPointF absolutePos = output->position() + relativeToSurface
|
||||
- + (subsurface ? subsurface->position() : QPoint());
|
||||
+ const QPointF absolutePos = output->position()
|
||||
+ + (relativeToSurface + (subsurface ? subsurface->position() : QPoint()))
|
||||
+ * output->presentationScale() / output->scale();
|
||||
Q_EMIT pointerMotionAbsolute(absolutePos, std::chrono::milliseconds(time), this);
|
||||
});
|
||||
connect(pointer, &Pointer::buttonStateChanged, this, [this](quint32 serial, quint32 time, quint32 button, Pointer::ButtonState nativeState) {
|
||||
@@ -182,7 +183,11 @@
|
||||
, m_relativePointer(relativePointer)
|
||||
{
|
||||
connect(relativePointer, &RelativePointer::relativeMotion, this, [this](const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestamp) {
|
||||
- Q_EMIT pointerMotion(sizeToPoint(delta), sizeToPoint(deltaNonAccelerated), std::chrono::microseconds(timestamp), this);
|
||||
+ const auto pointer = m_seat->pointerDevice();
|
||||
+ const auto output = pointer && pointer->m_pointer
|
||||
+ ? m_seat->backend()->findOutput(pointer->m_pointer->enteredSurface()) : nullptr;
|
||||
+ const qreal factor = output ? output->presentationScale() / output->scale() : 1.0;
|
||||
+ Q_EMIT pointerMotion(sizeToPoint(delta) * factor, sizeToPoint(deltaNonAccelerated) * factor, std::chrono::microseconds(timestamp), this);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,13 +204,19 @@
|
||||
connect(touch, &Touch::sequenceStarted, this, [this](TouchPoint *tp) {
|
||||
auto o = m_seat->backend()->findOutput(tp->surface());
|
||||
Q_ASSERT(o);
|
||||
- const QPointF position = o->position() + tp->position();
|
||||
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
|
||||
+ const QPointF position = o->position()
|
||||
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
|
||||
+ * o->presentationScale() / o->scale();
|
||||
Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
|
||||
});
|
||||
connect(touch, &Touch::pointAdded, this, [this](TouchPoint *tp) {
|
||||
auto o = m_seat->backend()->findOutput(tp->surface());
|
||||
Q_ASSERT(o);
|
||||
- const QPointF position = o->position() + tp->position();
|
||||
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
|
||||
+ const QPointF position = o->position()
|
||||
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
|
||||
+ * o->presentationScale() / o->scale();
|
||||
Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
|
||||
});
|
||||
connect(touch, &Touch::pointRemoved, this, [this](TouchPoint *tp) {
|
||||
@@ -214,7 +225,10 @@
|
||||
connect(touch, &Touch::pointMoved, this, [this](TouchPoint *tp) {
|
||||
auto o = m_seat->backend()->findOutput(tp->surface());
|
||||
Q_ASSERT(o);
|
||||
- const QPointF position = o->position() + tp->position();
|
||||
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
|
||||
+ const QPointF position = o->position()
|
||||
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
|
||||
+ * o->presentationScale() / o->scale();
|
||||
Q_EMIT touchMotion(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
|
||||
});
|
||||
}
|
||||
--- a/src/backends/wayland/wayland_layer.cpp
|
||||
+++ b/src/backends/wayland/wayland_layer.cpp
|
||||
@@ -95,7 +95,7 @@
|
||||
// this is a bit annoying, we need a new Wayland protocol
|
||||
// to do this properly with fractional scaling. Until we
|
||||
// have that, it may cause blurriness in some cases!
|
||||
- const Rect logicalTarget = targetRect().scaled(1.0 / m_output->scale()).rounded();
|
||||
+ const Rect logicalTarget = targetRect().scaled(1.0 / output->presentationScale()).rounded();
|
||||
if (m_viewport) {
|
||||
m_viewport->setSource(sourceRect());
|
||||
m_viewport->setDestination(logicalTarget.size());
|
||||
--- a/src/backends/wayland/wayland_qpainter_backend.cpp
|
||||
+++ b/src/backends/wayland/wayland_qpainter_backend.cpp
|
||||
@@ -124,7 +124,9 @@
|
||||
wl_buffer *buffer = static_cast<WaylandOutput *>(m_output.get())->backend()->importBuffer(m_back->buffer());
|
||||
Q_ASSERT(buffer);
|
||||
|
||||
- static_cast<WaylandOutput *>(m_output.get())->cursor()->update(buffer, m_back->buffer()->size() / m_output->scale(), hotspot().toPoint());
|
||||
+ auto output = static_cast<WaylandOutput *>(m_output.get());
|
||||
+ output->cursor()->update(buffer, m_back->buffer()->size() / output->presentationScale(),
|
||||
+ (hotspot() * output->scale() / output->presentationScale()).toPoint());
|
||||
m_swapchain->release(m_back);
|
||||
return true;
|
||||
}
|
||||
--- a/src/backends/wayland/wayland_egl_backend.cpp
|
||||
+++ b/src/backends/wayland/wayland_egl_backend.cpp
|
||||
@@ -202,7 +202,9 @@
|
||||
wl_buffer *buffer = m_backend->backend()->importBuffer(m_buffer->buffer());
|
||||
Q_ASSERT(buffer);
|
||||
|
||||
- static_cast<WaylandOutput *>(m_output.get())->cursor()->update(buffer, m_buffer->buffer()->size() / m_output->scale(), (hotspot() / m_output->scale()).toPoint());
|
||||
+ auto output = static_cast<WaylandOutput *>(m_output.get());
|
||||
+ output->cursor()->update(buffer, m_buffer->buffer()->size() / output->presentationScale(),
|
||||
+ (hotspot() / output->presentationScale()).toPoint());
|
||||
|
||||
EGLNativeFence releaseFence{m_backend->eglDisplayObject()};
|
||||
m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor());
|
||||
@@ -1,4 +1,4 @@
|
||||
DESKTOP_KDE_REPO=Droid-Deck/DroidDeck-Components
|
||||
DESKTOP_KDE_TAG=desktop-kde-r1
|
||||
DESKTOP_KDE_SHA256=55747e75d0ec055ab7ea1e92a757f3be227cc3205bb9101f5b53cadef6318579
|
||||
DESKTOP_KDE_SIZE=846370256
|
||||
DESKTOP_KDE_TAG=desktop-kde-r2
|
||||
DESKTOP_KDE_SHA256=9ba832677b498654136c69d8c8330434d17e4d53cd099acac9bde3ba429b35bf
|
||||
DESKTOP_KDE_SIZE=846933224
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Check the engine before modifying build assets; never rebuild for a daemon error."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run(*args):
|
||||
try:
|
||||
return subprocess.run(['docker', *args], capture_output=True, text=True, timeout=15)
|
||||
except subprocess.TimeoutExpired:
|
||||
sys.exit('Docker is not responding. Restart Docker Desktop, then rerun tools/build_local.sh.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
engine = run('info', '--format', '{{.ServerVersion}}')
|
||||
if engine.returncode:
|
||||
sys.exit('Docker is unavailable: ' + engine.stderr.strip())
|
||||
image = run('image', 'inspect', sys.argv[1])
|
||||
if image.returncode:
|
||||
if 'No such image' not in image.stderr:
|
||||
sys.exit('Cannot inspect the build image: ' + image.stderr.strip())
|
||||
repo = Path(__file__).resolve().parents[1]
|
||||
subprocess.run(['docker', 'build', '--platform', 'linux/amd64', '-t', sys.argv[1],
|
||||
'-f', str(repo / 'tools/local-cross.Dockerfile'), str(repo)], check=True)
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shared native ABI checks for CI and local builds.
|
||||
set -euo pipefail
|
||||
D=${1:?asset directory}
|
||||
NEED=$("${READELF:-readelf}" -d "$D/libfakeinput.so" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p')
|
||||
for bad in libstdc++.so.6 libgcc_s.so.1; do
|
||||
if printf '%s\n' "$NEED" | grep -qx "$bad"; then
|
||||
echo "::error::libfakeinput.so links $bad - the C++ runtime must stay static"; exit 1
|
||||
fi
|
||||
done
|
||||
syms() { "${READELF:-readelf}" -Ws "$1" | awk '$4 == "FUNC" && $5 == "GLOBAL" {sub(/@.*/, "", $8); print $8}'; }
|
||||
FAKE=$(syms "$D/libfakeinput.so")
|
||||
for sym in open openat ioctl read close poll ppoll select stat fstat access scandir; do
|
||||
grep -qx "$sym" <<<"$FAKE" || { echo "::error::libfakeinput.so does not export $sym"; exit 1; }
|
||||
done
|
||||
# The static C++ runtime stays private: every session process preloads this library,
|
||||
# and an exported personality routine takes over other programs' unwinding (shadPS4
|
||||
# aborted in pthread_exit).
|
||||
if grep -qxE '__gxx_personality_v0|__cxa_throw|_Unwind_Resume' <<<"$FAKE"; then
|
||||
echo "::error::libfakeinput.so exports the C++ runtime"; exit 1
|
||||
fi
|
||||
SESSION=$(syms "$D/libblsession.so")
|
||||
for sym in socket bind getsockname setsockopt statfs statvfs syscall shm_open shm_unlink mmap mmap64 munmap drmPrimeFDToHandle drmCloseBufferHandle; do
|
||||
grep -qx "$sym" <<<"$SESSION" || { echo "::error::libblsession.so does not export $sym"; exit 1; }
|
||||
done
|
||||
# Zink's GEM_CLOSE is caught at ioctl(); an exported drmIoctl made NMS replay old frames.
|
||||
if grep -qx drmIoctl <<<"$SESSION"; then
|
||||
echo "::error::libblsession.so exports drmIoctl"; exit 1
|
||||
fi
|
||||
SSBS=$(syms "$D/libssbs.so")
|
||||
for sym in sigaction signal bsd_signal sysv_signal; do
|
||||
grep -qx "$sym" <<<"$SSBS" || { echo "::error::libssbs.so does not export $sym"; exit 1; }
|
||||
done
|
||||
test -f "$D/usr/local/bin/droiddeck-session"
|
||||
test -f "$D/usr/local/bin/droiddeck-proton-extra"
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Android clipboard
|
||||
Exec=/usr/local/bin/droiddeck-desktop-clipboard
|
||||
OnlyShowIn=KDE;
|
||||
NoDisplay=true
|
||||
@@ -38,6 +38,7 @@ export MOZ_SHM_NO_SEALS=1
|
||||
# to the app as a Steam session - SteamOS's "Return to Gaming Mode". The session's own GL choice
|
||||
# (zink on Turnip, for the Steam client) is put back by droiddeck-gpu.
|
||||
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
||||
export DROIDDECK_NESTED_SCALE=1
|
||||
export DROIDDECK_GLTHREAD=${mesa_glthread:-}
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2 mesa_glthread
|
||||
# The desktop's own log, beside the session's, so KWin and the programs on it can be read apart
|
||||
@@ -72,6 +73,8 @@ python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
|
||||
# Games and emulators from the menu run through droiddeck-gpu; BL_DESKTOP_GPU=on/off overrides,
|
||||
# and each entry keeps "Run in a desktop window" either way.
|
||||
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
|
||||
# The windowed action still opens melonDS at the size/placement the LXQt desktop used.
|
||||
/usr/local/bin/droiddeck-desktop-window-rules 2>&1 | sed 's/^/[rules] /'
|
||||
# SteamOS's desktop icons: Return to Gaming Mode and Steam, put there once - what the user moves
|
||||
# or deletes stays that way.
|
||||
desktop_dir=$(xdg-user-dir DESKTOP 2>/dev/null); [ -n "$desktop_dir" ] && [ "$desktop_dir" != "$HOME" ] || desktop_dir=$HOME/Desktop
|
||||
|
||||
@@ -31,7 +31,7 @@ export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=tr
|
||||
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
|
||||
# AppImages cannot mount under proot; the menu entries already say so, a hand-typed one may not.
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
gamescope "${args[@]}" -- "$@"
|
||||
gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
||||
rc=$?
|
||||
echo "== droiddeck-gpu $(date -u +%H:%M:%S): exited $rc"
|
||||
exit $rc
|
||||
@@ -1,13 +1,114 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Expose the selected secondary library in PCManFM's Places sidebar."""
|
||||
"""Expose available Steam libraries in Dolphin, retaining the old PCManFM bookmark."""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import runpy
|
||||
import sys
|
||||
import tempfile
|
||||
from urllib.parse import unquote, urlsplit
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
LIBRARY = Path("/mnt/droiddeck-sd")
|
||||
URI = "file:///mnt/droiddeck-sd"
|
||||
KDE_OWNER = "http://www.kde.org"
|
||||
MARK = "DroidDeckSteamLibrary"
|
||||
ICON_NS = "http://www.freedesktop.org/standards/desktop-bookmarks"
|
||||
ET.register_namespace("bookmark", ICON_NS)
|
||||
|
||||
|
||||
def steam_libraries(home, data):
|
||||
steam = data / "Steam"
|
||||
libraries = {steam: "Internal Storage"}
|
||||
listing = os.environ.get("BL_STEAM_LIBRARIES")
|
||||
selected = None
|
||||
if listing:
|
||||
try:
|
||||
selected = {Path(e["path"]): str(e["label"]) for e in json.loads(Path(listing).read_text())}
|
||||
except (OSError, ValueError, KeyError, TypeError):
|
||||
pass # Fall back to the client's registered libraries if the app's list is unreadable.
|
||||
vdf = steam / "steamapps/libraryfolders.vdf"
|
||||
if vdf.is_file():
|
||||
parser = runpy.run_path(str(Path(__file__).with_name("droiddeck-steam-ui-scale")))
|
||||
folders = parser["parse"](vdf.read_text()).get("libraryfolders")
|
||||
if not isinstance(folders, parser["Block"]):
|
||||
raise ValueError("missing libraryfolders")
|
||||
for _, entry in folders.pairs:
|
||||
if not isinstance(entry, parser["Block"]):
|
||||
continue
|
||||
path = entry.get("path")
|
||||
if not isinstance(path, str):
|
||||
continue
|
||||
path = Path(re.sub(r'\\(["\\])', r'\1', path))
|
||||
managed = path == LIBRARY or path.is_relative_to(home / "Games")
|
||||
if selected is not None and managed and path not in selected:
|
||||
continue
|
||||
if path == LIBRARY and selected is None and not os.environ.get("BL_LIBRARY_LABEL"):
|
||||
continue
|
||||
label = entry.get("label")
|
||||
label = re.sub(r'\\(["\\])', r'\1', label) if isinstance(label, str) else ""
|
||||
libraries[path] = label or path.name
|
||||
if selected is not None:
|
||||
libraries.update(selected)
|
||||
elif os.environ.get("BL_LIBRARY_LABEL"):
|
||||
libraries[LIBRARY] = os.environ["BL_LIBRARY_LABEL"]
|
||||
libraries[steam] = "Internal Storage"
|
||||
return {path.as_uri(): "Steam (" + (" ".join(label.split()) or path.name) + ")"
|
||||
for path, label in libraries.items() if path.is_absolute() and (path / "steamapps").is_dir()}
|
||||
|
||||
|
||||
def place_uri(uri):
|
||||
url = urlsplit(uri or "")
|
||||
if url.scheme == "file" and url.netloc in ("", "localhost") and url.path.startswith("/"):
|
||||
return Path(unquote(url.path)).as_uri()
|
||||
return uri
|
||||
|
||||
|
||||
def update_places(path, libraries):
|
||||
if path.is_file():
|
||||
parser = ET.XMLParser(target=ET.TreeBuilder(insert_comments=True, insert_pis=True))
|
||||
root = ET.fromstring(path.read_bytes(), parser=parser)
|
||||
if root.tag != "xbel":
|
||||
raise ValueError("invalid Dolphin places file")
|
||||
else:
|
||||
if not libraries:
|
||||
return
|
||||
# Leave KDE's file version unset so it still adds its normal Home/Downloads/etc. places.
|
||||
root = ET.Element("xbel", {"version": "1.0"})
|
||||
before = ET.tostring(root)
|
||||
seen = set()
|
||||
personal = {place_uri(b.get("href")) for b in root.findall("bookmark")
|
||||
if b.find("info/metadata[@owner='" + KDE_OWNER + "']/" + MARK) is None}
|
||||
for bookmark in root.findall("bookmark"):
|
||||
metadata = bookmark.find("info/metadata[@owner='" + KDE_OWNER + "']")
|
||||
if metadata is None or metadata.find(MARK) is None:
|
||||
continue
|
||||
uri = place_uri(bookmark.get("href"))
|
||||
if uri not in libraries or uri in seen or uri in personal:
|
||||
root.remove(bookmark)
|
||||
continue
|
||||
seen.add(uri)
|
||||
title = bookmark.find("title")
|
||||
if title is None:
|
||||
title = ET.SubElement(bookmark, "title")
|
||||
title.text = libraries[uri]
|
||||
for uri, label in libraries.items():
|
||||
if uri in seen or uri in personal:
|
||||
continue
|
||||
bookmark = ET.SubElement(root, "bookmark", {"href": uri})
|
||||
ET.SubElement(bookmark, "title").text = label
|
||||
info = ET.SubElement(bookmark, "info")
|
||||
icon = ET.SubElement(info, "metadata", {"owner": "http://freedesktop.org"})
|
||||
ET.SubElement(icon, "{" + ICON_NS + "}icon", {"name": "steam"})
|
||||
metadata = ET.SubElement(info, "metadata", {"owner": KDE_OWNER})
|
||||
ET.SubElement(metadata, "ID").text = "droiddeck-steam-" + hashlib.sha256(uri.encode()).hexdigest()[:16]
|
||||
ET.SubElement(metadata, MARK).text = "true"
|
||||
ET.SubElement(metadata, "isSystemItem").text = "false"
|
||||
if ET.tostring(root) != before:
|
||||
atomic_write(path, ET.tostring(root, encoding="unicode", xml_declaration=True))
|
||||
|
||||
|
||||
def bookmarks_file(home, config):
|
||||
@@ -31,6 +132,10 @@ def update_bookmark(path, label):
|
||||
content += URI + " " + label + "\n"
|
||||
if content == original:
|
||||
return
|
||||
atomic_write(path, content)
|
||||
|
||||
|
||||
def atomic_write(path, content):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
temporary = None
|
||||
try:
|
||||
@@ -51,10 +156,12 @@ def main():
|
||||
# An unbound mount-point directory may remain from a previous session.
|
||||
available = bool(label) and (LIBRARY / "steamapps").is_dir()
|
||||
update_bookmark(bookmarks_file(home, config), label if available else None)
|
||||
data = Path(os.environ.get("XDG_DATA_HOME") or home / ".local/share")
|
||||
update_places(data / "user-places.xbel", steam_libraries(home, data))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except OSError as error:
|
||||
except (OSError, ValueError, ET.ParseError) as error:
|
||||
print("== desktop library bookmark: " + str(error), file=sys.stderr)
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Plasma starts this after its nested Xwayland display is available. The session launcher still
|
||||
# sees the outer compositor before startplasma, so starting its X11 helper there cannot work.
|
||||
[ -n "${BL_ANDROID_CLIPBOARD:-}" ] && [ -n "${DISPLAY:-}" ] || exit 0
|
||||
# The native helper dies with its parent. Keep this shell until it exits: Plasma's autostart
|
||||
# launcher may itself exit immediately after starting us.
|
||||
/usr/local/bin/droiddeck-clipboard "$BL_ANDROID_CLIPBOARD" &
|
||||
child=$!
|
||||
trap 'kill "$child" 2>/dev/null' EXIT
|
||||
trap 'exit 0' TERM INT
|
||||
wait "$child"
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Port the old desktop's melonDS window rule once; later window rules belong to the user.
|
||||
set -euo pipefail
|
||||
config=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||
marker=$config/droiddeck-window-rules-v1
|
||||
[ ! -e "$marker" ] || exit 0
|
||||
rules=$(kreadconfig6 --file kwinrulesrc --group General --key rules)
|
||||
IFS=, read -ra groups <<< "$rules"
|
||||
for group in "${groups[@]}"; do
|
||||
title=$(kreadconfig6 --file kwinrulesrc --group "$group" --key title)
|
||||
wmclass=$(kreadconfig6 --file kwinrulesrc --group "$group" --key wmclass)
|
||||
case ${title,,}${wmclass,,} in
|
||||
*melonds*) mkdir -p "$config"; touch "$marker"; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
write() { kwriteconfig6 --file kwinrulesrc --group droiddeck-melonds --key "$1" "$2"; }
|
||||
write Description 'melonDS desktop window'
|
||||
write title '^melonDS.*'
|
||||
write titlematch 3
|
||||
write types 1
|
||||
write size 800,600
|
||||
write sizerule 3
|
||||
write placement Centered
|
||||
write placementrule 2
|
||||
write ignoregeometry true
|
||||
write ignoregeometryrule 3
|
||||
kwriteconfig6 --file kwinrulesrc --group General --key rules "${rules:+$rules,}droiddeck-melonds"
|
||||
kwriteconfig6 --file kwinrulesrc --group General --key count "$(( ${#groups[@]} + 1 ))"
|
||||
mkdir -p "$config"
|
||||
touch "$marker"
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/python3
|
||||
"""Let GTK draw close buttons inside gamescope, which supplies no window decorations."""
|
||||
import ctypes as c
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def advertise_compositing():
|
||||
# This is gamescope's private X server: it composites alpha buffers already, but GTK also
|
||||
# requires the compositing-manager selection and frame-extents hint before enabling CSD.
|
||||
x = c.CDLL('libX11.so.6')
|
||||
display_type, window_type = c.c_void_p, c.c_ulong
|
||||
x.XOpenDisplay.argtypes = [c.c_char_p]
|
||||
x.XOpenDisplay.restype = display_type
|
||||
display = x.XOpenDisplay(None)
|
||||
if not display:
|
||||
raise RuntimeError('no X display')
|
||||
x.XDefaultRootWindow.argtypes = [display_type]
|
||||
x.XDefaultRootWindow.restype = window_type
|
||||
x.XDefaultScreen.argtypes = [display_type]
|
||||
x.XDefaultScreen.restype = c.c_int
|
||||
root = x.XDefaultRootWindow(display)
|
||||
x.XInternAtom.argtypes = [display_type, c.c_char_p, c.c_int]
|
||||
x.XInternAtom.restype = window_type
|
||||
atom = lambda name: x.XInternAtom(display, name.encode(), False)
|
||||
manager = atom('_NET_WM_CM_S%d' % x.XDefaultScreen(display))
|
||||
x.XGetSelectionOwner.argtypes = [display_type, window_type]
|
||||
x.XGetSelectionOwner.restype = window_type
|
||||
if not x.XGetSelectionOwner(display, manager):
|
||||
x.XCreateSimpleWindow.argtypes = [display_type, window_type, c.c_int, c.c_int,
|
||||
c.c_uint, c.c_uint, c.c_uint, window_type, window_type]
|
||||
x.XCreateSimpleWindow.restype = window_type
|
||||
owner = x.XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0)
|
||||
x.XSetSelectionOwner.argtypes = [display_type, window_type, window_type, window_type]
|
||||
x.XSetSelectionOwner(display, manager, owner, 0)
|
||||
x.XChangeProperty.argtypes = [display_type, window_type, window_type, window_type,
|
||||
c.c_int, c.c_int, c.c_void_p, c.c_int]
|
||||
extents = window_type(atom('_GTK_FRAME_EXTENTS'))
|
||||
x.XChangeProperty(display, root, atom('_NET_SUPPORTED'), atom('ATOM'), 32, 2, c.byref(extents), 1)
|
||||
x.XSync.argtypes = [display_type, c.c_int]
|
||||
x.XSync(display, False)
|
||||
# Keep the selection's connection alive until the program exits.
|
||||
return x, display
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
raise SystemExit('usage: droiddeck-gpu-window <program> [args...]')
|
||||
os.environ.setdefault('GTK_CSD', '1')
|
||||
try:
|
||||
connection = advertise_compositing()
|
||||
except (OSError, RuntimeError):
|
||||
os.execvp(sys.argv[1], sys.argv[1:])
|
||||
child = subprocess.Popen(sys.argv[1:])
|
||||
for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP):
|
||||
signal.signal(sig, lambda number, frame: child.send_signal(number))
|
||||
status = child.wait()
|
||||
raise SystemExit(status if status >= 0 else 128 - status)
|
||||
@@ -214,7 +214,9 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
||||
args+=(-r "$BL_REFRESH")
|
||||
fi
|
||||
[ "$mode" = steam ] && args+=(-e)
|
||||
# Steam integration advertises a Deck session and makes the client select Big Picture even
|
||||
# without -gamepadui. The desktop UI uses ordinary gamescope window management instead.
|
||||
[ "$mode" = steam ] && [ "${BL_STEAM_UI:-}" != desktop ] && args+=(-e)
|
||||
# Two Xwayland servers, as SteamOS runs Steam: the client on the first, games on the second
|
||||
# (STEAM_GAME_DISPLAY_0). The client then sizes the games' server to each game's Game Resolution
|
||||
# (GAMESCOPE_XWAYLAND_MODE_CONTROL; native unless one is set), and gamescope scales it to the
|
||||
@@ -886,10 +888,19 @@ BUSCONF
|
||||
droiddeck-steam-language "$HOME" "$BL_STEAM_LANGUAGE" || true
|
||||
fi
|
||||
step "starting the Steam client${BL_STEAM_UI:+ ($BL_STEAM_UI UI)}"
|
||||
desktop_ui_pid=
|
||||
if [ "${BL_STEAM_UI:-}" = desktop ]; then
|
||||
/usr/local/bin/droiddeck-steam-desktop-ui &
|
||||
desktop_ui_pid=$!
|
||||
fi
|
||||
"$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 \
|
||||
-cef-use-gl=angle -cef-use-angle=vulkan "$@"
|
||||
rc=$?
|
||||
if [ -n "$desktop_ui_pid" ]; then
|
||||
kill "$desktop_ui_pid" 2>/dev/null || true
|
||||
wait "$desktop_ui_pid" 2>/dev/null || true
|
||||
fi
|
||||
echo "== steam exited rc=$rc"
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ] && [ -f "$BL_ADDED_GAMES" ]; then
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
"""Honor a desktop launch even when Steam remembers Big Picture from its last session."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
import time
|
||||
|
||||
|
||||
def select_desktop(evaluate, timeout=90):
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
result = evaluate("typeof SteamClient !== 'undefined' && "
|
||||
"typeof SteamClient.UI.ExitBigPictureMode === 'function' && "
|
||||
"(SteamClient.UI.ExitBigPictureMode(), true)")
|
||||
if result.get('value') is True:
|
||||
return True
|
||||
except Exception:
|
||||
# CEF and SharedJSContext are not ready during the client's initial startup/update.
|
||||
pass
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
base = os.environ.get('BL_LAUNCH_DIR')
|
||||
if not base:
|
||||
raise SystemExit('BL_LAUNCH_DIR is not set')
|
||||
agent = runpy.run_path('/usr/local/bin/droiddeck-agent')
|
||||
selected = select_desktop(lambda expression: agent['cdp_eval'](
|
||||
Path(base) / 'agent', expression, timeout=2))
|
||||
print('== steam: desktop UI selected' if selected else
|
||||
'== steam: desktop UI was not ready within 90 seconds', flush=True)
|
||||
@@ -6,8 +6,12 @@ RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
binutils \
|
||||
binutils-aarch64-linux-gnu \
|
||||
gcc \
|
||||
g++ \
|
||||
gcc-aarch64-linux-gnu \
|
||||
g++-aarch64-linux-gnu \
|
||||
python3 \
|
||||
zstd \
|
||||
unzip \
|
||||
&& mkdir -p /src
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ PATH="$WORK/bin:$PATH" make -C "$WORK/proot/src" -j"$(getconf _NPROCESSORS_ONLN)
|
||||
install -m755 "$WORK/proot/src/proot" "$OUTDIR/libproot.so"
|
||||
install -m755 "$WORK/proot/src/loader/loader" "$OUTDIR/libproot-loader.so"
|
||||
"$TOOLCHAIN/llvm-strip" --strip-unneeded "$OUTDIR/libproot.so"
|
||||
"$TOOLCHAIN/llvm-strip" --strip-unneeded "$OUTDIR/libproot-loader.so"
|
||||
grep -q '^#define HAVE_SECCOMP_FILTER' "$WORK/proot/src/build.h" || { echo "ERROR: proot was built without seccomp acceleration"; exit 1; }
|
||||
grep -q '^#define HAVE_PROCESS_VM' "$WORK/proot/src/build.h" || { echo "ERROR: proot was built without process_vm"; exit 1; }
|
||||
NEEDED=$("$TOOLCHAIN/llvm-readelf" -d "$OUTDIR/libproot.so" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p' | tr '\n' ' ')
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
"""Validate the JNI entry points and Android ELF dependency closure in the actual APK."""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
SYSTEM = set('libc.so libm.so libdl.so liblog.so libandroid.so libz.so libvulkan.so libstdc++.so '
|
||||
'libGLESv2.so libEGL.so libnativewindow.so libjnigraphics.so libaaudio.so '
|
||||
'libOpenSLES.so libmediandk.so libcamera2ndk.so libsync.so libneuralnetworks.so'.split())
|
||||
EXPORTS = ['Java_com_droiddeck_launcher_stores_StoresNative_nativeVersion',
|
||||
'Java_com_droiddeck_launcher_stores_gog_GogNative_nativeStart',
|
||||
'Java_com_droiddeck_launcher_stores_epic_EpicNative_nativeStart',
|
||||
'Java_com_droiddeck_launcher_stores_epic_EpicNative_nativeAssemble',
|
||||
'Java_com_droiddeck_launcher_stores_amazon_AmazonNative_nativeStart']
|
||||
|
||||
|
||||
def check(apk, readelf, stores=True):
|
||||
errors = []
|
||||
with tempfile.TemporaryDirectory() as temp, ZipFile(apk) as package:
|
||||
libraries = {}
|
||||
for name in package.namelist():
|
||||
if name.startswith('lib/arm64-v8a/') and name.endswith('.so'):
|
||||
path = Path(temp) / Path(name).name
|
||||
path.write_bytes(package.read(name))
|
||||
libraries[path.name] = path
|
||||
for name, path in libraries.items():
|
||||
dynamic = subprocess.check_output([readelf, '-d', str(path)], text=True)
|
||||
for dependency in re.findall(r'NEEDED.*\[(.*?)\]', dynamic):
|
||||
if dependency not in libraries and dependency not in SYSTEM:
|
||||
errors.append(name + ' needs missing ' + dependency)
|
||||
library = libraries.get('libdroiddeckstores.so')
|
||||
if stores:
|
||||
if library is None:
|
||||
errors.append('APK missing libdroiddeckstores.so')
|
||||
else:
|
||||
symbols = subprocess.check_output([readelf, '--dyn-syms', '--wide', str(library)], text=True)
|
||||
exports = {line.split()[-1] for line in symbols.splitlines()
|
||||
if ' GLOBAL ' in line and ' UND ' not in line and line.split()}
|
||||
errors += ['Store library missing ' + symbol for symbol in EXPORTS if symbol not in exports]
|
||||
elif library is not None:
|
||||
errors.append('Rust was skipped but the APK contains a cached store library')
|
||||
return errors
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('apk')
|
||||
parser.add_argument('--readelf', default='readelf')
|
||||
parser.add_argument('--without-stores', action='store_true')
|
||||
args = parser.parse_args()
|
||||
errors = check(args.apk, args.readelf, not args.without_stores)
|
||||
if errors:
|
||||
parser.exit(1, '\n'.join(errors) + '\n')
|
||||
print('APK native exports and dependencies verified')
|
||||
@@ -7,14 +7,25 @@ from zipfile import ZipFile
|
||||
OVERLAY = Path(__file__).resolve().parents[1] / 'linuxfs/overlay'
|
||||
|
||||
|
||||
def check(apk, overlay=OVERLAY):
|
||||
def source_assets(overlay=OVERLAY):
|
||||
sources = list((overlay / 'usr/local/bin').glob('droiddeck-*'))
|
||||
sources += [path for path in [overlay / 'usr/local/bin/steam-compatibility'] if path.is_file()]
|
||||
sources += [path for path in (overlay / 'usr/bin').rglob('*') if path.is_file()]
|
||||
result = {source: 'assets/linuxfs/' + source.relative_to(overlay).as_posix() for source in sources}
|
||||
if overlay == OVERLAY:
|
||||
desktop = overlay.parent / 'desktop'
|
||||
for name in ['droiddeck-desktop', 'droiddeck-gpu', 'droiddeck-desktop-gpu', 'kwin_wayland_wrapper']:
|
||||
result[desktop / name] = 'assets/linuxfs/usr/local/bin/' + name
|
||||
result[desktop / 'firefox-droiddeck.js'] = 'assets/linuxfs/usr/lib/firefox/defaults/pref/droiddeck.js'
|
||||
result[desktop / 'droiddeck-clipboard.desktop'] = 'assets/linuxfs/etc/xdg/autostart/droiddeck-clipboard.desktop'
|
||||
result[overlay.parent.parent / 'mangoapp/mangoapp'] = 'assets/linuxfs/usr/local/bin/mangoapp'
|
||||
return result
|
||||
|
||||
|
||||
def check(apk, overlay=OVERLAY):
|
||||
errors = []
|
||||
with ZipFile(apk) as package:
|
||||
for source in sources:
|
||||
asset = 'assets/linuxfs/' + source.relative_to(overlay).as_posix()
|
||||
for source, asset in source_assets(overlay).items():
|
||||
try:
|
||||
content = package.read(asset)
|
||||
except KeyError:
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
"""Attest prepared runtime inputs and reject stale local or CI APK payloads."""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import shutil
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = Path('app/build/runtime-inputs.json')
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/build_local.sh',
|
||||
'tools/release/runtime_inputs.py']
|
||||
|
||||
|
||||
def digest(path):
|
||||
with path.open('rb') as source:
|
||||
result = hashlib.file_digest(source, 'sha256') if hasattr(hashlib, 'file_digest') else None
|
||||
if result is None:
|
||||
result = hashlib.sha256()
|
||||
for block in iter(lambda: source.read(1024 * 1024), b''):
|
||||
result.update(block)
|
||||
return result.hexdigest()
|
||||
|
||||
|
||||
def sources(root):
|
||||
files = []
|
||||
for name in SOURCE_PATHS:
|
||||
path = root / name
|
||||
files.extend(path.rglob('*') if path.is_dir() else [path])
|
||||
return {str(path.relative_to(root)): digest(path) for path in sorted(set(files))
|
||||
if path.is_file() and '__pycache__' not in path.parts and path.suffix != '.pyc'}
|
||||
|
||||
|
||||
def outputs(root):
|
||||
result = {}
|
||||
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync']:
|
||||
base = root / 'app/src/main/assets' / tree
|
||||
for path in base.rglob('*'):
|
||||
if path.is_file() and not any(part.startswith('.') for part in path.relative_to(base).parts):
|
||||
result['assets/' + tree + '/' + str(path.relative_to(base))] = str(path.relative_to(root))
|
||||
for library in ['libproot.so', 'libproot-loader.so', 'libdirectaudiorelay.so']:
|
||||
result['lib/arm64-v8a/' + library] = 'app/src/main/jniLibs/arm64-v8a/' + library
|
||||
result['assets/pulseaudio.tzst'] = 'app/build/prepared-assets/pulseaudio.tzst'
|
||||
return result
|
||||
|
||||
|
||||
def required():
|
||||
paths = ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libblsession.so',
|
||||
'libblfastpath.so', 'libssbs.so', 'usr/local/bin/droiddeck-clipboard',
|
||||
'usr/local/bin/gamescope', 'usr/local/lib/droiddeck/uruntime']]
|
||||
for arch in ['x86_64', 'i386']:
|
||||
paths += ['assets/linuxfs/' + arch + '/' + lib for lib in ['libfakeinput.so', 'libblsession.so']]
|
||||
paths += ['assets/linuxfs/x86_64/' + lib for lib in
|
||||
['libfaultreport.so', 'libthunkaudit.so', 'libvulkan-thunk.so']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-msitools/' + name for name in
|
||||
['msiinfo', 'cabextract', '7z', '7z.so', 'libmsi-1.0.so.0', 'libgsf-1.so.114', 'libgcab-1.0.so.0']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/mangoapp/' + name for name in
|
||||
['mangoapp', 'libfmt.so.10', 'libspdlog.so.1.13', 'libglfw.so.3', 'libtraceevent.so.1', 'libtracefs.so.1']]
|
||||
for driver in ['linux-wine11', 'linux-wine11-systhread']:
|
||||
paths += ['assets/directaudio/' + driver + '/' + name for name in
|
||||
['aarch64-unix/winedirectaudio.so', 'aarch64-windows/winedirectaudio.drv',
|
||||
'i386-windows/winedirectaudio.drv', 'version.txt']]
|
||||
paths += ['assets/droiddeck-esync/index.json', 'assets/droiddeck-esync/index.json.sig',
|
||||
'lib/arm64-v8a/libproot.so', 'lib/arm64-v8a/libproot-loader.so',
|
||||
'lib/arm64-v8a/libdirectaudiorelay.so', 'assets/pulseaudio.tzst']
|
||||
return paths
|
||||
|
||||
|
||||
def record(root=ROOT):
|
||||
# Refresh scripts even on a CI native-cache hit; these are source, not cached binaries.
|
||||
if root == ROOT:
|
||||
from check_session_assets import source_assets
|
||||
for source, asset in source_assets().items():
|
||||
target = root / 'app/src/main' / asset
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source, target)
|
||||
paths = outputs(root)
|
||||
missing = [name for name in required() if name not in paths or not (root / paths[name]).is_file()]
|
||||
if missing:
|
||||
raise ValueError('Missing runtime inputs:\n' + '\n'.join(missing))
|
||||
# Check inside the compressed payload, where a plain Gradle build used to ship no sinks.
|
||||
process = subprocess.Popen(['zstd', '-dc', str(root / paths['assets/pulseaudio.tzst'])], stdout=subprocess.PIPE)
|
||||
try:
|
||||
with tarfile.open(fileobj=process.stdout, mode='r|') as archive:
|
||||
names = {member.name.removeprefix('./') for member in archive}
|
||||
finally:
|
||||
process.stdout.close()
|
||||
if process.wait():
|
||||
raise ValueError('Invalid audio bundle')
|
||||
for name in ['pactl', 'modules/arm64/module-aaudio-sink.so', 'modules/arm64/module-directaudio-native-sink.so']:
|
||||
if name not in names:
|
||||
raise ValueError('Audio bundle missing ' + name)
|
||||
data = {'version': 1, 'sources': sources(root), 'outputs': {
|
||||
name: {'path': path, 'sha256': digest(root / path)} for name, path in sorted(paths.items())}}
|
||||
(root / MANIFEST).write_text(json.dumps(data, sort_keys=True, indent=2) + '\n')
|
||||
|
||||
|
||||
def verify(root=ROOT):
|
||||
try:
|
||||
data = json.loads((root / MANIFEST).read_text())
|
||||
except (OSError, ValueError):
|
||||
raise ValueError('Runtime inputs have not been prepared. Run tools/build_local.sh.')
|
||||
if data.get('version') != 1 or data.get('sources') != sources(root):
|
||||
raise ValueError('Runtime sources changed since preparation. Run tools/build_local.sh.')
|
||||
for name in required():
|
||||
if name not in data['outputs']:
|
||||
raise ValueError('Runtime manifest missing ' + name)
|
||||
for name, output in data['outputs'].items():
|
||||
path = root / output['path']
|
||||
if not path.is_file() or digest(path) != output['sha256']:
|
||||
raise ValueError('Missing or changed runtime input: ' + name + '. Run tools/build_local.sh.')
|
||||
if outputs(root) != {name: output['path'] for name, output in data['outputs'].items()}:
|
||||
raise ValueError('Runtime file set changed. Run tools/build_local.sh.')
|
||||
return data
|
||||
|
||||
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
with ZipFile(apk) as package:
|
||||
for name, output in data['outputs'].items():
|
||||
try:
|
||||
content = package.read(name)
|
||||
except KeyError:
|
||||
raise ValueError('APK missing ' + name)
|
||||
if hashlib.sha256(content).hexdigest() != output['sha256']:
|
||||
raise ValueError('APK has stale runtime input: ' + name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
if sys.argv[1] == 'record':
|
||||
record()
|
||||
elif sys.argv[1] == 'verify':
|
||||
verify()
|
||||
elif sys.argv[1] == 'apk':
|
||||
check_apk(sys.argv[2])
|
||||
else:
|
||||
raise ValueError('Expected record, verify or apk <path>')
|
||||
except (ValueError, OSError) as error:
|
||||
sys.exit(str(error))
|
||||
print('Runtime inputs verified')
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Session helpers and ELF preload tests need Linux (/proc, inotify and glibc), as in CI.
|
||||
set -euo pipefail
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
cd "$repo_root"
|
||||
if [[ $(uname -s) == Linux ]]; then
|
||||
exec python3 -m unittest discover -s tools/tests "$@"
|
||||
fi
|
||||
image=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
|
||||
python3 tools/docker_preflight.py "$image"
|
||||
exec docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" \
|
||||
-v "$repo_root:/src:ro" -w /src "$image" python3 -m unittest discover -s tools/tests "$@"
|
||||
@@ -1,8 +1,10 @@
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
import tempfile
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@@ -65,5 +67,112 @@ class DesktopBookmarksTest(unittest.TestCase):
|
||||
self.assertEqual(self.bookmarks.read_text(), "")
|
||||
|
||||
|
||||
class DolphinPlacesTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temporary = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temporary.cleanup)
|
||||
self.home = Path(temporary.name)
|
||||
self.data = self.home / ".local/share"
|
||||
self.steam = self.data / "Steam"
|
||||
(self.steam / "steamapps").mkdir(parents=True)
|
||||
self.places = self.data / "user-places.xbel"
|
||||
self.environment = patch.dict(os.environ, {}, clear=True)
|
||||
self.environment.start()
|
||||
self.addCleanup(self.environment.stop)
|
||||
|
||||
def registered(self, libraries):
|
||||
entries = []
|
||||
for index, (path, label) in enumerate(libraries):
|
||||
quote = lambda s: json.dumps(str(s), ensure_ascii=False)
|
||||
entries.append(f'"{index}" {{ "path" {quote(path)} "label" {quote(label)} "apps" {{ "1" "0" }} }}')
|
||||
(self.steam / "steamapps/libraryfolders.vdf").write_text('"libraryfolders" { ' + " ".join(entries) + ' }')
|
||||
|
||||
def libraries(self):
|
||||
return MODULE["steam_libraries"](self.home, self.data)
|
||||
|
||||
def update(self, libraries):
|
||||
MODULE["update_places"](self.places, libraries)
|
||||
return ET.parse(self.places).getroot()
|
||||
|
||||
def test_internal_and_all_available_registered_libraries_with_escaped_names(self):
|
||||
external = self.home / 'USB café "Games"'
|
||||
(external / "steamapps").mkdir(parents=True)
|
||||
missing = self.home / "removed drive"
|
||||
self.registered([(self.steam, ""), (external, 'Games "USB"'), (missing, "Gone")])
|
||||
self.assertEqual({self.steam.as_uri(): "Steam (Internal Storage)", external.as_uri(): 'Steam (Games "USB")'}, self.libraries())
|
||||
|
||||
def test_app_list_adds_new_library_before_steam_and_removes_unbound_managed_path(self):
|
||||
old = self.home / "Games/old"
|
||||
new = self.home / "Games/new"
|
||||
for library in (old, new):
|
||||
(library / "steamapps").mkdir(parents=True)
|
||||
self.registered([(old, "Old")])
|
||||
listing = self.home / "libraries.json"
|
||||
listing.write_text(json.dumps([{"path": str(new), "label": "New\nLibrary"}]))
|
||||
os.environ["BL_STEAM_LIBRARIES"] = str(listing)
|
||||
self.assertEqual({self.steam.as_uri(): "Steam (Internal Storage)", new.as_uri(): "Steam (New Library)"}, self.libraries())
|
||||
|
||||
def test_unreadable_app_list_falls_back_to_registered_libraries(self):
|
||||
external = self.home / "USB"
|
||||
(external / "steamapps").mkdir(parents=True)
|
||||
self.registered([(external, "Drive")])
|
||||
os.environ["BL_STEAM_LIBRARIES"] = str(self.home / "missing.json")
|
||||
self.assertIn(external.as_uri(), self.libraries())
|
||||
|
||||
def test_xml_escaping_stable_ids_and_idempotence(self):
|
||||
libraries = {self.steam.as_uri(): "Steam (A & <B>)"}
|
||||
root = self.update(libraries)
|
||||
self.assertEqual("Steam (A & <B>)", root.findtext("bookmark/title"))
|
||||
identity = root.findtext("bookmark/info/metadata[@owner='http://www.kde.org']/ID")
|
||||
before = self.places.stat().st_mtime_ns
|
||||
self.update(libraries)
|
||||
self.assertEqual(before, self.places.stat().st_mtime_ns)
|
||||
root = self.update({self.steam.as_uri(): "Renamed"})
|
||||
self.assertEqual(identity, root.findtext("bookmark/info/metadata[@owner='http://www.kde.org']/ID"))
|
||||
self.assertEqual("Renamed", root.findtext("bookmark/title"))
|
||||
|
||||
def test_personal_places_and_metadata_survive_unplugging_and_returning(self):
|
||||
personal = '<bookmark href="file:///root/Documents"><title>Mine</title><info><metadata owner="custom"><private>keep</private></metadata></info></bookmark>'
|
||||
self.places.write_text('<xbel version="1.0"><!--keep comment-->' + personal + '</xbel>')
|
||||
self.update({self.steam.as_uri(): "Steam"})
|
||||
root = self.update({})
|
||||
self.assertEqual(["file:///root/Documents"], [b.get("href") for b in root.findall("bookmark")])
|
||||
self.assertEqual("keep", root.findtext("bookmark/info/metadata/private"))
|
||||
self.assertIn("<!--keep comment-->", self.places.read_text())
|
||||
self.assertEqual(2, len(self.update({self.steam.as_uri(): "Steam"}).findall("bookmark")))
|
||||
|
||||
def test_personal_place_at_library_url_is_not_duplicated_renamed_or_removed(self):
|
||||
self.places.write_text(f'<xbel><bookmark href="{self.steam.as_uri()}"><title>My games</title></bookmark></xbel>')
|
||||
before = self.places.read_bytes()
|
||||
self.update({self.steam.as_uri(): "Steam"})
|
||||
self.update({})
|
||||
self.assertEqual(before, self.places.read_bytes())
|
||||
|
||||
def test_user_hidden_state_on_managed_place_is_kept(self):
|
||||
root = self.update({self.steam.as_uri(): "Steam"})
|
||||
metadata = root.find("bookmark/info/metadata[@owner='http://www.kde.org']")
|
||||
ET.SubElement(metadata, "IsHidden").text = "true"
|
||||
self.places.write_bytes(ET.tostring(root))
|
||||
root = self.update({self.steam.as_uri(): "Renamed"})
|
||||
self.assertEqual("true", root.findtext("bookmark/info/metadata/IsHidden"))
|
||||
|
||||
def test_personal_place_with_trailing_slash_is_not_duplicated(self):
|
||||
self.places.write_text(f'<xbel><bookmark href="{self.steam.as_uri()}/"><title>My games</title></bookmark></xbel>')
|
||||
root = self.update({self.steam.as_uri(): "Steam"})
|
||||
self.assertEqual(1, len(root.findall("bookmark")))
|
||||
self.assertEqual("My games", root.findtext("bookmark/title"))
|
||||
|
||||
def test_invalid_xml_is_not_overwritten(self):
|
||||
self.places.write_text("<xbel>unfinished")
|
||||
with self.assertRaises(ET.ParseError):
|
||||
self.update({self.steam.as_uri(): "Steam"})
|
||||
self.assertEqual("<xbel>unfinished", self.places.read_text())
|
||||
|
||||
def test_new_places_leave_default_version_for_kde_to_initialize(self):
|
||||
root = self.update({self.steam.as_uri(): "Steam"})
|
||||
self.assertEqual("1.0", root.get("version"))
|
||||
self.assertIsNone(root.find("info/metadata/Version"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,76 @@
|
||||
import importlib.util
|
||||
import io
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location('runtime_inputs', Path(__file__).resolve().parents[1] / 'release/runtime_inputs.py')
|
||||
runtime = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(runtime)
|
||||
|
||||
|
||||
class RuntimeInputsTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
paths = runtime.outputs(self.root)
|
||||
for name in runtime.required():
|
||||
path = self.root / paths.get(name, 'app/src/main/' + name)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(b'prepared runtime')
|
||||
self.source = self.root / 'tools/linuxfs/preload/test.c'
|
||||
self.source.parent.mkdir(parents=True)
|
||||
self.source.write_text('current source')
|
||||
self.audio(['pactl', 'modules/arm64/module-aaudio-sink.so', 'modules/arm64/module-directaudio-native-sink.so'])
|
||||
|
||||
def audio(self, names):
|
||||
stream = io.BytesIO()
|
||||
with tarfile.open(fileobj=stream, mode='w') as archive:
|
||||
for name in names:
|
||||
entry = tarfile.TarInfo('./' + name)
|
||||
entry.size = 1
|
||||
archive.addfile(entry, io.BytesIO(b'x'))
|
||||
path = self.root / 'app/build/prepared-assets/pulseaudio.tzst'
|
||||
path.write_bytes(subprocess.run(['zstd', '-q', '-c'], input=stream.getvalue(), capture_output=True, check=True).stdout)
|
||||
|
||||
def test_missing_proot_cannot_be_attested(self):
|
||||
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').unlink()
|
||||
with self.assertRaisesRegex(ValueError, 'libproot.so'):
|
||||
runtime.record(self.root)
|
||||
|
||||
def test_base_audio_without_compiled_sinks_is_rejected(self):
|
||||
self.audio(['pactl'])
|
||||
with self.assertRaisesRegex(ValueError, 'module-aaudio-sink'):
|
||||
runtime.record(self.root)
|
||||
|
||||
def test_changed_native_source_rejects_old_outputs(self):
|
||||
runtime.record(self.root)
|
||||
self.source.write_text('new implementation')
|
||||
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
||||
runtime.verify(self.root)
|
||||
|
||||
def test_modified_prebuilt_binary_is_rejected(self):
|
||||
runtime.record(self.root)
|
||||
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').write_bytes(b'old APK binary')
|
||||
with self.assertRaisesRegex(ValueError, 'changed runtime input'):
|
||||
runtime.verify(self.root)
|
||||
|
||||
def test_an_old_apk_is_rejected_even_when_staging_is_current(self):
|
||||
runtime.record(self.root)
|
||||
data = runtime.verify(self.root)
|
||||
apk = self.root / 'old.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
content = b'stale' if name == 'assets/linuxfs/libssbs.so' else (self.root / output['path']).read_bytes()
|
||||
package.writestr(name, content)
|
||||
with self.assertRaisesRegex(ValueError, 'stale runtime input'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_complete_current_payload_passes(self):
|
||||
runtime.record(self.root)
|
||||
runtime.verify(self.root)
|
||||
@@ -0,0 +1,23 @@
|
||||
import runpy
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
|
||||
select_desktop = runpy.run_path(str(Path(__file__).resolve().parents[1] /
|
||||
'linuxfs/overlay/usr/local/bin/droiddeck-steam-desktop-ui'))['select_desktop']
|
||||
|
||||
|
||||
class SteamDesktopUiTest(unittest.TestCase):
|
||||
def test_waits_for_cef_and_native_api_then_selects_once(self):
|
||||
evaluate = Mock(side_effect=[ConnectionError(), {'value': False}, {'value': True}])
|
||||
with patch('time.sleep'):
|
||||
self.assertTrue(select_desktop(evaluate))
|
||||
self.assertEqual(evaluate.call_count, 3)
|
||||
self.assertIn('SteamClient.UI.ExitBigPictureMode()', evaluate.call_args.args[0])
|
||||
|
||||
def test_a_client_that_never_starts_has_a_bounded_wait(self):
|
||||
evaluate = Mock()
|
||||
with patch('time.monotonic', side_effect=[0, 91]):
|
||||
self.assertFalse(select_desktop(evaluate))
|
||||
evaluate.assert_not_called()
|
||||
Reference in new issue
Block a user