meta-agl-bsp: update meta-virtualization bbappends
[AGL/meta-agl.git] / scripts / envsetup.sh
1 #!/bin/bash
2
3 ################################################################################
4 #
5 # The MIT License (MIT)
6 #
7 # Copyright (c) 2016 Stéphane Desneux <sdx@iot.bzh>
8 #
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 # SOFTWARE.
26 #
27 ################################################################################
28
29 #################################################################################
30 #                              IMPORTANT NOTICE
31 #
32 # This script is a compatiblity script with previous (AGL 1.0) envsetup script
33 # It has been replaced by another script named "aglsetup.sh".
34
35 ################################################################################
36
37 # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594
38 SOURCED=0
39 if [ -n "$ZSH_EVAL_CONTEXT" ]; then 
40         [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $0) && pwd -P); }
41 elif [ -n "$KSH_VERSION" ]; then
42         [[ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- ${.sh.file}) && pwd -P); }
43 elif [ -n "$BASH_VERSION" ]; then
44         [[ $0 != "$BASH_SOURCE" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $BASH_SOURCE) && pwd -P); }
45 fi
46
47 if [ $SOURCED -ne 1 ]; then
48         unset SOURCED
49         unset SOURCEDIR
50         echo "Error: this script needs to be sourced in a supported shell" >&2
51         echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2
52         return 1
53 else
54         unset SOURCED
55         if [ -z $1 ]; then
56         echo -e "Usage: source envsetup.sh <board/device> [build dir]"
57         return 1
58         fi
59         if [ -n "$2" ]; then
60                 BUILD_DIR="$2"
61         else
62                 BUILD_DIR=build
63         fi
64         # echo "DEPRECATED..." | figlet -f big -w 80 -c
65         cat <<'EOF' >&2
66  ------------------------------------------------------------------------------
67 | using this script is...                                                      |
68 |   _____  ______ _____  _____  ______ _____       _______ ______ _____        |
69 |  |  __ \|  ____|  __ \|  __ \|  ____/ ____|   /\|__   __|  ____|  __ \       |
70 |  | |  | | |__  | |__) | |__) | |__ | |       /  \  | |  | |__  | |  | |      |
71 |  | |  | |  __| |  ___/|  _  /|  __|| |      / /\ \ | |  |  __| | |  | |      |
72 |  | |__| | |____| |    | | \ \| |___| |____ / ____ \| |  | |____| |__| | _ _  |
73 |  |_____/|______|_|    |_|  \_\______\_____/_/    \_\_|  |______|_____(_|_|_) |
74 |                                                                              |
75 | To support the newest/upcoming features, please use the script aglsetup.sh.  |
76  ------------------------------------------------------------------------------
77 EOF
78         . $SOURCEDIR/aglsetup.sh -m $1 -b $BUILD_DIR agl-devel agl-netboot agl-demo
79         rc=$?
80         unset SOURCEDIR
81         unset BUILD_DIR
82         return $rc
83 fi