Files
os/image/build.sh
Tamas Csikel deedf1416a Split the apps and the SDK out of Fennec OS
The apps are developed apart from the OS now, each in its own repo under
gitea.bluefox.support/fennec:
- sdk: sf-app (the app contract: manifest, permissions, store rules,
  sandbox, launch; from sf-ipc), sf-ui, sf-pack, the app template, the
  developer guide. The OS depends on it by tag (v0.1.0).
- youtube, steam: store apps. netflex (native) replaces the Netflex web app.
- store: the Fennec catalog, the store source a new TV starts with.

This repo keeps the OS and its own apps (Settings, App Store, AirPlay,
Miracast). sf-ipc re-exports sf-app, so OS code is mostly unchanged.

- Store apps may register for DIAL (the `dial` permission); an official
  app with the same DIAL name wins.
- Built-in icon names are for official apps only.
- The image installs the catalog apps at build time (factory-store.toml,
  sf-update store in mkosi.postinst.chroot). Steam's system part stays in
  the image: 32-bit libraries, controller udev rules (from Valve's apt
  repo), Valve's key.
- Older TVs move over by themselves: sf-update adds the replacements to
  store.toml once, the old factory app stays until its replacement is
  installed, YouTube's and Steam's data folders move to the new ids, and
  the old sf-app-<id> packages are not installed any more.

Shell 0.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 17:58:21 +01:00

71 lines
3.4 KiB
Bash

#!/usr/bin/env bash
# Builds the Fennec OS binaries and the OS disk image.
# Run as root inside WSL Debian (or any Debian/Ubuntu host):
# sudo bash /mnt/g/source/smartfox/image/build.sh
set -euo pipefail
SRC="$(cd "$(dirname "$0")/.." && pwd)"
WORK="${SMARTFOX_WORK:-/root/smartfox}"
echo "== sync $SRC -> $WORK"
mkdir -p "$WORK"
# Files on NTFS show up as 0777; normalize, the image must not get world-writable files.
rsync -a --delete --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
--exclude /target --exclude '*/target' --exclude /image/mkosi.output --exclude /image/mkosi.cache --exclude /image/stage --exclude /image/ovmf-vars.fd \
--exclude /image/installer/mkosi.output --exclude /image/installer/mkosi.cache --exclude /image/iso --exclude /image/out \
"$SRC/" "$WORK/"
cd "$WORK"
echo "== cargo build"
if ! command -v cargo >/dev/null; then
[ -x "$HOME/.cargo/bin/cargo" ] || curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
export PATH="$HOME/.cargo/bin:$PATH"
fi
cargo build --release -p sf-launcher -p sf-remote -p sf-update -p sf-core -p sf-miracast -p sf-compositor
echo "== stage"
STAGE="$WORK/image/stage"
rm -rf "$STAGE"
install -Dm755 target/release/sf-launcher "$STAGE/usr/bin/sf-launcher"
install -Dm755 target/release/sf-remote "$STAGE/usr/bin/sf-remote"
install -Dm755 tools/siri-remote/fastpair.py "$STAGE/usr/bin/sf-pair"
install -Dm755 target/release/sf-update "$STAGE/usr/bin/sf-update"
for b in sf-core sf-miracast sf-compositor; do
install -Dm755 "target/release/$b" "$STAGE/usr/bin/$b"
done
# Registry login for sf-update (read:package only). Kept out of git; without it
# the TV can only update if the registry allows anonymous downloads.
if [ -f image/secrets/update-token ]; then
install -Dm600 image/secrets/update-token "$STAGE/usr/share/smartfox/update-token"
else
echo "warning: image/secrets/update-token is missing, sf-update will log in anonymously"
fi
mkdir -p "$STAGE/usr/share/smartfox"
# Official apps only. A folder with its own .git is a store app checked out
# here for development (e.g. apps/netflex-tv): not part of the image. Store
# apps come from their own repos (factory-store.toml, mkosi.postinst.chroot).
mkdir -p "$STAGE/usr/share/smartfox/apps"
for d in apps/*/; do
[ -e "$d/.git" ] && continue
cp -r "$d" "$STAGE/usr/share/smartfox/apps/"
done
chmod -R a+x "$STAGE"/usr/share/smartfox/apps/*/bin 2>/dev/null || true
# Versions of the factory copies: sf-update only installs newer packages.
{
echo "sf-shell = \"$(sed -n '/^\[workspace.package\]/,/^\[/ s/^version *= *"\(.*\)"/\1/p' Cargo.toml)\""
for d in "$STAGE"/usr/share/smartfox/apps/*/; do
v=$(sed -n 's/^version *= *"\(.*\)".*/\1/p' "$d/app.toml" | head -1)
[ -n "$v" ] && echo "sf-app-$(basename "$d") = \"$v\""
done
} >"$STAGE/usr/share/smartfox/factory-versions.toml"
mkdir -p "$STAGE/usr/share/doc/smartfox"
cp docs/updates.md docs/store.md "$STAGE/usr/share/doc/smartfox/"
chmod +x image/mkosi.postinst.chroot image/mkosi.extra/usr/bin/sf-session image/mkosi.extra/usr/bin/sf-launcher-start image/mkosi.extra/usr/bin/sf-remote-debug image/mkosi.extra/usr/bin/sf-diag image/mkosi.extra/usr/bin/sf-shell-exec image/*.sh tools/vm/*.sh tools/siri-remote/*.sh tools/siri-remote/*.py
echo "== mkosi"
# Cache and output stay on the Linux filesystem (NTFS mounts break mkosi).
mkdir -p image/mkosi.cache
cd image
mkosi -f build
ls -lh mkosi.output/