yggdrasil/build.sh

53 lines
927 B
Bash
Executable File

#!/bin/sh
set -e
if [ "${ARCH}" = "" ]; then
ARCH=aarch64
fi
if [ "${PROFILE}" = "" ]; then
PROFILE=debug
fi
USER_TARGET=${ARCH}-unknown-yggdrasil
USER_CARGO_OPTS="--target=${USER_TARGET}"
USER_FILES=init
pstatus() {
echo -e "[BUILD] \033[32;1m$@\033[0m"
}
die() {
echo -e "[ERROR] \033[31;1m$@\033[0m" >&2
exit 1
}
check_toolchain() {
pstatus "Checking toolchain"
if ! cargo +ygg-stage1 --version; then
die "Yggdrasil OS Rust toolchain is not built/installed, see https://git.alnyan.me/yggdrasil/yggdrasil-rust"
fi
}
pack_initrd() {
cd "target/${USER_TARGET}/${PROFILE}"
tar --xform='s/^/\//' -cf initrd.tar ${USER_FILES}
cd -
}
check_toolchain
case "$1" in
build|"")
pstatus "Building userspace programs"
cargo +ygg-stage1 build ${USER_CARGO_OPTS}
pstatus "Creating initrd.tar"
pack_initrd
;;
**)
;;
esac