torttube/scripts/build-addon-zip.sh
Kayos 085693603c M6 DONE — torttube ships, Rick Astley plays fullscreen on the Livingroom Pi
Live install verified end-to-end:
- SSH'd into 192.168.0.158 (LibreELEC, Kodi 20.3 Nexus, kernel aarch64
  / userspace armhf — that's why the static Rust sidecar runs but the
  PyInstaller yt-dlp binary couldn't)
- Dropped addon dir into /storage/.kodi/addons/
- systemctl restart kodi → Kodi rescans /storage/.kodi/addons/
- JSON-RPC Addons.SetAddonEnabled flipped enabled:false → true
- Player.Open with plugin URL → 7s yt-dlp resolve → VideoFullScreen.xml,
  fullscreen:true, currentwindow 12005, audio+video synced

Fixes that surfaced during the install:
- yt-dlp swap: PyInstaller aarch64 binary needs ld-linux-aarch64.so.1
  which LibreELEC doesn't ship. Switched to the universal Python zipapp
  (~3MB) which runs on /usr/bin/python3.11. build-addon-zip.sh updated.
- main.py now puts the addon's bin/ dir on PATH so the sidecar's
  Command::new('yt-dlp') call resolves to the bundled zipapp.
- Cosmetic fix: resolve.rs's classify_yt_dlp_error preserves the
  original error message (was downcasing it for keyword matching and
  then using the lowercased copy as the user-facing error).

Caveats logged for later:
- 360p ceiling (yt-dlp '-f best[ext=mp4]' picks itag 18; 720p
  progressive itag 22 is deprecated by YouTube; higher quality wants
  DASH manifest generation).
- ALSA sink: device 'sysdefault:CARD=vc4hdmi1' fails to open on this
  Pi but Kodi auto-falls-back to 'sysdefault' so audio works. Worth
  cleaning up in Kodi audio settings later.

MILESTONES + docs/install.md updated with the SSH + JSON-RPC alternate
install path.
2026-05-23 10:18:26 -07:00

60 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build addon.zip for torttube — runs from a host that can ssh lucy.
#
# Cross-compiles the sidecar via messense/rust-musl-cross:aarch64-musl
# (one-shot container, no crafting-table mutation), bundles yt-dlp's
# aarch64 release binary, packages with the Kodi addon dir layout, and
# drops the zip at /mnt/user/downloads/torttube/ on Lucy.
#
# Usage: bash scripts/build-addon-zip.sh
#
# Expected: ssh alias "lucy" works (per Sulkta SSH config), and the
# torttube source is at /mnt/cache/appdata/crafting-table/workspace/torttube/
# on Lucy (rsync first if you're iterating locally).
set -euo pipefail
VERSION="${VERSION:-0.0.1}"
SRC=/mnt/cache/appdata/crafting-table/workspace/torttube
CARGO_HOME_CACHE=/mnt/cache/appdata/crafting-table/workspace/.cargo-aarch64
TARGET_DIR=/mnt/cache/appdata/crafting-table/workspace/.aarch64-target
STAGE=/tmp/torttube-stage
DEST_DIR=/mnt/user/downloads/torttube
echo ">>> Cross-compile sidecar for aarch64-musl"
ssh lucy "docker run --rm \
-v $SRC/sidecar:/src \
-v $CARGO_HOME_CACHE:/cargo-home \
-v $TARGET_DIR:/target \
-e PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/bin:/usr/bin:/bin \
-e CARGO_HOME=/cargo-home \
-e CARGO_TARGET_DIR=/target \
-e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-unknown-linux-musl-gcc \
-e CC_aarch64_unknown_linux_musl=aarch64-unknown-linux-musl-gcc \
-w /src \
messense/rust-musl-cross:aarch64-musl \
cargo build --release"
echo ">>> Stage addon tree"
ssh lucy "rm -rf $STAGE && mkdir -p $STAGE/plugin.video.torttube/bin"
ssh lucy "rsync -a $SRC/addon/plugin.video.torttube/ $STAGE/plugin.video.torttube/ --exclude bin"
ssh lucy "cp $TARGET_DIR/aarch64-unknown-linux-musl/release/torttube-sidecar $STAGE/plugin.video.torttube/bin/"
echo ">>> Fetch yt-dlp universal Python zipapp"
# Pure-Python zipapp runs on any Python 3.9+ — works around LibreELEC's
# armhf userspace (where yt-dlp's dynamic aarch64 binary can't find
# ld-linux-aarch64.so.1). Kodi 20 ships Python 3.11.
ssh lucy "curl -sSL -o $STAGE/plugin.video.torttube/bin/yt-dlp \
https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp"
ssh lucy "chmod +x $STAGE/plugin.video.torttube/bin/*"
echo ">>> Build addon.zip"
ssh lucy "cd $STAGE && rm -f plugin.video.torttube.zip && \
zip -r plugin.video.torttube.zip plugin.video.torttube/ -x '*.DS_Store' > /dev/null"
echo ">>> Drop at $DEST_DIR/plugin.video.torttube-$VERSION.zip"
ssh lucy "mkdir -p $DEST_DIR && cp $STAGE/plugin.video.torttube.zip \
$DEST_DIR/plugin.video.torttube-$VERSION.zip"
ssh lucy "ls -la $DEST_DIR/"
echo ">>> done — install via Kodi: Settings > Add-ons > Install from zip"
echo " SMB path: smb://lucy/downloads/torttube/plugin.video.torttube-$VERSION.zip"