diff options
Diffstat (limited to 'scripts/oe-setup-builddir')
-rwxr-xr-x | scripts/oe-setup-builddir | 106 |
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 | ||
10 | if [ -z "$BUILDDIR" ]; then | 10 | die() { |
11 | echo >&2 "Error: The build directory (BUILDDIR) must be set!" | 11 | echo Error: "$@" >&2 |
12 | exit 1 | 12 | exit 1 |
13 | fi | 13 | } |
14 | |||
15 | [ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!" | ||
14 | 16 | ||
15 | if [ "$1" = '--help' -o "$1" = '-h' ]; then | 17 | if [ "$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 | ||
23 | mkdir -p "$BUILDDIR/conf" | 25 | mkdir -p "$BUILDDIR/conf" |
24 | 26 | ||
25 | if [ ! -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" |
28 | fi | ||
29 | |||
30 | if [ ! -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 | ||
33 | fi | ||
34 | 30 | ||
35 | # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf | 31 | # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf |
36 | chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" | 32 | chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" |
37 | chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf" | 33 | chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf" |
38 | 34 | ||
39 | cd "$BUILDDIR" | 35 | cd "$BUILDDIR" || die "Failed to change directory to $BUILDDIR!" |
40 | 36 | ||
41 | if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then | 37 | . "$OEROOT/.templateconf" |
42 | TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") | ||
43 | fi | ||
44 | |||
45 | . $OEROOT/.templateconf | ||
46 | 38 | ||
47 | if [ ! -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" | 40 | ORG_TEMPLATECONF=$TEMPLATECONF |
49 | fi | ||
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 | # |
54 | if [ -n "$TEMPLATECONF" ]; then | 45 | if [ -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" |
68 | fi | 62 | fi |
69 | 63 | ||
70 | unset SHOWYPDOC | 64 | unset SHOWYPDOC |
71 | if [ -z "$OECORELOCALCONF" ]; then | 65 | if [ -z "$OECORELOCALCONF" ]; then |
72 | OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample" | 66 | OECORELOCALCONF="$OEROOT/meta/conf/templates/default/local.conf.sample" |
73 | fi | 67 | fi |
74 | if [ ! -r "$BUILDDIR/conf/local.conf" ]; then | 68 | if [ ! -r "$BUILDDIR/conf/local.conf" ]; then |
75 | cat <<EOM | 69 | cat <<EOM |
76 | You had no conf/local.conf file. This configuration file has therefore been | 70 | You had no conf/local.conf file. This configuration file has therefore been |
77 | created for you with some default values. You may wish to edit it to, for | 71 | created for you from $OECORELOCALCONF |
78 | example, select a different MACHINE (target hardware). See conf/local.conf | 72 | You may wish to edit it to, for example, select a different MACHINE (target |
79 | for more information as common configuration options are commented. | 73 | hardware). |
80 | 74 | ||
81 | EOM | 75 | EOM |
82 | cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf" | 76 | cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf" |
83 | SHOWYPDOC=yes | 77 | SHOWYPDOC=yes |
84 | fi | 78 | fi |
85 | 79 | ||
86 | if [ -z "$OECORELAYERCONF" ]; then | 80 | if [ -z "$OECORELAYERCONF" ]; then |
87 | OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample" | 81 | OECORELAYERCONF="$OEROOT/meta/conf/templates/default/bblayers.conf.sample" |
88 | fi | 82 | fi |
89 | if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then | 83 | if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then |
90 | cat <<EOM | 84 | cat <<EOM |
91 | You had no conf/bblayers.conf file. This configuration file has therefore been | 85 | You had no conf/bblayers.conf file. This configuration file has therefore been |
92 | created for you with some default values. To add additional metadata layers | 86 | created for you from $OECORELAYERCONF |
93 | into your configuration please add entries to conf/bblayers.conf. | 87 | To add additional metadata layers into your configuration please add entries |
88 | to conf/bblayers.conf. | ||
94 | 89 | ||
95 | EOM | 90 | EOM |
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 |
105 | fi | 100 | fi |
106 | 101 | ||
102 | if [ -z "$OECORESUMMARYCONF" ]; then | ||
103 | OECORESUMMARYCONF="$OEROOT/meta/conf/templates/default/conf-summary.txt" | ||
104 | fi | ||
105 | if [ ! -r "$BUILDDIR/conf/conf-summary.txt" ]; then | ||
106 | [ ! -r "$OECORESUMMARYCONF" ] || cp "$OECORESUMMARYCONF" "$BUILDDIR/conf/conf-summary.txt" | ||
107 | fi | ||
108 | |||
109 | if [ -z "$OECORENOTESCONF" ]; then | ||
110 | OECORENOTESCONF="$OEROOT/meta/conf/templates/default/conf-notes.txt" | ||
111 | fi | ||
112 | if [ ! -r "$BUILDDIR/conf/conf-notes.txt" ]; then | ||
113 | [ ! -r "$OECORENOTESCONF" ] || cp "$OECORENOTESCONF" "$BUILDDIR/conf/conf-notes.txt" | ||
114 | fi | ||
115 | |||
107 | # Prevent disturbing a new GIT clone in same console | 116 | # Prevent disturbing a new GIT clone in same console |
108 | unset OECORELOCALCONF | 117 | unset OECORELOCALCONF |
109 | unset OECORELAYERCONF | 118 | unset OECORELAYERCONF |
119 | unset OECORESUMMARYCONF | ||
120 | unset 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. |
112 | if [ ! -z "$SHOWYPDOC" ]; then | 123 | if [ -n "$SHOWYPDOC" ]; then |
113 | cat <<EOM | 124 | cat <<EOM |
114 | The Yocto Project has extensive documentation about OE including a reference | 125 | The Yocto Project has extensive documentation about OE including a reference |
115 | manual which can be found at: | 126 | manual which can be found at: |
116 | http://yoctoproject.org/documentation | 127 | https://docs.yoctoproject.org |
117 | 128 | ||
118 | For more information about OpenEmbedded see their website: | 129 | For more information about OpenEmbedded see the website: |
119 | http://www.openembedded.org/ | 130 | https://www.openembedded.org/ |
120 | 131 | ||
121 | EOM | 132 | EOM |
122 | # unset SHOWYPDOC | 133 | # unset SHOWYPDOC |
123 | fi | 134 | fi |
124 | 135 | ||
125 | if [ -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 | |||
139 | if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then | ||
140 | echo "$ORG_TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg" | ||
127 | fi | 141 | fi |
128 | [ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF | ||
129 | unset OECORENOTESCONF | ||