mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
Target Android SDK 37 for Play Store review
Integrate current main while preserving the original SDK migration history. Update the Android toolchain, runtime permissions, foreground service lifecycle, storage access, native execution and platform API compatibility. Complete translations and regression coverage. Validation: 3,260 JVM tests, 1,620 Python tests (eight skips), 171 Rust tests, six native regression programs and release lint with zero errors. Signed APK upgrade installed on the requested device. Signed app bundle validated with bundletool. Review candidate: physical before/after feature checks, performance parity and native 16 KiB audio compatibility remain pending. Play Console acceptance has not been verified.
This commit is contained in:
commit
b14587baeb
1553 files changed
+124616
-8790
No files matched your search
@@ -0,0 +1,123 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#include <stdio.h>
|
||||
#include <pulsecore/core-rtclock.h>
|
||||
#include <pulsecore/core-subscribe.h>
|
||||
|
||||
#define ANDROID_VOLUME_IDLE_MS 100
|
||||
#define ANDROID_VOLUME_ACTIVE_MS 16
|
||||
#define ANDROID_VOLUME_ACTIVE_TICKS 40
|
||||
|
||||
struct android_volume {
|
||||
pa_sink *sink;
|
||||
char *directory;
|
||||
pa_time_event *timer;
|
||||
unsigned active_ticks;
|
||||
};
|
||||
|
||||
static bool android_volume_read(const char *directory, unsigned *level, unsigned *maximum, unsigned *muted) {
|
||||
char *path = pa_sprintf_malloc("%s/volume.state", directory);
|
||||
FILE *file = fopen(path, "r");
|
||||
pa_xfree(path);
|
||||
if (!file) return false;
|
||||
int fields = fscanf(file, "%u %u %u", level, maximum, muted);
|
||||
fclose(file);
|
||||
return fields == 3 && *maximum > 0 && *level <= *maximum && *muted <= 1;
|
||||
}
|
||||
|
||||
static void android_volume_request(pa_sink *sink, const char *name, unsigned value) {
|
||||
struct userdata *u = sink->userdata;
|
||||
if (!u->android_volume || sink->state == PA_SINK_INIT) return;
|
||||
char *path = pa_sprintf_malloc("%s/%s.request", u->android_volume->directory, name);
|
||||
char *staged = pa_sprintf_malloc("%s.tmp", path);
|
||||
FILE *file = fopen(staged, "w");
|
||||
if (file) {
|
||||
fprintf(file, "%u\n", value);
|
||||
if (fclose(file) == 0 && rename(staged, path) < 0) pa_log_warn("Could not publish Android %s", name);
|
||||
}
|
||||
pa_xfree(staged);
|
||||
pa_xfree(path);
|
||||
}
|
||||
|
||||
static void android_volume_set(pa_sink *sink) {
|
||||
struct userdata *u = sink->userdata;
|
||||
unsigned level, maximum, muted;
|
||||
if (!u->android_volume || !android_volume_read(u->android_volume->directory, &level, &maximum, &muted)) return;
|
||||
unsigned requested = PA_MIN(pa_cvolume_max(&sink->real_volume), PA_VOLUME_NORM);
|
||||
level = ((uint64_t)requested * maximum + PA_VOLUME_NORM / 2) / PA_VOLUME_NORM;
|
||||
pa_cvolume_set(&sink->real_volume, sink->sample_spec.channels, (uint64_t)level * PA_VOLUME_NORM / maximum);
|
||||
pa_cvolume_reset(&sink->soft_volume, sink->sample_spec.channels);
|
||||
android_volume_request(sink, "volume", level);
|
||||
}
|
||||
|
||||
static void android_volume_mute(pa_sink *sink) {
|
||||
android_volume_request(sink, "mute", sink->muted ? 1 : 0);
|
||||
}
|
||||
|
||||
static void android_volume_refresh(pa_mainloop_api *api, pa_time_event *event, const struct timeval *tv, void *userdata) {
|
||||
struct android_volume *bridge = userdata;
|
||||
unsigned level, maximum, muted;
|
||||
char *request = pa_sprintf_malloc("%s/volume.request", bridge->directory);
|
||||
char *mute_request = pa_sprintf_malloc("%s/mute.request", bridge->directory);
|
||||
char *processing = pa_sprintf_malloc("%s.processing", request);
|
||||
char *mute_processing = pa_sprintf_malloc("%s.processing", mute_request);
|
||||
if (access(request, F_OK) != 0 && access(mute_request, F_OK) != 0 &&
|
||||
access(processing, F_OK) != 0 && access(mute_processing, F_OK) != 0) {
|
||||
if (android_volume_read(bridge->directory, &level, &maximum, &muted)) {
|
||||
pa_cvolume volume;
|
||||
bool changed = false;
|
||||
if (bridge->sink->n_volume_steps != maximum + 1) {
|
||||
bridge->sink->n_volume_steps = maximum + 1;
|
||||
pa_subscription_post(bridge->sink->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_CHANGE, bridge->sink->index);
|
||||
}
|
||||
pa_cvolume_set(&volume, bridge->sink->sample_spec.channels, (uint64_t)level * PA_VOLUME_NORM / maximum);
|
||||
if (!pa_cvolume_equal(&volume, &bridge->sink->real_volume)) {
|
||||
pa_sink_volume_changed(bridge->sink, &volume);
|
||||
changed = true;
|
||||
}
|
||||
if (bridge->sink->muted != !!muted) {
|
||||
pa_sink_mute_changed(bridge->sink, !!muted);
|
||||
changed = true;
|
||||
}
|
||||
if (changed) bridge->active_ticks = ANDROID_VOLUME_ACTIVE_TICKS;
|
||||
}
|
||||
} else {
|
||||
bridge->active_ticks = ANDROID_VOLUME_ACTIVE_TICKS;
|
||||
}
|
||||
pa_xfree(request);
|
||||
pa_xfree(mute_request);
|
||||
pa_xfree(processing);
|
||||
pa_xfree(mute_processing);
|
||||
unsigned delay_ms = ANDROID_VOLUME_IDLE_MS;
|
||||
if (bridge->active_ticks) {
|
||||
bridge->active_ticks--;
|
||||
delay_ms = ANDROID_VOLUME_ACTIVE_MS;
|
||||
}
|
||||
pa_core_rttime_restart(bridge->sink->core, event, pa_rtclock_now() + delay_ms * PA_USEC_PER_MSEC);
|
||||
}
|
||||
|
||||
static struct android_volume *android_volume_new(pa_sink *sink, const char *directory) {
|
||||
unsigned level, maximum, muted;
|
||||
if (!directory) return NULL;
|
||||
struct android_volume *bridge = pa_xnew0(struct android_volume, 1);
|
||||
bridge->sink = sink;
|
||||
bridge->directory = pa_xstrdup(directory);
|
||||
if (android_volume_read(directory, &level, &maximum, &muted)) {
|
||||
pa_cvolume_set(&sink->real_volume, sink->sample_spec.channels, (uint64_t)level * PA_VOLUME_NORM / maximum);
|
||||
sink->reference_volume = sink->real_volume;
|
||||
sink->muted = !!muted;
|
||||
sink->n_volume_steps = maximum + 1;
|
||||
}
|
||||
pa_cvolume_reset(&sink->soft_volume, sink->sample_spec.channels);
|
||||
pa_sink_set_set_volume_callback(sink, android_volume_set);
|
||||
pa_sink_set_set_mute_callback(sink, android_volume_mute);
|
||||
bridge->timer = pa_core_rttime_new(sink->core, pa_rtclock_now() + ANDROID_VOLUME_IDLE_MS * PA_USEC_PER_MSEC,
|
||||
android_volume_refresh, bridge);
|
||||
return bridge;
|
||||
}
|
||||
|
||||
static void android_volume_free(struct android_volume *bridge) {
|
||||
if (!bridge) return;
|
||||
bridge->sink->core->mainloop->time_free(bridge->timer);
|
||||
pa_xfree(bridge->directory);
|
||||
pa_xfree(bridge);
|
||||
}
|
||||
@@ -42,6 +42,7 @@ PA_MODULE_USAGE(
|
||||
"channels=<number of channels> "
|
||||
"channel_map=<channel map> "
|
||||
"volume=<initial volume, linear, 1.0 = full> "
|
||||
"control_dir=<Android media volume bridge directory> "
|
||||
"performance_mode=<0 none, 1 low latency, 2 power saving> "
|
||||
"adaptive=<grow the buffer after underruns: 0 or 1> "
|
||||
"buffer_frames=<initial buffer size in frames, 0 = two bursts> "
|
||||
@@ -56,6 +57,7 @@ PA_MODULE_USAGE(
|
||||
#define STATS_EVERY_USEC (30 * PA_USEC_PER_SEC)
|
||||
|
||||
static const char* const valid_modargs[] = {
|
||||
"control_dir",
|
||||
"sink_name",
|
||||
"sink_properties",
|
||||
"format",
|
||||
@@ -70,7 +72,10 @@ static const char* const valid_modargs[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
struct android_volume;
|
||||
|
||||
struct userdata {
|
||||
struct android_volume *android_volume;
|
||||
pa_core *core;
|
||||
pa_module *module;
|
||||
pa_sink *sink;
|
||||
@@ -100,6 +105,9 @@ struct userdata {
|
||||
int32_t xruns_reported;
|
||||
};
|
||||
|
||||
#include "android-volume.h"
|
||||
|
||||
|
||||
static pa_usec_t frames_to_usec(const struct userdata *u, int64_t frames) {
|
||||
return (pa_usec_t) (frames * (int64_t) PA_USEC_PER_SEC / (int64_t) u->ss.rate);
|
||||
}
|
||||
@@ -472,6 +480,7 @@ int pa__init(pa_module *m) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
u->android_volume = android_volume_new(u->sink, pa_modargs_get_value(ma, "control_dir", NULL));
|
||||
pa_sink_put(u->sink);
|
||||
pa_modargs_free(ma);
|
||||
return 0;
|
||||
@@ -498,6 +507,8 @@ void pa__done(pa_module *m) {
|
||||
if (!(u = m->userdata))
|
||||
return;
|
||||
|
||||
android_volume_free(u->android_volume);
|
||||
u->android_volume = NULL;
|
||||
if (u->sink)
|
||||
pa_sink_unlink(u->sink);
|
||||
if (u->thread) {
|
||||
|
||||
+38
-12
@@ -24,7 +24,8 @@ java_dir="${JAVA_HOME:-/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents
|
||||
[[ -x "$java_dir/bin/java" ]] || java_dir="${HOME}/.local/share/mise/installs/java/temurin-17"
|
||||
[[ "$java_dir" == */homebrew/* ]] && echo "using homebrew java path: $java_dir"
|
||||
[[ "$java_dir" == */mise/* ]] && echo "using mise java path: $java_dir"
|
||||
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
|
||||
. "${repo_root}/tools/docker_platform.sh"
|
||||
image_name=${DROIDDECK_BUILD_IMAGE}
|
||||
build_variant=${DROIDDECK_BUILD_VARIANT:-release}
|
||||
case "$build_variant" in
|
||||
debug) gradle_task=assembleDebug ;;
|
||||
@@ -44,7 +45,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 python3; do
|
||||
for tool in curl tar zstd shasum unzip python3 go; do
|
||||
if ! command -v "${tool}" >/dev/null 2>&1; then
|
||||
echo "${tool} is required to build the CI-equivalent APK." >&2
|
||||
exit 1
|
||||
@@ -85,8 +86,6 @@ trap 'exit 143' TERM
|
||||
|
||||
cache_dir=${DROIDDECK_BUILD_CACHE:-"${HOME}/.cache/droiddeck-build"}
|
||||
mkdir -p "${cache_dir}"
|
||||
# Steps whose output depends only on tracked sources are kept per input hash in the
|
||||
# shared cache, so a rerun or a fresh worktree copies them instead of rebuilding.
|
||||
inputs_hash() {
|
||||
(cd "${repo_root}" && { printf '%s\n' "$1"; shift; find "$@" -type f ! -name '*.pyc' | LC_ALL=C sort | xargs shasum -a 256; }) \
|
||||
| shasum -a 256 | cut -d' ' -f1
|
||||
@@ -104,7 +103,6 @@ save_step() {
|
||||
part=$(mktemp -d "${stored}.part.XXXXXX")
|
||||
(cd "$3" && tar -cf - .) | tar -xf - -C "${part}"
|
||||
touch "${part}/.complete"
|
||||
# Another checkout may have published the same key meanwhile; its copy is equivalent.
|
||||
if [[ -e "${stored}" ]]; then rm -rf "${part}"; else mv "${part}" "${stored}" || rm -rf "${part}"; fi
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ image_id=$(docker image inspect --format '{{.Id}}' "${image_name}")
|
||||
rm -rf -- "${linuxfs_dir}"
|
||||
mkdir -p "${linuxfs_dir}"
|
||||
|
||||
docker run --rm --platform linux/amd64 \
|
||||
docker run --rm --platform "${docker_platform}" \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "${repo_root}:/src" -w /src "${image_name}" bash -lc '
|
||||
set -euo pipefail
|
||||
@@ -180,6 +178,13 @@ if ! restore_step vr "${vr_key}" "${vr_out}"; then
|
||||
save_step vr "${vr_key}" "${vr_out}"
|
||||
fi
|
||||
|
||||
gpuload_out="${linuxfs_dir}/usr/local/lib/droiddeck-gpuload"
|
||||
gpuload_key=$(inputs_hash "${image_id} ${ndk_version} ${VK_INCLUDE:-}" tools/gpuload)
|
||||
if ! restore_step gpuload "${gpuload_key}" "${gpuload_out}"; then
|
||||
DROIDDECK_BUILD_IMAGE="${image_name}" "${repo_root}/tools/gpuload/build.sh" "${gpuload_out}"
|
||||
save_step gpuload "${gpuload_key}" "${gpuload_out}"
|
||||
fi
|
||||
|
||||
github_repo=${DROIDDECK_GITHUB_REPOSITORY:-}
|
||||
if [[ -z "${github_repo}" ]]; then
|
||||
origin_url=$(git -C "${repo_root}" remote get-url origin)
|
||||
@@ -221,7 +226,7 @@ fi
|
||||
|
||||
. "${repo_root}/tools/linuxfs/uruntime.env"
|
||||
uruntime_binary=$(cached "${URUNTIME_SHA256}" "${URUNTIME_ASSET}" \
|
||||
bash -c 'curl -fsSL --retry 3 -o "$out" "$0"' "https://github.com/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/${URUNTIME_ASSET}")
|
||||
bash -c 'curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "$out" "$0"' "https://github.com/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/${URUNTIME_ASSET}")
|
||||
mkdir -p "${linuxfs_dir}/usr/local/lib/droiddeck" "${linuxfs_dir}/usr/local/share/licenses/uruntime"
|
||||
install -m644 "${uruntime_binary}" "${linuxfs_dir}/usr/local/lib/droiddeck/uruntime"
|
||||
install -m644 "${repo_root}/tools/linuxfs/licenses/uruntime-LICENSE" "${linuxfs_dir}/usr/local/share/licenses/uruntime/LICENSE"
|
||||
@@ -256,7 +261,7 @@ 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}")
|
||||
bash -c 'curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -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
|
||||
@@ -276,14 +281,14 @@ mkdir -p "${mango_dir}" "${mango_pkgs}"
|
||||
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}")
|
||||
bash -c 'curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "$out" "$0"' "${package_url}")
|
||||
zstd -dc "${package_archive}" | tar -xf - -C "${mango_pkgs}"
|
||||
done < <(grep -v '^#' "${repo_root}/tools/mangoapp/packages.txt")
|
||||
install -m644 "${mango_pkgs}/usr/bin/mangoapp" "${mango_dir}/mangoapp"
|
||||
for library in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1; do
|
||||
cp -L "${mango_pkgs}/usr/lib/${library}" "${mango_dir}/${library}"
|
||||
done
|
||||
docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" -v "${repo_root}:/src" -w /src "${image_name}" \
|
||||
docker run --rm --platform "${docker_platform}" --user "$(id -u):$(id -g)" -v "${repo_root}:/src" -w /src "${image_name}" \
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wl,-soname,libtracefs.so.1 \
|
||||
-o app/src/main/assets/linuxfs/usr/local/lib/mangoapp/libtracefs.so.1 tools/mangoapp/libtracefs-shim.c
|
||||
mkdir -p "${linuxfs_dir}/usr/local/bin"
|
||||
@@ -294,7 +299,7 @@ mkdir -p "${pw_pkgs}"
|
||||
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}")
|
||||
bash -c 'curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "$out" "$0"' "${package_url}")
|
||||
zstd -dc "${package_archive}" | tar -xf - -C "${pw_pkgs}"
|
||||
done < <(grep -v '^#' "${repo_root}/tools/pipewire/packages.txt")
|
||||
"${repo_root}/tools/pipewire/assemble.sh" "${pw_pkgs}" "${linuxfs_dir}/usr/local/lib/droiddeck-pipewire.tzst"
|
||||
@@ -303,7 +308,7 @@ pa_source=${DROIDDECK_PA13_SOURCE_DIR:-"${staging_dir}/pulseaudio-13.0"}
|
||||
if [[ -z "${DROIDDECK_PA13_SOURCE_DIR:-}" ]]; then
|
||||
pa_tarball="${cache_dir}/pulseaudio-13.0.tar.gz"
|
||||
if [[ ! -s "${pa_tarball}" ]] || ! tar -tzf "${pa_tarball}" >/dev/null 2>&1; then
|
||||
curl -fsSL -o "${pa_tarball}.part" \
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "${pa_tarball}.part" \
|
||||
https://github.com/pulseaudio/pulseaudio/archive/refs/tags/v13.0.tar.gz
|
||||
mv "${pa_tarball}.part" "${pa_tarball}"
|
||||
fi
|
||||
@@ -336,6 +341,27 @@ else
|
||||
(cd "${proot_out}" && shasum -a 256 libproot.so libproot-loader.so > .proot-outputs)
|
||||
fi
|
||||
|
||||
syncthing_src="${repo_root}/tools/syncthing/syncthing-android/syncthing/src/github.com/syncthing/syncthing"
|
||||
git -C "${repo_root}" submodule update --init --recursive tools/syncthing/syncthing-android
|
||||
syncthing_inputs=$(printf '%s\n' "$(cd "${repo_root}" && shasum -a 256 tools/syncthing/build.sh \
|
||||
tools/syncthing/syncthing-android/gradle/libs.versions.toml)" \
|
||||
"$(git -C "${syncthing_src}" rev-parse HEAD)" \
|
||||
"$(git -C "${syncthing_src}" diff --binary HEAD | shasum -a 256)" \
|
||||
"$(cd "${syncthing_src}" && git ls-files -z --others --exclude-standard | xargs -0 shasum -a 256)" \
|
||||
"${ndk_version}" | shasum -a 256 | cut -d' ' -f1)
|
||||
if [[ -f "${proot_out}/libsyncthingnative.so" \
|
||||
&& "$(cat "${proot_out}/.syncthing-inputs" 2>/dev/null)" = "${syncthing_inputs}" ]]; then
|
||||
echo "syncthing: sources unchanged, keeping ${proot_out}/libsyncthingnative.so"
|
||||
else
|
||||
syncthing_stage="${staging_dir}/syncthing"
|
||||
if ! restore_step syncthing "${syncthing_inputs}" "${syncthing_stage}"; then
|
||||
"${repo_root}/tools/syncthing/build.sh" "${syncthing_stage}"
|
||||
save_step syncthing "${syncthing_inputs}" "${syncthing_stage}"
|
||||
fi
|
||||
install -m755 "${syncthing_stage}/libsyncthingnative.so" "${proot_out}/"
|
||||
echo "${syncthing_inputs}" > "${proot_out}/.syncthing-inputs"
|
||||
fi
|
||||
|
||||
bundle_dir="${staging_dir}/pulseaudio-bundle"
|
||||
mkdir -p "${bundle_dir}"
|
||||
zstd -dc "${bundle_asset}" | tar -xf - -C "${bundle_dir}"
|
||||
|
||||
@@ -45,8 +45,6 @@ int main(void) {
|
||||
cardboard_push_constants(&q, pose, 0, 0, 0, 0, pc);
|
||||
CHECK(isfinite(pc[17]) && isfinite(pc[19]));
|
||||
|
||||
// Narrow optical profiles and the lower SteamVR slider values must reach
|
||||
// the projection unchanged, rather than all becoming a 30-degree view.
|
||||
const float glasses_fovs[] = {22.0f, 23.3f, 24.0f, 25.8f, 29.0f};
|
||||
for (unsigned i = 0; i < sizeof(glasses_fovs) / sizeof(glasses_fovs[0]); i++) {
|
||||
q.fov_deg = glasses_fovs[i];
|
||||
|
||||
@@ -156,7 +156,6 @@ def main():
|
||||
read(0,0,width,height,0x1908,0x1401,actual)
|
||||
samples = []
|
||||
for x, y in coords:
|
||||
# Readback is GL bottom-up; coordinates below are image top-left.
|
||||
offset = ((height-1-y)*width+x)*4
|
||||
rgb = list(actual[offset:offset+3])
|
||||
eye = 0 if mono or x < width/2 else 1
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
missing=()
|
||||
for package in "$@"; do
|
||||
if [ "$(dpkg-query -W -f='${Status}' "$package" 2>/dev/null || true)" != 'install ok installed' ]; then
|
||||
missing+=("$package")
|
||||
fi
|
||||
done
|
||||
if [ "${#missing[@]}" = 0 ]; then
|
||||
echo "Ubuntu build dependencies are already installed."
|
||||
exit 0
|
||||
fi
|
||||
options=(
|
||||
-o Dir::Etc::sourcelist=sources.list.d/ubuntu.sources
|
||||
-o Dir::Etc::sourceparts=-
|
||||
-o Acquire::Retries=1
|
||||
-o Acquire::http::Timeout=15
|
||||
-o Acquire::https::Timeout=15
|
||||
-o DPkg::Lock::Timeout=30
|
||||
)
|
||||
install_packages() {
|
||||
echo "Updating Ubuntu package indexes."
|
||||
sudo timeout --kill-after=10s 60s apt-get "${options[@]}" -o APT::Update::Error-Mode=any update -q || return $?
|
||||
echo "Installing: ${missing[*]}"
|
||||
sudo timeout --kill-after=10s 120s env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get "${options[@]}" install -y -q --no-install-recommends "${missing[@]}"
|
||||
}
|
||||
if install_packages; then
|
||||
exit 0
|
||||
fi
|
||||
echo "::warning::Runner mirror failed or timed out; retrying with the official Ubuntu mirror."
|
||||
sources=$(mktemp --suffix=.sources)
|
||||
trap 'rm -f "$sources"' EXIT
|
||||
mirror=https://archive.ubuntu.com/ubuntu
|
||||
case "$(dpkg --print-architecture)" in
|
||||
arm64) mirror=https://ports.ubuntu.com/ubuntu-ports ;;
|
||||
esac
|
||||
sed -E "s@^URIs:.*@URIs: $mirror@" /etc/apt/sources.list.d/ubuntu.sources > "$sources"
|
||||
chmod 644 "$sources"
|
||||
options[1]="Dir::Etc::sourcelist=$sources"
|
||||
install_packages
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
repo=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
source "$repo/tools/ci/toolchains.env"
|
||||
ndk="$ANDROID_HOME/ndk/$CI_ANDROID_NDK_VERSION"
|
||||
if [ ! -f "$ndk/source.properties" ]; then
|
||||
sdkmanager --sdk_root="$ANDROID_HOME" --install "ndk;$CI_ANDROID_NDK_VERSION"
|
||||
fi
|
||||
actual=$(sed -n 's/^Pkg.Revision *= *//p' "$ndk/source.properties" | tr -d '\r')
|
||||
test "$actual" = "$CI_ANDROID_NDK_VERSION"
|
||||
{
|
||||
echo "NDK_VERSION=$actual"
|
||||
echo "ANDROID_NDK_HOME=$ndk"
|
||||
echo "ANDROID_NDK_ROOT=$ndk"
|
||||
echo "ANDROID_NDK_LATEST_HOME=$ndk"
|
||||
} >> "$GITHUB_ENV"
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
groups=${PYTHON_TEST_GROUPS:-3}
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
index=0
|
||||
while read -r file; do
|
||||
module=$(basename "$file" .py)
|
||||
echo "$module" >> "$work/group-$((index % groups)).list"
|
||||
index=$((index + 1))
|
||||
done < <(ls -S tools/tests/test_*.py)
|
||||
pids=()
|
||||
for list in "$work"/group-*.list; do
|
||||
(
|
||||
PYTHONPATH=tools/tests python3 -m unittest $(cat "$list") > "${list%.list}.log" 2>&1
|
||||
echo $? > "${list%.list}.status"
|
||||
) &
|
||||
pids+=($!)
|
||||
done
|
||||
wait "${pids[@]}"
|
||||
failed=0
|
||||
for list in "$work"/group-*.list; do
|
||||
echo "::group::$(basename "$list"): $(tr '\n' ' ' < "$list" | cut -c1-120)"
|
||||
cat "${list%.list}.log"
|
||||
echo "::endgroup::"
|
||||
if [ "$(cat "${list%.list}.status")" != 0 ]; then
|
||||
failed=1
|
||||
echo "::error::$(basename "$list") failed"
|
||||
fi
|
||||
done
|
||||
exit "$failed"
|
||||
@@ -0,0 +1 @@
|
||||
CI_ANDROID_NDK_VERSION=30.0.16248370
|
||||
@@ -1,14 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
repo=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
image=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
|
||||
docker run --rm --platform linux/amd64 -v "$repo:/src" \
|
||||
-v "${HOME}/.cache/droiddeck-comet-rust:/rust" -w /src \
|
||||
. "$repo/tools/docker_platform.sh"
|
||||
image=${DROIDDECK_BUILD_IMAGE}
|
||||
platform=${DROIDDECK_DOCKER_PLATFORM}
|
||||
rust_cache="${HOME}/.cache/droiddeck-comet-rust${platform#linux/amd64}"
|
||||
rust_cache=${rust_cache/\/arm64/-arm64}
|
||||
docker run --rm --platform "$platform" -v "$repo:/src" \
|
||||
-v "${rust_cache}:/rust" -w /src \
|
||||
-e CARGO_HOME=/rust/cargo -e RUSTUP_HOME=/rust/rustup "$image" bash -lc '
|
||||
set -euo pipefail
|
||||
trap "chown -R '"$(id -u):$(id -g)"' app/build/comet app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet /rust 2>/dev/null || true" EXIT
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq curl git unzip ca-certificates pkg-config >/dev/null
|
||||
git config --global --add safe.directory "*"
|
||||
export PATH=/rust/cargo/bin:$PATH
|
||||
if ! command -v cargo >/dev/null; then
|
||||
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.90.0
|
||||
|
||||
@@ -16,7 +16,7 @@ cargo build --locked --release --target aarch64-unknown-linux-gnu
|
||||
install -m644 target/aarch64-unknown-linux-gnu/release/comet "$out/comet"
|
||||
zip="$cache/dummy-service.zip"
|
||||
if ! echo "7fc5facd1fce4d516cd3ce527e7e4dbe0bfd17649cea805e8ea7c37d4ba58d9a $zip" | sha256sum -c - >/dev/null 2>&1; then
|
||||
curl -fsSL --retry 3 -o "$zip" https://github.com/imLinguin/comet/releases/download/v0.3.2/dummy-service.zip
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "$zip" https://github.com/imLinguin/comet/releases/download/v0.3.2/dummy-service.zip
|
||||
fi
|
||||
echo "7fc5facd1fce4d516cd3ce527e7e4dbe0bfd17649cea805e8ea7c37d4ba58d9a $zip" | sha256sum -c -
|
||||
unzip -o "$zip" GalaxyCommunication.exe update-permissions.exe -d "$out"
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# Runtime component preparation
|
||||
|
||||
`recipes.json` owns component source inputs, builders, outputs, package requirements
|
||||
and pinned downloads. `prepare.py` runs those recipes, calculates cache identities,
|
||||
installs the union of missing tools and verifies the prepared artifact handoff.
|
||||
Builders live in `recipes/`; the workflow describes scheduling and gates.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
Source[Pin source tree] --> Components[Prepare verified components]
|
||||
Source --> Xbox[Xbox ARM64 backend]
|
||||
Source --> Tests[Python and native tests]
|
||||
Components --> APK[Compile APK and Android tests]
|
||||
Xbox --> APK
|
||||
APK --> Gate[Compile and test APK gate]
|
||||
Tests --> Gate
|
||||
Gate --> Publish[Main only: signing and publishing]
|
||||
```
|
||||
|
||||
All workers verify the same source tree. The component artifact records that tree,
|
||||
recipe identities and every output hash; the APK worker verifies the inventory
|
||||
before building. This handoff verifies consistency within the same CI run. It is
|
||||
not independent provenance for arbitrary artifacts. Source policy checks, tests,
|
||||
APK content/ABI checks and signing/publication gates remain in place.
|
||||
|
||||
`tools/ci/toolchains.env` pins the Android NDK shared by component, APK and native
|
||||
test workers. Linux builds use Ubuntu 24.04. Recipe and input changes invalidate
|
||||
the relevant component cache; ordinary caches remain performance aids.
|
||||
|
||||
## Verified preload snapshots
|
||||
|
||||
`preloads.lock.json` pins a small immutable preload archive. It records each
|
||||
binary's hash, its producing main CI run, the original APK artifact identity and
|
||||
digest, source/header hashes, the ARM64 build recipe and x86 compiler-image inputs.
|
||||
It covers core ARM64 preloads and the x86 preload libraries. VR, Android native
|
||||
libraries, Comet and Xbox use their registered recipes and existing release pins
|
||||
or component caches.
|
||||
|
||||
Every build compares current source inputs, including transitive quoted headers,
|
||||
and build recipes with this manifest. Changed groups rebuild from source. A
|
||||
missing release also selects a rebuild. Corrupt archives, unexpected files and
|
||||
binary hash mismatches fail the build. Existing preload checks, runtime packaging
|
||||
checks and all test jobs still run.
|
||||
|
||||
The trust anchor is the manifest in the pinned main base. A new or changed PR
|
||||
manifest is independently checked against a successful `push` build of main:
|
||||
GitHub must confirm the run/source/workflow and original APK artifact digest, and
|
||||
every claimed binary must match that APK. The claimed source inputs and recipe
|
||||
must match that run's Git source. A PR cannot establish trust by changing both a
|
||||
binary and its claimed checksum. This is approved-build reuse, not a claim of
|
||||
bit-for-bit reproducible compilation or a signed SLSA attestation.
|
||||
|
||||
To refresh after source or compiler changes:
|
||||
|
||||
1. Let a main build compile and test the new inputs.
|
||||
2. Run `python tools/components/preloads.py snapshot --run RUN_ID`.
|
||||
3. Publish `app/build/component-snapshot/preloads.tar.gz` to
|
||||
DroidDeck-Components as `preloads-<full archive SHA-256>`, without replacing an
|
||||
existing release. Include the manifest and producing run in the release notes.
|
||||
4. Review and commit the updated manifest. CI independently checks its origin.
|
||||
|
||||
The workflow dispatch `rebuild_preloads` option forces source compilation even
|
||||
when an approved snapshot matches. Use it when refreshing a compiler or system
|
||||
header revision. Runner image updates do not silently replace an approved binary;
|
||||
the producing run remains the record of its compiler environment.
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
D=${1:?output directory}
|
||||
mkdir -p "$D"
|
||||
aarch64-linux-gnu-g++ -shared -fPIC -O2 -Wall -Wno-attributes -Wno-nonnull-compare \
|
||||
-pthread -std=c++17 -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL \
|
||||
-o "$D/libfakeinput.so" app/src/main/cpp/fakeinput_steam.cpp -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$D/libfakeinput.so"
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
|
||||
-o "$D/libblsession.so" tools/linuxfs/preload/*.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$D/libblsession.so"
|
||||
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 -nostdlib -ffreestanding -fno-stack-protector \
|
||||
-fno-tree-loop-distribute-patterns -Wl,-z,defs -o "$D/libblaudit.so" tools/proot/fastpath/audit.c
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$D/libblaudit.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"
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"archive_sha256": "cb6487a94f25a3068fd07958174eb5b5e14f709655ff4ef0a8cdbd99138513b2",
|
||||
"arm64_recipe": "1c92a1b0669277de3e78e9f292634affb5b5a19d5ea49d3ad8610c1dc638c2fb",
|
||||
"groups": {
|
||||
"arm64": {
|
||||
"@runner": "84f825635599f81ed33f62c5fc4c73f66044d1468b060d65f83855eb9c8bfe77",
|
||||
"app/src/main/cpp/adrenotools/src/hook/kgsl.h": "396c56761034a4ed783543ee3312c6ec64d63b2a1cf7eecf1939c23251f25adf",
|
||||
"app/src/main/cpp/fakeinput_steam.cpp": "3d11e859ca58a42a9da92a3fc589d404df790e151f7e18ea6114645750e70ef5",
|
||||
"app/src/main/cpp/venc/venc_proto.h": "2242ddbc8981d14a33bac70264bb3e7f701fd1c3ebb988e17bbb2b19b6b808f7",
|
||||
"tools/linuxfs/clipboard/clipboard.c": "96291c2bbc040c83caabf059ab3e95a9ed90d6a768c759d7cb4c0b64706bddfa",
|
||||
"tools/linuxfs/preload/binfmt.c": "0933cc49cb53f0aa1206e2eae516d38dc3337e74174be07e10619c42aa56792b",
|
||||
"tools/linuxfs/preload/dircache.c": "8e7f19ea4a1198783d53a3f357326c6177da157b0cc7e0d22e1670963e1c26e7",
|
||||
"tools/linuxfs/preload/drm.c": "e0eabab0d8ed9e841918e827bf87168efa7f2dfb8404169e9bed3ab5eda2836c",
|
||||
"tools/linuxfs/preload/fsync.c": "795c114c2a05d3f250d07145d04c5658091699da3b96290da36348ccadfb0c09",
|
||||
"tools/linuxfs/preload/inputudev.c": "2648248d3d235a582eb8459709e0a85de537c03ac10c5040fbfb50d9846c68eb",
|
||||
"tools/linuxfs/preload/kgslid.c": "88a7875fd5289930204d155d92ac9d15492cd06db16ed87aa9c95af37f3e7089",
|
||||
"tools/linuxfs/preload/kgslpoll.c": "f0d853d919a52487c04cbda5fb3fa22269da54b7f4ee2f7dd3b5bd9909418670",
|
||||
"tools/linuxfs/preload/links.c": "b7bbcf9112393b152f358fe6f8dc9a1955f0c8532e1eddf016a971415cd13c64",
|
||||
"tools/linuxfs/preload/lock.c": "f71b3fd40e6a2b74908d3cdc601e8748699ae9c7a89b542d2445b999015ffd66",
|
||||
"tools/linuxfs/preload/net.c": "335853c8ea0e9a8ebbc5a5500dc4bded9c34c4310a6ab8aa46b07d5ce1c2b55e",
|
||||
"tools/linuxfs/preload/netif.c": "cc26d50b8d4639d8dd4697811bbf85c9d9f31761f9504a4af42473de3cb22b3c",
|
||||
"tools/linuxfs/preload/noexec.c": "1855aeaeda3d506329bd9af1107580c74d1f56787c411b2e01c0a8a9d4059c7b",
|
||||
"tools/linuxfs/preload/ntsync.c": "0614c48af0c062bfcb4c30141efe1b792b340767a67d2fe92ee9877d2ba16e0d",
|
||||
"tools/linuxfs/preload/opens.c": "92ae4aea16aa457a898dedf4a70eb332d80d3b1e77f3a60bace7715a4317399e",
|
||||
"tools/linuxfs/preload/pathcache.c": "eb0d4b5238fe6c8891e805d90bd837e466754100c978fad2d0ff717116b9b8a3",
|
||||
"tools/linuxfs/preload/perms.c": "f600619c4ca130f69001ed7ad7bd74a3dc215b14c61479c45bb770f916d244b9",
|
||||
"tools/linuxfs/preload/pulseguard.c": "57674ea40283e53a27bc78362de1ba41ee972d172ea38b1f818b1d6eed0abe65",
|
||||
"tools/linuxfs/preload/quest_kgsl.c": "59d9b8416be6a1c680f1d1e4c2427d2cbb7b415344261adb357d9d211ec95cfe",
|
||||
"tools/linuxfs/preload/robust.c": "9eb6c0ed50e0f48a8cfb86bd92587f471354bdf2531b9177f4b3ab83bdfed39a",
|
||||
"tools/linuxfs/preload/rptouch.c": "0e3f8bf2f9a41324361f38fa4da8d2d47593c9555f0cabf8228767397846c7c3",
|
||||
"tools/linuxfs/preload/space.c": "118389bcc89dfa2b4230b80915e21d2d4331c4cff1f5a58265f85e6ecb5c29d2",
|
||||
"tools/linuxfs/preload/storage.c": "08a8b46c3588f3160bb8608489768010ec36d5ccdb2b25a431ec9d6fcd413a6e",
|
||||
"tools/linuxfs/preload/sysv.c": "49774ee5e2e39b84dcfadf63abdc741b3df236cb11783744a1280adee36965e8",
|
||||
"tools/linuxfs/preload/tracefs.c": "be3f8a2f032b56e6e08a931e77a9386aea4bb93421a482271e06386ec0c469b6",
|
||||
"tools/linuxfs/preload/tracer.c": "f34e5377c891b0a8d00489245d66f96bc352df4cd90f47a951dcadae980af4c1",
|
||||
"tools/linuxfs/preload/udevmon.c": "2045dfb883cfb6e2016c359a3dc3af17f3b8f383f6dd0d5dfee407ef0d344852",
|
||||
"tools/linuxfs/preload/usr2.c": "6ae704380b45a9b3a74c4fe2b3ce4482470dae59ced26cf0aee64f4b4dcc11f9",
|
||||
"tools/linuxfs/preload/venc.c": "24c3c46fe49d28adfc8c977e52c9cc407f534b26f56d94b3425b8bb01803dba8",
|
||||
"tools/linuxfs/preload/vmwrite.c": "1a3ea2ec4354e0716c17f7db537b19ab82bcd524f2aece2fa5dec89b076a2188",
|
||||
"tools/linuxfs/preload/webhelper.c": "a8213a7a96b407459c83fb93365cfe58fd05964e7bb262b8061c1c0792a6aac8",
|
||||
"tools/linuxfs/preload/writewatch.c": "61e395d1caa184d329dead0e36c4e92cb1069b1154ac36581f37406c1c242240",
|
||||
"tools/linuxfs/preload/xmode.c": "9a09995bf52d40b07f16828bcc545b59b8fb1ba60d9cb09f14f7f31dba1e65a6",
|
||||
"tools/linuxfs/preload/zram.c": "12bcf07459728d4a7ede6fa0fea8deb330f7c5d0f0dd61e610e81b9efecd4262",
|
||||
"tools/linuxfs/ssbs/ssbs_adapter.c": "9e4e0fe637f7b8f91f12d8151f02e8d31bcb4294be2b2c62d3cd3ce76f200306",
|
||||
"tools/proot/fastpath/audit.c": "bfe347a2ddaceef40a78d7d590e4e679724ee4c82f3f1f1e3c7017a18ad536d4",
|
||||
"tools/proot/fastpath/fastpath.c": "4cd07b25ba14f6faa6bac5091ae323ded6b646dbb34b9e5a92ea6385e4d37cb5",
|
||||
"tools/quest/kgsl_compat.c": "111afffda7a6df2469610f6c342ae086b1a97a559c586efc4a28015b86efd6bd",
|
||||
"tools/quest/kgsl_compat.h": "2e9e0eb647530a35277954b7e61a22ee958067fe46056a608fb32f40f273f1bf"
|
||||
},
|
||||
"x86": {
|
||||
"@runner": "84f825635599f81ed33f62c5fc4c73f66044d1468b060d65f83855eb9c8bfe77",
|
||||
"app/src/main/cpp/adrenotools/src/hook/kgsl.h": "396c56761034a4ed783543ee3312c6ec64d63b2a1cf7eecf1939c23251f25adf",
|
||||
"app/src/main/cpp/fakeinput_steam.cpp": "3d11e859ca58a42a9da92a3fc589d404df790e151f7e18ea6114645750e70ef5",
|
||||
"app/src/main/cpp/venc/venc_proto.h": "2242ddbc8981d14a33bac70264bb3e7f701fd1c3ebb988e17bbb2b19b6b808f7",
|
||||
"tools/linuxfs/build-x86-preloads.sh": "d0820252809881db89db5a17427e74b9aa4964aae70623cb7f4b474e90c7a23b",
|
||||
"tools/linuxfs/debian-image.env": "1c79dea4314c784042a5c59208765c8401771098f293185d61a157d89edf6e52",
|
||||
"tools/linuxfs/fex/faultreport.c": "573bf780f32f7256dc2fbf40fe850d67e67c354509fdedcac3ff7f1a261daac3",
|
||||
"tools/linuxfs/fex/vulkanpin.c": "f2693ac2be8d15f7881115e61b1c6b3fe4aeec8f603584c6fce5b0f046563d51",
|
||||
"tools/linuxfs/fex/webkitinput.c": "693ffd6c8c8c97e87156444ad2255c84dbf22cd0053d135fb8d9be094b5534d1",
|
||||
"tools/linuxfs/preload/binfmt.c": "0933cc49cb53f0aa1206e2eae516d38dc3337e74174be07e10619c42aa56792b",
|
||||
"tools/linuxfs/preload/dircache.c": "8e7f19ea4a1198783d53a3f357326c6177da157b0cc7e0d22e1670963e1c26e7",
|
||||
"tools/linuxfs/preload/drm.c": "e0eabab0d8ed9e841918e827bf87168efa7f2dfb8404169e9bed3ab5eda2836c",
|
||||
"tools/linuxfs/preload/fsync.c": "795c114c2a05d3f250d07145d04c5658091699da3b96290da36348ccadfb0c09",
|
||||
"tools/linuxfs/preload/inputudev.c": "2648248d3d235a582eb8459709e0a85de537c03ac10c5040fbfb50d9846c68eb",
|
||||
"tools/linuxfs/preload/kgslid.c": "88a7875fd5289930204d155d92ac9d15492cd06db16ed87aa9c95af37f3e7089",
|
||||
"tools/linuxfs/preload/kgslpoll.c": "f0d853d919a52487c04cbda5fb3fa22269da54b7f4ee2f7dd3b5bd9909418670",
|
||||
"tools/linuxfs/preload/links.c": "b7bbcf9112393b152f358fe6f8dc9a1955f0c8532e1eddf016a971415cd13c64",
|
||||
"tools/linuxfs/preload/lock.c": "f71b3fd40e6a2b74908d3cdc601e8748699ae9c7a89b542d2445b999015ffd66",
|
||||
"tools/linuxfs/preload/net.c": "335853c8ea0e9a8ebbc5a5500dc4bded9c34c4310a6ab8aa46b07d5ce1c2b55e",
|
||||
"tools/linuxfs/preload/netif.c": "cc26d50b8d4639d8dd4697811bbf85c9d9f31761f9504a4af42473de3cb22b3c",
|
||||
"tools/linuxfs/preload/noexec.c": "1855aeaeda3d506329bd9af1107580c74d1f56787c411b2e01c0a8a9d4059c7b",
|
||||
"tools/linuxfs/preload/ntsync.c": "0614c48af0c062bfcb4c30141efe1b792b340767a67d2fe92ee9877d2ba16e0d",
|
||||
"tools/linuxfs/preload/opens.c": "92ae4aea16aa457a898dedf4a70eb332d80d3b1e77f3a60bace7715a4317399e",
|
||||
"tools/linuxfs/preload/pathcache.c": "eb0d4b5238fe6c8891e805d90bd837e466754100c978fad2d0ff717116b9b8a3",
|
||||
"tools/linuxfs/preload/perms.c": "f600619c4ca130f69001ed7ad7bd74a3dc215b14c61479c45bb770f916d244b9",
|
||||
"tools/linuxfs/preload/pulseguard.c": "57674ea40283e53a27bc78362de1ba41ee972d172ea38b1f818b1d6eed0abe65",
|
||||
"tools/linuxfs/preload/quest_kgsl.c": "59d9b8416be6a1c680f1d1e4c2427d2cbb7b415344261adb357d9d211ec95cfe",
|
||||
"tools/linuxfs/preload/robust.c": "9eb6c0ed50e0f48a8cfb86bd92587f471354bdf2531b9177f4b3ab83bdfed39a",
|
||||
"tools/linuxfs/preload/rptouch.c": "0e3f8bf2f9a41324361f38fa4da8d2d47593c9555f0cabf8228767397846c7c3",
|
||||
"tools/linuxfs/preload/space.c": "118389bcc89dfa2b4230b80915e21d2d4331c4cff1f5a58265f85e6ecb5c29d2",
|
||||
"tools/linuxfs/preload/storage.c": "08a8b46c3588f3160bb8608489768010ec36d5ccdb2b25a431ec9d6fcd413a6e",
|
||||
"tools/linuxfs/preload/sysv.c": "49774ee5e2e39b84dcfadf63abdc741b3df236cb11783744a1280adee36965e8",
|
||||
"tools/linuxfs/preload/tracefs.c": "be3f8a2f032b56e6e08a931e77a9386aea4bb93421a482271e06386ec0c469b6",
|
||||
"tools/linuxfs/preload/tracer.c": "f34e5377c891b0a8d00489245d66f96bc352df4cd90f47a951dcadae980af4c1",
|
||||
"tools/linuxfs/preload/udevmon.c": "2045dfb883cfb6e2016c359a3dc3af17f3b8f383f6dd0d5dfee407ef0d344852",
|
||||
"tools/linuxfs/preload/usr2.c": "6ae704380b45a9b3a74c4fe2b3ce4482470dae59ced26cf0aee64f4b4dcc11f9",
|
||||
"tools/linuxfs/preload/venc.c": "24c3c46fe49d28adfc8c977e52c9cc407f534b26f56d94b3425b8bb01803dba8",
|
||||
"tools/linuxfs/preload/vmwrite.c": "1a3ea2ec4354e0716c17f7db537b19ab82bcd524f2aece2fa5dec89b076a2188",
|
||||
"tools/linuxfs/preload/webhelper.c": "a8213a7a96b407459c83fb93365cfe58fd05964e7bb262b8061c1c0792a6aac8",
|
||||
"tools/linuxfs/preload/writewatch.c": "61e395d1caa184d329dead0e36c4e92cb1069b1154ac36581f37406c1c242240",
|
||||
"tools/linuxfs/preload/xmode.c": "9a09995bf52d40b07f16828bcc545b59b8fb1ba60d9cb09f14f7f31dba1e65a6",
|
||||
"tools/linuxfs/preload/zram.c": "12bcf07459728d4a7ede6fa0fea8deb330f7c5d0f0dd61e610e81b9efecd4262",
|
||||
"tools/quest/kgsl_compat.c": "111afffda7a6df2469610f6c342ae086b1a97a559c586efc4a28015b86efd6bd",
|
||||
"tools/quest/kgsl_compat.h": "2e9e0eb647530a35277954b7e61a22ee958067fe46056a608fb32f40f273f1bf"
|
||||
}
|
||||
},
|
||||
"origin": {
|
||||
"artifact": 12520502054,
|
||||
"artifact_sha256": "b7e800a1884a516ec52b050b7f904f9881427bca4579f660b909fd18f15e49ff",
|
||||
"commit": "b76f13f7acc0af0cc00369dde61fb88e40529e6d",
|
||||
"run": 39992155294,
|
||||
"url": "https://github.com/Droid-Deck/DroidDeck/actions/runs/39992155294"
|
||||
},
|
||||
"outputs": {
|
||||
"i386/libblsession.so": "5343cdb704217ddc81ee593e67d5987363dc7b5ac78bd4bd36000219e5063268",
|
||||
"i386/libfakeinput.so": "188d88dfb13b6e2f2df948e7b8b4d9ec604770f55d1ea5b6b9e21ad56a74ce5e",
|
||||
"i386/libfaultreport.so": "95f9ef60f04a13ee60cfbd4d2d2efb60a7063b722e646c78c9dc27162292877b",
|
||||
"libblaudit.so": "6c6abe89baf5d7309babee0c3372a4b00c2b689e2a63de38c5e9a660626509b5",
|
||||
"libblfastpath.so": "0e1f151b5c1c5ea9dd380ad58d09f8fe7ba3ae037d0991cb3eef6899e9d5ec83",
|
||||
"libblsession.so": "29d4b5ea46dba941107e02c0ee544244b137a339cada43bff65c350f2ef2755a",
|
||||
"libfakeinput.so": "5f6dc3aea05de2dc1fbe0bbfac2ce4d11e3d47f761c6b06c8badb15fe1904392",
|
||||
"libssbs.so": "c288ed0da26c2481aff270d1cdafe1205061c4a300c2c46ae1b53c6e0c94f44b",
|
||||
"usr/local/bin/droiddeck-clipboard": "ec50e8f67fdf76372927189b0fdb670f9b70fd3484f2fe3e833bc8f9fdc44205",
|
||||
"x86_64/libblsession.so": "61d19f06aebab6a789f8c99f687af9903376bfc853e46b70c48a2ce5e497accc",
|
||||
"x86_64/libfakeinput.so": "8663dd2086bf8ae53069a480dd9ae4619109d32f0947a29e2ce38f07a21ae2e6",
|
||||
"x86_64/libfaultreport.so": "bb0dc9165d0d764473e552508650edd586df16d620fc5b16b8b1c5740a28ce22",
|
||||
"x86_64/libvulkan-thunk.so": "74f01b652d7e8179561a096a552328b68da640cc4bad3981edd38e6afbf90243",
|
||||
"x86_64/libwebkitinput.so": "9b07380a7b017397b9c56bb7bb1161e046b0c6a647fc413888904606b0def6d0"
|
||||
},
|
||||
"toolchain": {
|
||||
"arm64": "Ubuntu 24.04 GCC cross compiler; exact build commands pinned by arm64_recipe",
|
||||
"x86": "Debian bullseye compiler image and recipe pinned by source inputs"
|
||||
},
|
||||
"version": 1,
|
||||
"x86_recipe": "36d06d49f7a4bff5ef675c1e03ce5a5b61498df4c36b9d15a938b41564f755cc"
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
import argparse
|
||||
import gzip
|
||||
import http.client
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tarfile
|
||||
import textwrap
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from zipfile import ZipFile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
REPO = 'Droid-Deck/DroidDeck'
|
||||
LOCK = 'tools/components/preloads.lock.json'
|
||||
DEFINITIONS = json.loads((ROOT / 'tools/components/recipes.json').read_text())
|
||||
INPUTS = {group: DEFINITIONS[name]['source_inputs'] for group, name in
|
||||
[('arm64', 'arm64-preloads'), ('x86', 'x86-preloads')]}
|
||||
OUTPUTS = {group: DEFINITIONS[name]['snapshot_outputs'] for group, name in
|
||||
[('arm64', 'arm64-preloads'), ('x86', 'x86-preloads')]}
|
||||
COMMON = [name for name in INPUTS['arm64'] if name in INPUTS['x86']]
|
||||
FILES = set(sum(OUTPUTS.values(), []))
|
||||
|
||||
|
||||
def sha(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def run(*args, root=ROOT):
|
||||
return subprocess.check_output(args, cwd=root)
|
||||
|
||||
|
||||
def api(path):
|
||||
return json.loads(run('gh', 'api', 'repos/' + REPO + '/' + path))
|
||||
|
||||
|
||||
def source_files(group, root=ROOT, commit=None, patterns=None):
|
||||
patterns = patterns if patterns is not None else INPUTS[group]
|
||||
if commit:
|
||||
paths = run('git', 'ls-tree', '-r', '--name-only', commit, '--', *patterns, root=root).decode().splitlines()
|
||||
read = lambda path: run('git', 'show', f'{commit}:{path}', root=root)
|
||||
else:
|
||||
paths = run('git', 'ls-files', '--cached', '--others', '--exclude-standard', '--', *patterns, root=root).decode().splitlines()
|
||||
read = lambda path: (root / path).read_bytes()
|
||||
paths = [p for p in paths if not p.endswith('.md') and '__pycache__' not in p and not p.endswith('.pyc')]
|
||||
if not paths:
|
||||
raise ValueError('No preload inputs found')
|
||||
result = {}
|
||||
pending = list(paths)
|
||||
while pending:
|
||||
path = pending.pop()
|
||||
if path in result:
|
||||
continue
|
||||
if path.startswith('../') or path.startswith('/'):
|
||||
raise ValueError('Preload include escapes repository')
|
||||
content = read(path).replace(b'\r\n', b'\n')
|
||||
result[path] = sha(content)
|
||||
for include in re.findall(rb'^\s*#\s*include\s*"([^"\n]+)"', content, re.M):
|
||||
pending.append(posixpath.normpath(posixpath.join(posixpath.dirname(path), include.decode())))
|
||||
workflow = (run('git', 'show', f'{commit}:.github/workflows/build.yml', root=root).decode() if commit
|
||||
else (root / '.github/workflows/build.yml').read_text())
|
||||
job = 'components' if re.search(r'(?m)^ components:', workflow) else 'build'
|
||||
runner = re.search(r'(?ms)^ ' + job + r':\n.*?^ runs-on: ([^\n]+)', workflow)
|
||||
if runner is None:
|
||||
raise ValueError('APK build runner policy is missing')
|
||||
result['@runner'] = sha(runner[1].strip().encode())
|
||||
return dict(sorted(result.items()))
|
||||
|
||||
|
||||
def recipe(root=ROOT, commit=None):
|
||||
def read(path):
|
||||
return (run('git', 'show', f'{commit}:{path}', root=root).decode() if commit
|
||||
else (root / path).read_text())
|
||||
script = 'tools/components/build-arm64-preloads.sh'
|
||||
if commit and run('git', 'ls-tree', commit, script, root=root) == b'':
|
||||
workflow = read('.github/workflows/build.yml')
|
||||
text = workflow[workflow.index(' aarch64-linux-gnu-g++ -shared'):]
|
||||
text = textwrap.dedent(text[:text.index(' VK_INCLUDE=')])
|
||||
else:
|
||||
text = read(script)
|
||||
preamble = '#!/usr/bin/env bash\nset -euo pipefail\nD=${1:?output directory}\nmkdir -p "$D"\n'
|
||||
if not text.startswith(preamble):
|
||||
return sha(text.encode())
|
||||
text = text[len(preamble):]
|
||||
return sha(text.replace('\r\n', '\n').encode())
|
||||
|
||||
|
||||
def x86_recipe(root=ROOT, commit=None):
|
||||
path = 'tools/components/recipes/x86-preloads.sh'
|
||||
if commit and not run('git', 'ls-tree', commit, path, root=root):
|
||||
workflow = run('git', 'show', f'{commit}:.github/workflows/build.yml', root=root).decode()
|
||||
section = workflow[workflow.index(' - name: Build the x86 preloads'):]
|
||||
text = section.split(' run: |\n', 1)[1].split('\n - name:', 1)[0]
|
||||
text = textwrap.dedent(text).rstrip() + '\n'
|
||||
else:
|
||||
text = (run('git', 'show', f'{commit}:{path}', root=root).decode() if commit
|
||||
else (root / path).read_text())
|
||||
text = text.removeprefix('#!/usr/bin/env bash\n')
|
||||
return sha(text.replace('\r\n', '\n').encode())
|
||||
|
||||
|
||||
def artifact_bytes(origin, cache):
|
||||
build = api(f"actions/runs/{origin['run']}")
|
||||
if (build['event'] != 'push' or build['head_branch'] != 'main' or build['conclusion'] != 'success'
|
||||
or build['head_sha'] != origin['commit'] or build['path'] != '.github/workflows/build.yml'
|
||||
or build['repository']['full_name'] != REPO):
|
||||
raise ValueError('Snapshot is not from a successful main APK build')
|
||||
artifact = api(f"actions/artifacts/{origin['artifact']}")
|
||||
if (artifact['name'] != 'droiddeck-apk' or artifact['workflow_run']['id'] != origin['run']
|
||||
or artifact['digest'] != 'sha256:' + origin['artifact_sha256']):
|
||||
raise ValueError('Original APK artifact identity or digest mismatch')
|
||||
cache.mkdir(parents=True, exist_ok=True)
|
||||
path = cache / (origin['artifact_sha256'] + '.zip')
|
||||
if not path.exists():
|
||||
path.write_bytes(run('gh', 'api', f"repos/{REPO}/actions/artifacts/{origin['artifact']}/zip"))
|
||||
content = path.read_bytes()
|
||||
if sha(content) != origin['artifact_sha256']:
|
||||
raise ValueError('Original APK archive checksum mismatch')
|
||||
with ZipFile(io.BytesIO(content)) as archive:
|
||||
names = [name for name in archive.namelist() if name.endswith('.apk')]
|
||||
if len(names) != 1:
|
||||
raise ValueError('Expected one original APK')
|
||||
with ZipFile(io.BytesIO(archive.read(names[0]))) as apk:
|
||||
return {name: apk.read('assets/linuxfs/' + name) for name in FILES}
|
||||
|
||||
|
||||
def validate_lock(data):
|
||||
if data.get('version') != 1 or set(data['groups']) != set(INPUTS):
|
||||
raise ValueError('Unsupported preload snapshot')
|
||||
if set(data['outputs']) != FILES:
|
||||
raise ValueError('Unexpected preload output set')
|
||||
for digest in [data['archive_sha256'], *data['outputs'].values()]:
|
||||
if len(digest) != 64 or any(c not in '0123456789abcdef' for c in digest):
|
||||
raise ValueError('Invalid preload checksum')
|
||||
|
||||
|
||||
def producer_sources(group, commit, root=ROOT):
|
||||
config = 'tools/components/recipes.json'
|
||||
if run('git', 'ls-tree', commit, config, root=root):
|
||||
definitions = json.loads(run('git', 'show', f'{commit}:{config}', root=root))
|
||||
name = 'arm64-preloads' if group == 'arm64' else 'x86-preloads'
|
||||
patterns = definitions[name]['source_inputs']
|
||||
else:
|
||||
if group == 'arm64':
|
||||
text = run('git', 'show', f'{commit}:.github/workflows/build.yml', root=root).decode()
|
||||
text = text[text.index(' aarch64-linux-gnu-g++ -shared'):]
|
||||
text = text[:text.index(' VK_INCLUDE=')]
|
||||
else:
|
||||
text = run('git', 'show', f'{commit}:tools/linuxfs/build-x86-preloads.sh', root=root).decode()
|
||||
patterns = re.findall(r'\b((?:tools|app)/[\w./*+-]+\.(?:cpp|c|h))(?=\s|$)', text)
|
||||
if group == 'x86':
|
||||
patterns += ['tools/linuxfs/fex', 'tools/linuxfs/build-x86-preloads.sh', 'tools/linuxfs/debian-image.env']
|
||||
return source_files(group, root, commit, patterns)
|
||||
|
||||
|
||||
def prove_origin(data, cache, root=ROOT):
|
||||
content = artifact_bytes(data['origin'], cache)
|
||||
if {name: sha(value) for name, value in content.items()} != data['outputs']:
|
||||
raise ValueError('Snapshot binaries differ from the original main APK')
|
||||
commit = data['origin']['commit']
|
||||
run('git', 'fetch', '--no-tags', 'origin', commit, root=root)
|
||||
for group in INPUTS:
|
||||
if source_files(group, root, commit) != data['groups'][group]:
|
||||
raise ValueError('Snapshot inputs differ from the producing source')
|
||||
for name, checksum in producer_sources(group, commit, root).items():
|
||||
if data['groups'][group].get(name) != checksum:
|
||||
raise ValueError('Snapshot omits or changes a producing build dependency')
|
||||
if recipe(root, commit) != data['arm64_recipe']:
|
||||
raise ValueError('Snapshot recipe differs from the producing source')
|
||||
if x86_recipe(root, commit) != data['x86_recipe']:
|
||||
raise ValueError('Snapshot x86 recipe differs from the producing source')
|
||||
|
||||
|
||||
def unpack(content, data):
|
||||
if sha(content) != data['archive_sha256']:
|
||||
raise ValueError('Preload archive checksum mismatch')
|
||||
result = {}
|
||||
total = 0
|
||||
with tarfile.open(fileobj=io.BytesIO(content), mode='r:gz') as archive:
|
||||
for entry in archive:
|
||||
if entry.name not in FILES or entry.name in result or not entry.isfile() or entry.size > 32 * 1024 * 1024:
|
||||
raise ValueError('Unsafe or unexpected preload archive entry')
|
||||
total += entry.size
|
||||
if total > 64 * 1024 * 1024:
|
||||
raise ValueError('Preload archive exceeds expanded size limit')
|
||||
value = archive.extractfile(entry).read()
|
||||
if sha(value) != data['outputs'][entry.name]:
|
||||
raise ValueError('Preload binary checksum mismatch')
|
||||
result[entry.name] = value
|
||||
if set(result) != FILES:
|
||||
raise ValueError('Incomplete preload archive')
|
||||
return result
|
||||
|
||||
|
||||
def restore(root=ROOT):
|
||||
data = json.loads((root / LOCK).read_text())
|
||||
validate_lock(data)
|
||||
matching = {group: source_files(group, root) == data['groups'][group] for group in INPUTS}
|
||||
matching['arm64'] &= recipe(root) == data['arm64_recipe']
|
||||
matching['x86'] &= x86_recipe(root) == data.get('x86_recipe')
|
||||
if os.environ.get('FORCE_PRELOAD_REBUILD') == 'true':
|
||||
matching = dict.fromkeys(INPUTS, False)
|
||||
if any(matching.values()):
|
||||
base = os.environ.get('COMPONENT_TRUSTED_BASE')
|
||||
approved = None
|
||||
if base:
|
||||
result = subprocess.run(['git', 'show', f'{base}:{LOCK}'], cwd=root, capture_output=True)
|
||||
if result.returncode == 0:
|
||||
approved = json.loads(result.stdout)
|
||||
if approved != data:
|
||||
try:
|
||||
prove_origin(data, root / 'app/build/component-downloads', root)
|
||||
except (subprocess.CalledProcessError, OSError, http.client.HTTPException):
|
||||
print('Snapshot origin is unavailable; rebuilding without trusting the snapshot.')
|
||||
matching = dict.fromkeys(INPUTS, False)
|
||||
if any(matching.values()):
|
||||
url = (f"https://github.com/Droid-Deck/DroidDeck-Components/releases/download/"
|
||||
f"preloads-{data['archive_sha256']}/preloads.tar.gz")
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=60) as response:
|
||||
content = response.read(64 * 1024 * 1024)
|
||||
except (OSError, http.client.HTTPException) as error:
|
||||
if isinstance(error, urllib.error.HTTPError) and error.code not in (404, 429) and error.code < 500:
|
||||
raise
|
||||
print('Preload snapshot is unavailable; rebuilding from source.')
|
||||
matching = dict.fromkeys(INPUTS, False)
|
||||
else:
|
||||
binaries = unpack(content, data)
|
||||
for group, matches in matching.items():
|
||||
if matches:
|
||||
for name in OUTPUTS[group]:
|
||||
path = root / 'app/src/main/assets/linuxfs' / name
|
||||
if not path.resolve().is_relative_to(root.resolve()) or path.is_symlink():
|
||||
raise ValueError('Preload output escapes repository or is a symlink')
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(binaries[name])
|
||||
path.chmod(0o755 if name.endswith('droiddeck-clipboard') else 0o644)
|
||||
for group, matches in matching.items():
|
||||
print(f"{group}: {'verified snapshot reused' if matches else 'inputs changed or snapshot unavailable; rebuild required'}")
|
||||
if os.environ.get('GITHUB_OUTPUT'):
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
||||
output.write(f'{group}={str(matches).lower()}\n')
|
||||
return matching
|
||||
|
||||
|
||||
def snapshot(run_id, destination, root=ROOT):
|
||||
build = api(f'actions/runs/{run_id}')
|
||||
candidates = api(f'actions/runs/{run_id}/artifacts?per_page=100')['artifacts']
|
||||
artifact = next(a for a in candidates if a['name'] == 'droiddeck-apk')
|
||||
origin = dict(run=run_id, commit=build['head_sha'], artifact=artifact['id'],
|
||||
artifact_sha256=artifact['digest'].removeprefix('sha256:'),
|
||||
url=build['html_url'])
|
||||
content = artifact_bytes(origin, root / 'app/build/component-downloads')
|
||||
run('git', 'fetch', '--no-tags', 'origin', origin['commit'], root=root)
|
||||
data = dict(version=1, origin=origin, groups={g: source_files(g, root, origin['commit']) for g in INPUTS},
|
||||
arm64_recipe=recipe(root, origin['commit']), x86_recipe=x86_recipe(root, origin['commit']),
|
||||
outputs={name: sha(value) for name, value in content.items()},
|
||||
toolchain=dict(arm64='Ubuntu 24.04 GCC cross compiler; exact build commands pinned by arm64_recipe',
|
||||
x86='Debian bullseye compiler image and recipe pinned by source inputs'))
|
||||
stream = io.BytesIO()
|
||||
with gzip.GzipFile(fileobj=stream, mode='wb', mtime=0) as compressed:
|
||||
with tarfile.open(fileobj=compressed, mode='w') as archive:
|
||||
for name, value in sorted(content.items()):
|
||||
entry = tarfile.TarInfo(name)
|
||||
entry.size, entry.mode = len(value), 0o644
|
||||
archive.addfile(entry, io.BytesIO(value))
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
(destination / 'preloads.tar.gz').write_bytes(stream.getvalue())
|
||||
data['archive_sha256'] = sha(stream.getvalue())
|
||||
(root / LOCK).write_text(json.dumps(data, indent=2, sort_keys=True) + '\n')
|
||||
print('Snapshot SHA-256: ' + data['archive_sha256'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('operation', choices=['restore', 'snapshot'])
|
||||
parser.add_argument('--run', type=int)
|
||||
parser.add_argument('--out', type=Path, default=ROOT / 'app/build/component-snapshot')
|
||||
args = parser.parse_args()
|
||||
if args.operation == 'restore':
|
||||
restore()
|
||||
else:
|
||||
snapshot(args.run, args.out)
|
||||
@@ -0,0 +1,166 @@
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path, PurePosixPath
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
REGISTRY = 'tools/components/recipes.json'
|
||||
TREES = ['app/src/main/assets/linuxfs', 'app/src/main/assets/directaudio',
|
||||
'app/src/main/assets/droiddeck-esync', 'app/build/prepared-assets',
|
||||
'app/build/component-records']
|
||||
LIBRARIES = ['app/src/main/jniLibs/arm64-v8a/' + name for name in
|
||||
('libproot.so', 'libproot-loader.so', 'libdirectaudiorelay.so')]
|
||||
MANIFEST = 'app/build/prepared-components.json'
|
||||
|
||||
|
||||
def digest(path):
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def registry(root=ROOT):
|
||||
return json.loads((root / REGISTRY).read_text())
|
||||
|
||||
|
||||
def identity(name, root=ROOT):
|
||||
spec = registry(root)[name]
|
||||
paths = subprocess.check_output(['git', 'ls-files', '--cached', '--others', '--exclude-standard',
|
||||
'--', *spec['inputs'], *spec.get('source_inputs', [])], cwd=root, text=True).splitlines()
|
||||
values = {}
|
||||
for name_ in sorted(set(paths)):
|
||||
if '__pycache__' in name_ or name_.endswith(('.pyc', '.md')):
|
||||
continue
|
||||
content = (root / name_).read_bytes()
|
||||
if b'\0' not in content:
|
||||
content = content.replace(b'\r\n', b'\n')
|
||||
values[name_] = hashlib.sha256(content).hexdigest()
|
||||
policy = dict(spec=spec, sources=values, runner=os.environ.get('RUNNER_OS', 'Linux'),
|
||||
architecture=os.environ.get('RUNNER_ARCH', 'X64'))
|
||||
entrypoint = root / 'tools/components/prepare.py'
|
||||
if entrypoint.is_file():
|
||||
policy['entrypoint'] = hashlib.sha256(entrypoint.read_bytes().replace(b'\r\n', b'\n')).hexdigest()
|
||||
installer = root / 'tools/ci/install-ubuntu-packages.sh'
|
||||
if spec.get('packages') and installer.is_file():
|
||||
policy['installer'] = hashlib.sha256(installer.read_bytes().replace(b'\r\n', b'\n')).hexdigest()
|
||||
if spec.get('ndk'):
|
||||
policy['ndk'] = os.environ.get('NDK_VERSION', '')
|
||||
policy['ndk_policy'] = hashlib.sha256((root / 'tools/ci/toolchains.env').read_bytes().replace(b'\r\n', b'\n')).hexdigest()
|
||||
return hashlib.sha256(json.dumps(policy, sort_keys=True).encode()).hexdigest()
|
||||
|
||||
|
||||
def prepare(name, root=ROOT):
|
||||
spec = registry(root)[name]
|
||||
prepare_tools([name], root)
|
||||
if 'command' in spec:
|
||||
command = spec['command']
|
||||
else:
|
||||
script = (root / spec['script']).resolve()
|
||||
if not script.is_relative_to((root / 'tools/components').resolve()):
|
||||
raise ValueError('Recipe script escapes components directory')
|
||||
command = ['bash', str(script)]
|
||||
environment = dict(os.environ)
|
||||
if spec.get('source'):
|
||||
environment.update(COMPONENT_SOURCE_URL=spec['source']['url'],
|
||||
COMPONENT_SOURCE_SHA256=spec['source']['sha256'])
|
||||
subprocess.run(command, cwd=root, env=environment, check=True)
|
||||
missing = [name_ for name_ in spec['outputs'] if not (root / name_).is_file()]
|
||||
if missing:
|
||||
raise ValueError(f'{name} did not prepare required outputs: {missing}')
|
||||
record = dict(component=name, input_sha256=identity(name, root),
|
||||
outputs={p: digest(root / p) for p in spec['outputs']})
|
||||
destination = root / 'app/build/component-records' / (name + '.json')
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
destination.write_text(json.dumps(record, sort_keys=True, indent=2) + '\n')
|
||||
|
||||
|
||||
def prepare_tools(names, root=ROOT):
|
||||
packages = sorted({package for name in names for package in registry(root)[name].get('packages', [])})
|
||||
if packages:
|
||||
subprocess.run(['bash', 'tools/ci/install-ubuntu-packages.sh', *packages], cwd=root, check=True)
|
||||
|
||||
|
||||
def files(root=ROOT):
|
||||
result = []
|
||||
for name in TREES:
|
||||
folder = root / name
|
||||
if not folder.is_dir() or folder.is_symlink():
|
||||
raise ValueError('Missing prepared component tree: ' + name)
|
||||
for path in folder.rglob('*'):
|
||||
if path.is_symlink():
|
||||
raise ValueError('Symlink in prepared components: ' + str(path))
|
||||
if path.is_file():
|
||||
result.append(path.relative_to(root).as_posix())
|
||||
for name in LIBRARIES:
|
||||
if not (root / name).is_file() or (root / name).is_symlink():
|
||||
raise ValueError('Missing prepared component library: ' + name)
|
||||
result.append(name)
|
||||
return sorted(result)
|
||||
|
||||
|
||||
def pack(destination, root=ROOT):
|
||||
names = files(root)
|
||||
tree = subprocess.check_output(['git', 'rev-parse', 'HEAD^{tree}'], cwd=root, text=True).strip()
|
||||
data = dict(version=1, source_tree=tree, run=os.environ.get('GITHUB_RUN_ID', ''),
|
||||
recipes={name: identity(name, root) for name in registry(root)},
|
||||
files={name: digest(root / name) for name in names})
|
||||
(root / MANIFEST).write_text(json.dumps(data, sort_keys=True, indent=2) + '\n')
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
with tarfile.open(destination, mode='w:gz', compresslevel=1) as archive:
|
||||
for name in names + [MANIFEST]:
|
||||
archive.add(root / name, arcname=name, recursive=False)
|
||||
|
||||
|
||||
def unpack(archive_path, source_tree, root=ROOT):
|
||||
total = 0
|
||||
seen = set()
|
||||
with tarfile.open(archive_path, mode='r:gz') as archive:
|
||||
for entry in archive:
|
||||
allowed = entry.name in LIBRARIES + [MANIFEST] or any(entry.name.startswith(p + '/') for p in TREES)
|
||||
path = root / entry.name
|
||||
total += entry.size
|
||||
if (not allowed or '\\' in entry.name or '..' in PurePosixPath(entry.name).parts
|
||||
or PurePosixPath(entry.name).as_posix() != entry.name
|
||||
or not entry.isfile() or entry.name in seen or len(seen) >= 100000
|
||||
or entry.size > 512 * 1024 * 1024
|
||||
or total > 2 * 1024**3 or not path.resolve().is_relative_to(root.resolve())
|
||||
or path.is_symlink()):
|
||||
raise ValueError('Unsafe prepared component archive')
|
||||
seen.add(entry.name)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open('wb') as output:
|
||||
shutil.copyfileobj(archive.extractfile(entry), output)
|
||||
path.chmod(entry.mode & 0o777)
|
||||
data = json.loads((root / MANIFEST).read_text())
|
||||
actual = {name: digest(root / name) for name in files(root)}
|
||||
recipes = {name: identity(name, root) for name in registry(root)}
|
||||
if (data.get('version') != 1 or data['source_tree'] != source_tree or data['files'] != actual
|
||||
or data['recipes'] != recipes):
|
||||
raise ValueError('Prepared components do not match the pinned source tree and file hashes')
|
||||
print('Prepared component source identity and all output hashes verified.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('recipe')
|
||||
parser.add_argument('--archive', type=Path, default=ROOT / 'app/build/prepared-components.tar.gz')
|
||||
parser.add_argument('--tree')
|
||||
args = parser.parse_args()
|
||||
if args.recipe == 'plan':
|
||||
for name in registry():
|
||||
value = identity(name)
|
||||
print(f'{name}: {value}')
|
||||
if os.environ.get('GITHUB_OUTPUT'):
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as stream:
|
||||
stream.write(f'{name}={value}\n')
|
||||
elif args.recipe == 'tools':
|
||||
prepare_tools(os.environ.get('COMPONENTS_TO_BUILD', '').split())
|
||||
elif args.recipe == 'pack':
|
||||
pack(args.archive)
|
||||
elif args.recipe == 'unpack':
|
||||
unpack(args.archive, args.tree)
|
||||
else:
|
||||
prepare(args.recipe)
|
||||
@@ -0,0 +1,243 @@
|
||||
{
|
||||
"runtime": {
|
||||
"script": "tools/components/recipes/runtime.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/runtime.sh",
|
||||
"tools/quest",
|
||||
"tools/linuxfs/overlay",
|
||||
"tools/linuxfs/desktop",
|
||||
"tools/linuxfs/licenses",
|
||||
"tools/linuxfs/uruntime.env",
|
||||
"tools/gamescope/release.env",
|
||||
"tools/wlroots/release.env",
|
||||
"tools/mangoapp",
|
||||
"tools/msitools",
|
||||
"tools/pipewire",
|
||||
"tools/vr",
|
||||
"tools/gpuload",
|
||||
"app/src/main/cpp/waylandcomp/generated",
|
||||
"app/src/main/cpp/waylandcomp/src/headpose_shm.h",
|
||||
"app/src/main/cpp/waylandcomp/src/spatialpose_shm.h",
|
||||
"app/src/main/cpp/venc/venc_proto.h"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/bin/gamescope",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-vr/droiddeck/bin/linuxarm64/driver_droiddeck.so",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-gpuload/libVkLayer_droiddeck_gpuload.so"
|
||||
],
|
||||
"ndk": true,
|
||||
"packages": [
|
||||
"gcc-aarch64-linux-gnu",
|
||||
"g++-aarch64-linux-gnu",
|
||||
"libvulkan1",
|
||||
"mesa-vulkan-drivers"
|
||||
]
|
||||
},
|
||||
"esync": {
|
||||
"script": "tools/components/recipes/esync.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/esync.sh",
|
||||
"tools/droiddeck-esync/release.env"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/droiddeck-esync/index.json",
|
||||
"app/src/main/assets/droiddeck-esync/index.json.sig"
|
||||
]
|
||||
},
|
||||
"debian-image": {
|
||||
"script": "tools/components/recipes/debian-image.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/debian-image.sh"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
"x86-preloads": {
|
||||
"script": "tools/components/recipes/x86-preloads.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/x86-preloads.sh",
|
||||
"tools/linuxfs/build-x86-preloads.sh",
|
||||
"tools/linuxfs/preload",
|
||||
"tools/linuxfs/fex"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/x86_64/libfakeinput.so",
|
||||
"app/src/main/assets/linuxfs/x86_64/libblsession.so",
|
||||
"app/src/main/assets/linuxfs/x86_64/libfaultreport.so",
|
||||
"app/src/main/assets/linuxfs/i386/libfakeinput.so",
|
||||
"app/src/main/assets/linuxfs/i386/libblsession.so",
|
||||
"app/src/main/assets/linuxfs/i386/libfaultreport.so",
|
||||
"app/src/main/assets/linuxfs/x86_64/libwebkitinput.so",
|
||||
"app/src/main/assets/linuxfs/x86_64/libvulkan-thunk.so"
|
||||
],
|
||||
"source_inputs": [
|
||||
"app/src/main/cpp/fakeinput_steam.cpp",
|
||||
"app/src/main/cpp/adrenotools/src/hook/kgsl.h",
|
||||
"app/src/main/cpp/venc/venc_proto.h",
|
||||
"tools/linuxfs/preload",
|
||||
"tools/quest/kgsl_compat.c",
|
||||
"tools/quest/kgsl_compat.h",
|
||||
"tools/linuxfs/fex",
|
||||
"tools/linuxfs/build-x86-preloads.sh",
|
||||
"tools/linuxfs/debian-image.env"
|
||||
],
|
||||
"snapshot_outputs": [
|
||||
"x86_64/libfakeinput.so",
|
||||
"x86_64/libblsession.so",
|
||||
"x86_64/libfaultreport.so",
|
||||
"i386/libfakeinput.so",
|
||||
"i386/libblsession.so",
|
||||
"i386/libfaultreport.so",
|
||||
"x86_64/libwebkitinput.so",
|
||||
"x86_64/libvulkan-thunk.so"
|
||||
]
|
||||
},
|
||||
"pulseaudio-source": {
|
||||
"script": "tools/components/recipes/pulseaudio-source.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/pulseaudio-source.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"pa13/src/pulsecore/module.h"
|
||||
],
|
||||
"source": {
|
||||
"url": "https://github.com/pulseaudio/pulseaudio/archive/refs/tags/v13.0.tar.gz",
|
||||
"sha256": "bd7980bc9bd44bd3b3363545dabd19476ebf4d6bb6d2527e7d179256394a6758"
|
||||
}
|
||||
},
|
||||
"directaudio": {
|
||||
"script": "tools/components/recipes/directaudio.sh",
|
||||
"inputs": [
|
||||
"tools/components/recipes/directaudio.sh",
|
||||
"tools/directaudio"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so"
|
||||
],
|
||||
"ndk": true
|
||||
},
|
||||
"audio": {
|
||||
"script": "tools/components/recipes/audio.sh",
|
||||
"inputs": [
|
||||
"tools/aaudio-sink",
|
||||
"tools/directaudio",
|
||||
"tools/components/recipes/audio.sh",
|
||||
"app/src/main/assets/pulseaudio.tzst"
|
||||
],
|
||||
"outputs": [
|
||||
"app/build/prepared-assets/pulseaudio.tzst"
|
||||
],
|
||||
"ndk": true
|
||||
},
|
||||
"proot": {
|
||||
"script": "tools/components/recipes/proot.sh",
|
||||
"inputs": [
|
||||
"tools/proot",
|
||||
"tools/components/recipes/proot.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/jniLibs/arm64-v8a/libproot.so",
|
||||
"app/src/main/jniLibs/arm64-v8a/libproot-loader.so"
|
||||
],
|
||||
"ndk": true
|
||||
},
|
||||
"comet": {
|
||||
"script": "tools/components/recipes/comet.sh",
|
||||
"inputs": [
|
||||
"tools/comet",
|
||||
"tools/components/recipes/comet.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet/comet",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet/version"
|
||||
],
|
||||
"packages": [
|
||||
"gcc-aarch64-linux-gnu"
|
||||
]
|
||||
},
|
||||
"arm64-preloads": {
|
||||
"script": "tools/components/recipes/arm64-preloads.sh",
|
||||
"inputs": [
|
||||
"tools/components/build-arm64-preloads.sh",
|
||||
"tools/linuxfs/preload",
|
||||
"app/src/main/cpp/fakeinput_steam.cpp",
|
||||
"tools/components/recipes/arm64-preloads.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/libfakeinput.so",
|
||||
"app/src/main/assets/linuxfs/libblsession.so",
|
||||
"app/src/main/assets/linuxfs/libblfastpath.so",
|
||||
"app/src/main/assets/linuxfs/libblaudit.so",
|
||||
"app/src/main/assets/linuxfs/libssbs.so",
|
||||
"app/src/main/assets/linuxfs/usr/local/bin/droiddeck-clipboard"
|
||||
],
|
||||
"packages": [
|
||||
"gcc-aarch64-linux-gnu",
|
||||
"g++-aarch64-linux-gnu"
|
||||
],
|
||||
"source_inputs": [
|
||||
"app/src/main/cpp/fakeinput_steam.cpp",
|
||||
"app/src/main/cpp/adrenotools/src/hook/kgsl.h",
|
||||
"app/src/main/cpp/venc/venc_proto.h",
|
||||
"tools/linuxfs/preload",
|
||||
"tools/quest/kgsl_compat.c",
|
||||
"tools/quest/kgsl_compat.h",
|
||||
"tools/proot/fastpath",
|
||||
"tools/linuxfs/ssbs",
|
||||
"tools/linuxfs/clipboard"
|
||||
],
|
||||
"snapshot_outputs": [
|
||||
"libfakeinput.so",
|
||||
"libblsession.so",
|
||||
"libblfastpath.so",
|
||||
"libblaudit.so",
|
||||
"libssbs.so",
|
||||
"usr/local/bin/droiddeck-clipboard"
|
||||
]
|
||||
},
|
||||
"preload-snapshot": {
|
||||
"command": [
|
||||
"python3",
|
||||
"tools/components/preloads.py",
|
||||
"restore"
|
||||
],
|
||||
"inputs": [
|
||||
"tools/components/preloads.py",
|
||||
"tools/components/preloads.lock.json"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
"xbox": {
|
||||
"script": "tools/components/recipes/xbox.sh",
|
||||
"inputs": [
|
||||
"tools/xbox",
|
||||
"tools/components/recipes/xbox.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox/xodus-cli",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox/xodus-service"
|
||||
],
|
||||
"packages": [
|
||||
"build-essential",
|
||||
"pkg-config",
|
||||
"libssl-dev",
|
||||
"protobuf-compiler",
|
||||
"cmake",
|
||||
"xz-utils"
|
||||
]
|
||||
},
|
||||
"dirt-ws2": {
|
||||
"script": "tools/components/recipes/dirt-ws2.sh",
|
||||
"inputs": [
|
||||
"tools/dirt-ws2",
|
||||
"tools/components/recipes/dirt-ws2.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt/ws2_32.dll"
|
||||
],
|
||||
"packages": [
|
||||
"clang",
|
||||
"lld",
|
||||
"llvm"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
bash tools/components/build-arm64-preloads.sh app/src/main/assets/linuxfs
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
|
||||
tools/aaudio-sink/build.sh "$PWD/pa13" "$PWD/sink-out"
|
||||
rm -rf pa-bundle && mkdir -p pa-bundle
|
||||
tar --use-compress-program=unzstd -xf app/src/main/assets/pulseaudio.tzst -C pa-bundle
|
||||
test ! -f pa-bundle/modules/arm64/module-aaudio-sink.so
|
||||
install -m755 sink-out/module-aaudio-sink.so pa-bundle/modules/arm64/module-aaudio-sink.so
|
||||
install -m755 sink-out/module-directaudio-native-sink.so pa-bundle/modules/arm64/module-directaudio-native-sink.so
|
||||
(cd pa-bundle && tar --use-compress-program='zstd -19' -cf ../pulseaudio.tzst .)
|
||||
mkdir -p app/build/prepared-assets
|
||||
mv pulseaudio.tzst app/build/prepared-assets/pulseaudio.tzst
|
||||
tar --use-compress-program=unzstd -tf app/build/prepared-assets/pulseaudio.tzst | grep -c '\.so$'
|
||||
rm -rf pa-bundle sink-out
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
rustup toolchain install 1.90.0 --profile minimal
|
||||
rustup target add --toolchain 1.90.0 aarch64-unknown-linux-gnu
|
||||
RUSTUP_TOOLCHAIN=1.90.0 bash tools/comet/build.sh
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
. tools/linuxfs/debian-image.env
|
||||
image=public.ecr.aws/docker/library/debian:bullseye
|
||||
if gh release download "$DEBIAN_IMAGE_TAG" -R "$GITHUB_REPOSITORY" -p "$DEBIAN_IMAGE_ASSET" -O /tmp/debian-image.tar.zst \
|
||||
&& { [ -z "$DEBIAN_IMAGE_SHA256" ] || echo "$DEBIAN_IMAGE_SHA256 /tmp/debian-image.tar.zst" | sha256sum -c -; }; then
|
||||
zstd -dc /tmp/debian-image.tar.zst | docker load
|
||||
rm -f /tmp/debian-image.tar.zst
|
||||
else
|
||||
echo "::warning::the hosted Debian image could not be fetched; pulling from the registry instead"
|
||||
for attempt in 1 2 3 4 5; do
|
||||
docker pull "$image" && break
|
||||
[ "$attempt" -lt 5 ] || { echo "::error::could not pull $image after $attempt attempts"; exit 1; }
|
||||
echo "pull attempt $attempt failed (registry busy?); retrying in $((attempt * 30)) s"
|
||||
sleep $((attempt * 30))
|
||||
done
|
||||
fi
|
||||
docker image ls "$image"
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
tools/directaudio/fetch.sh "$PWD" "$PWD/sink-out"
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
bash tools/dirt-ws2/build.sh app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ -f tools/droiddeck-esync/release.env ]; then
|
||||
. tools/droiddeck-esync/release.env
|
||||
release_url="https://github.com/${SYNC_BUNDLE_REPO}/releases/download/${SYNC_BUNDLE_TAG}"
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o sync-bundle.tzst "$release_url/$SYNC_BUNDLE_ASSET"
|
||||
echo "$SYNC_BUNDLE_SHA256 sync-bundle.tzst" | sha256sum -c -
|
||||
mkdir -p app/src/main/assets/droiddeck-esync
|
||||
tar --use-compress-program=unzstd -xf sync-bundle.tzst -C app/src/main/assets/droiddeck-esync
|
||||
rm sync-bundle.tzst
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o sync-index.json "$release_url/index.json"
|
||||
revoked=$(python3 -c 'import json, sys; print(" ".join(p["id"] for p in json.load(open(sys.argv[1]))["packs"] if p.get("revoked") is True))' sync-index.json)
|
||||
for id in $revoked; do
|
||||
if [ -e "app/src/main/assets/droiddeck-esync/packs/$id.tzst" ]; then
|
||||
echo "::warning::$SYNC_BUNDLE_ASSET carries revoked pack $id; it is left out of the APK (point tools/droiddeck-esync/release.env at a newer bundle)"
|
||||
rm -f "app/src/main/assets/droiddeck-esync/packs/$id.tzst"
|
||||
fi
|
||||
done
|
||||
rm sync-index.json
|
||||
test -f app/src/main/assets/droiddeck-esync/index.json
|
||||
test -f app/src/main/assets/droiddeck-esync/index.json.sig
|
||||
ls -lR app/src/main/assets/droiddeck-esync
|
||||
fi
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
|
||||
tools/proot/build.sh app/src/main/jniLibs/arm64-v8a
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o pa.tar.gz "$COMPONENT_SOURCE_URL"
|
||||
echo "$COMPONENT_SOURCE_SHA256 pa.tar.gz" | sha256sum -c -
|
||||
mkdir -p pa13 && tar -xzf pa.tar.gz -C pa13 --strip-components=1 && rm pa.tar.gz
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
D=app/src/main/assets/linuxfs
|
||||
mkdir -p "$D"
|
||||
VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1) \
|
||||
tools/vr/build.sh --native "$D/usr/local/lib/droiddeck-vr"
|
||||
VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1) \
|
||||
tools/gpuload/build.sh --native "$D/usr/local/lib/droiddeck-gpuload"
|
||||
for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
|
||||
install -Dm644 "$script" "$D/usr/local/bin/$(basename "$script")"
|
||||
done
|
||||
for f in tools/linuxfs/overlay/usr/bin/* tools/linuxfs/overlay/usr/bin/steamos-polkit-helpers/*; do
|
||||
[ -f "$f" ] && install -Dm644 "$f" "$D/${f#tools/linuxfs/overlay/}"
|
||||
done
|
||||
if [ -f tools/gamescope/release.env ]; then
|
||||
. tools/gamescope/release.env
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o gamescope.tzst "https://github.com/${GAMESCOPE_REPO:-${GITHUB_REPOSITORY}}/releases/download/${GAMESCOPE_TAG}/gamescope.tzst"
|
||||
echo "${GAMESCOPE_SHA256} gamescope.tzst" | sha256sum -c -
|
||||
tar --use-compress-program=unzstd -xf gamescope.tzst -C "$D"
|
||||
test -f "$D/usr/local/bin/gamescope"
|
||||
rm gamescope.tzst
|
||||
fi
|
||||
. tools/linuxfs/uruntime.env
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o uruntime "https://github.com/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/${URUNTIME_ASSET}"
|
||||
echo "${URUNTIME_SHA256} uruntime" | sha256sum -c -
|
||||
install -Dm644 uruntime "$D/usr/local/lib/droiddeck/uruntime"
|
||||
install -Dm644 tools/linuxfs/licenses/uruntime-LICENSE "$D/usr/local/share/licenses/uruntime/LICENSE"
|
||||
rm uruntime
|
||||
M="$D/usr/local/lib/mangoapp"
|
||||
mkdir -p "$M" mango-pkgs
|
||||
grep -v '^#' tools/mangoapp/packages.txt | while read -r sum url; do
|
||||
[ -n "$url" ] || continue
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o mango-pkgs/pkg.tar.zst "$url"
|
||||
echo "$sum mango-pkgs/pkg.tar.zst" | sha256sum -c -
|
||||
tar --use-compress-program=unzstd -xf mango-pkgs/pkg.tar.zst -C mango-pkgs
|
||||
rm mango-pkgs/pkg.tar.zst
|
||||
done
|
||||
install -m644 mango-pkgs/usr/bin/mangoapp "$M/mangoapp"
|
||||
for so in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1; do
|
||||
cp -L "mango-pkgs/usr/lib/$so" "$M/$so"
|
||||
done
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wl,-soname,libtracefs.so.1 \
|
||||
-o "$M/libtracefs.so.1" tools/mangoapp/libtracefs-shim.c
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$M/libtracefs.so.1"
|
||||
install -Dm644 tools/mangoapp/mangoapp "$D/usr/local/bin/mangoapp"
|
||||
rm -rf mango-pkgs
|
||||
ls -l "$M"
|
||||
mkdir -p pw-pkgs
|
||||
grep -v '^#' tools/pipewire/packages.txt | while read -r sum url; do
|
||||
[ -n "$url" ] || continue
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o pw-pkgs/pkg.tar.zst "$url"
|
||||
echo "$sum pw-pkgs/pkg.tar.zst" | sha256sum -c -
|
||||
tar --use-compress-program=unzstd -xf pw-pkgs/pkg.tar.zst -C pw-pkgs
|
||||
rm pw-pkgs/pkg.tar.zst
|
||||
done
|
||||
tools/pipewire/assemble.sh pw-pkgs "$D/usr/local/lib/droiddeck-pipewire.tzst"
|
||||
rm -rf pw-pkgs
|
||||
ls -l "$D/usr/local/lib/droiddeck-pipewire.tzst"
|
||||
T="$D/usr/local/lib/droiddeck-msitools"
|
||||
mkdir -p "$T" msi-pkgs
|
||||
grep -v '^#' tools/msitools/packages.txt | while read -r sum url; do
|
||||
[ -n "$url" ] || continue
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o msi-pkgs/pkg.tar.xz "$url"
|
||||
echo "$sum msi-pkgs/pkg.tar.xz" | sha256sum -c -
|
||||
tar -xJf msi-pkgs/pkg.tar.xz -C msi-pkgs
|
||||
rm msi-pkgs/pkg.tar.xz
|
||||
done
|
||||
install -m644 msi-pkgs/usr/bin/msiinfo "$T/msiinfo"
|
||||
install -m644 msi-pkgs/usr/bin/cabextract "$T/cabextract"
|
||||
install -m644 msi-pkgs/usr/lib/7zip/7z "$T/7z"
|
||||
install -m644 msi-pkgs/usr/lib/7zip/7z.so "$T/7z.so"
|
||||
for so in libmsi-1.0.so.0 libgsf-1.so.114 libgcab-1.0.so.0; do
|
||||
cp -L "msi-pkgs/usr/lib/$so" "$T/$so"
|
||||
done
|
||||
for f in NOTICE GPL-2 GPL-3 LGPL-2.1 7zip-License 7zip-unRarLicense; do
|
||||
install -Dm644 "tools/msitools/licenses/$f" "$D/usr/local/share/licenses/droiddeck-msitools/$f"
|
||||
done
|
||||
rm -rf msi-pkgs
|
||||
ls -l "$T"
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-desktop "$D/usr/local/bin/droiddeck-desktop"
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-gpu "$D/usr/local/bin/droiddeck-gpu"
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-desktop-gpu "$D/usr/local/bin/droiddeck-desktop-gpu"
|
||||
install -Dm644 tools/linuxfs/desktop/kwin_wayland_wrapper "$D/usr/local/bin/kwin_wayland_wrapper"
|
||||
install -Dm644 tools/linuxfs/desktop/firefox-droiddeck.js "$D/usr/lib/firefox/defaults/pref/droiddeck.js"
|
||||
ls -lR "$D"
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
docker run --rm -v "$PWD:/src" -w /src public.ecr.aws/docker/library/debian:bullseye bash -c '
|
||||
set -euo pipefail
|
||||
install_compilers() {
|
||||
apt-get -o Acquire::Check-Valid-Until=false update -qq &&
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends gcc g++ gcc-multilib g++-multilib binutils >/dev/null
|
||||
}
|
||||
printf "deb http://deb.debian.org/debian bullseye main\ndeb http://security.debian.org/debian-security bullseye-security main\n" > /etc/apt/sources.list
|
||||
if ! install_compilers; then
|
||||
printf "deb http://archive.debian.org/debian bullseye main\ndeb http://archive.debian.org/debian-security bullseye-security main\n" > /etc/apt/sources.list
|
||||
install_compilers
|
||||
fi
|
||||
tools/linuxfs/build-x86-preloads.sh app/src/main/assets/linuxfs
|
||||
'
|
||||
sudo chown -R "$(id -u):$(id -g)" app/src/main/assets/linuxfs
|
||||
ls -l app/src/main/assets/linuxfs/x86_64 app/src/main/assets/linuxfs/i386
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
rustup toolchain install 1.99.0 --profile minimal
|
||||
bash tools/xbox/build.sh
|
||||
@@ -0,0 +1,324 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Deploy session-helper changes by grafting them into the latest main CI APK.
|
||||
|
||||
Downloads the newest release-signed main build from DroidDeck-CI that this checkout
|
||||
descends from, replaces the helper assets whose sources differ from that build, re-signs
|
||||
the result with the local release signer and optionally installs it. Any other change
|
||||
(Kotlin, resources, native code, runtime components, deletions) stops the run so a full
|
||||
build covers it.
|
||||
"""
|
||||
import argparse
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from zipfile import ZipFile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/release'))
|
||||
from check_session_assets import source_assets
|
||||
|
||||
CI_REPO = 'Droid-Deck/DroidDeck-CI'
|
||||
CACHE = Path.home() / '.cache/droiddeck-donors'
|
||||
IGNORED_PREFIXES = ('docs/', '.github/', 'tools/tests/', 'tools/ci/')
|
||||
IGNORED_FILES = {'.gitignore', 'LICENSE', 'tools/deploy_fast.py'}
|
||||
SIGNATURE_SUFFIXES = ('.SF', '.RSA', '.DSA', '.EC')
|
||||
SIGNER = Path(os.environ.get('LOCALAPPDATA', '')) / 'DroidDeckSigning/Sign-DroidDeckApk.ps1'
|
||||
PWSH_FALLBACK = Path.home() / '.cache/codex-runtimes/codex-primary-runtime/dependencies/native/powershell/pwsh.exe'
|
||||
|
||||
|
||||
class Refused(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def run_bounded(command, timeout, **options):
|
||||
try:
|
||||
return subprocess.run(command, timeout=timeout, **options)
|
||||
except subprocess.TimeoutExpired:
|
||||
raise Refused(' '.join(map(str, command[:4])) + ' timed out')
|
||||
|
||||
|
||||
def git(*args, check=True):
|
||||
result = run_bounded(['git', '-C', str(ROOT), *args], 300, capture_output=True, check=False)
|
||||
if check and result.returncode:
|
||||
raise Refused('git ' + ' '.join(args) + ' failed: ' + result.stderr.decode(errors='replace').strip())
|
||||
return result.stdout
|
||||
|
||||
|
||||
def digest(path):
|
||||
return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def is_ignored(path):
|
||||
return path in IGNORED_FILES or path.endswith('.md') or path.startswith(IGNORED_PREFIXES)
|
||||
|
||||
|
||||
def graft_targets():
|
||||
return {source.relative_to(ROOT).as_posix(): asset for source, asset in source_assets().items()}
|
||||
|
||||
|
||||
def changed_paths(donor_commit):
|
||||
changes = {}
|
||||
fields = git('diff', '--name-status', '-z', '--no-renames', donor_commit).decode().split('\0')
|
||||
for status, path in zip(fields[0::2], fields[1::2]):
|
||||
changes[path] = status
|
||||
for path in filter(None, git('ls-files', '-z', '-o', '--exclude-standard').decode().split('\0')):
|
||||
changes[path] = 'A'
|
||||
return changes
|
||||
|
||||
|
||||
def classify(changes, targets, donor_entries):
|
||||
grafts, ignored, blocked = {}, [], {}
|
||||
for path, status in sorted(changes.items()):
|
||||
if is_ignored(path):
|
||||
ignored.append(path)
|
||||
elif path not in targets:
|
||||
blocked[path] = 'not a graftable session helper'
|
||||
elif status == 'D':
|
||||
blocked[path] = 'deleted helper'
|
||||
elif targets[path] not in donor_entries:
|
||||
blocked[path] = 'new helper the donor APK does not carry'
|
||||
else:
|
||||
grafts[path] = targets[path]
|
||||
return grafts, ignored, blocked
|
||||
|
||||
|
||||
def helper_bytes(path):
|
||||
data = (ROOT / path).read_bytes()
|
||||
return data if b'\0' in data else data.replace(b'\r\n', b'\n')
|
||||
|
||||
|
||||
def graft(donor, replacements, output):
|
||||
with ZipFile(donor) as source, ZipFile(output, 'w') as target:
|
||||
for info in source.infolist():
|
||||
name = info.filename
|
||||
if name.startswith('META-INF/') and (name == 'META-INF/MANIFEST.MF' or name.endswith(SIGNATURE_SUFFIXES)):
|
||||
continue
|
||||
data = replacements.get(name)
|
||||
if data is None:
|
||||
data = source.read(name)
|
||||
entry = copy.copy(info)
|
||||
entry.extra = b''
|
||||
target.writestr(entry, data, compress_type=info.compress_type)
|
||||
missing = set(replacements) - {i.filename for i in ZipFile(output).infolist()}
|
||||
if missing:
|
||||
raise Refused('Replacement entries missing from the output: ' + ', '.join(sorted(missing)))
|
||||
|
||||
|
||||
def release_tags(limit=60):
|
||||
out = run_bounded(['gh', 'release', 'list', '-R', CI_REPO, '--limit', str(limit), '--json', 'tagName'],
|
||||
120, capture_output=True, text=True)
|
||||
if out.returncode:
|
||||
raise Refused('Could not list DroidDeck-CI releases: ' + out.stderr.strip())
|
||||
return [item['tagName'] for item in json.loads(out.stdout) if item['tagName'].startswith('main-')]
|
||||
|
||||
|
||||
def donor_commit(tag):
|
||||
short = tag.removeprefix('main-')
|
||||
commit = git('rev-parse', '--verify', '--quiet', short + '^{commit}', check=False).decode().strip()
|
||||
if not commit:
|
||||
git('fetch', '--no-tags', 'origin', 'main')
|
||||
commit = git('rev-parse', '--verify', short + '^{commit}').decode().strip()
|
||||
return commit
|
||||
|
||||
|
||||
def is_ancestor(commit):
|
||||
return subprocess.run(['git', '-C', str(ROOT), 'merge-base', '--is-ancestor', commit, 'HEAD']).returncode == 0
|
||||
|
||||
|
||||
def pick_tag(requested):
|
||||
if requested:
|
||||
return requested
|
||||
for tag in release_tags():
|
||||
try:
|
||||
if is_ancestor(donor_commit(tag)):
|
||||
return tag
|
||||
except Refused:
|
||||
continue
|
||||
raise Refused('No recent DroidDeck-CI main build is an ancestor of this checkout; merge main first.')
|
||||
|
||||
|
||||
def fetch_donor(tag):
|
||||
folder = CACHE / tag
|
||||
apk = folder / f'DroidDeck-{tag}.apk'
|
||||
sums = folder / 'SHA256SUMS.txt'
|
||||
if not (apk.is_file() and sums.is_file()):
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
for pattern in (apk.name, sums.name):
|
||||
try:
|
||||
result = run_bounded(['gh', 'release', 'download', tag, '-R', CI_REPO, '-p', pattern,
|
||||
'-D', str(folder), '--clobber'], 900, capture_output=True, text=True)
|
||||
if result.returncode:
|
||||
raise Refused('Download failed: ' + result.stderr.strip())
|
||||
except Refused:
|
||||
apk.unlink(missing_ok=True)
|
||||
raise
|
||||
expected = dict(reversed(line.split(None, 1)) for line in sums.read_text().splitlines() if line.strip())
|
||||
if digest(apk) != expected.get(apk.name, '').strip():
|
||||
apk.unlink()
|
||||
raise Refused('Donor APK does not match SHA256SUMS.txt: ' + apk.name)
|
||||
return apk
|
||||
|
||||
|
||||
def sdk_root():
|
||||
return Path(os.environ.get('ANDROID_HOME') or os.environ.get('ANDROID_SDK_ROOT') or Path.home() / 'android-sdk')
|
||||
|
||||
|
||||
def apksigner():
|
||||
candidates = sorted((sdk_root() / 'build-tools').glob('*/apksigner*'), reverse=True)
|
||||
for path in candidates:
|
||||
if path.suffix in ('', '.bat'):
|
||||
return str(path)
|
||||
raise Refused('apksigner not found under ' + str(sdk_root() / 'build-tools'))
|
||||
|
||||
|
||||
def signer_sha256(apk):
|
||||
result = subprocess.run([apksigner(), 'verify', '--print-certs', str(apk)], capture_output=True, text=True)
|
||||
if result.returncode:
|
||||
raise Refused('APK signature does not verify: ' + (result.stdout + result.stderr).strip())
|
||||
for line in result.stdout.splitlines():
|
||||
if 'certificate SHA-256 digest:' in line:
|
||||
return line.rsplit(':', 1)[1].strip().lower()
|
||||
raise Refused('apksigner reported no certificate digest')
|
||||
|
||||
|
||||
def pwsh():
|
||||
found = shutil.which('pwsh')
|
||||
if found:
|
||||
return found
|
||||
if PWSH_FALLBACK.is_file():
|
||||
return str(PWSH_FALLBACK)
|
||||
raise Refused('PowerShell 7 (pwsh) is required for the local signer')
|
||||
|
||||
|
||||
def signing_env():
|
||||
common = Path(git('rev-parse', '--path-format=absolute', '--git-common-dir').decode().strip())
|
||||
for candidate in (os.environ.get('DROIDDECK_SIGNING_ENV'), ROOT / '.signing.env', common.parent / '.signing.env'):
|
||||
if candidate and Path(candidate).is_file():
|
||||
return Path(candidate).resolve()
|
||||
return None
|
||||
|
||||
|
||||
def version_key(path):
|
||||
return [int(part) if part.isdigit() else -1 for part in path.parent.name.replace('-', '.').split('.')]
|
||||
|
||||
|
||||
def sign_with_env(env_file, unsigned, signed):
|
||||
complete = [path for path in (sdk_root() / 'build-tools').glob('*/aapt')
|
||||
if all((path.parent / tool).is_file() for tool in ('zipalign', 'apksigner'))]
|
||||
build_tools = sorted(complete, key=version_key, reverse=True)
|
||||
if not build_tools:
|
||||
raise Refused('no build-tools with aapt, zipalign and apksigner under ' + str(sdk_root() / 'build-tools'))
|
||||
script = 'set -a; cd "$(dirname "$1")"; . "$1"; set +a; BUILD_TOOLS="$5" exec "$2" "$3" standard "$4"'
|
||||
result = subprocess.run(['bash', '-c', script, 'sign', str(env_file), str(ROOT / 'tools/release/sign-apk.sh'),
|
||||
str(unsigned), str(signed), str(build_tools[0].parent.resolve())],
|
||||
capture_output=True, text=True)
|
||||
if result.returncode or not signed.is_file():
|
||||
raise Refused('Signing failed:\n' + (result.stdout + result.stderr).strip())
|
||||
|
||||
|
||||
def sign(unsigned, signed):
|
||||
if not SIGNER.is_file() and (env_file := signing_env()):
|
||||
return sign_with_env(env_file, unsigned, signed)
|
||||
def quoted(value):
|
||||
return "'" + str(value).replace("'", "''") + "'"
|
||||
command = (f"if (-not (Test-Path -LiteralPath {quoted(SIGNER)})) {{ Write-Error 'Local signer not found'; exit 1 }}; "
|
||||
f"& {quoted(SIGNER)} -InputApk {quoted(unsigned)} -OutputApk {quoted(signed)} -SdkRoot {quoted(sdk_root())}")
|
||||
result = subprocess.run([pwsh(), '-NoProfile', '-Command', command], capture_output=True, text=True)
|
||||
if result.returncode or not signed.is_file():
|
||||
raise Refused('Signing failed:\n' + (result.stdout + result.stderr).strip())
|
||||
|
||||
|
||||
def verify_output(apk, grafts, pinned):
|
||||
if signer_sha256(apk) != pinned:
|
||||
raise Refused('Output is not signed with the release certificate')
|
||||
with ZipFile(apk) as package:
|
||||
for path, asset in grafts.items():
|
||||
if package.read(asset) != helper_bytes(path):
|
||||
raise Refused('Grafted helper does not match its source: ' + asset)
|
||||
for path, asset in graft_targets().items():
|
||||
if asset in package.namelist() and package.read(asset) != helper_bytes(path):
|
||||
raise Refused('Stale helper in the output: ' + asset)
|
||||
|
||||
|
||||
def install(apk):
|
||||
adb = Path(os.environ.get('ADB') or sdk_root() / 'platform-tools/adb.exe')
|
||||
if not adb.is_file():
|
||||
adb = Path(shutil.which('adb') or '')
|
||||
if not adb.is_file():
|
||||
raise Refused('adb not found; set ADB or ANDROID_HOME')
|
||||
serial = subprocess.run([sys.executable, str(ROOT / 'tools/adb_device.py'), '--adb', str(adb)],
|
||||
capture_output=True, text=True)
|
||||
if serial.returncode:
|
||||
raise Refused(serial.stderr.strip() or 'No device resolved')
|
||||
device = serial.stdout.strip()
|
||||
result = subprocess.run([str(adb), '-s', device, 'install', '-r', '--no-incremental', str(apk)])
|
||||
if result.returncode:
|
||||
raise Refused('adb install failed (a different signing certificate needs a manual uninstall)')
|
||||
print('Installed on ' + device)
|
||||
|
||||
|
||||
def run(args):
|
||||
pinned = (ROOT / 'keystore/release-signer.sha256').read_text().strip().lower()
|
||||
tag = pick_tag(args.donor)
|
||||
commit = donor_commit(tag)
|
||||
if not is_ancestor(commit):
|
||||
raise Refused(f'{tag} is not an ancestor of this checkout; merge main or pick an older build')
|
||||
donor = fetch_donor(tag)
|
||||
if signer_sha256(donor) != pinned:
|
||||
raise Refused('Donor APK is not signed with the release certificate')
|
||||
with ZipFile(donor) as package:
|
||||
entries = set(package.namelist())
|
||||
grafts, ignored, blocked = classify(changed_paths(commit), graft_targets(), entries)
|
||||
print(f'Donor {tag} ({commit[:7]})')
|
||||
for path in ignored:
|
||||
print(' ignored', path)
|
||||
for path, asset in grafts.items():
|
||||
print(' graft ', path, '->', asset)
|
||||
if blocked:
|
||||
for path, reason in blocked.items():
|
||||
print(' BLOCKED', path, f'({reason})')
|
||||
raise Refused('Changes outside the graftable set; run tools/build_local.sh for these.')
|
||||
if not grafts:
|
||||
print('Nothing to graft; the donor already matches this checkout.')
|
||||
if not args.plan:
|
||||
print('Donor APK:', donor)
|
||||
if args.install:
|
||||
install(donor)
|
||||
return
|
||||
if args.plan:
|
||||
return
|
||||
out_dir = ROOT / 'app/build/outputs/apk/fast'
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
stamp = f'{tag}-{git("rev-parse", "--short", "HEAD").decode().strip()}-{int(time.time())}'
|
||||
unsigned = out_dir / f'unsigned-{stamp}.apk'
|
||||
signed = out_dir / f'DroidDeck-fast-{stamp}.apk'
|
||||
graft(donor, {asset: helper_bytes(path) for path, asset in grafts.items()}, unsigned)
|
||||
try:
|
||||
sign(unsigned, signed)
|
||||
finally:
|
||||
unsigned.unlink(missing_ok=True)
|
||||
verify_output(signed, grafts, pinned)
|
||||
print('Signed APK:', signed)
|
||||
if args.install:
|
||||
install(signed)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--donor', help='DroidDeck-CI main tag such as main-4aa19b6; default is the newest ancestor build')
|
||||
parser.add_argument('--plan', action='store_true', help='Show what would be grafted without building')
|
||||
parser.add_argument('--install', action='store_true', help='Install the signed APK on the connected device')
|
||||
try:
|
||||
run(parser.parse_args())
|
||||
except Refused as error:
|
||||
parser.exit(2, str(error) + '\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -11,8 +11,30 @@ icon, Plasma's default bottom panel, and "Return to Gaming Mode" and Steam on th
|
||||
- `overlay/`: our files on top - system-wide KDE defaults in `/etc/xdg`, the Vapor theme and its
|
||||
layout script, the menu entries Steam and Return to Gaming Mode use.
|
||||
|
||||
pacman works on the desktop. `pacman-db.py` writes an install record for every package the desktop
|
||||
ships into `/var/lib/pacman/local`, and builds the `droiddeck` repository: Arch Linux ARM's core,
|
||||
extra and alarm databases as they were at build time, with the runtime's and the desktop's own
|
||||
packages at the installed versions. The release carries that database (`droiddeck.db`) and the
|
||||
packages `mirror.txt` names; everything else downloads from Arch Linux ARM as a `CacheServer`, so its
|
||||
404s never disable a mirror. Installs therefore resolve against the desktop's exact Qt and KDE
|
||||
versions, and `pacman -Syu` only ever moves packages the user added.
|
||||
|
||||
- `/usr/local/bin/pacman` runs the real pacman with `/usr/share/droiddeck/pacman/pacman.conf`, first
|
||||
copying in the shipped database and dropping the runtime's records for packages the desktop
|
||||
replaced (`prepare`). As root it adds `--needed` to installs, so guides that reinstall
|
||||
something the desktop has just skip it.
|
||||
- `sudo`, `su` and `sudoedit` run commands as root: the session is the app's own Android user, and
|
||||
`libdroiddeck-root.so` (`root/root.c`, preloaded by `sudo`) reports uid 0, accepts ownership
|
||||
changes and shows the runtime's 0700 directories as 0755. It grants nothing the user lacked.
|
||||
- `hooks/droiddeck-system.hook` refuses to remove or replace any runtime or desktop package;
|
||||
`droiddeck-remember.hook` keeps the user's own packages in
|
||||
`~/.local/share/droiddeck/pacman/packages.txt`, and `restore` (autostarted) reinstalls them after a
|
||||
runtime update and upgrades them after a desktop update. Hooks that need systemd, udev, kernel
|
||||
modules or an initramfs are masked.
|
||||
|
||||
`.github/workflows/build-desktop-kde.yml` builds it and, run with a new tag, publishes it as a
|
||||
release in Droid-Deck/DroidDeck-Components. `release.env` pins the tag, sha256 and size the apk
|
||||
release in Droid-Deck/DroidDeck-Components (tags with `-rc` are published as pre-releases for testing
|
||||
before an app build points at them). `release.env` pins the tag, sha256 and size the apk
|
||||
installs (`DesktopCatalog.desktopEntry`); a published tag is never replaced, so a changed package
|
||||
is a new tag and a `release.env` update.
|
||||
|
||||
@@ -20,6 +42,8 @@ At run time the desktop is started by `tools/linuxfs/desktop/droiddeck-desktop`
|
||||
at every session): Plasma's own `startplasma-wayland`, with KWin nested in the app's compositor
|
||||
through `kwin_wayland_wrapper`. The package's `kwin-compositor` marker selects OpenGL through
|
||||
Zink for KWin 6.8, which removed QPainter. Older packages retain their software compositor.
|
||||
KWin runs without Gallium's threaded context and without overlay layers. With the threaded context, KWin crashed
|
||||
uploading windows' shared-memory buffers by reading past their end, and the host shows only a single buffer.
|
||||
On Android the launcher explicitly selects the KGSL render node; the nested backend can use it
|
||||
when the host's dmabuf feedback cannot name a DRM device. Games and emulators from the menu go
|
||||
through `droiddeck-gpu`, and Steam goes back to the app as a Steam session.
|
||||
@@ -35,6 +59,9 @@ The behavior is enabled only with `DROIDDECK_NESTED_SCALE`, which the desktop sc
|
||||
`0002-select-explicit-nested-render-node.patch` lets that nested backend use one explicitly
|
||||
selected `KWIN_RENDER_NODES` device when host feedback cannot identify it. It does not guess
|
||||
between GPUs or change normal KWin device selection.
|
||||
`0003-forward-nested-scroll-source.patch` passes the host's scroll source, wheel steps and scroll stops
|
||||
through the nested backend, which upstream leaves as a TODO. Two-finger touch scrolling then reaches
|
||||
apps as touchpad scrolling, and wheel steps stay whole clicks.
|
||||
|
||||
`pins/mesa/desc` keeps Mesa 26.2.4 and its actual package dependencies ahead of the rolling
|
||||
repository metadata. Mesa 26.2.5 crashes in Zink shader compilation on Thor with the selected
|
||||
@@ -44,7 +71,7 @@ both build jobs verify the Arch Linux ARM signature and pinned SHA-256 as for ev
|
||||
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.8.0/kwin-6.8.0.tar.xz plus the patch in this repository.
|
||||
https://download.kde.org/stable/plasma/6.8.2/kwin-6.8.2.tar.xz plus the patch in this repository.
|
||||
|
||||
The inventories use `.gzip` rather than `.gz`: Android's asset packer expands `.gz` and strips
|
||||
its suffix. The shared local/CI runtime payload check verifies the exact APK names and bytes.
|
||||
|
||||
@@ -6,7 +6,7 @@ here=$(cd "$(dirname "$0")" && pwd)
|
||||
source "$here/kwin.env"
|
||||
source "$here/mesa.env"
|
||||
version=$DESKTOP_KWIN_VERSION
|
||||
source_sha=4bfaf31e29a8f9fdf231dc3bbb9b09b0ce07cae9fee7a01cfc86425ece796258
|
||||
source_sha=ea5e68d957c7d70abed97222a592d4445fda29129e20942658badd224ee138b4
|
||||
mirror=https://fl.us.mirror.archlinuxarm.org/aarch64
|
||||
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
|
||||
work=$(mktemp -d)
|
||||
@@ -52,6 +52,7 @@ 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 patch -d "$work/root/build/kwin-$version" -p1 < "$here/patches/0002-select-explicit-nested-render-node.patch"
|
||||
sudo patch -d "$work/root/build/kwin-$version" -p1 < "$here/patches/0003-forward-nested-scroll-source.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 \
|
||||
@@ -72,6 +73,7 @@ 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 "Render node patch sha256 $(sha256sum "$here/patches/0002-select-explicit-nested-render-node.patch" | cut -d' ' -f1)"
|
||||
echo "Scroll source patch sha256 $(sha256sum "$here/patches/0003-forward-nested-scroll-source.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):'
|
||||
|
||||
@@ -38,6 +38,12 @@ while read -r entry sum; do
|
||||
done < "$work/pkglist.txt"
|
||||
|
||||
cp -a "$here/overlay/." "$work/root/"
|
||||
mkdir -p "$work/root/usr/lib/droiddeck"
|
||||
${CC_AARCH64:-aarch64-linux-gnu-gcc} -shared -fPIC -O2 -Wall -Wextra \
|
||||
-o "$work/root/usr/lib/droiddeck/libdroiddeck-root.so" "$here/root/root.c" -ldl
|
||||
${STRIP_AARCH64:-aarch64-linux-gnu-strip} --strip-unneeded "$work/root/usr/lib/droiddeck/libdroiddeck-root.so"
|
||||
python3 "$here/pacman-db.py" "$work/db" "$pkgs" "$work/pkglist.txt" "$here/runtime-packages.txt" \
|
||||
"$here/mirror.txt" "${DESKTOP_KDE_RELEASE_TAG:-}" "$work/root" "$out/repo"
|
||||
|
||||
if [ -n "${KDE_KWIN_OVERRIDE:-}" ]; then
|
||||
kwin_package=$(awk '$1 ~ /^extra\/kwin-.*-aarch64\.pkg\.tar\./ {print $1}' "$work/pkglist.txt")
|
||||
@@ -61,7 +67,7 @@ if [ -d "$work/root/usr/share/locale" ]; then
|
||||
echo "i18n: $(wc -l < "$out/desktop-kde.i18n.txt") language packs"
|
||||
fi
|
||||
|
||||
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/man" "$work/root/usr/share/info" \
|
||||
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/info" \
|
||||
"$work/root/usr/share/gtk-doc" "$work/root/usr/include" "$work/root/usr/lib/pkgconfig" \
|
||||
"$work/root/usr/lib/cmake" "$work/root/usr/share/help"
|
||||
find "$work/root/usr/share/locale" -mindepth 1 -maxdepth 1 -type d ! -name 'en*' -exec rm -rf {} + 2>/dev/null || true
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The packages the KDE desktop package ships: the dependency closure of the seeds over Arch Linux
|
||||
ARM's extracted repository databases, minus what the runtime already has at a version that serves.
|
||||
|
||||
closure.py <db dir with x_core, x_extra, x_alarm> <runtime-packages.txt> <seeds.txt>
|
||||
|
||||
Prints one "repo/filename sha256" per package to ship (the sha256 the repository database gives).
|
||||
"""
|
||||
import collections
|
||||
import os
|
||||
import re
|
||||
@@ -107,7 +100,6 @@ def main():
|
||||
providers[pname].append((name, pver or pkgs[name]["version"]))
|
||||
|
||||
def resolve(dep):
|
||||
"""The package to take for a dependency string, and whether the runtime's copy serves."""
|
||||
name, op, want = parse_dep(dep)
|
||||
if name in runtime and satisfies(runtime[name], op, want):
|
||||
return name, True
|
||||
|
||||
@@ -1 +1 @@
|
||||
DESKTOP_KWIN_VERSION=6.8.0
|
||||
DESKTOP_KWIN_VERSION=6.8.2
|
||||
@@ -0,0 +1,16 @@
|
||||
neovim
|
||||
tmux
|
||||
screen
|
||||
rsync
|
||||
jq
|
||||
ripgrep
|
||||
fd
|
||||
bat
|
||||
ncdu
|
||||
btop
|
||||
fastfetch
|
||||
lsof
|
||||
strace
|
||||
python-pip
|
||||
nodejs
|
||||
npm
|
||||
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Restore pacman packages
|
||||
Exec=/usr/share/droiddeck/pacman/restore
|
||||
NoDisplay=true
|
||||
OnlyShowIn=KDE;
|
||||
X-KDE-autostart-phase=2
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
dir=/usr/share/droiddeck/pacman
|
||||
[ -r "$dir/pacman.conf" ] || exec /usr/bin/pacman "$@"
|
||||
"$dir/prepare" || exit 1
|
||||
install=0
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
letters= install=1
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--) break ;;
|
||||
--sync) letters+=S ;;
|
||||
--search|--info|--clean|--groups|--list|--print|--print-format|--downloadonly) install=0 ;;
|
||||
--*) ;;
|
||||
-*) letters+=${arg#-} ;;
|
||||
esac
|
||||
done
|
||||
case $letters in *S*) ;; *) install=0 ;; esac
|
||||
case $letters in *[sicglpw]*) install=0 ;; esac
|
||||
[ "$install" = 1 ] && set -- --needed "$@"
|
||||
fi
|
||||
[ "$install" = 1 ] || exec /usr/bin/pacman --config "$dir/pacman.conf" "$@"
|
||||
/usr/bin/pacman --config "$dir/pacman.conf" "$@" && exit 0
|
||||
status=$?
|
||||
mapfile -t paths < <("$dir/adopt" "$@")
|
||||
[ ${#paths[@]} -gt 0 ] || exit "$status"
|
||||
overwrite=()
|
||||
for path in "${paths[@]}"; do overwrite+=(--overwrite "$path"); done
|
||||
/usr/bin/pacman --config "$dir/pacman.conf" "${overwrite[@]}" "$@" || exit
|
||||
mapfile -t shared < <(/usr/bin/pacman --config "$dir/pacman.conf" -Qqd 2>/dev/null | grep -xF -f /var/lib/pacman/droiddeck-shared)
|
||||
[ ${#shared[@]} -eq 0 ] || /usr/bin/pacman --config "$dir/pacman.conf" -D --asexplicit "${shared[@]}" >/dev/null
|
||||
"$dir/remember"
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
login=0 command= shell=
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-|-l|--login) login=1; shift ;;
|
||||
-c|--command) [ $# -ge 2 ] || { echo "su: option requires an argument -- 'c'" >&2; exit 1; }; command=$2; shift 2 ;;
|
||||
--command=*) command=${1#*=}; shift ;;
|
||||
-s|--shell) [ $# -ge 2 ] || { echo "su: option requires an argument -- 's'" >&2; exit 1; }; shell=$2; shift 2 ;;
|
||||
--shell=*) shell=${1#*=}; shift ;;
|
||||
-m|-p|--preserve-environment|-P|--pty|-f|--fast) shift ;;
|
||||
-h|--help) echo "usage: su [-] [-c command] [-s shell] [root]"; exit 0 ;;
|
||||
-V|--version) echo "DroidDeck su: runs a root shell inside the DroidDeck desktop"; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
-*) echo "su: invalid option -- '${1#-}'" >&2; exit 1 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
user=${1:-root}
|
||||
[ $# -gt 0 ] && shift
|
||||
case $user in
|
||||
root|0|"$(id -un 2>/dev/null)") ;;
|
||||
*) echo "su: user $user does not exist or the user entry does not contain all the required fields" >&2; exit 1 ;;
|
||||
esac
|
||||
args=()
|
||||
[ "$login" = 1 ] && args+=(-i)
|
||||
if [ -n "$shell" ]; then
|
||||
if [ -n "$command" ]; then exec /usr/local/bin/sudo "${args[@]}" "$shell" -c "$command" "$@"; fi
|
||||
exec /usr/local/bin/sudo "${args[@]}" "$shell" "$@"
|
||||
fi
|
||||
if [ -n "$command" ]; then exec /usr/local/bin/sudo "${args[@]}" -s "$command"; fi
|
||||
[ "$login" = 1 ] && exec /usr/local/bin/sudo -i
|
||||
exec /usr/local/bin/sudo -s
|
||||
Executable
+94
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
lib=/usr/lib/droiddeck/libdroiddeck-root.so
|
||||
me=${0##*/}
|
||||
usage() {
|
||||
echo "usage: $me [-EHiknsSv] [-u user] [-g group] [-D directory] [--] command [arg ...]"
|
||||
echo " $me -e file ..."
|
||||
}
|
||||
known_user() {
|
||||
case $1 in
|
||||
''|root|0|'#0'|"$(id -un 2>/dev/null)"|"#$(id -ru 2>/dev/null)") return 0 ;;
|
||||
esac
|
||||
echo "$me: unknown user $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
login=0 shell=0 edit=0 background=0 dir=
|
||||
[ "$me" = sudoedit ] && edit=1
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--) shift; break ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
-V|--version) echo "DroidDeck sudo: runs commands as root inside the DroidDeck desktop"; exit 0 ;;
|
||||
-l|--list) echo "User $(id -un 2>/dev/null) may run the following commands on $(uname -n):"; echo " (ALL : ALL) ALL"; exit 0 ;;
|
||||
-v|--validate|-K|--remove-timestamp) exit 0 ;;
|
||||
-k|--reset-timestamp) shift; [ $# -eq 0 ] && exit 0 ;;
|
||||
-i|--login) login=1; shift ;;
|
||||
-s|--shell) shell=1; shift ;;
|
||||
-e|--edit) edit=1; shift ;;
|
||||
-b|--background) background=1; shift ;;
|
||||
-E|--preserve-env|--preserve-env=*|-H|--set-home|-n|--non-interactive|-S|--stdin|-P|--preserve-groups|-A|--askpass|-B|--bell|-N|--no-update) shift ;;
|
||||
-u|--user|-g|--group) [ $# -ge 2 ] || { usage >&2; exit 1; }; known_user "$2"; shift 2 ;;
|
||||
--user=*|--group=*) known_user "${1#*=}"; shift ;;
|
||||
-u*|-g*) known_user "${1:2}"; shift ;;
|
||||
-D|--chdir) [ $# -ge 2 ] || { usage >&2; exit 1; }; dir=$2; shift 2 ;;
|
||||
--chdir=*) dir=${1#*=}; shift ;;
|
||||
-p|--prompt|-C|--close-from|-r|--role|-t|--type|-T|--command-timeout|-R|--chroot) [ $# -ge 2 ] || { usage >&2; exit 1; }; shift 2 ;;
|
||||
--prompt=*|--close-from=*|--role=*|--type=*|--command-timeout=*) shift ;;
|
||||
-[A-Za-z][A-Za-z]*)
|
||||
flags=${1#-}; shift
|
||||
split=()
|
||||
while [ -n "$flags" ]; do
|
||||
split+=("-${flags:0:1}")
|
||||
case ${flags:0:1} in
|
||||
u|g|D|p|C|r|t|T|R) [ -n "${flags:1}" ] && split+=("${flags:1}"); flags= ;;
|
||||
*) flags=${flags:1} ;;
|
||||
esac
|
||||
done
|
||||
set -- "${split[@]}" "$@"
|
||||
;;
|
||||
-*) echo "$me: invalid option -- '${1#-}'" >&2; usage >&2; exit 1 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$edit" = 1 ]; then
|
||||
[ $# -gt 0 ] || { usage >&2; exit 1; }
|
||||
editor=${SUDO_EDITOR:-${VISUAL:-${EDITOR:-nano}}}
|
||||
exec $editor "$@"
|
||||
fi
|
||||
|
||||
if [ ! -r "$lib" ]; then
|
||||
echo "$me: $lib is missing; reinstall the desktop from DroidDeck's Desktop page" >&2
|
||||
exit 1
|
||||
fi
|
||||
case ":${LD_PRELOAD:-}:" in
|
||||
*":$lib:"*) ;;
|
||||
*) export LD_PRELOAD="$lib${LD_PRELOAD:+:$LD_PRELOAD}" ;;
|
||||
esac
|
||||
export SUDO_USER=${SUDO_USER:-$(id -un 2>/dev/null)}
|
||||
export SUDO_UID=${SUDO_UID:-$(id -ru 2>/dev/null)}
|
||||
export SUDO_GID=${SUDO_GID:-$(id -rg 2>/dev/null)}
|
||||
export SUDO_COMMAND="$*"
|
||||
[ -z "$dir" ] || cd "$dir" || exit 1
|
||||
|
||||
target_shell=$(getent passwd "$(id -un 2>/dev/null)" | cut -d: -f7)
|
||||
target_shell=${target_shell:-/bin/bash}
|
||||
if [ "$login" = 1 ]; then
|
||||
cd "${HOME:-/root}" 2>/dev/null
|
||||
if [ $# -gt 0 ]; then set -- "$target_shell" -l -c "$*"; else set -- "$target_shell" -l; fi
|
||||
elif [ "$shell" = 1 ]; then
|
||||
if [ $# -gt 0 ]; then set -- "${SHELL:-$target_shell}" -c "$*"; else set -- "${SHELL:-$target_shell}"; fi
|
||||
elif [ $# -eq 0 ]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
elif ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "$me: $1: command not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$background" = 1 ]; then
|
||||
"$@" &
|
||||
exit 0
|
||||
fi
|
||||
exec "$@"
|
||||
@@ -0,0 +1 @@
|
||||
sudo
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Avahi Zeroconf Browser
|
||||
Exec=/usr/bin/avahi-discover
|
||||
Icon=network-wired
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Avahi SSH Server Browser
|
||||
Exec=/usr/bin/bssh
|
||||
Icon=network-wired
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Avahi VNC Server Browser
|
||||
Exec=/usr/bin/bvnc
|
||||
Icon=network-wired
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Foot Server
|
||||
Exec=foot --server
|
||||
Icon=foot
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Foot Client
|
||||
Exec=footclient
|
||||
Icon=foot
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Hardware Locality lstopo
|
||||
Exec=lstopo
|
||||
Icon=hwloc
|
||||
NoDisplay=true
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=IBus Preferences
|
||||
Exec=ibus-setup
|
||||
Icon=ibus-setup
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Qt V4L2 test Utility
|
||||
Exec=qv4l2
|
||||
Icon=qv4l2
|
||||
NoDisplay=true
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Qt V4L2 video capture utility
|
||||
Exec=qvidcap
|
||||
Icon=qvidcap
|
||||
NoDisplay=true
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/python3
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
SHARE = "/usr/share/droiddeck/pacman"
|
||||
LIB = "/var/lib/pacman"
|
||||
CACHE = "/var/cache/pacman/pkg"
|
||||
SHARED = os.path.join(LIB, "droiddeck-shared")
|
||||
SHARED_FILES = SHARED + "-files"
|
||||
|
||||
|
||||
def owned():
|
||||
paths = set()
|
||||
local = os.path.join(LIB, "local")
|
||||
for entry in os.listdir(local):
|
||||
try:
|
||||
with open(os.path.join(local, entry, "files"), encoding="utf-8", errors="surrogateescape") as f:
|
||||
lines = f.read().split("\n")
|
||||
except OSError:
|
||||
continue
|
||||
reading = False
|
||||
for line in lines:
|
||||
if line.startswith("%"):
|
||||
reading = line == "%FILES%"
|
||||
elif reading and line:
|
||||
paths.add(line.rstrip("/"))
|
||||
return paths
|
||||
|
||||
|
||||
def same(archive, member, path):
|
||||
if member.issym():
|
||||
return os.path.islink(path) and os.readlink(path) == member.linkname
|
||||
if not member.isfile() or os.path.islink(path) or not os.path.isfile(path):
|
||||
return False
|
||||
if os.path.getsize(path) != member.size:
|
||||
return False
|
||||
with archive.extractfile(member) as packaged, open(path, "rb") as installed:
|
||||
return hashlib.file_digest(packaged, "sha256").digest() == hashlib.file_digest(installed, "sha256").digest()
|
||||
|
||||
|
||||
def planned(args):
|
||||
query = []
|
||||
for arg in args:
|
||||
if arg == "--refresh" or arg == "--noconfirm":
|
||||
continue
|
||||
if re.fullmatch(r"-[A-Za-z]+", arg):
|
||||
arg = arg.replace("y", "")
|
||||
if arg == "-":
|
||||
continue
|
||||
query.append(arg)
|
||||
run = subprocess.run(["/usr/bin/pacman", "--config", os.path.join(SHARE, "pacman.conf"), "--noconfirm", *query,
|
||||
"--print", "--print-format", "%n %f"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
||||
text=True)
|
||||
if run.returncode != 0:
|
||||
return []
|
||||
return [line.split(" ", 1) for line in run.stdout.splitlines() if " " in line]
|
||||
|
||||
|
||||
def main():
|
||||
targets = [(name, os.path.join(CACHE, os.path.basename(file))) for name, file in planned(sys.argv[1:])]
|
||||
targets = [(name, path) for name, path in targets if os.path.isfile(path)]
|
||||
if not targets:
|
||||
return 0
|
||||
have = owned()
|
||||
paths, names = [], []
|
||||
for name, path in targets:
|
||||
found = False
|
||||
with tarfile.open(path) as archive:
|
||||
for member in archive:
|
||||
if member.isdir() or member.name.startswith("."):
|
||||
continue
|
||||
if member.name in have or not os.path.lexists("/" + member.name) or os.path.isdir("/" + member.name):
|
||||
continue
|
||||
if not same(archive, member, "/" + member.name):
|
||||
continue
|
||||
paths.append("/" + member.name)
|
||||
found = True
|
||||
if found:
|
||||
names.append(name)
|
||||
if not paths:
|
||||
return 0
|
||||
shared = set()
|
||||
try:
|
||||
with open(SHARED) as f:
|
||||
shared = {line.strip() for line in f if line.strip()}
|
||||
except OSError:
|
||||
pass
|
||||
with open(SHARED + ".tmp", "w") as f:
|
||||
f.write("".join(f"{name}\n" for name in sorted(shared | set(names))))
|
||||
os.replace(SHARED + ".tmp", SHARED)
|
||||
files = set()
|
||||
try:
|
||||
with open(SHARED_FILES, encoding="utf-8", errors="surrogateescape") as f:
|
||||
files = {line.rstrip("\n") for line in f if line.strip()}
|
||||
except OSError:
|
||||
pass
|
||||
with open(SHARED_FILES + ".tmp", "w", encoding="utf-8", errors="surrogateescape") as f:
|
||||
f.write("".join(f"{path}\n" for path in sorted(files | set(paths))))
|
||||
os.replace(SHARED_FILES + ".tmp", SHARED_FILES)
|
||||
print(f":: Other DroidDeck software already installed {len(paths)} files from {' '.join(names)}.", file=sys.stderr)
|
||||
print(":: pacman will take them over and keep these packages installed so that software keeps working.",
|
||||
file=sys.stderr)
|
||||
for path in paths:
|
||||
print(re.sub(r"([\\*?\[])", r"\\\1", path))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except (OSError, tarfile.TarError) as e:
|
||||
print(f"error: could not check for files other DroidDeck software installed: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
+1
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
@@ -0,0 +1 @@
|
||||
/dev/null
|
||||
@@ -0,0 +1,11 @@
|
||||
[Trigger]
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Operation = Remove
|
||||
Type = Package
|
||||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Remembering the packages you installed...
|
||||
When = PostTransaction
|
||||
Exec = /usr/share/droiddeck/pacman/remember
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
[Trigger]
|
||||
Operation = Upgrade
|
||||
Type = Package
|
||||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Putting back files other DroidDeck software needs...
|
||||
When = PostTransaction
|
||||
Exec = /usr/share/droiddeck/pacman/keep restore
|
||||
@@ -0,0 +1,9 @@
|
||||
[Trigger]
|
||||
Operation = Upgrade
|
||||
Type = Package
|
||||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Saving files other DroidDeck software needs...
|
||||
When = PreTransaction
|
||||
Exec = /usr/share/droiddeck/pacman/keep save
|
||||
@@ -0,0 +1,11 @@
|
||||
[Trigger]
|
||||
Operation = Remove
|
||||
Type = Package
|
||||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Checking for files other DroidDeck software needs...
|
||||
When = PreTransaction
|
||||
Exec = /usr/share/droiddeck/pacman/shared
|
||||
NeedsTargets
|
||||
AbortOnFail
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
list=/var/lib/pacman/droiddeck-shared-files
|
||||
store=/var/lib/pacman/droiddeck-shared-keep
|
||||
[ -s "$list" ] || exit 0
|
||||
case $1 in
|
||||
save)
|
||||
mkdir -p "$store"
|
||||
while IFS= read -r path; do
|
||||
[ -e "$path" ] || [ -L "$path" ] || continue
|
||||
mkdir -p "$store${path%/*}"
|
||||
rm -f -- "$store$path"
|
||||
cp -a -- "$path" "$store$path"
|
||||
done < "$list"
|
||||
;;
|
||||
restore)
|
||||
[ -d "$store" ] || exit 0
|
||||
while IFS= read -r path; do
|
||||
[ -e "$path" ] || [ -L "$path" ] && continue
|
||||
[ -e "$store$path" ] || [ -L "$store$path" ] || continue
|
||||
mkdir -p "${path%/*}"
|
||||
cp -a -- "$store$path" "$path"
|
||||
done < "$list"
|
||||
rm -rf -- /var/lib/pacman/droiddeck-shared-keep
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/python3
|
||||
import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
SHARE = "/usr/share/droiddeck/pacman"
|
||||
LIB = "/var/lib/pacman"
|
||||
STATE = os.path.join(LIB, "droiddeck-desktop")
|
||||
|
||||
|
||||
def digest(path):
|
||||
with open(path, "rb") as f:
|
||||
return hashlib.sha256(f.read()).hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
for path in ("/var/cache/pacman/pkg", os.path.join(LIB, "sync"), "/etc/pacman.d/hooks", "/var/log"):
|
||||
os.makedirs(path, exist_ok=True)
|
||||
stamp = digest(os.path.join(SHARE, "desktop-packages.txt")) + " " + digest(os.path.join(SHARE, "droiddeck.db"))
|
||||
try:
|
||||
with open(STATE) as f:
|
||||
if f.read().strip() == stamp:
|
||||
return 0
|
||||
except OSError:
|
||||
pass
|
||||
want = dict(line.split() for line in open(os.path.join(SHARE, "desktop-packages.txt")) if line.strip())
|
||||
local = os.path.join(LIB, "local")
|
||||
for entry in os.listdir(local):
|
||||
desc = os.path.join(local, entry, "desc")
|
||||
if not os.path.isfile(desc):
|
||||
continue
|
||||
name = version = None
|
||||
with open(desc, encoding="utf-8", errors="replace") as f:
|
||||
lines = f.read().split("\n")
|
||||
for i, line in enumerate(lines[:-1]):
|
||||
if line == "%NAME%":
|
||||
name = lines[i + 1]
|
||||
elif line == "%VERSION%":
|
||||
version = lines[i + 1]
|
||||
if name in want and version != want[name]:
|
||||
shutil.rmtree(os.path.join(local, entry))
|
||||
shutil.copyfile(os.path.join(SHARE, "droiddeck.db"), os.path.join(LIB, "sync", "droiddeck.db"))
|
||||
with open(STATE + ".tmp", "w") as f:
|
||||
f.write(stamp + "\n")
|
||||
os.replace(STATE + ".tmp", STATE)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except OSError as e:
|
||||
print(f"error: could not prepare pacman's database: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
packages=$(tr '\n' ' ')
|
||||
echo "error: ${packages% } came with DroidDeck, so pacman can't remove or replace it." >&2
|
||||
echo "error: DroidDeck updates these itself; packages you installed with pacman are yours to change." >&2
|
||||
exit 1
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
dir=/usr/share/droiddeck/pacman
|
||||
state=/root/.local/share/droiddeck/pacman
|
||||
mkdir -p "$state"
|
||||
if [ -z "${DROIDDECK_PACMAN_RESTORING:-}" ] && explicit=$(/usr/bin/pacman --config "$dir/pacman.conf" -Qqe 2>/dev/null); then
|
||||
printf '%s\n' "$explicit" | grep -vxF -f "$dir/system-packages.txt" > "$state/packages.txt.tmp"
|
||||
if [ $? -le 1 ] && [ -f "$state/packages.txt.tmp" ]; then
|
||||
mv -f "$state/packages.txt.tmp" "$state/packages.txt"
|
||||
else
|
||||
rm -f "$state/packages.txt.tmp"
|
||||
fi
|
||||
fi
|
||||
[ -s "$state/restored" ] || sha256sum "$dir/droiddeck.db" | cut -d' ' -f1 > "$state/restored"
|
||||
rm -f /var/cache/pacman/pkg/*.pkg.tar.* /var/cache/pacman/pkg/*.pkg.tar.*.sig 2>/dev/null
|
||||
exit 0
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
dir=/usr/share/droiddeck/pacman
|
||||
state=/root/.local/share/droiddeck/pacman
|
||||
list=$state/packages.txt
|
||||
log=/root/.cache/droiddeck/pacman-restore.log
|
||||
[ -s "$list" ] && [ -r "$dir/pacman.conf" ] || exit 0
|
||||
pacman() { /usr/local/bin/pacman "$@"; }
|
||||
"$dir/prepare" || exit 0
|
||||
snapshot=$(sha256sum "$dir/droiddeck.db" | cut -d' ' -f1)
|
||||
mapfile -t missing < <(grep -vxF -f <(pacman -Qq 2>/dev/null) "$list")
|
||||
done_for=$(cat "$state/restored" 2>/dev/null)
|
||||
[ ${#missing[@]} -eq 0 ] && [ "$done_for" = "$snapshot" ] && exit 0
|
||||
attempt="$snapshot ${missing[*]}"
|
||||
[ "$(cat "$state/attempted" 2>/dev/null)" = "$attempt" ] && exit 0
|
||||
tries=$(cat "$state/tries" 2>/dev/null)
|
||||
count=0
|
||||
[ "${tries#* }" = "$attempt" ] && count=${tries%% *}
|
||||
count=$((count + 1))
|
||||
echo "$count $attempt" > "$state/tries"
|
||||
[ "$count" -ge 3 ] && echo "$attempt" > "$state/attempted"
|
||||
export DROIDDECK_PACMAN_RESTORING=1
|
||||
mkdir -p "${log%/*}"
|
||||
notify() { notify-send -a DroidDeck -i system-software-update "$@" 2>/dev/null; }
|
||||
notify "Restoring your packages" "Reinstalling software you added with pacman after a DroidDeck update."
|
||||
export LD_PRELOAD="/usr/lib/droiddeck/libdroiddeck-root.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||
{
|
||||
date
|
||||
ok=1
|
||||
[ "$done_for" = "$snapshot" ] || pacman -Su --noconfirm || ok=0
|
||||
[ ${#missing[@]} -eq 0 ] || pacman -S --needed --noconfirm "${missing[@]}" || ok=0
|
||||
} >> "$log" 2>&1
|
||||
if [ "$ok" = 1 ]; then
|
||||
echo "$snapshot" > "$state/restored"
|
||||
notify "Packages restored" "Your pacman packages are installed again."
|
||||
else
|
||||
notify "Some packages couldn't be restored" "See $log, then try sudo pacman -S in Konsole."
|
||||
fi
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
list=/var/lib/pacman/droiddeck-shared
|
||||
[ -s "$list" ] || exit 0
|
||||
mapfile -t packages < <(grep -xF -f "$list")
|
||||
[ ${#packages[@]} -eq 0 ] && exit 0
|
||||
echo "error: ${packages[*]} shares files with other DroidDeck software, so pacman can't remove it." >&2
|
||||
exit 1
|
||||
@@ -8,8 +8,8 @@ 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.8.0, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
|
||||
Corresponding source: https://download.kde.org/stable/plasma/6.8.0/kwin-6.8.0.tar.xz and
|
||||
- kwin_wayland: KWin 6.8.2, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
|
||||
Corresponding source: https://download.kde.org/stable/plasma/6.8.2/kwin-6.8.2.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).
|
||||
|
||||
|
||||
+9
@@ -14,6 +14,14 @@ kickoff.currentConfigGroup = ["Shortcuts"];
|
||||
kickoff.writeConfig("global", "Alt+F1");
|
||||
kickoff.currentConfigGroup = ["General"];
|
||||
kickoff.writeConfig("icon", "distributor-logo-steamdeck");
|
||||
kickoff.writeConfig("favorites", [
|
||||
"preferred://browser",
|
||||
"applications:org.kde.dolphin.desktop",
|
||||
"applications:org.kde.konsole.desktop",
|
||||
"applications:org.kde.kate.desktop",
|
||||
"applications:org.kde.discover.desktop",
|
||||
"applications:systemsettings.desktop",
|
||||
]);
|
||||
|
||||
panel.addWidget("org.kde.plasma.pager");
|
||||
|
||||
@@ -24,6 +32,7 @@ tasks.writeConfig("launchers", [
|
||||
"preferred://filemanager",
|
||||
"preferred://browser",
|
||||
"applications:org.kde.konsole.desktop",
|
||||
"applications:org.kde.kate.desktop",
|
||||
]);
|
||||
|
||||
panel.addWidget("org.kde.plasma.marginsseparator");
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
panels().forEach(function (panel) {
|
||||
panel.widgets("org.kde.plasma.icontasks").forEach(function (tasks) {
|
||||
tasks.currentConfigGroup = ["General"];
|
||||
var launchers = tasks.readConfig("launchers");
|
||||
if (typeof launchers === "string") launchers = launchers.length ? launchers.split(",") : [];
|
||||
if (launchers.indexOf("applications:org.kde.kate.desktop") < 0) {
|
||||
launchers.push("applications:org.kde.kate.desktop");
|
||||
tasks.writeConfig("launchers", launchers);
|
||||
}
|
||||
});
|
||||
});
|
||||
Executable
+258
@@ -0,0 +1,258 @@
|
||||
#!/usr/bin/env python3
|
||||
import base64
|
||||
import hashlib
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
|
||||
REPOS = ("core", "extra", "alarm")
|
||||
FIELDS = ("NAME", "VERSION", "BASE", "DESC", "URL", "ARCH", "BUILDDATE", "INSTALLDATE", "PACKAGER", "SIZE",
|
||||
"GROUPS", "LICENSE", "VALIDATION", "REPLACES", "DEPENDS", "OPTDEPENDS", "CONFLICTS", "PROVIDES", "XDATA")
|
||||
PKGINFO = {"pkgname": "NAME", "pkgbase": "BASE", "pkgver": "VERSION", "pkgdesc": "DESC", "url": "URL",
|
||||
"builddate": "BUILDDATE", "packager": "PACKAGER", "size": "SIZE", "arch": "ARCH", "license": "LICENSE",
|
||||
"replaces": "REPLACES", "group": "GROUPS", "conflict": "CONFLICTS", "provides": "PROVIDES",
|
||||
"depend": "DEPENDS", "optdepend": "OPTDEPENDS", "xdata": "XDATA"}
|
||||
BLOCKED = re.compile(r"^(sudo|opendoas|doas|mkinitcpio.*|linux|linux-.*|.*-firmware|firmware-.*|grub|uboot-.*|"
|
||||
r"raspberrypi-.*|archlinuxarm-keyring|pacman|pacman-mirrorlist)$")
|
||||
ALARM = "http://mirror.archlinuxarm.org/aarch64"
|
||||
RELEASES = "https://github.com/Droid-Deck/DroidDeck-Components/releases/download"
|
||||
BUILDER = "68B3537F39A313B3E574D06777193F152BDBE6A6"
|
||||
|
||||
|
||||
def read_entry(path):
|
||||
fields, key = {}, None
|
||||
for name in ("desc", "depends"):
|
||||
file = os.path.join(path, name)
|
||||
if not os.path.exists(file):
|
||||
continue
|
||||
for line in open(file, encoding="utf-8", errors="replace"):
|
||||
line = line.rstrip("\n")
|
||||
if line.startswith("%") and line.endswith("%") and len(line) > 2:
|
||||
key = line.strip("%")
|
||||
fields[key] = []
|
||||
elif line == "":
|
||||
key = None
|
||||
elif key:
|
||||
fields[key].append(line)
|
||||
return fields
|
||||
|
||||
|
||||
def write_fields(fields, order):
|
||||
out = []
|
||||
for key in order:
|
||||
values = fields.get(key)
|
||||
if values:
|
||||
out.append("%" + key + "%\n" + "".join(v + "\n" for v in values))
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def dep_name(dep):
|
||||
return re.split(r"[<>=]", dep, maxsplit=1)[0]
|
||||
|
||||
|
||||
def asset_name(name):
|
||||
return re.sub(r"[^A-Za-z0-9._-]", ".", name)
|
||||
|
||||
|
||||
def package_members(path):
|
||||
if path.endswith(".zst"):
|
||||
data = subprocess.run(["zstd", "-dc", path], check=True, stdout=subprocess.PIPE).stdout
|
||||
return tarfile.open(fileobj=io.BytesIO(data), mode="r:")
|
||||
return tarfile.open(path)
|
||||
|
||||
|
||||
def local_record(path, installed):
|
||||
with package_members(path) as tar:
|
||||
info, mtree, install, files = None, None, None, []
|
||||
for member in tar:
|
||||
name = member.name.removeprefix("./")
|
||||
if name == ".PKGINFO":
|
||||
info = tar.extractfile(member).read().decode("utf-8", "replace")
|
||||
elif name == ".MTREE":
|
||||
mtree = tar.extractfile(member).read()
|
||||
elif name == ".INSTALL":
|
||||
install = tar.extractfile(member).read()
|
||||
elif name in (".BUILDINFO", ".CHANGELOG") or not name:
|
||||
continue
|
||||
else:
|
||||
files.append(name.rstrip("/") + ("/" if member.isdir() else ""))
|
||||
if info is None or mtree is None:
|
||||
raise SystemExit(f"{path}: no .PKGINFO or .MTREE")
|
||||
fields, backup = {}, []
|
||||
for line in info.splitlines():
|
||||
if " = " not in line or line.startswith("#"):
|
||||
continue
|
||||
key, value = line.split(" = ", 1)
|
||||
if key == "backup":
|
||||
backup.append(value)
|
||||
elif key in PKGINFO:
|
||||
fields.setdefault(PKGINFO[key], []).append(value)
|
||||
fields["INSTALLDATE"] = [str(installed)]
|
||||
fields["VALIDATION"] = ["pgp"]
|
||||
for dir_ in sorted({f.rsplit("/", 1)[0] + "/" for f in files if "/" in f.rstrip("/")}):
|
||||
parts = dir_.rstrip("/").split("/")
|
||||
for i in range(1, len(parts) + 1):
|
||||
entry = "/".join(parts[:i]) + "/"
|
||||
if entry not in files:
|
||||
files.append(entry)
|
||||
sums = {}
|
||||
if backup:
|
||||
with package_members(path) as tar:
|
||||
for member in tar:
|
||||
name = member.name.removeprefix("./")
|
||||
if name in backup and member.isfile():
|
||||
sums[name] = hashlib.md5(tar.extractfile(member).read()).hexdigest()
|
||||
listing = "%FILES%\n" + "".join(f + "\n" for f in sorted(set(files)))
|
||||
if backup:
|
||||
listing += "\n%BACKUP%\n" + "".join(f"{b}\t{sums.get(b, '')}\n" for b in backup)
|
||||
return fields, listing, mtree, install
|
||||
|
||||
|
||||
def fetch(dest, *urls):
|
||||
for url in urls:
|
||||
if subprocess.run(["curl", "-fsSL", "--retry", "6", "--retry-delay", "5", "--retry-all-errors",
|
||||
"-o", dest, url]).returncode == 0:
|
||||
return
|
||||
raise SystemExit(f"could not download {os.path.basename(dest)}")
|
||||
|
||||
|
||||
def main():
|
||||
dbdir, cache, pkglist, runtime_file, mirror_file, tag, root, repo = sys.argv[1:9]
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
installed = int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
|
||||
|
||||
entries = {}
|
||||
for source, path in [("extra", os.path.join(here, "pins"))] + [(r, os.path.join(dbdir, "x_" + r)) for r in REPOS]:
|
||||
for entry in sorted(os.listdir(path)):
|
||||
fields = read_entry(os.path.join(path, entry))
|
||||
name = fields.get("NAME", [None])[0]
|
||||
if name and name not in entries:
|
||||
entries[name] = (source, fields)
|
||||
by_file = {fields["FILENAME"][0]: name for name, (_, fields) in entries.items()}
|
||||
|
||||
runtime = dict(line.split() for line in open(runtime_file) if len(line.split()) == 2)
|
||||
shipped = {}
|
||||
for line in open(pkglist):
|
||||
file = line.split()[0].split("/", 1)[1]
|
||||
shipped[by_file[file]] = file
|
||||
|
||||
local = os.path.join(root, "var/lib/pacman/local")
|
||||
os.makedirs(local, exist_ok=True)
|
||||
for name, file in sorted(shipped.items()):
|
||||
fields, listing, mtree, install = local_record(os.path.join(cache, file), installed)
|
||||
if fields["NAME"][0] != name:
|
||||
raise SystemExit(f"{file}: .PKGINFO names {fields['NAME'][0]}, not {name}")
|
||||
record = os.path.join(local, f"{name}-{fields['VERSION'][0]}")
|
||||
os.makedirs(record, exist_ok=True)
|
||||
with open(os.path.join(record, "desc"), "w") as out:
|
||||
out.write(write_fields(fields, FIELDS))
|
||||
with open(os.path.join(record, "files"), "w") as out:
|
||||
out.write(listing)
|
||||
with open(os.path.join(record, "mtree"), "wb") as out:
|
||||
out.write(mtree)
|
||||
if install:
|
||||
with open(os.path.join(record, "install"), "wb") as out:
|
||||
out.write(install)
|
||||
|
||||
system = set(runtime) | set(shipped)
|
||||
available = {n for n in entries if not BLOCKED.match(n)} | system
|
||||
providers = {}
|
||||
for name in available:
|
||||
if name in entries:
|
||||
for p in entries[name][1].get("PROVIDES", []):
|
||||
providers.setdefault(dep_name(p), name)
|
||||
satisfied = set(system)
|
||||
for name in system:
|
||||
if name in entries:
|
||||
satisfied.update(dep_name(p) for p in entries[name][1].get("PROVIDES", []))
|
||||
|
||||
wanted = [l.strip() for l in open(mirror_file) if l.strip() and not l.startswith("#")]
|
||||
mirrored, queue = set(), list(wanted)
|
||||
while queue:
|
||||
dep = dep_name(queue.pop())
|
||||
if dep in satisfied:
|
||||
continue
|
||||
name = dep if dep in available and dep in entries else providers.get(dep)
|
||||
if name is None:
|
||||
raise SystemExit(f"mirror.txt: nothing in the repository provides {dep}")
|
||||
if name in mirrored or name in system:
|
||||
continue
|
||||
mirrored.add(name)
|
||||
queue.extend(entries[name][1].get("DEPENDS", []))
|
||||
|
||||
os.makedirs(repo, exist_ok=True)
|
||||
for name in sorted(mirrored):
|
||||
source, fields = entries[name]
|
||||
file = fields["FILENAME"][0]
|
||||
dest = os.path.join(repo, asset_name(file))
|
||||
if not os.path.exists(dest) or hashlib.sha256(open(dest, "rb").read()).hexdigest() != fields["SHA256SUM"][0]:
|
||||
fetch(dest, f"{ALARM}/{source}/{file}")
|
||||
if hashlib.sha256(open(dest, "rb").read()).hexdigest() != fields["SHA256SUM"][0]:
|
||||
raise SystemExit(f"{file}: sha256 differs from the repository database's")
|
||||
signature = fields.get("PGPSIG", [None])[0]
|
||||
sig = dest + ".sig"
|
||||
if signature:
|
||||
with open(sig, "wb") as out:
|
||||
out.write(base64.b64decode(signature))
|
||||
else:
|
||||
fetch(sig, f"{ALARM}/{source}/{file}.sig")
|
||||
check = subprocess.run(["gpgv", "--status-fd", "1", "--keyring", os.path.join(here, "archlinuxarm-builder.gpg"),
|
||||
sig, dest], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True).stdout
|
||||
if not re.search(rf"^\[GNUPG:\] VALIDSIG .* {BUILDER}$", check, re.M):
|
||||
raise SystemExit(f"{file}: no valid Arch Linux ARM Build System signature")
|
||||
if not signature:
|
||||
fields["PGPSIG"] = [base64.b64encode(open(sig, "rb").read()).decode()]
|
||||
os.remove(sig)
|
||||
print(f"pacman: {len(shipped)} install records, {len(mirrored)} mirrored packages, "
|
||||
f"{sum(os.path.getsize(os.path.join(repo, asset_name(entries[n][1]['FILENAME'][0]))) for n in mirrored) // 1048576} MiB")
|
||||
|
||||
order = ["FILENAME", "NAME", "BASE", "VERSION", "DESC", "GROUPS", "CSIZE", "ISIZE", "MD5SUM", "SHA256SUM", "PGPSIG",
|
||||
"URL", "LICENSE", "ARCH", "BUILDDATE", "PACKAGER", "REPLACES", "CONFLICTS", "PROVIDES", "DEPENDS",
|
||||
"OPTDEPENDS", "MAKEDEPENDS", "CHECKDEPENDS", "XDATA"]
|
||||
buffer = io.BytesIO()
|
||||
with tarfile.open(fileobj=buffer, mode="w:gz", format=tarfile.GNU_FORMAT) as db:
|
||||
for name in sorted(available):
|
||||
if name in entries and (name not in runtime or name in shipped or runtime[name] == entries[name][1]["VERSION"][0]):
|
||||
fields = dict(entries[name][1])
|
||||
else:
|
||||
fields = {"FILENAME": [f"{name}-{runtime[name]}-aarch64.pkg.tar.xz"], "NAME": [name],
|
||||
"VERSION": [runtime[name]], "ARCH": ["aarch64"]}
|
||||
if name in mirrored:
|
||||
fields["FILENAME"] = [asset_name(fields["FILENAME"][0])]
|
||||
data = write_fields(fields, order).encode()
|
||||
folder = f"{name}-{fields['VERSION'][0]}"
|
||||
info = tarfile.TarInfo(folder)
|
||||
info.type, info.mode, info.mtime = tarfile.DIRTYPE, 0o755, installed
|
||||
db.addfile(info)
|
||||
info = tarfile.TarInfo(folder + "/desc")
|
||||
info.size, info.mode, info.mtime = len(data), 0o644, installed
|
||||
db.addfile(info, io.BytesIO(data))
|
||||
with open(os.path.join(repo, "droiddeck.db"), "wb") as out:
|
||||
out.write(buffer.getvalue())
|
||||
|
||||
share = os.path.join(root, "usr/share/droiddeck/pacman")
|
||||
os.makedirs(os.path.join(share, "hooks"), exist_ok=True)
|
||||
with open(os.path.join(share, "droiddeck.db"), "wb") as out:
|
||||
out.write(buffer.getvalue())
|
||||
with open(os.path.join(share, "system-packages.txt"), "w") as out:
|
||||
out.write("".join(n + "\n" for n in sorted(system)))
|
||||
with open(os.path.join(share, "desktop-packages.txt"), "w") as out:
|
||||
out.write("".join(f"{n} {entries[n][1]['VERSION'][0]}\n" for n in sorted(shipped)))
|
||||
with open(os.path.join(share, "hooks", "droiddeck-system.hook"), "w") as out:
|
||||
out.write("[Trigger]\nOperation = Upgrade\nOperation = Remove\nType = Package\n")
|
||||
out.write("".join(f"Target = {n}\n" for n in sorted(system)))
|
||||
out.write("\n[Action]\nDescription = Keeping the packages DroidDeck installed...\nWhen = PreTransaction\n"
|
||||
"Exec = /usr/share/droiddeck/pacman/refuse\nNeedsTargets\nAbortOnFail\n")
|
||||
server = f"{RELEASES}/{tag}" if tag else f"{RELEASES}/unpublished"
|
||||
template = open(os.path.join(here, "pacman.conf.in")).read()
|
||||
with open(os.path.join(share, "pacman.conf"), "w") as out:
|
||||
out.write(template.replace("@SERVER@", server).replace("@ALARM@", ALARM))
|
||||
print(f"pacman: repository {server}, {len(available)} packages ({len(system)} installed by DroidDeck)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,22 @@
|
||||
[options]
|
||||
RootDir = /
|
||||
DBPath = /var/lib/pacman/
|
||||
CacheDir = /var/cache/pacman/pkg/
|
||||
LogFile = /var/log/pacman.log
|
||||
GPGDir = /etc/pacman.d/gnupg/
|
||||
HookDir = /etc/pacman.d/hooks/
|
||||
HookDir = /usr/share/droiddeck/pacman/hooks/
|
||||
HoldPkg = pacman glibc
|
||||
Architecture = aarch64
|
||||
Color
|
||||
ParallelDownloads = 4
|
||||
DisableSandbox
|
||||
SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
NoExtract = usr/share/doc/* usr/share/gtk-doc/* usr/share/help/*
|
||||
|
||||
[droiddeck]
|
||||
Server = @SERVER@
|
||||
CacheServer = @ALARM@/extra
|
||||
CacheServer = @ALARM@/core
|
||||
CacheServer = @ALARM@/alarm
|
||||
@@ -1,13 +1,12 @@
|
||||
--- a/src/backends/wayland/wayland_backend.cpp
|
||||
+++ b/src/backends/wayland/wayland_backend.cpp
|
||||
@@ -455,6 +455,20 @@
|
||||
@@ -455,6 +455,19 @@
|
||||
|
||||
if (WaylandClient::LinuxDmabufV1 *dmabuf = m_display->linuxDmabuf()) {
|
||||
m_renderDevice = GpuManager::self()->compatibleRenderDevice(dmabuf->mainDevice());
|
||||
+ if (!m_renderDevice && qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
|
||||
+ const auto nodes = GpuManager::splitPathList(qEnvironmentVariable("KWIN_RENDER_NODES"));
|
||||
+ const auto &devices = GpuManager::self()->renderDevices();
|
||||
+ // Android's KGSL host cannot name a DRM device in its dmabuf feedback.
|
||||
+ if (nodes.size() == 1) {
|
||||
+ for (const auto &device : devices) {
|
||||
+ if (device->path() == nodes.constFirst()) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
--- a/src/backends/wayland/wayland_backend.cpp
|
||||
+++ b/src/backends/wayland/wayland_backend.cpp
|
||||
@@ -30,6 +30,9 @@
|
||||
|
||||
#include <QAbstractEventDispatcher>
|
||||
|
||||
+#include <array>
|
||||
+#include <memory>
|
||||
+
|
||||
#include <drm_fourcc.h>
|
||||
#include <fcntl.h>
|
||||
#include <gbm.h>
|
||||
@@ -124,8 +127,31 @@
|
||||
}
|
||||
Q_EMIT pointerButtonChanged(button, state, std::chrono::milliseconds(time), this);
|
||||
});
|
||||
- // TODO: Send discreteDelta and source as well.
|
||||
- connect(pointer, &Pointer::axisChanged, this, [this](quint32 time, Pointer::Axis nativeAxis, qreal delta) {
|
||||
+ auto axisSource = std::make_shared<PointerAxisSource>(PointerAxisSource::Unknown);
|
||||
+ auto axisDiscrete = std::make_shared<std::array<qint32, 2>>();
|
||||
+ connect(pointer, &Pointer::axisSourceChanged, this, [axisSource](Pointer::AxisSource source) {
|
||||
+ switch (source) {
|
||||
+ case Pointer::AxisSource::Wheel:
|
||||
+ *axisSource = PointerAxisSource::Wheel;
|
||||
+ break;
|
||||
+ case Pointer::AxisSource::Finger:
|
||||
+ *axisSource = PointerAxisSource::Finger;
|
||||
+ break;
|
||||
+ case Pointer::AxisSource::Continuous:
|
||||
+ *axisSource = PointerAxisSource::Continuous;
|
||||
+ break;
|
||||
+ case Pointer::AxisSource::WheelTilt:
|
||||
+ *axisSource = PointerAxisSource::WheelTilt;
|
||||
+ break;
|
||||
+ default:
|
||||
+ *axisSource = PointerAxisSource::Unknown;
|
||||
+ break;
|
||||
+ }
|
||||
+ });
|
||||
+ connect(pointer, &Pointer::axisDiscreteChanged, this, [axisDiscrete](Pointer::Axis nativeAxis, qint32 discreteDelta) {
|
||||
+ (*axisDiscrete)[nativeAxis == Pointer::Axis::Vertical ? 0 : 1] = discreteDelta * 120;
|
||||
+ });
|
||||
+ connect(pointer, &Pointer::axisChanged, this, [this, axisSource, axisDiscrete](quint32 time, Pointer::Axis nativeAxis, qreal delta) {
|
||||
PointerAxis axis;
|
||||
switch (nativeAxis) {
|
||||
case Pointer::Axis::Horizontal:
|
||||
@@ -137,10 +163,18 @@
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
- Q_EMIT pointerAxisChanged(axis, delta, 0, PointerAxisSource::Unknown, false, false, std::chrono::milliseconds(time), this);
|
||||
+ qint32 &discrete = (*axisDiscrete)[nativeAxis == Pointer::Axis::Vertical ? 0 : 1];
|
||||
+ Q_EMIT pointerAxisChanged(axis, delta, discrete, *axisSource, false, false, std::chrono::milliseconds(time), this);
|
||||
+ discrete = 0;
|
||||
+ });
|
||||
+ connect(pointer, &Pointer::axisStopped, this, [this, axisSource](quint32 time, Pointer::Axis nativeAxis) {
|
||||
+ const PointerAxis axis = nativeAxis == Pointer::Axis::Vertical ? PointerAxis::Vertical : PointerAxis::Horizontal;
|
||||
+ Q_EMIT pointerAxisChanged(axis, 0, 0, *axisSource, false, false, std::chrono::milliseconds(time), this);
|
||||
});
|
||||
|
||||
- connect(pointer, &Pointer::frame, this, [this]() {
|
||||
+ connect(pointer, &Pointer::frame, this, [this, axisSource, axisDiscrete]() {
|
||||
+ *axisSource = PointerAxisSource::Unknown;
|
||||
+ axisDiscrete->fill(0);
|
||||
Q_EMIT pointerFrame(this);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
DESKTOP_KDE_REPO=Droid-Deck/DroidDeck-Components
|
||||
DESKTOP_KDE_TAG=desktop-kde-r2
|
||||
DESKTOP_KDE_SHA256=9ba832677b498654136c69d8c8330434d17e4d53cd099acac9bde3ba429b35bf
|
||||
DESKTOP_KDE_SIZE=846933224
|
||||
DESKTOP_KDE_TAG=desktop-kde-r3
|
||||
DESKTOP_KDE_SHA256=8b7142fcec8d86143ae39fc14ffc86907d30d9a5b5a45f49cb1b55109d6fc4eb
|
||||
DESKTOP_KDE_SIZE=972598429
|
||||
@@ -1,14 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate removal inventories from checksum-pinned published archives.
|
||||
|
||||
Usage: removal-manifests.py <LXQt tar.zst> <KDE r1 tar.zst> <KDE r2 tar.zst>
|
||||
<emulators tar.zst> <verified KDE package cache> <output dir>
|
||||
<verified LXQt package cache>
|
||||
Removal includes desktop applications/themes and our overlay, not their shared dependencies.
|
||||
The KDE cache is verified against the published desktop-kde.packages.txt before use.
|
||||
The LXQt cache contains the signed application packages listed by desktop.packages.txt;
|
||||
verify their Arch Linux ARM Build System signatures before generating the inventory.
|
||||
"""
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
@@ -63,10 +53,7 @@ def write(out, name, records):
|
||||
gz.write(('\n'.join(sorted(set(records))) + '\n').encode())
|
||||
|
||||
|
||||
def main():
|
||||
archives = [pathlib.Path(p) for p in sys.argv[1:5]]
|
||||
cache, out, legacy_cache = map(pathlib.Path, sys.argv[5:8])
|
||||
here = pathlib.Path(__file__).resolve().parent
|
||||
def application_paths(here, cache):
|
||||
seeds = {line.strip() for line in (here / 'seeds.txt').read_text().splitlines() if line.strip() and not line.startswith('#')} - SHARED_SEEDS
|
||||
packages = dict(line.split() for line in (cache / 'desktop-kde.packages.txt').read_text().splitlines())
|
||||
selected = set()
|
||||
@@ -79,10 +66,39 @@ def main():
|
||||
if sha(archive) != digest:
|
||||
raise ValueError(f'{filename}: source package checksum mismatch')
|
||||
with tarfile.open(archive) as tar:
|
||||
selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir())
|
||||
selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir() and not e.name.removeprefix('./').startswith('.'))
|
||||
found.add(package)
|
||||
assert found == seeds, f'missing desktop packages: {seeds - found}'
|
||||
selected.update(str(p.relative_to(here / 'overlay')) for p in (here / 'overlay').rglob('*') if p.is_file())
|
||||
selected.update(str(p.relative_to(here / 'overlay')) for p in (here / 'overlay').rglob('*') if p.is_file() or p.is_symlink())
|
||||
return selected, packages, seeds
|
||||
|
||||
|
||||
def add(archive, tag, digest, cache, out):
|
||||
here = pathlib.Path(__file__).resolve().parent
|
||||
selected, packages, seeds = application_paths(here, cache)
|
||||
inv = inventory(archive, digest)
|
||||
generated = ('usr/share/droiddeck/pacman/', 'usr/lib/droiddeck/')
|
||||
remove = gzip.decompress((out / 'kde-remove.tsv.gzip').read_bytes()).decode().splitlines()
|
||||
keep = gzip.decompress((out / 'kde-keep.txt.gzip').read_bytes()).decode().splitlines()
|
||||
remove += [record for path, record in inv.items() if path in selected or path.startswith(generated)]
|
||||
keep += list(inv)
|
||||
write(out, 'kde-remove.tsv.gzip', remove)
|
||||
write(out, 'kde-keep.txt.gzip', keep)
|
||||
versions = (out / 'versions.txt').read_text().split()
|
||||
(out / 'versions.txt').write_text('\n'.join(dict.fromkeys(versions + [tag])) + '\n')
|
||||
sources = json.loads((out / 'sources.json').read_text())
|
||||
sources['archives'][tag] = digest
|
||||
sources['desktopApplications'] = {n: h for n, h in packages.items() if n.rsplit('-', 3)[0] in seeds}
|
||||
(out / 'sources.json').write_text(json.dumps(sources, indent=2) + '\n')
|
||||
print(tag, digest)
|
||||
print('KDE removable paths', sum(path in selected or path.startswith(generated) for path in inv))
|
||||
|
||||
|
||||
def main():
|
||||
archives = [pathlib.Path(p) for p in sys.argv[1:5]]
|
||||
cache, out, legacy_cache = map(pathlib.Path, sys.argv[5:8])
|
||||
here = pathlib.Path(__file__).resolve().parent
|
||||
selected, packages, seeds = application_paths(here, cache)
|
||||
inventories = [inventory(p, pin[1]) for p, pin in zip(archives, PINS)]
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
legacy_seeds = {line.strip() for line in (here / 'lxqt-applications.txt').read_text().splitlines()
|
||||
@@ -115,4 +131,7 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
if sys.argv[1:2] == ['--add']:
|
||||
add(pathlib.Path(sys.argv[2]), sys.argv[3], sys.argv[4], pathlib.Path(sys.argv[5]), pathlib.Path(sys.argv[6]))
|
||||
else:
|
||||
main()
|
||||
@@ -0,0 +1,190 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define REAL(name) static __typeof__(name) *real_##name; if (!real_##name) real_##name = dlsym(RTLD_NEXT, #name)
|
||||
|
||||
static uid_t real_uid(void) { return (uid_t)syscall(SYS_getuid); }
|
||||
static gid_t real_gid(void) { return (gid_t)syscall(SYS_getgid); }
|
||||
|
||||
uid_t getuid(void) { return 0; }
|
||||
uid_t geteuid(void) { return 0; }
|
||||
gid_t getgid(void) { return 0; }
|
||||
gid_t getegid(void) { return 0; }
|
||||
|
||||
int getresuid(uid_t *r, uid_t *e, uid_t *s) {
|
||||
if (r) *r = 0;
|
||||
if (e) *e = 0;
|
||||
if (s) *s = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getresgid(gid_t *r, gid_t *e, gid_t *s) {
|
||||
if (r) *r = 0;
|
||||
if (e) *e = 0;
|
||||
if (s) *s = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setuid(uid_t u) { (void)u; return 0; }
|
||||
int seteuid(uid_t u) { (void)u; return 0; }
|
||||
int setgid(gid_t g) { (void)g; return 0; }
|
||||
int setegid(gid_t g) { (void)g; return 0; }
|
||||
int setreuid(uid_t r, uid_t e) { (void)r; (void)e; return 0; }
|
||||
int setregid(gid_t r, gid_t e) { (void)r; (void)e; return 0; }
|
||||
int setresuid(uid_t r, uid_t e, uid_t s) { (void)r; (void)e; (void)s; return 0; }
|
||||
int setresgid(gid_t r, gid_t e, gid_t s) { (void)r; (void)e; (void)s; return 0; }
|
||||
int setgroups(size_t n, const gid_t *list) { (void)n; (void)list; return 0; }
|
||||
int initgroups(const char *user, gid_t group) { (void)user; (void)group; return 0; }
|
||||
|
||||
static int owner_result(int rc) {
|
||||
if (rc != 0 && (errno == EPERM || errno == EINVAL)) {
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int chown(const char *path, uid_t u, gid_t g) {
|
||||
REAL(chown);
|
||||
return owner_result(real_chown(path, u, g));
|
||||
}
|
||||
|
||||
int lchown(const char *path, uid_t u, gid_t g) {
|
||||
REAL(lchown);
|
||||
return owner_result(real_lchown(path, u, g));
|
||||
}
|
||||
|
||||
int fchown(int fd, uid_t u, gid_t g) {
|
||||
REAL(fchown);
|
||||
return owner_result(real_fchown(fd, u, g));
|
||||
}
|
||||
|
||||
int fchownat(int dirfd, const char *path, uid_t u, gid_t g, int flags) {
|
||||
REAL(fchownat);
|
||||
return owner_result(real_fchownat(dirfd, path, u, g, flags));
|
||||
}
|
||||
|
||||
static struct passwd *as_root_user(struct passwd *pw) {
|
||||
if (pw && pw->pw_uid == real_uid()) {
|
||||
pw->pw_uid = 0;
|
||||
pw->pw_gid = 0;
|
||||
}
|
||||
return pw;
|
||||
}
|
||||
|
||||
static struct group *as_root_group(struct group *gr) {
|
||||
if (gr && gr->gr_gid == real_gid()) gr->gr_gid = 0;
|
||||
return gr;
|
||||
}
|
||||
|
||||
struct passwd *getpwuid(uid_t uid) {
|
||||
REAL(getpwuid);
|
||||
return as_root_user(real_getpwuid(uid == 0 ? real_uid() : uid));
|
||||
}
|
||||
|
||||
struct passwd *getpwnam(const char *name) {
|
||||
REAL(getpwnam);
|
||||
return as_root_user(real_getpwnam(name));
|
||||
}
|
||||
|
||||
struct passwd *getpwent(void) {
|
||||
REAL(getpwent);
|
||||
return as_root_user(real_getpwent());
|
||||
}
|
||||
|
||||
int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t len, struct passwd **out) {
|
||||
REAL(getpwuid_r);
|
||||
int rc = real_getpwuid_r(uid == 0 ? real_uid() : uid, pw, buf, len, out);
|
||||
if (rc == 0) as_root_user(*out);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t len, struct passwd **out) {
|
||||
REAL(getpwnam_r);
|
||||
int rc = real_getpwnam_r(name, pw, buf, len, out);
|
||||
if (rc == 0) as_root_user(*out);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct group *getgrgid(gid_t gid) {
|
||||
REAL(getgrgid);
|
||||
return as_root_group(real_getgrgid(gid == 0 ? real_gid() : gid));
|
||||
}
|
||||
|
||||
struct group *getgrnam(const char *name) {
|
||||
REAL(getgrnam);
|
||||
return as_root_group(real_getgrnam(name));
|
||||
}
|
||||
|
||||
int getgrgid_r(gid_t gid, struct group *gr, char *buf, size_t len, struct group **out) {
|
||||
REAL(getgrgid_r);
|
||||
int rc = real_getgrgid_r(gid == 0 ? real_gid() : gid, gr, buf, len, out);
|
||||
if (rc == 0) as_root_group(*out);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int getgrnam_r(const char *name, struct group *gr, char *buf, size_t len, struct group **out) {
|
||||
REAL(getgrnam_r);
|
||||
int rc = real_getgrnam_r(name, gr, buf, len, out);
|
||||
if (rc == 0) as_root_group(*out);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int shown_mode(int rc, struct stat *st) {
|
||||
if (rc == 0 && S_ISDIR(st->st_mode) && (st->st_mode & 0777) == 0700) st->st_mode = (st->st_mode & ~0777) | 0755;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int stat(const char *path, struct stat *st) {
|
||||
REAL(stat);
|
||||
return shown_mode(real_stat(path, st), st);
|
||||
}
|
||||
|
||||
int lstat(const char *path, struct stat *st) {
|
||||
REAL(lstat);
|
||||
return shown_mode(real_lstat(path, st), st);
|
||||
}
|
||||
|
||||
int fstat(int fd, struct stat *st) {
|
||||
REAL(fstat);
|
||||
return shown_mode(real_fstat(fd, st), st);
|
||||
}
|
||||
|
||||
int fstatat(int dirfd, const char *path, struct stat *st, int flags) {
|
||||
REAL(fstatat);
|
||||
return shown_mode(real_fstatat(dirfd, path, st, flags), st);
|
||||
}
|
||||
|
||||
int statx(int dirfd, const char *path, int flags, unsigned int mask, struct statx *st) {
|
||||
REAL(statx);
|
||||
int rc = real_statx(dirfd, path, flags, mask, st);
|
||||
if (rc == 0 && S_ISDIR(st->stx_mode) && (st->stx_mode & 0777) == 0700) st->stx_mode = (st->stx_mode & ~0777) | 0755;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int stat64(const char *path, struct stat64 *st) {
|
||||
REAL(stat64);
|
||||
return shown_mode(real_stat64(path, st), (struct stat *)st);
|
||||
}
|
||||
|
||||
int lstat64(const char *path, struct stat64 *st) {
|
||||
REAL(lstat64);
|
||||
return shown_mode(real_lstat64(path, st), (struct stat *)st);
|
||||
}
|
||||
|
||||
int fstat64(int fd, struct stat64 *st) {
|
||||
REAL(fstat64);
|
||||
return shown_mode(real_fstat64(fd, st), (struct stat *)st);
|
||||
}
|
||||
|
||||
int fstatat64(int dirfd, const char *path, struct stat64 *st, int flags) {
|
||||
REAL(fstatat64);
|
||||
return shown_mode(real_fstatat64(dirfd, path, st, flags), (struct stat *)st);
|
||||
}
|
||||
@@ -26,3 +26,23 @@ noto-fonts-emoji
|
||||
xdg-utils
|
||||
firefox
|
||||
mpv
|
||||
zip
|
||||
unzip
|
||||
7zip
|
||||
unrar
|
||||
less
|
||||
man-db
|
||||
man-pages
|
||||
htop
|
||||
wl-clipboard
|
||||
xclip
|
||||
git
|
||||
wget
|
||||
kcalc
|
||||
okular
|
||||
filelight
|
||||
kfind
|
||||
plasma-systemmonitor
|
||||
elisa
|
||||
discover
|
||||
flatpak-kcm
|
||||
+38
-24
@@ -1,26 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke test of a DroidDeck build on a real device, over plain adb (no python, no root).
|
||||
#
|
||||
# What it does, in order, and restores afterwards:
|
||||
# 1. prints the device (model, Android, kernel, page size, SoC);
|
||||
# 2. installs --apk when given and launches the app;
|
||||
# 3. checks that the app starts and that nothing in the crash buffer belongs to it;
|
||||
# 4. changes the display density and the window size and checks the app keeps its process
|
||||
# (and does not recreate the activity that is on top);
|
||||
# 5. on a foldable cycles the device state (half-opened, and with --closed also closed) through
|
||||
# `cmd device_state`, then puts the original state back;
|
||||
# 6. reads the newest session folder of a debug build: first frame, last frame rate, the
|
||||
# memory page size and the last process exits.
|
||||
#
|
||||
# Usage: tools/device-smoke.sh [--serial SERIAL] [--apk FILE] [--pkg PACKAGE]
|
||||
# [--no-density] [--no-size] [--no-fold] [--closed]
|
||||
# Exit status: 0 when no check failed, 1 when one did, 2 for a usage or device problem.
|
||||
#
|
||||
# Not a replacement for tools/droiddeck-scenario, which drives a game through the agent bridge;
|
||||
# this covers what that does not: display changes and foldable states.
|
||||
set -u
|
||||
export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL='*'
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Smoke test of a DroidDeck build on a real device, over plain adb (no python, no root).
|
||||
|
||||
What it does, in order, and restores afterwards:
|
||||
1. prints the device (model, Android, kernel, page size, SoC);
|
||||
2. installs --apk when given and launches the app;
|
||||
3. checks that the app starts and that nothing in the crash buffer belongs to it;
|
||||
4. changes the display density and the window size and checks the app keeps its process
|
||||
(and does not recreate the activity that is on top);
|
||||
5. on a foldable cycles the device state (half-opened, and with --closed also closed) through
|
||||
`cmd device_state`, then puts the original state back;
|
||||
6. reads the newest session folder of a debug build: first frame, last frame rate, the
|
||||
memory page size, the proot that session ran, and the last process exits.
|
||||
|
||||
Usage: tools/device-smoke.sh [--serial SERIAL] [--apk FILE] [--pkg PACKAGE]
|
||||
[--no-density] [--no-size] [--no-fold] [--closed]
|
||||
Exit status: 0 when no check failed, 1 when one did, 2 for a usage or device problem.
|
||||
|
||||
Not a replacement for tools/droiddeck-scenario, which drives a game through the agent bridge;
|
||||
this covers what that does not: display changes and foldable states.
|
||||
EOF
|
||||
}
|
||||
|
||||
pkg=com.droiddeck.launcher
|
||||
serial=${ANDROID_SERIAL:-}
|
||||
apk=
|
||||
@@ -39,7 +44,7 @@ while [ $# -gt 0 ]; do
|
||||
--no-size) do_size=0 ;;
|
||||
--no-fold) do_fold=0 ;;
|
||||
--closed) do_closed=1 ;;
|
||||
-h|--help) sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown option: $1" >&2; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
@@ -96,7 +101,6 @@ restore_size() {
|
||||
echo "$current" | grep -q 'Physical size:' || return 1
|
||||
[ "$(echo "$current" | wm_override size)" = "$override_size" ]
|
||||
}
|
||||
# An override that was already in place (a test lab pins one) is put back; otherwise the request is cancelled.
|
||||
restore_fold() { if [ -n "$pre_override" ]; then sh_ cmd device_state state "$pre_override" >/dev/null; else sh_ cmd device_state state reset >/dev/null; fi; }
|
||||
|
||||
restore() {
|
||||
@@ -133,7 +137,7 @@ app_crashes() {
|
||||
pat=$(printf '%s' "$pkg" | sed 's/[.[\*^$]/\\&/g')
|
||||
printf '%s\n' "$out" | grep -c -E "(Process: |Cmdline: |>>> )$pat([ ,<:]|$)" || true
|
||||
}
|
||||
relaunches_of() { # $1 = activity class fragment
|
||||
relaunches_of() {
|
||||
sh_ logcat -b events -d 2>/dev/null | grep -E 'wm_(relaunch|destroy|create)_activity' | grep -c "$1"
|
||||
}
|
||||
|
||||
@@ -214,7 +218,7 @@ if [ "$do_size" = 1 ]; then
|
||||
phys=$(echo "$size_snapshot" | sed -n 's/.*Physical size: \([0-9]*\)x\([0-9]*\).*/\1 \2/p' | head -1)
|
||||
set -- $phys
|
||||
if [ -n "${1:-}" ]; then
|
||||
w=$(( ($2 * 2 / 3) / 2 * 2 )); h=$1 # a narrower, taller window, like a cover screen
|
||||
w=$(( ($2 * 2 / 3) / 2 * 2 )); h=$1
|
||||
pid0=$(app_pid)
|
||||
size_changed=1
|
||||
wm_status=0
|
||||
@@ -250,7 +254,7 @@ if [ "$do_fold" = 1 ]; then
|
||||
else
|
||||
id_of() { echo "$states" | sed -n "s/.*identifier=\([0-9]*\), name='$1'.*/\1/p" | head -1; }
|
||||
half=$(id_of HALF_OPENED); closed=$(id_of CLOSED)
|
||||
cycle() { # $1 name $2 id
|
||||
cycle() {
|
||||
pid0=$(app_pid)
|
||||
fold_changed=1
|
||||
sh_ cmd device_state state "$2" >/dev/null; sleep 8
|
||||
@@ -279,6 +283,16 @@ else
|
||||
ev=$(sh_ run-as "$pkg" cat "files/logs/$dir/events.jsonl" 2>/dev/null)
|
||||
echo "$ev" | grep -q '"frame.first"' && ok "first frame was drawn" || note "no frame.first in $dir"
|
||||
echo "$ev" | grep -q '"session.failed"' && bad "session.failed: $(echo "$ev" | grep '"session.failed"' | tail -1 | cut -c1-160)"
|
||||
report=$(sh_ run-as "$pkg" cat "files/logs/$dir/device.txt" 2>/dev/null)
|
||||
proot_line=$(echo "$report" | grep 'proot binary' | head -1)
|
||||
case $proot_line in
|
||||
*"rootfs fallback"*|*"missing"*) bad "session proot is not the patched binary ($proot_line)" ;;
|
||||
*"apk"*|*"add-on pack"*) ok "patched proot ($proot_line)" ;;
|
||||
*) note "device report has no proot binary line (build from before the check)" ;;
|
||||
esac
|
||||
app_log=$(sh_ run-as "$pkg" cat "files/logs/$dir/app.log" 2>/dev/null)
|
||||
echo "$app_log" | grep -Fq 'proot: fast path on (' && ok "proot fast path was on" \
|
||||
|| note "proot fast path activation was not recorded ($(echo "$report" | grep 'proot fast path' | tr '\n' '; '))"
|
||||
fps=$(sh_ run-as "$pkg" cat "files/logs/$dir/app.log" 2>/dev/null | grep 'last 10 s:' | tail -1 | sed 's/.*last 10 s: //' | cut -c1-70)
|
||||
[ -n "$fps" ] && echo " last stats $fps"
|
||||
sh_ run-as "$pkg" cat "files/logs/$dir/device.txt" 2>/dev/null | grep -E 'Memory page size|^Kernel' | sed 's/^/ report /'
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
repo_root=$1
|
||||
source_dir=$2
|
||||
: "${NDK:=${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-}}}}"
|
||||
: "${NDK:?set NDK to the Android NDK root}"
|
||||
case "$(uname -s)" in
|
||||
Darwin) host=darwin-x86_64 ;;
|
||||
Linux) host=linux-x86_64 ;;
|
||||
*) echo 'Unsupported NDK host' >&2; exit 1 ;;
|
||||
esac
|
||||
toolchain="$NDK/toolchains/llvm/prebuilt/$host/bin"
|
||||
patch -d "$source_dir" -p1 < "$repo_root/tools/directaudio/microphone-toggle.patch"
|
||||
"$toolchain/aarch64-linux-android28-clang" -O2 -Wl,-z,max-page-size=16384 \
|
||||
"$source_dir/directaudio-relay.c" -o "$repo_root/app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so" \
|
||||
-laaudio -llog -pthread
|
||||
"$toolchain/llvm-strip" --strip-unneeded "$repo_root/app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so"
|
||||
@@ -3,7 +3,7 @@ set -euo pipefail
|
||||
repo_root=$1
|
||||
sink_out=$2
|
||||
. "${repo_root}/tools/directaudio/release.env"
|
||||
for v in DIRECTAUDIO_REPO DIRECTAUDIO_TAG DIRECTAUDIO_WINE11_SHA256 DIRECTAUDIO_SYSTHREAD_SHA256 DIRECTAUDIO_RELAY_SHA256 DIRECTAUDIO_SINK_SHA256; do
|
||||
for v in DIRECTAUDIO_REPO DIRECTAUDIO_TAG DIRECTAUDIO_WINE11_SHA256 DIRECTAUDIO_SYSTHREAD_SHA256 DIRECTAUDIO_SINK_SHA256 DIRECTAUDIO_SOURCE_COMMIT DIRECTAUDIO_SOURCE_SHA256; do
|
||||
[[ -n "${!v:-}" && "${!v}" != TBD ]] || { echo "tools/directaudio/release.env: ${v} is not set" >&2; exit 1; }
|
||||
done
|
||||
work=$(mktemp -d)
|
||||
@@ -15,7 +15,7 @@ fetch() {
|
||||
local name=$1 sha=$2 kept="${cache}/$2-$1" part
|
||||
if ! echo "${sha} ${kept}" | sha256sum -c - >/dev/null 2>&1; then
|
||||
part=$(mktemp "${kept}.part.XXXXXX")
|
||||
curl -fsSL --retry 3 -o "${part}" \
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "${part}" \
|
||||
"https://github.com/${DIRECTAUDIO_REPO}/releases/download/${DIRECTAUDIO_TAG}/${name}"
|
||||
echo "${sha} ${part}" | sha256sum -c - >/dev/null || { echo "${name}: checksum mismatch" >&2; rm -f "${part}"; exit 1; }
|
||||
mv "${part}" "${kept}"
|
||||
@@ -24,7 +24,15 @@ fetch() {
|
||||
}
|
||||
fetch directaudio-linux-wine11.zip "${DIRECTAUDIO_WINE11_SHA256}"
|
||||
fetch directaudio-linux-wine11-systhread.zip "${DIRECTAUDIO_SYSTHREAD_SHA256}"
|
||||
fetch directaudio-linux-relay.zip "${DIRECTAUDIO_RELAY_SHA256}"
|
||||
source_archive="${cache}/${DIRECTAUDIO_SOURCE_SHA256}-directaudio-source.tar.gz"
|
||||
if ! echo "${DIRECTAUDIO_SOURCE_SHA256} ${source_archive}" | sha256sum -c - >/dev/null 2>&1; then
|
||||
curl -fsSL --retry 5 --retry-all-errors --connect-timeout 20 -o "${work}/source.tar.gz" \
|
||||
"https://github.com/${DIRECTAUDIO_REPO}/archive/${DIRECTAUDIO_SOURCE_COMMIT}.tar.gz"
|
||||
echo "${DIRECTAUDIO_SOURCE_SHA256} ${work}/source.tar.gz" | sha256sum -c - >/dev/null
|
||||
mv "${work}/source.tar.gz" "${source_archive}"
|
||||
fi
|
||||
mkdir "${work}/source"
|
||||
tar -xzf "${source_archive}" --strip-components=1 -C "${work}/source"
|
||||
fetch directaudio-linux-sink.zip "${DIRECTAUDIO_SINK_SHA256}"
|
||||
|
||||
assets="${repo_root}/app/src/main/assets/directaudio"
|
||||
@@ -40,9 +48,8 @@ done
|
||||
grep -q '^abi wine11$' "${assets}/linux-wine11/version.txt"
|
||||
grep -q '^abi systhread$' "${assets}/linux-wine11-systhread/version.txt"
|
||||
|
||||
mkdir -p "${work}/relay" "${work}/sink" "${sink_out}" "${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
unzip -q "${work}/directaudio-linux-relay.zip" -d "${work}/relay"
|
||||
install -m755 "${work}/relay/libdirectaudiorelay.so" "${repo_root}/app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so"
|
||||
mkdir -p "${work}/sink" "${sink_out}" "${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
"${repo_root}/tools/directaudio/build-relay.sh" "${repo_root}" "${work}/source"
|
||||
unzip -q "${work}/directaudio-linux-sink.zip" -d "${work}/sink"
|
||||
install -m755 "${work}/sink/module-directaudio-native-sink.so" "${sink_out}/"
|
||||
echo "DirectAudio ${DIRECTAUDIO_TAG}: two driver sets, the relay helper and the client sink in place"
|
||||
@@ -0,0 +1,123 @@
|
||||
--- a/directaudio-relay.c
|
||||
+++ b/directaudio-relay.c
|
||||
@@ -70,6 +70,9 @@
|
||||
* session log captures it too. Event-level lines are always on: they fire a
|
||||
* handful of times per session and are what makes a field report actionable. */
|
||||
static int g_verbose;
|
||||
+static const char *g_mic_control;
|
||||
+static int g_mic_enabled = 1;
|
||||
+static pthread_mutex_t g_mic_operations = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void rlog(const char *fmt, ...)
|
||||
{
|
||||
@@ -735,6 +738,9 @@
|
||||
(void)user;
|
||||
if (aq != __atomic_load_n(&g_mic.cq, __ATOMIC_SEQ_CST) && __atomic_load_n(&g_mic.cq, __ATOMIC_SEQ_CST))
|
||||
return AAUDIO_CALLBACK_RESULT_CONTINUE;
|
||||
+ if (!__atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE))
|
||||
+ memset(audioData, 0, numFrames * g_mic.in_channels *
|
||||
+ (g_mic.in_format == AAUDIO_FORMAT_PCM_I16 ? sizeof(int16_t) : sizeof(float)));
|
||||
__atomic_add_fetch(&g_mic.cb_count, 1, __ATOMIC_RELAXED);
|
||||
|
||||
pthread_mutex_lock(&g_clients_lock);
|
||||
@@ -832,13 +838,14 @@
|
||||
AAudioStream *aq = NULL;
|
||||
int start = 0, stop = 0;
|
||||
|
||||
+ pthread_mutex_lock(&g_mic_operations);
|
||||
pthread_mutex_lock(&g_mic.lock);
|
||||
g_mic.want += delta;
|
||||
if (g_mic.want < 0) g_mic.want = 0;
|
||||
if (g_mic.cq)
|
||||
{
|
||||
- if (g_mic.want > 0 && !g_mic.started) { g_mic.started = 1; start = 1; aq = g_mic.cq; }
|
||||
- if (g_mic.want == 0 && g_mic.started) { g_mic.started = 0; stop = 1; aq = g_mic.cq; }
|
||||
+ if (g_mic.want > 0 && __atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE) && !g_mic.started) { g_mic.started = 1; start = 1; aq = g_mic.cq; }
|
||||
+ if ((g_mic.want == 0 || !__atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE)) && g_mic.started) { g_mic.started = 0; stop = 1; aq = g_mic.cq; }
|
||||
}
|
||||
pthread_mutex_unlock(&g_mic.lock);
|
||||
|
||||
@@ -856,8 +863,23 @@
|
||||
else if (stop)
|
||||
{
|
||||
AAudioStream_requestStop(aq);
|
||||
- REVENT("mic stop (%s was the last consumer)", who);
|
||||
- }
|
||||
+ REVENT("mic stop (%s)", who);
|
||||
+ }
|
||||
+ pthread_mutex_unlock(&g_mic_operations);
|
||||
+}
|
||||
+
|
||||
+static void mic_control_update(void)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+ int enabled;
|
||||
+ if (!g_mic_control) return;
|
||||
+ f = fopen(g_mic_control, "r");
|
||||
+ enabled = f && fgetc(f) == '1';
|
||||
+ if (f) fclose(f);
|
||||
+ if (enabled == __atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE)) return;
|
||||
+ __atomic_store_n(&g_mic_enabled, enabled, __ATOMIC_RELEASE);
|
||||
+ mic_want(0, "session toggle");
|
||||
+ REVENT("mic enabled=%d", enabled);
|
||||
}
|
||||
|
||||
static void *mic_reopen_thread(void *unused)
|
||||
@@ -870,8 +892,9 @@
|
||||
|
||||
__atomic_store_n(&g_mic.reopen_redo, 0, __ATOMIC_SEQ_CST);
|
||||
|
||||
+ pthread_mutex_lock(&g_mic_operations);
|
||||
pthread_mutex_lock(&g_mic.lock);
|
||||
- want_start = g_mic.want > 0;
|
||||
+ want_start = g_mic.want > 0 && __atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE);
|
||||
pthread_mutex_unlock(&g_mic.lock);
|
||||
|
||||
if (open_input(&neu) == AAUDIO_OK)
|
||||
@@ -902,6 +925,7 @@
|
||||
AAudioStream_close(old);
|
||||
}
|
||||
|
||||
+ pthread_mutex_unlock(&g_mic_operations);
|
||||
if (__atomic_load_n(&g_mic.reopen_redo, __ATOMIC_SEQ_CST)) { usleep(20000); continue; }
|
||||
__atomic_store_n(&g_mic.reopen_running, 0, __ATOMIC_SEQ_CST);
|
||||
if (!__atomic_load_n(&g_mic.reopen_redo, __ATOMIC_SEQ_CST)) break;
|
||||
@@ -1348,7 +1372,8 @@
|
||||
/* ---- housekeeping: watchdog tick + mailbox watch, once a second ------------- */
|
||||
static void *housekeeping_thread(void *unused)
|
||||
{
|
||||
- struct timespec iv = { 1, 0 };
|
||||
+ struct timespec iv = { 0, 100000000 };
|
||||
+ unsigned tick = 0;
|
||||
|
||||
(void)unused;
|
||||
for (;;)
|
||||
@@ -1357,6 +1382,8 @@
|
||||
int reload = 0;
|
||||
|
||||
nanosleep(&iv, NULL);
|
||||
+ mic_control_update();
|
||||
+ if (++tick % 10) continue;
|
||||
|
||||
if (g_rt_path[0])
|
||||
{
|
||||
@@ -1402,8 +1429,9 @@
|
||||
{
|
||||
if (!strcmp(argv[i], "--socket") && i + 1 < argc) path = argv[++i];
|
||||
else if (!strcmp(argv[i], "--mic-fifo") && i + 1 < argc) fifo_path = argv[++i];
|
||||
+ else if (!strcmp(argv[i], "--mic-control") && i + 1 < argc) g_mic_control = argv[++i];
|
||||
else if (!strcmp(argv[i], "--log")) g_verbose = 1;
|
||||
- else { fprintf(stderr, "usage: directaudio-relay --socket <path> [--mic-fifo <path>] [--log]\n"); return 2; }
|
||||
+ else { fprintf(stderr, "usage: directaudio-relay --socket <path> [--mic-fifo <path>] [--mic-control <path>] [--log]\n"); return 2; }
|
||||
}
|
||||
if (!path)
|
||||
{
|
||||
@@ -1429,6 +1457,8 @@
|
||||
chmod(path, 0666);
|
||||
if (listen(srv, 8) != 0) { REVENT("listen: %d", errno); return 1; }
|
||||
|
||||
+ mic_control_update();
|
||||
+ REVENT("mic enabled=%d", __atomic_load_n(&g_mic_enabled, __ATOMIC_ACQUIRE));
|
||||
if (pthread_create(&th, NULL, housekeeping_thread, NULL) == 0) pthread_detach(th);
|
||||
if (fifo_path && fifo_setup(fifo_path) != 0)
|
||||
REVENT("mic-fifo: disabled");
|
||||
@@ -2,5 +2,6 @@ DIRECTAUDIO_REPO=The412Banner/directaudio
|
||||
DIRECTAUDIO_TAG=directaudio-linux-v1.1.0
|
||||
DIRECTAUDIO_WINE11_SHA256=835e6cab072f5148893c43379e60506483aeb3f1444e777b430c295cbeb472c9
|
||||
DIRECTAUDIO_SYSTHREAD_SHA256=2ddc47f446142d5940540ad40a423ca8d47fd536e3225b888df1077c6be7329e
|
||||
DIRECTAUDIO_RELAY_SHA256=b68eb6d7a892fd92a1cd73fac36dc05cabb77cc73792e2c582d3eeccad355942
|
||||
DIRECTAUDIO_SINK_SHA256=1d5d3ed709e5389ef7603f019c62b07e4e8428bb42882193d4a144a5c15425b6
|
||||
DIRECTAUDIO_SOURCE_COMMIT=52aedbf8ddd42874a5bbd21df20e1046367f442e
|
||||
DIRECTAUDIO_SOURCE_SHA256=a20c9a0684ae3b1e60a6b9c17b7f1d5ec2501627ae9683aa9f391576a6c1974d
|
||||
@@ -1,49 +1,10 @@
|
||||
/* DirectAudio relay - the contract between the driver and the relay helper.
|
||||
*
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* WHY THIS EXISTS. The driver's whole premise is an in-process AAudio client:
|
||||
* the guest's WASAPI buffers are mixed and handed to Android's audio server
|
||||
* from inside the game, no daemon in the path. That is only possible when the
|
||||
* game process is a bionic process. Under a glibc runtime (the Linux Steam
|
||||
* client, where the game runs inside a proot'd Arch rootfs on Valve's own
|
||||
* ARM64 Proton) libaaudio cannot be loaded at all: it is a bionic library and
|
||||
* the rootfs's dynamic linker does not know how to bring it into a glibc
|
||||
* process. The game side therefore has to stop at a boundary it CAN cross, and
|
||||
* the only thing both worlds agree on is the kernel: a unix socket, a memfd and
|
||||
* a futex word.
|
||||
*
|
||||
* SHAPE. One helper process (directaudio-relay, bionic, links libaaudio) runs
|
||||
* on the Android side and listens on a unix socket. Each game process that
|
||||
* needs audio connects once, sends its launch config (the same knobs the
|
||||
* in-process build reads from BANNER_AUDIO_DIRECT_*), and gets back one or two
|
||||
* shared rings (memfds passed with SCM_RIGHTS):
|
||||
*
|
||||
* render ring game (producer) -> helper (consumer) -> AAudio OUTPUT
|
||||
* capture ring helper (producer, AAudio INPUT) -> game (consumer)
|
||||
*
|
||||
* The driver keeps its mixer and its per-voice WASAPI rings exactly as in the
|
||||
* in-process build; what used to be the AAudio data callback is now a pump
|
||||
* thread that keeps the render ring topped up, and the capture callback is a
|
||||
* pump that drains the capture ring into the capture voices. Everything that
|
||||
* needs an AAudioStream (open, adaptive buffer growth and decay, route-change
|
||||
* reopen, the stalled-callback watchdog, the live-config mailbox) moves to the
|
||||
* helper unchanged in spirit.
|
||||
*
|
||||
* COST. One extra hand-off: the ring. The helper's callback pulls a burst from
|
||||
* the ring, so the ring must hold at least one burst at every callback; the
|
||||
* driver keeps DA_RING_TARGET_BURSTS bursts queued and the helper raises that
|
||||
* target when a callback finds the ring short. Everything else - the AAudio
|
||||
* buffer, AudioFlinger's own latency - is what the in-process build pays too.
|
||||
*
|
||||
* WIRE FORMAT. Fixed-width, native-endian, same-machine only. The two sides are
|
||||
* different libcs but the same CPU, so no marshalling beyond fixed-size structs.
|
||||
* Bump DA_RELAY_VERSION on any layout change; the helper refuses a mismatch.
|
||||
*/
|
||||
#ifndef DA_RELAY_PROTO_H
|
||||
#define DA_RELAY_PROTO_H
|
||||
@@ -52,34 +13,20 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#define DA_RELAY_VERSION 1
|
||||
#define DA_RING_MAGIC 0x44415247u /* 'DARG' */
|
||||
#define DA_HELLO_MAGIC 0x44414831u /* 'DAH1' */
|
||||
#define DA_ACK_MAGIC 0x44414131u /* 'DAA1' */
|
||||
#define DA_RING_MAGIC 0x44415247u
|
||||
#define DA_HELLO_MAGIC 0x44414831u
|
||||
#define DA_ACK_MAGIC 0x44414131u
|
||||
|
||||
/* Socket path. The driver reads BANNER_AUDIO_DIRECT_RELAY; when unset it falls
|
||||
* back to $XDG_RUNTIME_DIR/DA_RELAY_DEFAULT_NAME, which a host that already
|
||||
* hands its runtime dir into the session gets for free. */
|
||||
#define DA_RELAY_ENV "BANNER_AUDIO_DIRECT_RELAY"
|
||||
#define DA_RELAY_DEFAULT_NAME "directaudio-relay"
|
||||
|
||||
/* Both rings carry float32 interleaved stereo. The render ring is always
|
||||
* 48 kHz (the mixer's output rate); the capture ring runs at whatever rate the
|
||||
* input stream was granted, published in da_ring.rate, and the driver resamples
|
||||
* per voice as the in-process build already does. */
|
||||
#define DA_RING_RATE 48000
|
||||
#define DA_RING_CHANNELS 2
|
||||
|
||||
/* Render ring sizing. Capacity is the ceiling adaptive growth can reach; the
|
||||
* initial target is what the driver keeps queued. Two bursts: the helper's
|
||||
* callback consumes one burst and wakes the pump, which then has a full burst
|
||||
* period to refill before the next callback. */
|
||||
#define DA_RING_CAP_MS 250
|
||||
#define DA_RING_TARGET_BURSTS 2
|
||||
#define DA_RING_MAX_TARGET_MS 100
|
||||
|
||||
/* Capture ring: 200 ms is far more than a game ever leaves queued; on overrun
|
||||
* the helper drops the newest block, matching the in-process "guest is not
|
||||
* draining" behaviour of dropping data rather than blocking the mic thread. */
|
||||
#define DA_CAPTURE_RING_MS 200
|
||||
|
||||
enum da_ring_state
|
||||
@@ -93,35 +40,27 @@ struct da_ring
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint32_t cap_frames; /* ring capacity in frames */
|
||||
uint32_t rate; /* frames per second of the data in this ring */
|
||||
uint32_t channels; /* DA_RING_CHANNELS */
|
||||
uint32_t cap_frames;
|
||||
uint32_t rate;
|
||||
uint32_t channels;
|
||||
uint32_t _pad0;
|
||||
|
||||
/* Single producer, single consumer; monotonic frame totals, wrap-safe with
|
||||
* unsigned arithmetic. Producer writes widx with RELEASE after the data;
|
||||
* consumer writes ridx with RELEASE after it has copied the data out. */
|
||||
volatile uint32_t widx;
|
||||
volatile uint32_t ridx;
|
||||
|
||||
/* Futex word the CONSUMER of a render ring / PRODUCER of a capture ring
|
||||
* bumps after each block, so the other side can sleep on it instead of
|
||||
* polling. Waiters always use a timeout, so a missed wake only costs one
|
||||
* period. */
|
||||
volatile uint32_t wake;
|
||||
|
||||
volatile uint32_t quit; /* either side: tear down */
|
||||
volatile uint32_t state; /* enum da_ring_state, helper-owned */
|
||||
volatile uint32_t quit;
|
||||
volatile uint32_t state;
|
||||
|
||||
/* Render ring only, helper-owned, read by the driver: */
|
||||
volatile int32_t target_frames; /* keep at least this many queued */
|
||||
volatile int32_t hw_buf_frames; /* AAudio buffer size right now (get_latency) */
|
||||
volatile int32_t hw_burst; /* frames per burst of the output stream */
|
||||
volatile uint32_t underruns; /* callbacks that found fewer than they needed */
|
||||
volatile uint32_t cb_count; /* data callbacks so far (liveness) */
|
||||
volatile int32_t target_frames;
|
||||
volatile int32_t hw_buf_frames;
|
||||
volatile int32_t hw_burst;
|
||||
volatile uint32_t underruns;
|
||||
volatile uint32_t cb_count;
|
||||
uint32_t _pad1[3];
|
||||
|
||||
float data[]; /* cap_frames * channels */
|
||||
float data[];
|
||||
};
|
||||
|
||||
static inline size_t da_ring_bytes(uint32_t cap_frames)
|
||||
@@ -141,62 +80,52 @@ static inline uint32_t da_ring_space(const struct da_ring *r)
|
||||
return r->cap_frames - da_ring_avail(r);
|
||||
}
|
||||
|
||||
/* ---- wire messages ------------------------------------------------------- */
|
||||
|
||||
#define DA_HELLO_MIC 0x01u /* also open an INPUT stream + capture ring */
|
||||
#define DA_HELLO_EXCLUSIVE 0x02u /* AAUDIO_SHARING_MODE_EXCLUSIVE requested */
|
||||
#define DA_HELLO_MIC 0x01u
|
||||
#define DA_HELLO_EXCLUSIVE 0x02u
|
||||
#define DA_HELLO_ADAPTIVE 0x04u
|
||||
#define DA_HELLO_DECAY 0x08u
|
||||
#define DA_HELLO_WATCHDOG 0x10u
|
||||
|
||||
/* First message on a fresh connection, driver -> helper. Mirrors the launch
|
||||
* config the in-process build derives from BANNER_AUDIO_DIRECT_* so a preset
|
||||
* means the same thing under both runtimes. */
|
||||
struct da_hello
|
||||
{
|
||||
uint32_t magic; /* DA_HELLO_MAGIC */
|
||||
uint32_t version; /* DA_RELAY_VERSION */
|
||||
uint32_t flags; /* DA_HELLO_* */
|
||||
int32_t perf; /* 0 NONE, 1 LOW_LATENCY, 2 POWER_SAVING (host convention) */
|
||||
int32_t target_ms; /* AAudio buffer, ms; 0 = use target_frames or the default */
|
||||
int32_t max_ms; /* adaptive ceiling, ms; 0 = max_frames or the default */
|
||||
int32_t target_frames; /* frame forms, used only when the ms forms are 0 */
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint32_t flags;
|
||||
int32_t perf;
|
||||
int32_t target_ms;
|
||||
int32_t max_ms;
|
||||
int32_t target_frames;
|
||||
int32_t max_frames;
|
||||
uint32_t stall_ms; /* watchdog: callback silent this long => rebuild */
|
||||
uint32_t quiet_ms; /* decay pacing, see the driver */
|
||||
uint32_t stall_ms;
|
||||
uint32_t quiet_ms;
|
||||
uint32_t punish_ms;
|
||||
uint32_t max_backoff;
|
||||
int32_t pid; /* the game process, for the log */
|
||||
uint32_t log; /* BANNER_AUDIO_DIRECT_LOG */
|
||||
char runtime_path[256]; /* BANNER_AUDIO_DIRECT_RUNTIME mailbox, "" = none */
|
||||
char name[64]; /* process name, for the log */
|
||||
int32_t pid;
|
||||
uint32_t log;
|
||||
char runtime_path[256];
|
||||
char name[64];
|
||||
};
|
||||
|
||||
#define DA_ACK_MIC_FAILED 0x01u /* mic asked for, input stream would not open */
|
||||
#define DA_ACK_MIC_FAILED 0x01u
|
||||
|
||||
/* Reply, helper -> driver, followed by SCM_RIGHTS carrying the ring fds:
|
||||
* fd[0] = render ring, fd[1] = capture ring (present iff in_cap_frames > 0). */
|
||||
struct da_ack
|
||||
{
|
||||
uint32_t magic; /* DA_ACK_MAGIC */
|
||||
int32_t status; /* 0 = ok, else an AAudio error code (negative) */
|
||||
int32_t rate; /* output stream rate (48000) */
|
||||
int32_t burst; /* output frames per burst */
|
||||
int32_t buf_frames; /* output buffer size as opened */
|
||||
int32_t out_cap_frames; /* render ring capacity */
|
||||
int32_t in_cap_frames; /* capture ring capacity, 0 = no capture ring */
|
||||
int32_t in_rate; /* rate of the capture ring's data */
|
||||
uint32_t flags; /* DA_ACK_* */
|
||||
uint32_t magic;
|
||||
int32_t status;
|
||||
int32_t rate;
|
||||
int32_t burst;
|
||||
int32_t buf_frames;
|
||||
int32_t out_cap_frames;
|
||||
int32_t in_cap_frames;
|
||||
int32_t in_rate;
|
||||
uint32_t flags;
|
||||
uint32_t _pad;
|
||||
};
|
||||
|
||||
/* Subsequent messages, driver -> helper, on the same socket. The helper never
|
||||
* writes after the ack; everything it has to say is in the ring header. EOF on
|
||||
* the socket is how the helper learns the game is gone. */
|
||||
enum da_msg_type
|
||||
{
|
||||
DA_MSG_MIC_START = 1, /* first capture voice started: make the mic hot */
|
||||
DA_MSG_MIC_STOP = 2, /* last capture voice gone: stop (keep open) */
|
||||
DA_MSG_MIC_START = 1,
|
||||
DA_MSG_MIC_STOP = 2,
|
||||
DA_MSG_PING = 3,
|
||||
};
|
||||
|
||||
@@ -206,4 +135,4 @@ struct da_msg
|
||||
int32_t arg;
|
||||
};
|
||||
|
||||
#endif /* DA_RELAY_PROTO_H */
|
||||
#endif
|
||||
@@ -1,24 +1,5 @@
|
||||
/*
|
||||
* module-directaudio-native-sink: a PulseAudio 13 sink that is DirectAudio's AAudio engine,
|
||||
* in-process. For the native Linux Steam client on Android (DroidDeck, Bannerlator's Linux
|
||||
* session), whose sound can only ever reach a PulseAudio daemon: this module is where that
|
||||
* daemon's mixed output meets Android, one step away from AudioFlinger, with the same engine the
|
||||
* game driver has - adaptive device buffer that grows a burst on every xrun, optional decay with a
|
||||
* remembered floor, a primed ring with fades instead of clicks, route-change / error reopen on a
|
||||
* fresh stream, and a stall watchdog.
|
||||
*
|
||||
* It is the relay helper's per-client OUTPUT engine (directaudio-relay.c) with the socket and the
|
||||
* shared-memory ring replaced by a ring in this process, fed by the sink's IO thread exactly as
|
||||
* module-directaudio-sink feeds the relay. Compared with that module there is no second process
|
||||
* and no 40 ms proot safety margin: the ring here only has to cover the IO thread's own
|
||||
* scheduling jitter, so it starts at two bursts and grows only if a callback finds it short.
|
||||
*
|
||||
* The daemon must run on the Android side (the host app's process), not inside proot, for AAudio
|
||||
* to be reachable at all - which is where both host apps already run it.
|
||||
*
|
||||
* Field fixes carried from the relay (MaxsTechReview, Droid-Deck/DroidDeck#338): prime before
|
||||
* playing, fade on an underrun, one consumer per ring across a reopen, a device buffer of at
|
||||
* least two bursts.
|
||||
* Derived from the AAudio engine of DirectAudio's relay helper (directaudio-relay.c) by The412Banner.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
@@ -52,13 +33,14 @@
|
||||
#include <pulsecore/thread-mq.h>
|
||||
#include <pulsecore/thread.h>
|
||||
|
||||
#include "da_relay_proto.h" /* struct da_ring + the ring helpers; nothing of the socket protocol */
|
||||
#include "da_relay_proto.h"
|
||||
|
||||
PA_MODULE_AUTHOR("The412Banner");
|
||||
PA_MODULE_DESCRIPTION("Android audio output: DirectAudio's AAudio engine, in-process");
|
||||
PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||
PA_MODULE_LOAD_ONCE(false);
|
||||
PA_MODULE_USAGE(
|
||||
"control_dir=<Android media volume bridge directory> "
|
||||
"sink_name=<name for the sink> "
|
||||
"sink_properties=<properties for the sink> "
|
||||
"volume=<initial volume, linear, 1.0 = full> "
|
||||
@@ -76,7 +58,6 @@ PA_MODULE_USAGE(
|
||||
#define WATCHDOG_TICK_USEC (1 * PA_USEC_PER_SEC)
|
||||
#define AUDIO_NICE (-16)
|
||||
|
||||
/* ---- tunables: the in-process driver's, same defaults ----------------------- */
|
||||
#define DA_KNEE 0.75f
|
||||
#define DA_DEFAULT_MS 12
|
||||
#define DA_DEFAULT_MAX_MS 100
|
||||
@@ -91,11 +72,15 @@ PA_MODULE_USAGE(
|
||||
#define DA_FADE_FRAMES 64
|
||||
|
||||
static const char* const valid_modargs[] = {
|
||||
"control_dir",
|
||||
"sink_name", "sink_properties", "volume", "performance_mode", "buffer_ms", "max_ms", "ring_ms",
|
||||
"adaptive", "decay", "limiter", "watchdog", NULL
|
||||
};
|
||||
|
||||
struct android_volume;
|
||||
|
||||
struct userdata {
|
||||
struct android_volume *android_volume;
|
||||
pa_core *core;
|
||||
pa_module *module;
|
||||
pa_sink *sink;
|
||||
@@ -107,17 +92,14 @@ struct userdata {
|
||||
pa_sample_spec ss;
|
||||
size_t frame_size;
|
||||
|
||||
/* configuration */
|
||||
aaudio_performance_mode_t perf;
|
||||
int32_t target_ms, max_ms, ring_ms;
|
||||
bool adaptive, decay, limiter, watchdog_on;
|
||||
|
||||
/* the ring: this process's, same layout as the relay's so the engine is shared */
|
||||
struct da_ring *ring;
|
||||
int32_t burst;
|
||||
int32_t ring_max_target;
|
||||
|
||||
/* the one OUTPUT stream and its adaptive state (the relay's struct client, minus the socket) */
|
||||
AAudioStream *aq;
|
||||
pthread_mutex_t lock;
|
||||
int32_t last_xrun;
|
||||
@@ -129,13 +111,15 @@ struct userdata {
|
||||
int suspended;
|
||||
volatile int dead;
|
||||
|
||||
/* what the IO thread last logged, so engine changes made on the AAudio thread get a line */
|
||||
int32_t seen_target, seen_hw_buf;
|
||||
uint32_t seen_underruns;
|
||||
pa_usec_t next_watchdog, settled_at, stats_at;
|
||||
unsigned int opens;
|
||||
};
|
||||
|
||||
#include "../../aaudio-sink/android-volume.h"
|
||||
|
||||
|
||||
static uint64_t now_ns(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
@@ -144,8 +128,6 @@ static uint64_t now_ns(void) {
|
||||
|
||||
static void request_reopen(struct userdata *u, const char *why);
|
||||
|
||||
/* ---- the engine: the relay's out_cb / open_output / reopen / watchdog, on a local ring ---- */
|
||||
|
||||
static void fade(float *p, uint32_t frames, int in) {
|
||||
uint32_t i, ch;
|
||||
|
||||
@@ -157,8 +139,6 @@ static void fade(float *p, uint32_t frames, int in) {
|
||||
}
|
||||
}
|
||||
|
||||
/* The driver's soft-knee limiter: below DA_KNEE the signal is untouched, so ordinary material is
|
||||
* bit-identical; above it a smooth knee folds the overshoot back under full scale. */
|
||||
static void limit(float *p, uint32_t samples) {
|
||||
uint32_t i;
|
||||
|
||||
@@ -185,7 +165,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
int fade_in = 0, short_read = 0, starving = 0;
|
||||
uint64_t now;
|
||||
|
||||
/* Only the promoted stream reads the ring; an outgoing one during a reopen plays silence. */
|
||||
if ((live && aq != live) || __atomic_exchange_n(&u->consuming, 1, __ATOMIC_ACQUIRE)) {
|
||||
memset(out, 0, (size_t) frames * DA_RING_CHANNELS * sizeof(float));
|
||||
return AAUDIO_CALLBACK_RESULT_CONTINUE;
|
||||
@@ -240,8 +219,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
__atomic_add_fetch(&u->cb_count, 1, __ATOMIC_SEQ_CST);
|
||||
__atomic_store_n(&r->cb_count, u->cb_count, __ATOMIC_RELAXED);
|
||||
|
||||
/* The ring's own adaptive step: a short ring means the IO thread did not get scheduled in
|
||||
* time - an xrun one stage earlier - so keep one more burst queued. Only grows. */
|
||||
if (short_read)
|
||||
__atomic_add_fetch(&r->underruns, 1, __ATOMIC_RELAXED);
|
||||
if ((short_read || starving) && u->adaptive) {
|
||||
@@ -254,8 +231,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
__atomic_store_n(&r->target_frames, want, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
/* The device buffer: grow a burst per xrun; decay a burst after a quiet spell, never below
|
||||
* the floor a punished decay taught us. */
|
||||
if (u->adaptive) {
|
||||
int32_t xruns = AAudioStream_getXRunCount(aq);
|
||||
int32_t burst = AAudioStream_getFramesPerBurst(aq);
|
||||
@@ -304,8 +279,6 @@ static void out_error_cb(AAudioStream *aq, void *user, aaudio_result_t error) {
|
||||
|
||||
if (aq != __atomic_load_n(&u->aq, __ATOMIC_SEQ_CST)) return;
|
||||
if (__atomic_load_n(&u->suspended, __ATOMIC_SEQ_CST)) return;
|
||||
/* A disconnected stream (headphones plugged or unplugged, a Bluetooth route coming or going)
|
||||
* can never be restarted: it has to be closed and a new one opened on the current route. */
|
||||
if (error != AAUDIO_ERROR_DISCONNECTED &&
|
||||
error != AAUDIO_ERROR_INVALID_STATE &&
|
||||
error != AAUDIO_ERROR_INVALID_HANDLE &&
|
||||
@@ -314,8 +287,6 @@ static void out_error_cb(AAudioStream *aq, void *user, aaudio_result_t error) {
|
||||
request_reopen(u, "stream error");
|
||||
}
|
||||
|
||||
/* 48 kHz / float / stereo, buffer from the ms form rounded up to a burst and never below two,
|
||||
* capacity from the ceiling. The ring target floor is two bursts or ring_ms, whichever is more. */
|
||||
static aaudio_result_t open_output(struct userdata *u, AAudioStream **out) {
|
||||
AAudioStreamBuilder *builder = NULL;
|
||||
AAudioStream *aq = NULL;
|
||||
@@ -438,7 +409,6 @@ static void request_reopen(struct userdata *u, const char *why) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Ticked once a second from the IO thread: a callback silent for a second is a dead stream. */
|
||||
static void watchdog(struct userdata *u) {
|
||||
uint64_t now = now_ns(), last_cb, prev_tick;
|
||||
unsigned int cb;
|
||||
@@ -476,13 +446,10 @@ static void close_output(struct userdata *u) {
|
||||
AAudioStream_requestStop(aq);
|
||||
AAudioStream_close(aq);
|
||||
}
|
||||
/* A reopen still in flight sees u->dead and stops; give it a moment to let go of u. */
|
||||
while (__atomic_load_n(&u->reopen_running, __ATOMIC_SEQ_CST))
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
/* ---- the PulseAudio side: module-directaudio-sink's producer, on the local ring ---- */
|
||||
|
||||
static pa_usec_t frames_to_usec(const struct userdata *u, int64_t frames) {
|
||||
return (pa_usec_t) (frames * (int64_t) PA_USEC_PER_SEC / (int64_t) u->ss.rate);
|
||||
}
|
||||
@@ -520,7 +487,6 @@ static void produce(struct userdata *u, uint32_t frames) {
|
||||
__atomic_store_n(&r->widx, w + frames, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
/* Tops the ring up to the engine's target and narrates what the engine changed. */
|
||||
static void service_ring(struct userdata *u) {
|
||||
struct da_ring *r = u->ring;
|
||||
uint32_t avail, space;
|
||||
@@ -579,8 +545,6 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||
}
|
||||
|
||||
/* A started AAudio stream keeps audioserver's AudioMix wake lock held, so the device never
|
||||
* suspends while the session sleeps: stop it, and the IO thread's timer, until the sink reopens. */
|
||||
static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state, pa_suspend_cause_t new_suspend_cause) {
|
||||
struct userdata *u = s->userdata;
|
||||
aaudio_result_t res = AAUDIO_OK;
|
||||
@@ -621,9 +585,6 @@ static void thread_func(void *userdata) {
|
||||
for (;;) {
|
||||
int ret;
|
||||
|
||||
/* Half a burst between visits, never blocking on the stream: clients' audio reaches this
|
||||
* thread as messages pa_rtpoll_run handles, and a thread stuck in a write or a wait lets
|
||||
* them run dry (the crackle #338 fixed). */
|
||||
if (!u->suspended) {
|
||||
service_ring(u);
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, PA_MAX(frames_to_usec(u, u->burst) / 2, PA_USEC_PER_MSEC));
|
||||
@@ -711,7 +672,6 @@ int pa__init(pa_module *m) {
|
||||
pthread_mutex_init(&u->lock, NULL);
|
||||
pa_channel_map_init_stereo(&map);
|
||||
|
||||
/* The ring: the relay's layout in this process's memory. */
|
||||
cap_frames = DA_RING_CAP_MS_LOCAL * DA_RING_RATE / 1000;
|
||||
u->ring = pa_xmalloc0(da_ring_bytes(cap_frames));
|
||||
u->ring->magic = DA_RING_MAGIC;
|
||||
@@ -766,14 +726,13 @@ int pa__init(pa_module *m) {
|
||||
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
|
||||
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||
pa_sink_set_max_request(u->sink, (size_t) u->ring->target_frames * u->frame_size);
|
||||
/* What clients should keep queued on their side: the ring's starting target plus the device
|
||||
* buffer. Grows are reported live through GET_LATENCY. */
|
||||
pa_sink_set_fixed_latency(u->sink, frames_to_usec(u, (int64_t) u->ring->target_frames + u->base_buf_frames));
|
||||
|
||||
if (!(u->thread = pa_thread_new("directaudio-native-sink", thread_func, u))) {
|
||||
pa_log("Failed to create thread.");
|
||||
goto fail;
|
||||
}
|
||||
u->android_volume = android_volume_new(u->sink, pa_modargs_get_value(ma, "control_dir", NULL));
|
||||
pa_sink_put(u->sink);
|
||||
pa_modargs_free(ma);
|
||||
return 0;
|
||||
@@ -799,6 +758,8 @@ void pa__done(pa_module *m) {
|
||||
pa_assert(m);
|
||||
if (!(u = m->userdata))
|
||||
return;
|
||||
android_volume_free(u->android_volume);
|
||||
u->android_volume = NULL;
|
||||
if (u->sink)
|
||||
pa_sink_unlink(u->sink);
|
||||
if (u->thread) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# DiRT 3 / DiRT Showdown ws2_32 stand-in
|
||||
|
||||
DiRT 3 (`dirt3_game.exe`) and DiRT Showdown (`showdown.exe`, `showdown_avx.exe`) close their motion telemetry UDP
|
||||
socket at the end of a race, and when leaving Joyride, but keep calling `sendto()` on it. `sendto()` fails with
|
||||
WSAENOTSOCK and the game stops with "sendto failed with error 10038". The same happens on Windows.
|
||||
|
||||
`ws2_32.dll` here is a 32-bit stand-in: every export jumps to the same-ordinal export of Wine's own `ws2_32.dll`;
|
||||
only a `sendto()` that fails with 10038 reports 0 bytes sent instead. Same behaviour as
|
||||
[DiRTTelemetryErrorFix](https://github.com/RoccoC/DiRTTelemetryErrorFix) by RoccoC (MIT), based on the original fix
|
||||
by Carsten Gottschling.
|
||||
|
||||
Wine loads `ws2_32` as a KnownDLL, so a copy beside the game is ignored. `droiddeck-game-env` puts the stand-in in
|
||||
place of the prefix's `syswow64/ws2_32.dll` for these games while their telemetry output is on, adds
|
||||
`WINEDLLOVERRIDES=ws2_32=n,b`, and puts Wine's file back when the game exits. It skips the swap when the game's
|
||||
Proton already has the fix in its own `ws2_32.dll` (DroidDeck-Proton patch
|
||||
`dirt-telemetry-sendto-closed-socket.patch`).
|
||||
|
||||
`build.sh OUT` builds it with clang, lld and llvm-dlltool and checks its exports against `ws2_32-exports.txt`
|
||||
(taken from Wine 11's `ws2_32.dll`).
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
mkdir -p "$1"
|
||||
out=$(cd "$1" && pwd)
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
tool() {
|
||||
local found
|
||||
found=$(command -v "$1" || ls /usr/lib/llvm-*/bin/"$1" 2>/dev/null | sort -V | tail -n1 || true)
|
||||
[ -n "$found" ] || { echo "dirt-ws2: $1 not found" >&2; exit 1; }
|
||||
echo "$found"
|
||||
}
|
||||
clang=$(tool clang)
|
||||
dlltool=$(tool llvm-dlltool)
|
||||
tool ld.lld > /dev/null
|
||||
|
||||
python3 "$here/gen.py" generate "$here" "$work"
|
||||
"$dlltool" -m i386 -k -d "$here/kernel32.def" -l "$work/libkernel32.a"
|
||||
"$clang" --target=i686-w64-mingw32 -O2 -Wall -Wextra -Werror -ffreestanding -fno-stack-protector -fno-builtin \
|
||||
-nostdlib -shared -fuse-ld=lld -o "$work/ws2_32.dll" "$here/ws2_32.c" "$work/thunks.c" "$work/ws2_32.def" \
|
||||
-L"$work" -lkernel32 -Wl,--entry,DllMain@12 -Wl,--no-insert-timestamp
|
||||
python3 "$here/gen.py" verify "$here" "$work/ws2_32.dll"
|
||||
install -m 644 "$work/ws2_32.dll" "$out/ws2_32.dll"
|
||||
@@ -0,0 +1,69 @@
|
||||
import struct
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def exports_list(src):
|
||||
rows = []
|
||||
for line in (Path(src) / 'ws2_32-exports.txt').read_text().splitlines():
|
||||
ordinal, name = line.split()
|
||||
rows.append((int(ordinal), name))
|
||||
return rows
|
||||
|
||||
|
||||
def generate(src, out):
|
||||
rows = exports_list(src)
|
||||
passed = [(o, n) for o, n in rows if n != 'sendto']
|
||||
c = ['/* Generated by tools/dirt-ws2/gen.py. */',
|
||||
'const unsigned short dirtfix_ordinals[%d] = {%s};' % (len(passed), ', '.join(str(o) for o, _ in passed)),
|
||||
'const unsigned int dirtfix_count = %d;' % len(passed),
|
||||
'void *dirtfix_real[%d];' % len(passed),
|
||||
'__asm__(".text\\n"']
|
||||
for i, (o, _) in enumerate(passed):
|
||||
c.append(' ".globl _dirtfix_t%d\\n_dirtfix_t%d:\\n\\tjmp *_dirtfix_real+%d\\n"' % (o, o, 4 * i))
|
||||
c.append(');')
|
||||
(Path(out) / 'thunks.c').write_text('\n'.join(c) + '\n')
|
||||
d = ['LIBRARY ws2_32.dll', 'EXPORTS']
|
||||
d += [' %s=%s @%d' % (n, 'dirtfix_sendto@24' if n == 'sendto' else 'dirtfix_t%d' % o, o) for o, n in rows]
|
||||
(Path(out) / 'ws2_32.def').write_text('\n'.join(d) + '\n')
|
||||
|
||||
|
||||
def pe_exports(path):
|
||||
data = Path(path).read_bytes()
|
||||
pe = struct.unpack_from('<I', data, 0x3c)[0]
|
||||
machine, sections = struct.unpack_from('<HH', data, pe + 4)
|
||||
optional_size = struct.unpack_from('<H', data, pe + 20)[0]
|
||||
optional = pe + 24
|
||||
export_rva = struct.unpack_from('<I', data, optional + 96)[0]
|
||||
table = [struct.unpack_from('<IIII', data, optional + optional_size + 40 * i + 8) for i in range(sections)]
|
||||
|
||||
def offset(rva):
|
||||
for size, address, raw_size, raw in table:
|
||||
if address <= rva < address + max(size, raw_size):
|
||||
return rva - address + raw
|
||||
raise ValueError('RVA %#x outside the sections' % rva)
|
||||
|
||||
base, functions, names, function_rva, name_rva, ordinal_rva = struct.unpack_from('<IIIIII', data, offset(export_rva) + 16)
|
||||
named = {}
|
||||
for i in range(names):
|
||||
text = struct.unpack_from('<I', data, offset(name_rva) + 4 * i)[0]
|
||||
index = struct.unpack_from('<H', data, offset(ordinal_rva) + 2 * i)[0]
|
||||
named[index] = data[offset(text):].split(b'\0')[0].decode()
|
||||
result = [(base + i, named.get(i)) for i in range(functions) if struct.unpack_from('<I', data, offset(function_rva) + 4 * i)[0]]
|
||||
return machine, result
|
||||
|
||||
|
||||
def verify(src, dll):
|
||||
machine, found = pe_exports(dll)
|
||||
if machine != 0x14c:
|
||||
sys.exit('%s is not a 32-bit x86 DLL (machine %#x)' % (dll, machine))
|
||||
expected = exports_list(src)
|
||||
if found != expected:
|
||||
sys.exit('%s exports differ from ws2_32-exports.txt: %d found, %d expected' % (dll, len(found), len(expected)))
|
||||
if b'droiddeck-dirt-ws2_32' not in Path(dll).read_bytes():
|
||||
sys.exit('%s lacks the stand-in marker' % dll)
|
||||
print('%s: %d exports match, marker present' % (dll, len(found)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
{'generate': generate, 'verify': verify}[sys.argv[1]](sys.argv[2], sys.argv[3])
|
||||
@@ -0,0 +1,7 @@
|
||||
LIBRARY kernel32.dll
|
||||
EXPORTS
|
||||
LoadLibraryW@4
|
||||
GetProcAddress@8
|
||||
GetSystemDirectoryW@8
|
||||
GetEnvironmentVariableW@12
|
||||
GetFileAttributesW@4
|
||||
@@ -0,0 +1,135 @@
|
||||
1 accept
|
||||
2 bind
|
||||
3 closesocket
|
||||
4 connect
|
||||
5 getpeername
|
||||
6 getsockname
|
||||
7 getsockopt
|
||||
8 htonl
|
||||
9 htons
|
||||
10 ioctlsocket
|
||||
11 inet_addr
|
||||
12 inet_ntoa
|
||||
13 listen
|
||||
14 ntohl
|
||||
15 ntohs
|
||||
16 recv
|
||||
17 recvfrom
|
||||
18 select
|
||||
19 send
|
||||
20 sendto
|
||||
21 setsockopt
|
||||
22 shutdown
|
||||
23 socket
|
||||
24 FreeAddrInfoEx
|
||||
25 FreeAddrInfoExW
|
||||
26 FreeAddrInfoW
|
||||
27 GetAddrInfoExCancel
|
||||
28 GetAddrInfoExOverlappedResult
|
||||
29 GetAddrInfoExW
|
||||
30 GetAddrInfoW
|
||||
31 GetHostNameW
|
||||
32 GetNameInfoW
|
||||
33 InetNtopW
|
||||
34 InetPtonW
|
||||
35 WSApSetPostRoutine
|
||||
36 WPUCompleteOverlappedRequest
|
||||
37 WSAAccept
|
||||
38 WSAAddressToStringA
|
||||
39 WSAAddressToStringW
|
||||
40 WSACloseEvent
|
||||
41 WSAConnect
|
||||
42 WSAConnectByNameA
|
||||
43 WSAConnectByNameW
|
||||
44 WSACreateEvent
|
||||
45 WSADuplicateSocketA
|
||||
46 WSADuplicateSocketW
|
||||
47 WSAEnumNameSpaceProvidersA
|
||||
48 WSAEnumNameSpaceProvidersW
|
||||
49 WSAEnumNetworkEvents
|
||||
50 WSAEnumProtocolsA
|
||||
51 gethostbyaddr
|
||||
52 gethostbyname
|
||||
53 getprotobyname
|
||||
54 getprotobynumber
|
||||
55 getservbyname
|
||||
56 getservbyport
|
||||
57 gethostname
|
||||
58 WSAEnumProtocolsW
|
||||
59 WSAEventSelect
|
||||
60 WSAGetOverlappedResult
|
||||
61 WSAGetQOSByName
|
||||
62 WSAGetServiceClassInfoA
|
||||
63 WSAGetServiceClassInfoW
|
||||
64 WSAGetServiceClassNameByClassIdA
|
||||
65 WSAGetServiceClassNameByClassIdW
|
||||
66 WSAHtonl
|
||||
67 WSAHtons
|
||||
68 WSAInstallServiceClassA
|
||||
69 WSAInstallServiceClassW
|
||||
70 WSAIoctl
|
||||
71 WSAJoinLeaf
|
||||
72 WSALookupServiceBeginA
|
||||
73 WSALookupServiceBeginW
|
||||
74 WSALookupServiceEnd
|
||||
75 WSALookupServiceNextA
|
||||
76 WSALookupServiceNextW
|
||||
77 WSANSPIoctl
|
||||
78 WSANtohl
|
||||
79 WSANtohs
|
||||
80 WSAPoll
|
||||
81 WSAProviderConfigChange
|
||||
82 WSARecv
|
||||
83 WSARecvDisconnect
|
||||
84 WSARecvFrom
|
||||
85 WSARemoveServiceClass
|
||||
86 WSAResetEvent
|
||||
87 WSASend
|
||||
88 WSASendDisconnect
|
||||
89 WSASendMsg
|
||||
90 WSASendTo
|
||||
91 WSASetEvent
|
||||
92 WSASetServiceA
|
||||
93 WSASetServiceW
|
||||
94 WSASocketA
|
||||
95 WSASocketW
|
||||
96 WSAStringToAddressA
|
||||
97 WSAStringToAddressW
|
||||
98 WSAWaitForMultipleEvents
|
||||
99 WSCDeinstallProvider
|
||||
100 WSCEnableNSProvider
|
||||
101 WSAAsyncSelect
|
||||
102 WSAAsyncGetHostByAddr
|
||||
103 WSAAsyncGetHostByName
|
||||
104 WSAAsyncGetProtoByNumber
|
||||
105 WSAAsyncGetProtoByName
|
||||
106 WSAAsyncGetServByPort
|
||||
107 WSAAsyncGetServByName
|
||||
108 WSACancelAsyncRequest
|
||||
109 WSASetBlockingHook
|
||||
110 WSAUnhookBlockingHook
|
||||
111 WSAGetLastError
|
||||
112 WSASetLastError
|
||||
113 WSACancelBlockingCall
|
||||
114 WSAIsBlocking
|
||||
115 WSAStartup
|
||||
116 WSACleanup
|
||||
117 WSCEnumProtocols
|
||||
118 WSCEnumProtocols32
|
||||
119 WSCGetApplicationCategory
|
||||
120 WSCGetProviderInfo
|
||||
121 WSCGetProviderPath
|
||||
122 WSCInstallNameSpace
|
||||
123 WSCInstallProvider
|
||||
124 WSCSetApplicationCategory
|
||||
125 WSCUnInstallNameSpace
|
||||
126 WSCUpdateProvider
|
||||
127 WSCWriteNameSpaceOrder
|
||||
128 WSCWriteProviderOrder
|
||||
129 freeaddrinfo
|
||||
130 getaddrinfo
|
||||
131 getnameinfo
|
||||
132 inet_ntop
|
||||
133 inet_pton
|
||||
151 __WSAFDIsSet
|
||||
500 WEP
|
||||
@@ -0,0 +1,95 @@
|
||||
/* Same behaviour as DiRTTelemetryErrorFix by RoccoC (MIT), based on the fix by Carsten Gottschling. */
|
||||
|
||||
typedef unsigned short WCHAR;
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned int UINT_PTR;
|
||||
typedef int BOOL;
|
||||
typedef void *HMODULE;
|
||||
#define WINAPI __attribute__((stdcall))
|
||||
#define WSAENOTSOCK 10038
|
||||
#define ORDINAL(n) ((const char *)(UINT_PTR)(n))
|
||||
|
||||
__attribute__((dllimport)) HMODULE WINAPI LoadLibraryW(const WCHAR *name);
|
||||
__attribute__((dllimport)) void *WINAPI GetProcAddress(HMODULE module, const char *name);
|
||||
__attribute__((dllimport)) UINT WINAPI GetSystemDirectoryW(WCHAR *buffer, UINT size);
|
||||
__attribute__((dllimport)) DWORD WINAPI GetEnvironmentVariableW(const WCHAR *name, WCHAR *buffer, DWORD size);
|
||||
__attribute__((dllimport)) DWORD WINAPI GetFileAttributesW(const WCHAR *name);
|
||||
|
||||
__attribute__((used)) const char dirtfix_marker[] = "droiddeck-dirt-ws2_32";
|
||||
|
||||
extern const unsigned short dirtfix_ordinals[];
|
||||
extern const unsigned int dirtfix_count;
|
||||
extern void *dirtfix_real[];
|
||||
|
||||
static int (WINAPI *real_sendto)(UINT_PTR, const char *, int, int, const void *, int);
|
||||
static int (WINAPI *real_WSAGetLastError)(void);
|
||||
static void (WINAPI *real_WSASetLastError)(int);
|
||||
|
||||
int WINAPI dirtfix_sendto(UINT_PTR s, const char *buf, int len, int flags, const void *to, int tolen)
|
||||
{
|
||||
int ret = real_sendto(s, buf, len, flags, to, tolen);
|
||||
if (ret == -1 && real_WSAGetLastError() == WSAENOTSOCK)
|
||||
{
|
||||
real_WSASetLastError(0);
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void append(WCHAR *dst, const char *src)
|
||||
{
|
||||
while (*dst) dst++;
|
||||
while ((*dst++ = (WCHAR)(unsigned char)*src++));
|
||||
}
|
||||
|
||||
static void append_number(WCHAR *dst, UINT n)
|
||||
{
|
||||
char digits[12];
|
||||
int i = 11;
|
||||
|
||||
digits[i] = 0;
|
||||
do digits[--i] = (char)('0' + n % 10); while (n /= 10);
|
||||
append(dst, digits + i);
|
||||
}
|
||||
|
||||
static HMODULE load_wine_ws2_32(HMODULE self)
|
||||
{
|
||||
WCHAR name[24], path[600];
|
||||
HMODULE real;
|
||||
UINT n, d;
|
||||
|
||||
for (d = 0; d < 16; d++)
|
||||
{
|
||||
name[0] = 0;
|
||||
append(name, "WINEDLLDIR");
|
||||
append_number(name, d);
|
||||
n = GetEnvironmentVariableW(name, path, 500);
|
||||
if (!n || n >= 500) continue;
|
||||
if (path[0] == '\\' && path[1] == '?' && path[2] == '?' && path[3] == '\\') path[1] = '\\';
|
||||
append(path, "\\i386-windows\\ws2_32.dll");
|
||||
if (GetFileAttributesW(path) == (DWORD)-1) continue;
|
||||
if ((real = LoadLibraryW(path)) && real != self) return real;
|
||||
}
|
||||
n = GetSystemDirectoryW(path, 280);
|
||||
if (!n || n >= 280) return 0;
|
||||
path[n] = 0;
|
||||
append(path, "\\ws2_32.dll");
|
||||
real = LoadLibraryW(path);
|
||||
return real != self ? real : 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *reserved)
|
||||
{
|
||||
HMODULE real;
|
||||
UINT i;
|
||||
|
||||
(void)reserved;
|
||||
if (reason != 1) return 1;
|
||||
if (!(real = load_wine_ws2_32(self))) return 0;
|
||||
for (i = 0; i < dirtfix_count; i++) dirtfix_real[i] = GetProcAddress(real, ORDINAL(dirtfix_ordinals[i]));
|
||||
real_sendto = GetProcAddress(real, ORDINAL(20));
|
||||
real_WSAGetLastError = GetProcAddress(real, ORDINAL(111));
|
||||
real_WSASetLastError = GetProcAddress(real, ORDINAL(112));
|
||||
return real_sendto && real_WSAGetLastError && real_WSASetLastError;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
docker_platform=${DROIDDECK_DOCKER_PLATFORM:-}
|
||||
if [[ -z "${docker_platform}" ]]; then
|
||||
case "$(uname -m)" in arm64|aarch64) docker_platform=linux/arm64 ;; *) docker_platform=linux/amd64 ;; esac
|
||||
fi
|
||||
case "${docker_platform}" in linux/arm64|linux/arm64/*) docker_platform=linux/arm64 ;; esac
|
||||
if [[ -z "${DROIDDECK_BUILD_IMAGE:-}" ]]; then
|
||||
DROIDDECK_BUILD_IMAGE=droiddeck-local-cross:24.04-v3
|
||||
[[ "${docker_platform}" == linux/arm64 ]] && DROIDDECK_BUILD_IMAGE+=-arm64
|
||||
fi
|
||||
export DROIDDECK_DOCKER_PLATFORM=${docker_platform} DROIDDECK_BUILD_IMAGE
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Check the engine before modifying build assets; never rebuild for a daemon error."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -17,8 +17,8 @@ if __name__ == '__main__':
|
||||
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:
|
||||
if 'No such image' not in image.stderr and 'image not known' 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],
|
||||
subprocess.run(['docker', 'build', '--platform', os.environ.get('DROIDDECK_DOCKER_PLATFORM', 'linux/amd64'), '-t', sys.argv[1],
|
||||
'-f', str(repo / 'tools/local-cross.Dockerfile'), str(repo)], check=True)
|
||||
Loaded 100 of 1553 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user