1#!/bin/sh 2 3# OE Build Environment Setup Script 4# 5# Copyright (C) 2006-2011 Linux Foundation 6# 7# SPDX-License-Identifier: GPL-2.0-or-later 8# 9 10if [ -z "$BUILDDIR" ]; then 11 echo >&2 "Error: The build directory (BUILDDIR) must be set!" 12 exit 1 13fi 14 15if [ "$1" = '--help' -o "$1" = '-h' ]; then 16 echo 'Usage: oe-setup-builddir' 17 echo '' 18 echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR" 19 echo '' 20 exit 2 21fi 22 23mkdir -p "$BUILDDIR/conf" 24 25if [ ! -d "$BUILDDIR" ]; then 26 echo >&2 "Error: The builddir ($BUILDDIR) does not exist!" 27 exit 1 28fi 29 30if [ ! -w "$BUILDDIR" ]; then 31 echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build" 32 exit 1 33fi 34 35# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf 36chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" 37chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf" 38 39cd "$BUILDDIR" 40 41if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then 42 TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") 43fi 44 45. "$OEROOT"/.templateconf 46 47if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then 48 echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg" 49fi 50 51# 52# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf 53# 54if [ -n "$TEMPLATECONF" ]; then 55 if [ ! -d "$TEMPLATECONF" ]; then 56 # Allow TEMPLATECONF=meta-xyz/conf as a shortcut 57 if [ -d "$OEROOT/$TEMPLATECONF" ]; then 58 TEMPLATECONF="$OEROOT/$TEMPLATECONF" 59 fi 60 if [ ! -d "$TEMPLATECONF" ]; then 61 echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" 62 exit 1 63 fi 64 fi 65 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" 66 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" 67 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt" 68fi 69 70unset SHOWYPDOC 71if [ -z "$OECORELOCALCONF" ]; then 72 OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample" 73fi 74if [ ! -r "$BUILDDIR/conf/local.conf" ]; then 75 cat <<EOM 76You had no conf/local.conf file. This configuration file has therefore been 77created for you from $OECORELOCALCONF 78You may wish to edit it to, for example, select a different MACHINE (target 79hardware). See conf/local.conf for more information as common configuration 80options are commented. 81 82EOM 83 cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf" 84 SHOWYPDOC=yes 85fi 86 87if [ -z "$OECORELAYERCONF" ]; then 88 OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample" 89fi 90if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then 91 cat <<EOM 92You had no conf/bblayers.conf file. This configuration file has therefore been 93created for you from $OECORELAYERCONF 94To add additional metadata layers into your configuration please add entries 95to conf/bblayers.conf. 96 97EOM 98 99 # Put the absolute path to the layers in bblayers.conf so we can run 100 # bitbake without the init script after the first run. 101 # ##COREBASE## is deprecated as its meaning was inconsistent, but continue 102 # to replace it for compatibility. 103 sed -e "s|##OEROOT##|$OEROOT|g" \ 104 -e "s|##COREBASE##|$OEROOT|g" \ 105 "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf" 106 SHOWYPDOC=yes 107fi 108 109# Prevent disturbing a new GIT clone in same console 110unset OECORELOCALCONF 111unset OECORELAYERCONF 112 113# Ending the first-time run message. Show the YP Documentation banner. 114if [ ! -z "$SHOWYPDOC" ]; then 115 cat <<EOM 116The Yocto Project has extensive documentation about OE including a reference 117manual which can be found at: 118 https://docs.yoctoproject.org 119 120For more information about OpenEmbedded see the website: 121 https://www.openembedded.org/ 122 123EOM 124# unset SHOWYPDOC 125fi 126 127if [ -z "$OECORENOTESCONF" ]; then 128 OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt" 129fi 130[ ! -r "$OECORENOTESCONF" ] || cat "$OECORENOTESCONF" 131unset OECORENOTESCONF 132