Files
mu300-linux/tools/make-extra.sh
T
Abdurrahman Kaan DikeçandClaude Opus 5.5 e1a317557b mu300-extra: the VPN engines leave the images and become the vpn extra
The images carried Xray, hev-socks5-tunnel and sing-box (120 MB) whether the VPN was used or not. They are now a
release asset, mu300-extra-vpn.tar.gz (tools/make-extra.sh, 41 MB), installed with mu300-extra install vpn onto the
Linux partition (extra/vpn), where both systems share it and no update or reinstall of a system touches it.

- mu300-update: the extra core (extra_unpack, extra_adopt, extras_to_fetch, extras_install), fetch_verified takes
  MU300_RELEASE_URL; apply brings installed extras to the release and gives a system that uses the VPN with the
  engines of its image the vpn extra (downloaded with the rest, before anything changes; else the old image's
  engines are kept); check lists the extras
- mu300-extra: list, status, install, remove, link, adopt; downloads from the release of the running system
  (MU300_RELEASE, MU300_RELEASE_URL, MU300_EXTRA_FILE for tests and offline use)
- mu300-vpn: engines from the extra first, the image second; a missing engine says mu300-extra install vpn, and a
  VPN that is on gets its engines back by itself (adopt, else download) before the kill switch
- one list of commands on the PATH (opt/mu300/lib/path-commands), read by both image builds and by mu300-extra
  link at boot (rootfs-fixups, OpenWrt mu300-post); mu300-ussd, sms, mu300-voice and mu300-extra join it
- make-release builds the extra, audits that no image carries an engine; the toolkit installs it on Turn on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
2026-10-05 09:06:07 +03:00

40 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Build an extra: the optional parts that are not in the images and that mu300-extra installs on the device.
# tools/make-extra.sh NAME OUT.tar.gz [TAG] (TAG: the release it belongs to, default dev)
# Extras:
# vpn Xray-core + hev-socks5-tunnel (tools/fetch-xray.sh) and sing-box (tools/fetch-sing-box.sh), pinned by hash
# Layout (what mu300-update's extra_unpack checks): ./name ./release ./components ./bin/<programs>, owned by root.
set -eu
NAME=${1:?usage: tools/make-extra.sh NAME OUT.tar.gz [TAG]}
OUT=${2:?usage: tools/make-extra.sh NAME OUT.tar.gz [TAG]}
TAG=${3:-dev}
TOP=$(cd "$(dirname "$0")/.." && pwd)
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/x/bin"
case $NAME in
vpn)
sh "$TOP/tools/fetch-xray.sh" "$tmp/x/bin" >&2
sh "$TOP/tools/fetch-sing-box.sh" "$tmp/x/bin/sing-box" >&2
{
printf 'xray %s\n' "$(sed -n 's/^XRAY_VER=//p' "$TOP/tools/fetch-xray.sh")"
printf 'hev-socks5-tunnel %s\n' "$(sed -n 's/^HEV_VER=//p' "$TOP/tools/fetch-xray.sh")"
printf 'sing-box %s\n' "$(sed -n 's/^VER=//p' "$TOP/tools/fetch-sing-box.sh")"
} > "$tmp/x/components" ;;
*) echo "unknown extra '$NAME' (vpn)" >&2; exit 2 ;;
esac
echo "$NAME" > "$tmp/x/name"
echo "$TAG" > "$tmp/x/release"
# python's tarfile, not tar: the same root-owned archive from macOS (bsdtar) and Linux (GNU tar)
python3 - "$tmp/x" "$OUT" <<'PY'
import os, sys, tarfile
src, out = sys.argv[1], sys.argv[2]
def root(ti):
ti.uid = ti.gid = 0
ti.uname = ti.gname = 'root'
return ti
with tarfile.open(out, 'w:gz', format=tarfile.GNU_FORMAT) as t:
for name in ('name', 'release', 'components', 'bin'):
t.add(os.path.join(src, name), arcname='./' + name, filter=root)
PY
echo "$NAME extra ($TAG): $OUT, $(du -h "$OUT" | cut -f1)"