summaryrefslogtreecommitdiffstats
path: root/scripts/oe-setup-builddir
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-setup-builddir')
-rwxr-xr-xscripts/oe-setup-builddir106
1 files changed, 59 insertions, 47 deletions
diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir
index 30eaa8efbe..dcb384c33a 100755
--- a/scripts/oe-setup-builddir
+++ b/scripts/oe-setup-builddir
@@ -7,12 +7,14 @@
7# SPDX-License-Identifier: GPL-2.0-or-later 7# SPDX-License-Identifier: GPL-2.0-or-later
8# 8#
9 9
10if [ -z "$BUILDDIR" ]; then 10die() {
11 echo >&2 "Error: The build directory (BUILDDIR) must be set!" 11 echo Error: "$@" >&2
12 exit 1 12 exit 1
13fi 13}
14
15[ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!"
14 16
15if [ "$1" = '--help' -o "$1" = '-h' ]; then 17if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then
16 echo 'Usage: oe-setup-builddir' 18 echo 'Usage: oe-setup-builddir'
17 echo '' 19 echo ''
18 echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR" 20 echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR"
@@ -22,33 +24,22 @@ fi
22 24
23mkdir -p "$BUILDDIR/conf" 25mkdir -p "$BUILDDIR/conf"
24 26
25if [ ! -d "$BUILDDIR" ]; then 27[ -d "$BUILDDIR" ] || die "The build directory ($BUILDDIR) does not exist!"
26 echo >&2 "Error: The builddir ($BUILDDIR) does not exist!" 28[ -w "$BUILDDIR" ] ||
27 exit 1 29 die "Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
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 30
35# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf 31# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
36chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" 32chmod -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" 33chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
38 34
39cd "$BUILDDIR" 35cd "$BUILDDIR" || die "Failed to change directory to $BUILDDIR!"
40 36
41if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then 37. "$OEROOT/.templateconf"
42 TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg")
43fi
44
45. $OEROOT/.templateconf
46 38
47if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then 39# Keep the original TEMPLATECONF before possibly prefixing it with $OEROOT below.
48 echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg" 40ORG_TEMPLATECONF=$TEMPLATECONF
49fi
50 41
51# 42#
52# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf 43# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
53# 44#
54if [ -n "$TEMPLATECONF" ]; then 45if [ -n "$TEMPLATECONF" ]; then
@@ -57,73 +48,94 @@ if [ -n "$TEMPLATECONF" ]; then
57 if [ -d "$OEROOT/$TEMPLATECONF" ]; then 48 if [ -d "$OEROOT/$TEMPLATECONF" ]; then
58 TEMPLATECONF="$OEROOT/$TEMPLATECONF" 49 TEMPLATECONF="$OEROOT/$TEMPLATECONF"
59 fi 50 fi
60 if [ ! -d "$TEMPLATECONF" ]; then 51 [ -d "$TEMPLATECONF" ] ||
61 echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" 52 die "TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'"
62 exit 1 53 fi
63 fi 54 templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" "$TEMPLATECONF")
55 if [ "$templatesdir" != templates ] || [ ! -f "$TEMPLATECONF/../../layer.conf" ]; then
56 die "TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name"
64 fi 57 fi
65 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" 58 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
66 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" 59 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
60 OECORESUMMARYCONF="$TEMPLATECONF/conf-summary.txt"
67 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt" 61 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
68fi 62fi
69 63
70unset SHOWYPDOC 64unset SHOWYPDOC
71if [ -z "$OECORELOCALCONF" ]; then 65if [ -z "$OECORELOCALCONF" ]; then
72 OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample" 66 OECORELOCALCONF="$OEROOT/meta/conf/templates/default/local.conf.sample"
73fi 67fi
74if [ ! -r "$BUILDDIR/conf/local.conf" ]; then 68if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
75 cat <<EOM 69 cat <<EOM
76You had no conf/local.conf file. This configuration file has therefore been 70You had no conf/local.conf file. This configuration file has therefore been
77created for you with some default values. You may wish to edit it to, for 71created for you from $OECORELOCALCONF
78example, select a different MACHINE (target hardware). See conf/local.conf 72You may wish to edit it to, for example, select a different MACHINE (target
79for more information as common configuration options are commented. 73hardware).
80 74
81EOM 75EOM
82 cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf" 76 cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf"
83 SHOWYPDOC=yes 77 SHOWYPDOC=yes
84fi 78fi
85 79
86if [ -z "$OECORELAYERCONF" ]; then 80if [ -z "$OECORELAYERCONF" ]; then
87 OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample" 81 OECORELAYERCONF="$OEROOT/meta/conf/templates/default/bblayers.conf.sample"
88fi 82fi
89if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then 83if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
90 cat <<EOM 84 cat <<EOM
91You had no conf/bblayers.conf file. This configuration file has therefore been 85You had no conf/bblayers.conf file. This configuration file has therefore been
92created for you with some default values. To add additional metadata layers 86created for you from $OECORELAYERCONF
93into your configuration please add entries to conf/bblayers.conf. 87To add additional metadata layers into your configuration please add entries
88to conf/bblayers.conf.
94 89
95EOM 90EOM
96 91
97 # Put the abosolute path to the layers in bblayers.conf so we can run 92 # Put the absolute path to the layers in bblayers.conf so we can run
98 # bitbake without the init script after the first run 93 # bitbake without the init script after the first run.
99 # ##COREBASE## is deprecated as it's meaning was inconsistent, but continue 94 # ##COREBASE## is deprecated as its meaning was inconsistent, but continue
100 # to replace it for compatibility. 95 # to replace it for compatibility.
101 sed -e "s|##OEROOT##|$OEROOT|g" \ 96 sed -e "s|##OEROOT##|$OEROOT|g" \
102 -e "s|##COREBASE##|$OEROOT|g" \ 97 -e "s|##COREBASE##|$OEROOT|g" \
103 $OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf" 98 "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
104 SHOWYPDOC=yes 99 SHOWYPDOC=yes
105fi 100fi
106 101
102if [ -z "$OECORESUMMARYCONF" ]; then
103 OECORESUMMARYCONF="$OEROOT/meta/conf/templates/default/conf-summary.txt"
104fi
105if [ ! -r "$BUILDDIR/conf/conf-summary.txt" ]; then
106 [ ! -r "$OECORESUMMARYCONF" ] || cp "$OECORESUMMARYCONF" "$BUILDDIR/conf/conf-summary.txt"
107fi
108
109if [ -z "$OECORENOTESCONF" ]; then
110 OECORENOTESCONF="$OEROOT/meta/conf/templates/default/conf-notes.txt"
111fi
112if [ ! -r "$BUILDDIR/conf/conf-notes.txt" ]; then
113 [ ! -r "$OECORENOTESCONF" ] || cp "$OECORENOTESCONF" "$BUILDDIR/conf/conf-notes.txt"
114fi
115
107# Prevent disturbing a new GIT clone in same console 116# Prevent disturbing a new GIT clone in same console
108unset OECORELOCALCONF 117unset OECORELOCALCONF
109unset OECORELAYERCONF 118unset OECORELAYERCONF
119unset OECORESUMMARYCONF
120unset OECORENOTESCONF
110 121
111# Ending the first-time run message. Show the YP Documentation banner. 122# Ending the first-time run message. Show the YP Documentation banner.
112if [ ! -z "$SHOWYPDOC" ]; then 123if [ -n "$SHOWYPDOC" ]; then
113 cat <<EOM 124 cat <<EOM
114The Yocto Project has extensive documentation about OE including a reference 125The Yocto Project has extensive documentation about OE including a reference
115manual which can be found at: 126manual which can be found at:
116 http://yoctoproject.org/documentation 127 https://docs.yoctoproject.org
117 128
118For more information about OpenEmbedded see their website: 129For more information about OpenEmbedded see the website:
119 http://www.openembedded.org/ 130 https://www.openembedded.org/
120 131
121EOM 132EOM
122# unset SHOWYPDOC 133# unset SHOWYPDOC
123fi 134fi
124 135
125if [ -z "$OECORENOTESCONF" ]; then 136[ ! -r "$BUILDDIR/conf/conf-summary.txt" ] || cat "$BUILDDIR/conf/conf-summary.txt"
126 OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt" 137[ ! -r "$BUILDDIR/conf/conf-notes.txt" ] || cat "$BUILDDIR/conf/conf-notes.txt"
138
139if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
140 echo "$ORG_TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
127fi 141fi
128[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
129unset OECORENOTESCONF