summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2022-09-06 16:58:52 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-09-08 14:59:39 +0100
commit1085192e8e8c127e170f0ef13d97a21192f57cb7 (patch)
tree5d7eb218b6d3bdba8c1004068647cf3fdb02dd65 /scripts
parent7162ba29c78c7af8270e95ca63cd62ce6eda3db2 (diff)
downloadpoky-1085192e8e8c127e170f0ef13d97a21192f57cb7.tar.gz
oe-setup-builddir: Simplify error handling
(From OE-Core rev: 670f255bf639ca19a396ee67ec7d78094da2f576) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/oe-setup-builddir29
1 files changed, 11 insertions, 18 deletions
diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir
index 70f2245b16..69c33049c7 100755
--- a/scripts/oe-setup-builddir
+++ b/scripts/oe-setup-builddir
@@ -7,10 +7,12 @@
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' -o "$1" = '-h' ]; then
16 echo 'Usage: oe-setup-builddir' 18 echo 'Usage: oe-setup-builddir'
@@ -22,15 +24,9 @@ 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"
@@ -59,15 +55,12 @@ if [ -n "$TEMPLATECONF" ]; then
59 if [ -d "$OEROOT/$TEMPLATECONF" ]; then 55 if [ -d "$OEROOT/$TEMPLATECONF" ]; then
60 TEMPLATECONF="$OEROOT/$TEMPLATECONF" 56 TEMPLATECONF="$OEROOT/$TEMPLATECONF"
61 fi 57 fi
62 if [ ! -d "$TEMPLATECONF" ]; then 58 [ -d "$TEMPLATECONF" ] ||
63 echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" 59 die "TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'"
64 exit 1
65 fi
66 fi 60 fi
67 templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) 61 templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF)
68 if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then 62 if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then
69 echo >&2 "Error: TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" 63 die "TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name"
70 exit 1
71 fi 64 fi
72 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" 65 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
73 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" 66 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"