# NOTE: This is a shared Cargo workspace. The output will be placed in
# the workspace, not the source directory. Rust template does not work.
abinfo "Building the OOBE program ..."
pushd "$SRCDIR"/oobe-gui/src-tauri
cargo build --release --features custom-protocol

abinfo "Installing the OOBE program ..."
install -Dvm755 "$SRCDIR"/target/release/oobe-gui \
	"$PKGDIR"/usr/libexec/aosc-os-oobe/aosc-os-oobe-gui

abinfo "Installing script ..."
install -Dvm755 "$SRCDIR"/contrib/aosc-os-oobe-gui-launcher \
	"$PKGDIR"/usr/bin/aosc-os-oobe-gui-launcher

abinfo "Installing systemd unit file ..."
install -Dvm644 "$SRCDIR"/contrib/aosc-os-oobe-gui.service \
	"$PKGDIR"/usr/lib/systemd/system/aosc-os-oobe-gui.service

abinfo "Enabling the service ..."
for tgt in first-boot-complete.target multi-user.target ; do
	mkdir -p "$PKGDIR"/usr/lib/systemd/system/"$tgt".wants
	ln -sv ../aosc-os-oobe-gui.service \
		"$PKGDIR"/usr/lib/systemd/system/"$tgt".wants/aosc-os-oobe-gui.service
done
