ROBOX:Upload robox scripts for IEC release 6
[iec.git] / src / use_cases / robox / setupenv / build_android.sh
1 #!/bin/bash
2 set -e
3
4 ANDROID=anbox-work
5 ROBOX=robox
6 EXAGEAR=$ROBOX/Exagear
7
8 echo "please set git user and email. e.g."
9 echo git config --global user.email "you@example.com"
10 echo git config --global user.name "Your Name"
11 echo "make use both termial and git could accesss google.com, press enter to continue"
12 read
13
14 #if [ 0 -gt 1 ]; then
15 echo "prepare environment"
16 sudo sed -i "s/# deb-src/ deb-src/g" /etc/apt/sources.list
17 sudo apt update
18 sudo apt install -y openjdk-8-jdk
19 sudo apt install -y libx11-dev libreadline6-dev libgl1-mesa-dev g++-multilib
20 sudo apt install -y git flex bison gperf build-essential libncurses5-dev
21 sudo apt install -y tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev
22 sudo apt install -y dpkg-dev libsdl1.2-dev
23 sudo apt install -y git-core gnupg flex bison gperf build-essential
24 sudo apt install -y zip curl zlib1g-dev gcc-multilib g++-multilib
25 sudo apt install -y libc6-dev
26 sudo apt install -y lib32ncurses5-dev x11proto-core-dev libx11-dev
27 sudo apt install -y libgl1-mesa-dev libxml2-utils xsltproc unzip m4
28 sudo apt install -y lib32z-dev ccache
29 sudo apt install -y bc python flex bison gperf libsdl-dev build-essential zip curl
30
31 if [ ! -d robox ]; then
32     echo "clone robox"
33     git clone https://github.com/kunpengcompute/robox.git
34 else
35     echo "robox directory exist, skip, clone robox"
36 fi
37
38 echo "try to clone Android"
39 if [ ! -x /usr/bin/repo ]; then
40     sudo apt install -y repo
41     #do not use the official repo because it it too new.
42     #if [ ! -x ~/bin/repo ]; then
43     #echo "get repo"
44     #mkdir ~/bin
45     #PATH=~/bin:$PATH
46     #curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
47     #chmod a+x ~/bin/repo
48     #echo "replace with python3"
49     #sed -i "s/#\!\/usr\/bin\/env python$/#\!\/usr\/bin\/env python3/g" ~/bin/repo
50 else
51     echo "repo exist, skip"
52 fi
53
54 if [ ! -d anbox-work ]; then
55     echo "clone anbox android code"
56     mkdir -p anbox-work
57     cd anbox-work
58     repo init -u https://github.com/anbox/platform_manifests.git -b anbox
59     # total disk size is about 160G
60     repo sync -j16
61     echo "fallback the code"
62     cp -p robox/binaryFiles/snapshot20191206.xml anbox-work/.repo/manifests/
63     cd anbox-work
64     repo init -m snapshot20191206.xml
65     repo sync --force-sync frameworks/opt/net/wifi
66     repo sync -d -j16
67     cd -
68 else
69     echo "anbox-work exist, skip to clone anbox android code"
70     echo "fallback the code locally"
71     cp -p robox/binaryFiles/snapshot20191206.xml anbox-work/.repo/manifests/
72     cd anbox-work
73     repo init -m snapshot20191206.xml
74     repo sync --force-sync frameworks/opt/net/wifi
75     repo sync -d -j16 --local-only
76     cd -
77 fi
78
79 echo "replace anbox code"
80 rm -rf $ANDROID/vendor/anbox
81 cp -rp $ROBOX $ANDROID/vendor/anbox
82 #fi # if [ 0 -gt 1 ]; then
83
84 echo "The exagear"
85 cp -p $EXAGEAR/android/android-7.1.1_r13.patch $ANDROID
86 cp -pr $EXAGEAR/android/vendor $ANDROID
87 ls $ANDROID/vendor/
88 #
89 cp -pr $ROBOX/patch/android-7.1.1_r13-V1.0/* $ANDROID
90 status=`cat script/status`
91 if [ ! "PATCH_ANDROID_DONE" == $status ]; then
92     echo "Patching Android"
93     cp -pr $ROBOX/patch/patch.sh $ANDROID
94     cd $ANDROID
95     sh patch.sh
96     echo PATCH_ANDROID_DONE > script/status
97     cd -
98 else
99     echo "Patch has already finished, skip patch"
100 fi
101
102 echo "build Android"
103 cd $ANDROID
104 #setup build environment
105 source build/envsetup.sh
106 #choose compile env
107 lunch anbox_arm64-userdebug
108 export JACK_EXTRA_CURL_OPTIONS=-k
109 export LC_ALL=C
110 make -j16
111
112 echo "generate the android.img"
113 cd vendor/anbox && ./scripts/create-package.sh $PWD/../../out/target/product/arm64/ramdisk.img $PWD/../../out/target/product/arm64/system.img
114 ls -lh android.img
115