yggdrasil/build.sh

59 lines
1.0 KiB
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}"
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() {
local build_dir=target/${USER_TARGET}/${PROFILE}
local root_dir=${build_dir}/rootfs
mkdir -p "${root_dir}"
cp ${build_dir}/init ${root_dir}
cd "${root_dir}"
mkdir -p dev
tar cf ../initrd.tar `find . -printf "%P\n"`
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