Files
hermes-agent/scripts/termux/launchers.py
ethernet 1bf588234c refactor(build): share product recipes across distributions
Build TUI, web, desktop UI and runnable agent products from explicit
prepared inputs. Keep dependency preparation separate from distribution
packaging, with PM and native builds sharing uv environment construction.

Docker copies compiled frontend products instead of build dependencies.
Nix retains uv2nix environments and consumes shared assembly through store
references. Native desktop and Termux use the same launcher and frontend
contracts. Preserve the independent PM runtime and source imports from
arbitrary working directories.

Keep failed frontend builds from replacing the previous product, reject
source/output overlap, and bound dependency-process output draining.
Include hermes_wisdom in the Nix wheel: real CLI smoke tests exposed its
missing package declaration on the base revision too.

Verified focused Python and JavaScript suites, Docker build/runtime checks,
Nix desktop and CLI/ACP checks, standalone TUI and packaged Electron PTY,
and real full-Chromium interaction. Native signed installers, Android device
installation and the full repository suite remain CI verification.
2026-09-11 13:16:55 -04:00

63 lines
1.9 KiB
Python

"""APT maintainer hooks; agent entrypoints belong to scripts.build.launchers."""
from __future__ import annotations
import argparse
from pathlib import Path
import shlex
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
def write_maintainer_scripts(control: Path, names: list[str]) -> None:
names_text = " ".join(shlex.quote(name) for name in names)
postinst = '''#!/data/data/com.termux/files/usr/bin/sh
set -eu
PREFIX="${PREFIX:-/data/data/com.termux/files/usr}"
mkdir -p "$PREFIX/bin"
for name in __NAMES__; do
link="$PREFIX/bin/$name"
target="../lib/hermes-agent/bin/$name"
if [ -L "$link" ] && [ "$(readlink "$link")" = "$target" ]; then
continue
fi
if [ -e "$link" ] || [ -L "$link" ]; then
printf 'Refusing to replace foreign launcher: %s\\n' "$link" >&2
exit 1
fi
ln -s "$target" "$link"
done
'''
prerm = '''#!/data/data/com.termux/files/usr/bin/sh
set -eu
PREFIX="${PREFIX:-/data/data/com.termux/files/usr}"
case "${1:-remove}" in
remove|deconfigure) ;;
*) exit 0 ;;
esac
for name in __NAMES__; do
link="$PREFIX/bin/$name"
if [ -L "$link" ] && [ "$(readlink "$link")" = "../lib/hermes-agent/bin/$name" ]; then
rm -f "$link"
fi
done
'''
for name, script in (("postinst", postinst), ("prerm", prerm)):
path = control / name
path.write_text(script.replace("__NAMES__", names_text), encoding="utf-8")
path.chmod(0o755)
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--payload", type=Path, required=True)
parser.add_argument("--control", type=Path, required=True)
args = parser.parse_args()
from scripts.build.inputs import project_entries
entries = project_entries(args.payload / "app/pyproject.toml")
write_maintainer_scripts(args.control, list(entries))
if __name__ == "__main__":
main()