-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup-environment
112 lines (98 loc) · 3.85 KB
/
setup-environment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# SPDX-License-Identifier: MIT
#
# Helper script for generation of OE conf/local.conf and conf/bblayers.conf
# files from custom layer samples with preset machine and distro variables.
#
# The usage of the script is limited to a particular configuration of layers.
#
# Copyright (C) 2019 ilbers GmbH
# Copyright (C) 2019 Christ Electronic Systems GmbH
if [ -n "$BASH_SOURCE" ]; then
THIS_SCRIPT=`readlink -f $BASH_SOURCE`
elif [ -n "$ZSH_NAME" ]; then
THIS_SCRIPT=`readlink -f $0`
else
THIS_SCRIPT=`readlink -f $(pwd)/setup-environment`
if [ ! -e "$THIS_SCRIPT" ]; then
echo "Can not find $THIS_SCRIPT file." >&2
echo "Please run the script from the directory containing it." >&2
exit 1
fi
fi
BB_ENV_EXTRAWHITE="RAUC_VAULT_TOKEN"
THIS_LAYER_DIR=`dirname $THIS_SCRIPT`
export TEMPLATECONF="$THIS_LAYER_DIR/conf"
. $THIS_LAYER_DIR/../poky/oe-init-build-env "$1" "$THIS_LAYER_DIR/../poky/bitbake"
unset TEMPLATECONF
SUPPORTED_LAYER_MACHINES=`ls $THIS_LAYER_DIR/conf/machine/*.conf | sed 's#.*/\(.*\)\.conf# \1#g'`
if [ -n "$MACHINE" ]; then
if [ `echo $SUPPORTED_LAYER_MACHINES | grep -c $MACHINE` -gt 0 ]; then
sed "s#^MACHINE ??=.*#MACHINE ??= \"$MACHINE\"#g" -i $BUILDDIR/conf/local.conf
else
echo "Machine '$MACHINE' is unsupported by the layer maintainers, ignoring."
echo -e "List of supported machines:\n$SUPPORTED_LAYER_MACHINES\n"
fi
fi
SUPPORTED_POKY_DISTROS=`ls $THIS_LAYER_DIR/../poky/meta-poky/conf/distro/*.conf | sed 's#.*/\(.*\)\.conf# \1#g'`
SUPPORTED_LAYER_DISTROS=`ls $THIS_LAYER_DIR/conf/distro/*.conf | sed 's#.*/\(.*\)\.conf# \1#g'`
if [ -n "$DISTRO" ]; then
if [ `echo $SUPPORTED_LAYER_DISTROS | grep -c $DISTRO` -gt 0 -o \
`echo $SUPPORTED_POKY_DISTROS | grep -c $DISTRO` -gt 0 ]; then
sed "s#^DISTRO ?=.*#DISTRO ?= \"$DISTRO\"#g" -i $BUILDDIR/conf/local.conf
else
echo "Distro '$DISTRO' is unsupported in this layer and not a Poky distro, ignoring."
echo -e "List of the supported distros:\n$SUPPORTED_LAYER_DISTROS\n"
echo -e "List of Poky distros:\n$SUPPORTED_POKY_DISTROS\n"
fi
fi
CWD=`pwd`
# Handle EULA setting
EULA_ACCEPTED=
BUILD_DIR=$1
# EULA has been accepted already (ACCEPT_FSL_EULA is set in local.conf)
if grep -q '^\s*ACCEPT_FSL_EULA\s*=\s*["'\'']..*["'\'']' conf/local.conf; then
EULA_ACCEPTED=1
fi
if [ -z "$EULA_ACCEPTED" ] && [ -n "$EULA" ]; then
# The FSL EULA is not set as accepted in local.conf, but the EULA
# variable is set in the environment, so we just configure
# ACCEPT_FSL_EULA in local.conf according to $EULA.
echo "ACCEPT_FSL_EULA = \"$EULA\"" >> conf/local.conf
elif [ -n "$EULA_ACCEPTED" ]; then
# The FSL EULA has been accepted once, so ACCEPT_FSL_EULA is set
# in local.conf. No need to do anything.
:
else
# THE FSL EULA is not set as accepted in local.conf, and EULA is
# not set in the environment, so we need to ask user if he/she
# accepts the FSL EULA:
cat <<EOF
Some BSPs depend on libraries and packages which are covered by Freescale's
End User License Agreement (EULA). To have the right to use these binaries in
your images, you need to read and accept the following...
EOF
sleep 4
more -d $CWD/../sources/meta-freescale/EULA
echo
REPLY=
while [ -z "$REPLY" ]; do
echo -n "Do you accept the EULA you just read? (y/n) "
read REPLY
case "$REPLY" in
y|Y)
echo "EULA has been accepted."
echo "" >> conf/local.conf
echo "#Accept EULA of meta-freescale" >> conf/local.conf
echo "ACCEPT_FSL_EULA = \"1\"" >> conf/local.conf
;;
n|N)
echo "EULA has not been accepted."
echo "May a build with this BSP will not work! Initialize bitbake again and accept EULA then!"
;;
*)
REPLY=
;;
esac
done
fi