Adding s4sk support
[AGL/meta-agl.git] / templates / base / 01_setup_EULAfunc.sh
1 find_and_ack_eula() {
2     # Handle EULA , if needed. This is a generic method to handle BSPs
3     # that might (or not) come with a EULA. If a machine has a EULA, we
4     # assume that its corresponding layers has conf/EULA/$MACHINE file
5     # with the EULA text, which we will display to the user and request
6     # for acceptance. If accepted, the variable ACCEPT_EULA_$MACHINE is
7     # set to 1 in local.conf, which can later be used by the BSP.
8     # If the env variable EULA_$MACHINE is set it is used by default,
9     # without prompting the user.
10     # FIXME: there is a potential issue if the same $MACHINE is set in more than one layer.. but we should assert that earlier
11     # $1 is layer directory
12     # $2 is location of EULA file relative to layer directory
13     if test x"" == x"$2"; then
14         EULA=$(find $1 -print | grep "conf/eula/$MACHINE" | grep -v scripts | grep -v openembedded-core || true)
15     else
16         EULA=$1/$2
17     fi
18     if [ -n "$EULA" ]; then
19         # remove '-' since we are constructing a bash variable name here
20         EULA_MACHINE="EULA_$(echo $MACHINE | sed 's/-//g')"
21         # NOTE: indirect reference / dynamic variable
22         if [ -n "${!EULA_MACHINE}" ]; then
23             # the EULA_$MACHINE variable is set in the environment, so we just configure
24             # ACCEPT_EULA_$MACHINE in local.conf
25             EULA_ACCEPT=${!EULA_MACHINE}
26         else
27             # so we need to ask user if he/she accepts the EULA:
28             cat <<EOF
29 The BSP for $MACHINE depends on packages and firmware which are covered by an 
30 End User License Agreement (EULA). To have the right to use these binaries
31 in your images, you need to read and accept the following...
32
33 The firmware package can contains several types of firmware (depending on BSP):
34
35 * bootloaders: the first stage bootloaders are proprietary for this
36   board, they are included in this firmware package.
37 * firmware for the power management 'companion' core: on QCOM SoC some
38   power management features are implemented in a companion core , called
39   RPM, and not on the main CPU.
40 * firmware for GPU, WLAN, DSP/GPS and video codecs. These firmware are
41   used by their respective linux drivers (DRM, wlan, v4l2, .. ) and are
42   loaded on-demand by the main CPU onto the various cores on the SoC.
43 EOF
44
45             echo
46             REPLY=
47             while [ -z "$REPLY" ]; do
48                 echo -n "Do you want to read the EULA ? (y/n) "
49                 read REPLY
50                 case "$REPLY" in
51                     y|Y)
52                         READ_EULA=1
53                         ;;
54                     n|N)
55                         READ_EULA=0
56                         ;;
57                     *)
58                         REPLY=
59                         ;;
60                 esac
61             done
62
63             if [ "$READ_EULA" == 1 ]; then
64                 more -d ${EULA}
65                 echo
66                 REPLY=
67                 while [ -z "$REPLY" ]; do
68                     echo -n "Do you accept the EULA you just read? (y/n) "
69                     read REPLY
70                     case "$REPLY" in
71                         y|Y)
72                             echo "EULA has been accepted."
73                             EULA_ACCEPT=1
74                             ;;
75                         n|N)
76                             echo "EULA has not been accepted."
77                             ;;
78                         *)
79                             REPLY=
80                             ;;
81                     esac
82                 done
83             fi
84         fi
85     fi
86 }
87
88 EULA_ACCEPT=0