cbf47be6e140ea042fa87d2b6598643af791ad75
[AGL/meta-agl.git] / meta-agl-bsp / meta-rcar-gen3 / scripts / setup_mm_packages.sh
1 #!/bin/bash
2
3 ZIP_1="R-Car_Gen3_Series_Evaluation_Software_Package_for_Linux-weston5-20190212.zip"
4 ZIP_2="R-Car_Gen3_Series_Evaluation_Software_Package_of_Linux_Drivers-weston5-20190212.zip"
5
6 COPY_SCRIPT="$METADIR/bsp/meta-renesas-rcar-gen3/meta-rcar-gen3/docs/sample/copyscript/copy_evaproprietary_softwares.sh"
7
8 test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
9 DOWNLOAD_DIR=${XDG_DOWNLOAD_DIR:-$HOME/Downloads}
10 EXTRACT_DIR=$METADIR/binary-tmp
11
12 stdout_in_terminal=1
13 [[ -t 1 ]] && stdout_in_terminal=1
14 function color {
15     [[ $stdout_in_terminal == 0 ]] && return
16     for k in $*; do
17         case $k in
18             bold) tput bold;;
19             none) tput sgr0;;
20             *) tput setaf $k;;
21         esac
22         if [[ $? != 0 ]]; then
23             echo "tput: terminal doesn't support color settings, continuing" >&2
24             true
25         fi
26     done
27 }
28 color_green=$(color bold 2)
29 color_yellow=$(color bold 3)
30 color_red=$(color bold 1)
31 color_none=$(color none)
32
33 function error() {
34     echo "${color_red}$@${color_none}" >&2
35 }
36
37 function log() {
38     echo "$@" >&2
39 }
40
41 function copy_mm_packages() {
42         # first clean up workdir
43         [[ -d $EXTRACT_DIR ]] && rm -r $EXTRACT_DIR
44
45     if [ -f $DOWNLOAD_DIR/$ZIP_1 -a -f $DOWNLOAD_DIR/$ZIP_2 ]; then
46         mkdir -p $EXTRACT_DIR
47         cp --update $DOWNLOAD_DIR/$ZIP_1 $EXTRACT_DIR
48         cp --update $DOWNLOAD_DIR/$ZIP_2 $EXTRACT_DIR
49     else
50         error "ERROR: FILES \""+$DOWNLOAD_DIR/$ZIP_1+"\" NOT EXTRACTING CORRECTLY"
51         error "ERROR: FILES \""+$DOWNLOAD_DIR/$ZIP_2+"\" NOT EXTRACTING CORRECTLY"
52         log   "The graphics and multimedia acceleration packages for "
53         log   "the R-Car Gen3 board BSP can be downloaded from:"
54         log   "<https://www.renesas.com/us/en/solutions/automotive/rcar-download/rcar-demoboard-2.html>"
55         log
56         error  "These 2 files from there should be stored in your"
57         error  "'$DOWNLOAD_DIR' directory."
58         error  "  $ZIP_1"
59         error  "  $ZIP_2"
60         return 1
61     fi
62
63     if [ -f $COPY_SCRIPT ]; then
64         cd $METADIR/bsp/meta-renesas-rcar-gen3/
65         $COPY_SCRIPT -d -f $EXTRACT_DIR
66         cd ..
67     else
68         log   "scripts to copy drivers for Gen3 not found."
69         return 1
70     fi
71 }