Blame view

scripts/install.sh 3.82 KB
60ea7fa3d   Eric Lee   Embedian Android ...
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  #!/bin/bash
  #
  # install
  #
  # This script must be run from the Android main directory.
  # embedian/install must be at ~/o810_130_8m_build
  #
  # Embedian SMARC-iMX8M patches for Android 8.1.0 1.3.0 8M
  
  set -e
  #set -x
  
  SCRIPT_NAME=${0##*/}
  readonly SCRIPT_VERSION="0.1"
  
  #### Exports Variables ####
  #### global variables ####
  readonly ABSOLUTE_FILENAME=$(readlink -e "$0")
  readonly ABSOLUTE_DIRECTORY=$(dirname ${ABSOLUTE_FILENAME})
  readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY}
  readonly SCRIPT_START_DATE=$(date +%Y%m%d)
  readonly ANDROID_DIR="${SCRIPT_POINT}/../../.."
  
  readonly BASE_BRANCH_NAME="base_o8.1.0_1.3.0_8m"
  
  ## git variables get from base script!
  readonly _EXTPARAM_BRANCH="o8.1.0_1.3.0_8m-ga-smarc01"
  
  ## dirs ##
  readonly EMBEDIAN_PATCHS_DIR="${SCRIPT_POINT}/platform"
  readonly EMBEDIAN_SH_DIR="${SCRIPT_POINT}/sh"
  VENDOR_BASE_DIR=${ANDROID_DIR}/vendor/embedian
  
  
  # print error message
  # p1 - printing string
  function pr_error() {
  	echo ${2} "E: $1"
  }
  
  # print warning message
  # p1 - printing string
  function pr_warning() {
  	echo ${2} "W: $1"
  }
  
  # print info message
  # p1 - printing string
  function pr_info() {
  	echo ${2} "I: $1"
  }
  
  # print debug message
  # p1 - printing string
  function pr_debug() {
  	echo ${2} "D: $1"
  }
  
  # test existing brang in git repo
  # p1 - git folder
  # p2 - branch name
  function is_branch_exist()
  {
  	local D="${1}"
  	local B="${2}"
  	local B_found
  	local HERE
  
  	if [ \( ! -d "${D}" \) -o \( -z "${B}" \) ]; then
  		echo false
  		return
  	fi
  
  	HERE=${PWD}
  	cd "${D}" > /dev/null
  
  	# Check branch
  	git branch 2>&1 > /dev/null
  	if [ ${?} -ne 0 ]; then
  		echo false
  		cd ${HERE} > /dev/null
  		return
  	fi
  	B_found=$(git branch | grep -w "${B}")
  	if [ -z "${B_found}" ]; then
  		echo false
  	else
  		echo true
  	fi
  
  	cd ${HERE} > /dev/null
  	return
  }
  
  ############### main code ##############
  pr_info "Script version ${SCRIPT_VERSION} (g:20160527)"
  
  # disable NXP kernel Android.mk
  cd ${ANDROID_DIR} > /dev/null
  mv vendor/nxp-opensource/kernel_imx/drivers/staging/greybus/tools/Android.mk vendor/nxp-opensource/kernel_imx/drivers/staging/greybus/tools/Android.mk__
  
  # make a copy of NXP imx-mkimage
  cp -r vendor/nxp-opensource/imx-mkimage ${VENDOR_BASE_DIR}
  
  pr_info "###############################"
  pr_info "# Misc. external repositories #"
  pr_info "###############################"
  
  pr_info "clone ${VENDOR_BASE_DIR}/can-utils"
  git clone https://github.com/linux-can/can-utils.git ${VENDOR_BASE_DIR}/can-utils
  cd ${VENDOR_BASE_DIR}/can-utils > /dev/null
  git checkout 791890542ac1ce99131f36435e72af5635afc2fa -b ${BASE_BRANCH_NAME}
  
  pr_info "clone ${VENDOR_BASE_DIR}/i2c-tools"
  git clone https://github.com/Hashcode/i2c-tools.git ${VENDOR_BASE_DIR}/i2c-tools
  cd ${VENDOR_BASE_DIR}/i2c-tools > /dev/null
  git checkout 4aea42526b73eed33f811ce4b894df5d545e4d57 -b ${BASE_BRANCH_NAME}
  
  pr_info "###########################"
  pr_info "# Apply framework patches #"
  pr_info "###########################"
  cd ${EMBEDIAN_PATCHS_DIR} > /dev/null
  git_array=$(find * -type d | grep '.git')
  cd - > /dev/null
  
  for _ddd in ${git_array}
  do
  	_git_p=$(echo ${_ddd} | sed 's/.git//g')
  	cd ${ANDROID_DIR}/${_git_p}/ > /dev/null
  	
  	pr_info "Apply patches for this git: \"${_git_p}/\""
  	
  	git checkout -b ${_EXTPARAM_BRANCH} || {
  		pr_warning "Branch ${_EXTPARAM_BRANCH} is present!"
  	};
  
  	git am ${EMBEDIAN_PATCHS_DIR}/${_ddd}/*
  
  	cd - > /dev/null
  done
  
  pr_info "#######################"
  pr_info "# Copy bluetooth vendor file #"
  pr_info "#######################"
  cp ${EMBEDIAN_PATCHS_DIR}/bt/vnd_smarc_mx8m.txt ${ANDROID_DIR}/hardware/qcom/bt/msm8992/libbt-vendor/include/
  
  pr_info "#####################"
  pr_info "# Done             #"
  pr_info "#####################"
  
  pr_info "#######################"
  pr_info "# Copy shell utilites #"
  pr_info "#######################"
  cp -r ${EMBEDIAN_SH_DIR}/* ${ANDROID_DIR}/
  
  pr_info "#####################"
  pr_info "# Done             #"
  pr_info "#####################"
  
  exit 0