#!/bin/sh # Tegra demo distro setup script # # Copyright (c) 2020, Matthew Madison # Poritions Copyright (C) 2006-2001 Linux Foundation # # SPDX-License-Identifier: GPL-2.0-or-later # # See scripts-setup/setup-env-internal for usage information. # For shells that do not pass arguments to sourced scripts (e.g., dash), # you can set MACHINE and DISTRO in your environment to appropriate # values before sourcing this script. # # # Initial boilerplate from the oe-init-build-env if [ -n "$BASH_SOURCE" ]; then THIS_SCRIPT=$BASH_SOURCE elif [ -n "$ZSH_NAME" ]; then THIS_SCRIPT=$0 else THIS_SCRIPT="$(pwd)/setup-env" if [ ! -e "$THIS_SCRIPT" ]; then echo "Error: $THIS_SCRIPT doesn't exist!" >&2 echo "Please run this script in setup-env's directory." >&2 return 1 fi fi if [ -n "$BBSERVER" ]; then unset BBSERVER fi if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2 exit 1 fi # Running bitbake builds as root can cause issues, so flag this if [ $(id -u) -eq 0 ]; then echo "ERROR: do not use the BSP as root. Exiting..." unset THIS_SCRIPT return 1 fi TD_TOP=$(dirname "$THIS_SCRIPT") TD_TOP=$(readlink -f "$TD_TOP") TD_SCRIPTDIR="$TD_TOP/scripts-setup" # Automatically update the git submodules. It's common to forget # to do this after updating the main repository to latest. "$TD_SCRIPTDIR/update-git-submodules" "$TD_TOP" # We use TD_VARS to track the variables that need to # be unset before exiting this script. TD_RC=0 TD_VARS="TD_RC TD_SCRIPTDIR TD_TOP THIS_SCRIPT TD_VARS" # Call on setup-env-internal to parse any arguments. It # will emit variable assignments on stdout. eval $(TD_TOP="$TD_TOP" "$TD_SCRIPTDIR/setup-env-internal" "$THIS_SCRIPT" "$@") if [ $TD_RC -ne 0 ]; then for var in $(echo $TD_VARS); do unset $var; done; unset var return 1 fi OEROOT=$(readlink -f "$TD_TOP/layers") export OEROOT # There can be multiple distro layers in the repository, which # may require different setups. The .templateconf file in the # distro layer can be used to handle where to look for config # templates. if [ -n "$TD_NEEDSETUP" ]; then DISTRO="$TD_DISTRO" # If the layer directory has a .templateconf file, use that to set TEMPLATECONF if [ -e "$OEROOT/$TD_LAYERPATH/.templateconf" ]; then . "$OEROOT/$TD_LAYERPATH/.templateconf" fi fi # Now things are set up to let the OE setup scripts to their jobs . $OEROOT/scripts/oe-buildenv-internal && TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || { for var in $(echo $TD_VARS OEROOT DISTRO TEMPLATECONF); do unset $var; done; unset var return 1 } # Make sure to configure in the user's distro and machine settings # into local.conf if this is the first time setting up. if [ -n "$TD_NEEDSETUP" ]; then unset DISTRO TEMPLATECONF echo "$TD_LAYERPATH" > "$BUILDDIR/conf/distrolayer.cfg" # Replace placeholder comments with default settings sed -e"/@TD_SETUP_MACHINE@/c \MACHINE ?= \"$TD_MACHINE\"" \ -e"/@TD_SETUP_DISTRO@/c \DISTRO ?= \"$TD_DISTRO\"" -i "$BUILDDIR/conf/local.conf" cat <