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