oe-buildenv/init.sh
Thomas Klaehn 7c533389fc Yocto build container: start as same user as caller
Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
2017-12-07 13:22:40 +01:00

42 lines
731 B
Bash
Executable File

#!/bin/bash
uid=$(id -u $USER)
if [ ${uid} -lt 100 ]
then
echo "Usage of system users isn't allowed (${uid})."
exit 1
fi
if [[ ! $(pwd) == /home/* ]]
then
echo "Only run it from any '/home/*' folder, not '$(pwd)'."
exit 2
fi
USERNAME=$(whoami | sed -e 's/@.*$//')
HOME=/home/$USERNAME
HOSTNAME=oe
# Determine parallel build capabilities.
parallel_build="$(nproc >&1)"
if [ ${parallel_build} -gt 20 ]
then
BB_NUMBER_THREADS=20
PARALLEL_MAKE="-j 20"
else
BB_NUMBER_THREADS=${parallel_build}
PARALLEL_MAKE="-j "${parallel_build}
fi
BB_ENV_EXTRAWHITE="BB_NUMBER_THREADS PARALLEL_MAKE BB_NUMBER_PARSE_THREADS"
export BB_NUMBER_THREADS
export PARALLEL_MAKE
export BB_ENV_EXTRAWHITE
export HOME
export HOSTNAME
exec "$@"