From d8be6305bc87b5056bc3ebd5347ac2fe1f173377 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Wed, 21 Oct 2026 18:56:58 +0200 Subject: [PATCH] fix(llamacpp): skip mesa patches already applied upstream The upstream llama.cpp CPU image moved to Ubuntu resolute, whose mesa 26.0.8 already lacks the VK_KHR_external_memory_fd requirement that 0001-Revert-venus-filter-out-venus-incapable-physical-dev.patch removes. patch detects it as reversed, skips all 4 hunks and exits 1, which fails the linux/arm64 CPU image build under set -e. Skip a patch when it reverse-applies cleanly, so the same script keeps working on older base images where the patch is still needed. --- scripts/apt-install.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/apt-install.sh b/scripts/apt-install.sh index 867773ece..341608b2e 100755 --- a/scripts/apt-install.sh +++ b/scripts/apt-install.sh @@ -16,6 +16,15 @@ enable_source_repos() { [ -f /etc/apt/sources.list ] && sed -i '/^#\s*deb-src/s/^#\s*//' /etc/apt/sources.list } +apply_patch() { + local patch_file="$1" + if patch -p1 -R --dry-run -s < "$patch_file" >/dev/null 2>&1; then + echo "Skipping $(basename "$patch_file"): already applied upstream" + return + fi + patch -p1 < "$patch_file" +} + rebuild_and_install_mesa() { enable_source_repos apt-get update @@ -31,9 +40,9 @@ rebuild_and_install_mesa() { local script_dir script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - patch -p1 < "$script_dir/0001-Revert-venus-filter-out-venus-incapable-physical-dev.patch" - patch -p1 < "$script_dir/0001-virtio-vulkan-force-16k-alignment-for-allocations-HA.patch" - patch -p1 < "$script_dir/0002-virtio-vulkan-silence-stuck-in-wait-message-HACK.patch" + apply_patch "$script_dir/0001-Revert-venus-filter-out-venus-incapable-physical-dev.patch" + apply_patch "$script_dir/0001-virtio-vulkan-force-16k-alignment-for-allocations-HA.patch" + apply_patch "$script_dir/0002-virtio-vulkan-silence-stuck-in-wait-message-HACK.patch" dpkg-buildpackage -us -uc -b