From 6f6207eaa9492477171a19799c14c22f574625b4 Mon Sep 17 00:00:00 2001 From: GaimsDevSoftware Date: Mon, 29 Jun 2026 17:51:30 +0200 Subject: [PATCH] Bundle protobuf in RPM/deb instead of depending on the distro package The bundled androidtvremote2 ships generated *_pb2.py that import google.protobuf.internal.builder, which only exists in protobuf >= 3.20. Fedora's python3-protobuf is 3.19.6, so the installed app crashed on startup with "cannot import name 'builder'". Vendor protobuf into /opt/tellykeys/lib (alongside androidtvremote2 and aiofiles), strip its arch-specific C extension, and force the pure-Python implementation in the launcher so the package stays noarch / Architecture: all. Drop the now-unnecessary python3-protobuf dependency from both the RPM spec and the deb control. Co-Authored-By: Claude Opus 4.8 --- scripts/build-deb | 12 ++++++++++-- scripts/build-rpm | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/build-deb b/scripts/build-deb index 0d45f3d..62523a7 100755 --- a/scripts/build-deb +++ b/scripts/build-deb @@ -20,7 +20,7 @@ PY )" SITE="$ROOT/.venv/lib/python${PYVER}/site-packages" -if [[ ! -d "$SITE/androidtvremote2" || ! -d "$SITE/aiofiles" ]]; then +if [[ ! -d "$SITE/androidtvremote2" || ! -d "$SITE/aiofiles" || ! -d "$SITE/google" ]]; then echo "Missing bundled Python dependencies in .venv. Run: python -m pip install -e ." >&2 exit 1 fi @@ -31,6 +31,11 @@ mkdir -p "$PKGROOT/DEBIAN" "$PKGROOT/opt/tellykeys/lib" "$PKGROOT/usr/bin" "$PKG cp -a "$ROOT/src/tellykeys" "$PKGROOT/opt/tellykeys/lib/" cp -a "$SITE/androidtvremote2" "$PKGROOT/opt/tellykeys/lib/" cp -a "$SITE/aiofiles" "$PKGROOT/opt/tellykeys/lib/" +# Bundle protobuf so we don't depend on the distro's (often too old) build. +# Strip the arch-specific C extension and force the pure-Python implementation +# (see launcher below) so the package stays Architecture: all. +cp -a "$SITE/google" "$PKGROOT/opt/tellykeys/lib/" +find "$PKGROOT/opt/tellykeys/lib/google" -name '*.so' -delete cp "$ROOT/packaging/linux/tellykeys.desktop" "$PKGROOT/usr/share/applications/" cp "$ROOT/packaging/linux/tellykeys-tray.desktop" "$PKGROOT/usr/share/applications/" cp "$ROOT/assets/tellykeys.svg" "$PKGROOT/usr/share/icons/hicolor/scalable/apps/tellykeys.svg" @@ -39,6 +44,9 @@ cp "$ROOT/README.md" "$PKGROOT/usr/share/doc/tellykeys/README.md" cat > "$PKGROOT/usr/bin/tellykeys" <<'EOF' #!/usr/bin/env bash export PYTHONPATH="/opt/tellykeys/lib${PYTHONPATH:+:$PYTHONPATH}" +# Use the bundled pure-Python protobuf (the C extension is stripped to keep the +# package architecture-independent). +export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="${PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION:-python}" exec python3 -m tellykeys.app "$@" EOF chmod 0755 "$PKGROOT/usr/bin/tellykeys" @@ -50,7 +58,7 @@ Section: utils Priority: optional Architecture: all Maintainer: GaimsDevSoftware -Depends: python3 (>= 3.11), python3-gi, gir1.2-gtk-3.0, avahi-utils, python3-cryptography, python3-protobuf, pipewire-bin | pulseaudio-utils +Depends: python3 (>= 3.11), python3-gi, gir1.2-gtk-3.0, avahi-utils, python3-cryptography, pipewire-bin | pulseaudio-utils Recommends: android-tools-adb Description: Google TV and Android TV remote for Linux TellyKeys is a GTK desktop remote for Google TV and Android TV with pairing, diff --git a/scripts/build-rpm b/scripts/build-rpm index c0dd7ad..71667bf 100755 --- a/scripts/build-rpm +++ b/scripts/build-rpm @@ -24,7 +24,7 @@ command -v rpmbuild >/dev/null 2>&1 || { exit 1 } -if [[ ! -d "$SITE/androidtvremote2" || ! -d "$SITE/aiofiles" ]]; then +if [[ ! -d "$SITE/androidtvremote2" || ! -d "$SITE/aiofiles" || ! -d "$SITE/google" ]]; then echo "Missing bundled Python dependencies in .venv. Run: python -m pip install -e ." >&2 exit 1 fi @@ -36,6 +36,12 @@ mkdir -p "$PAYLOAD/opt/tellykeys/lib" "$PAYLOAD/usr/bin" "$PAYLOAD/usr/share/app cp -a "$ROOT/src/tellykeys" "$PAYLOAD/opt/tellykeys/lib/" cp -a "$SITE/androidtvremote2" "$PAYLOAD/opt/tellykeys/lib/" cp -a "$SITE/aiofiles" "$PAYLOAD/opt/tellykeys/lib/" +# Bundle protobuf: Fedora's python3-protobuf (3.19.6) is too old for the +# generated *_pb2.py in androidtvremote2 (needs the >=3.20 'builder' module). +# Strip the arch-specific C extension and force the pure-Python implementation +# (see launcher below) so the package stays noarch. +cp -a "$SITE/google" "$PAYLOAD/opt/tellykeys/lib/" +find "$PAYLOAD/opt/tellykeys/lib/google" -name '*.so' -delete cp "$ROOT/packaging/linux/tellykeys.desktop" "$PAYLOAD/usr/share/applications/" cp "$ROOT/packaging/linux/tellykeys-tray.desktop" "$PAYLOAD/usr/share/applications/" cp "$ROOT/assets/tellykeys.svg" "$PAYLOAD/usr/share/icons/hicolor/scalable/apps/tellykeys.svg" @@ -44,6 +50,9 @@ cp "$ROOT/README.md" "$PAYLOAD/usr/share/doc/tellykeys/README.md" cat > "$PAYLOAD/usr/bin/tellykeys" <<'EOF' #!/usr/bin/env bash export PYTHONPATH="/opt/tellykeys/lib${PYTHONPATH:+:$PYTHONPATH}" +# Use the bundled pure-Python protobuf (the C extension is stripped to keep the +# package noarch). +export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="${PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION:-python}" exec python3 -m tellykeys.app "$@" EOF chmod 0755 "$PAYLOAD/usr/bin/tellykeys" @@ -63,7 +72,6 @@ Requires: python3-gobject Requires: gtk3 Requires: avahi-tools Requires: python3-cryptography -Requires: python3-protobuf Requires: pipewire-utils Recommends: android-tools