Files
os/image/mkosi.postinst.chroot
Tamas Csikel d5be90443d Package-based updates: sf-update, signed shell and app packages
- sf-update (root): lists sf-shell / sf-app-* in the Gitea generic registry,
  downloads, checks the Ed25519 signature and unpacks to /var/lib/sf-pkg,
  switches via current/previous/staged symlinks; the factory copies on the
  read-only root stay as fallback. A new shell is on trial and rolls back
  after 3 failed starts.
- Launcher: apps from factory + installed packages (newer version wins),
  Settings > System > Updates (check, install now), shell trial confirm.
- Image: sf-update units (boot apply, 6-hourly download, launcher requests),
  sf-shell-exec wrapper for sf-remote, factory versions, registry token.
- CI: .gitea/workflows/packages.yml builds, signs and uploads packages whose
  version isn't published yet (tools/pkg/packages.sh).
- docs/updates.md: protocol and layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 09:27:59 +02:00

74 lines
3.6 KiB
Bash

#!/bin/sh
# Runs inside the image after packages and extra trees are installed.
set -e
# Homes live on the writable data partition (/var); root is read-only.
if [ ! -L /home ]; then
mkdir -p /var/home
cp -a /home/. /var/home/ 2>/dev/null || true
rm -rf /home
ln -s var/home /home
fi
# The TV user (uid 1000): auto-login on tty1 starts the SmartFox session.
if ! id tv >/dev/null 2>&1; then
useradd -m -d /var/home/tv -u 1000 -s /bin/bash -G video,render,input,audio,bluetooth tv
fi
# Wi-Fi settings: iwd's D-Bus policy lets the netdev group manage networks.
getent group netdev >/dev/null || groupadd -r netdev
usermod -aG netdev tv
systemctl enable systemd-networkd systemd-resolved iwd bluetooth sf-remote.service sf-data-init.service sf-remote-debug-boot.service sf-remote-debug.path sf-update-apply.service sf-update-requests.path sf-update-auto.timer
# sshd only runs when remote debugging is on (Settings > System, sf-remote-debug).
systemctl disable ssh.service ssh.socket 2>/dev/null || true
systemctl set-default multi-user.target
# No interactive first-boot questions on a TV (locale, timezone, etc. come from mkosi.conf).
systemctl mask systemd-firstboot.service
# Root is read-only and stays its built size; the data partition takes the rest.
systemctl mask systemd-growfs-root.service
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf || true
# Invisible mouse cursor: the TV only has a keyboard and the remote. Every
# cursor name is a 1x1 transparent image; cage, the launcher and Chromium all
# load cursors from this theme (XCURSOR_THEME in sf-session, and "default").
python3 - <<'EOF'
import os, struct
d = "/usr/share/icons/smartfox-blank/cursors"
os.makedirs(d, exist_ok=True)
img = struct.pack("<9I", 36, 0xFFFD0002, 24, 1, 1, 1, 0, 0, 0) + struct.pack("<I", 0)
data = b"Xcur" + struct.pack("<3I", 16, 0x10000, 1) + struct.pack("<3I", 0xFFFD0002, 24, 28) + img
with open(f"{d}/default", "wb") as f:
f.write(data)
names = """
left_ptr arrow top_left_arrow right_ptr pointer hand hand1 hand2 pointing_hand
text xterm ibeam vertical-text wait watch progress left_ptr_watch half-busy
crosshair cross tcross cell move fleur all-scroll grab grabbing openhand
closedhand dnd-move dnd-copy dnd-link dnd-none dnd-ask copy alias no-drop
not-allowed forbidden crossed_circle circle help question_arrow whats_this
context-menu zoom-in zoom-out col-resize row-resize sb_h_double_arrow
sb_v_double_arrow h_double_arrow v_double_arrow ew-resize ns-resize
nesw-resize nwse-resize e-resize w-resize n-resize s-resize ne-resize
nw-resize se-resize sw-resize right_side left_side top_side bottom_side
top_right_corner top_left_corner bottom_right_corner bottom_left_corner
size_hor size_ver size_bdiag size_fdiag split_h split_v sb_left_arrow
sb_right_arrow sb_up_arrow sb_down_arrow center_ptr pencil draft X_cursor
""".split()
for n in names:
p = f"{d}/{n}"
if not os.path.lexists(p):
os.symlink("default", p)
EOF
printf '[Icon Theme]\nName=smartfox-blank\nComment=Invisible cursor\n' >/usr/share/icons/smartfox-blank/index.theme
mkdir -p /usr/share/icons/default
printf '[Icon Theme]\nInherits=smartfox-blank\n' >/usr/share/icons/default/index.theme
chmod +x /usr/bin/sf-session /usr/bin/sf-pair /usr/bin/sf-remote-debug /usr/bin/sf-diag /usr/bin/sf-shell-exec 2>/dev/null || true
# Factory copy of /var: sf-data-init.service fills the empty data partition from it.
rm -rf /usr/share/factory/var
mkdir -p /usr/share/factory
cp -a /var /usr/share/factory/var
rm -rf /usr/share/factory/var/cache/apt/* /usr/share/factory/var/lib/apt/lists/* /usr/share/factory/var/log/*
mkdir -p /usr/share/factory/var/lib/bluetooth
chmod 700 /usr/share/factory/var/lib/bluetooth