42 lines
1.8 KiB
Bash
42 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
# Builds the SmartFox 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 /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
|
|
|
|
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"
|
|
mkdir -p "$STAGE/usr/share/smartfox"
|
|
cp -r apps "$STAGE/usr/share/smartfox/apps"
|
|
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/*.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/
|