-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathinstall_nuc970_bsp.sh
executable file
·236 lines (215 loc) · 6.81 KB
/
install_nuc970_bsp.sh
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/bash
# Copyright (c) Nuvoton Tech. Corp. All rights reserved.
# Description: Nuvoton Linux platform toolchain install script
# Version: 2017-01-18 first release version
BR2_CONFIG="./.config"
BASE_DIR="./output"
BUILD_DIR=$BASE_DIR/build
HOST_DIR=$BASE_DIR/host
BINARIES_DIR=$BASE_DIR/images
TARGET_DIR=$BASE_DIR/target
APPLICATION_CONFIG="./package/applications/applications.mk"
if [ $BR2_CONFIG ]; then
export $(grep "BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION=" $BR2_CONFIG | sed 's/\"//g')
export $(grep "BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION=" $BR2_CONFIG | sed 's/\"//g')
export $(grep "BR2_APPLICATION_CUSTOM_REPO_VERSION=" $BR2_CONFIG | sed 's/\"//g')
fi
if [ $APPLICATION_CONFIG ]; then
export $(grep "APPLICATIONS_VERSION=" $APPLICATION_CONFIG | sed 's/\"//g')
fi
KERNEL_VER=linux-$BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION
APPLICATION_VER=applications-$APPLICATIONS_VERSION
UBOOT_VER=uboot-$BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ] ;then
echo 'Sorry, you are not root !!'
exit 1
fi
#chown -R $USER:$USER ${BUILD_DIR};
ARM_TOOL_ROOT="/usr/local"
ARM_TOOL_SUBDIR="usr"
ARM_TOOL_NANE="arm_linux_4.8"
#if grep -q "BR2_GCC_VERSION_4_9_X=y" $BR2_CONFIG; then \
# ARM_TOOL_NANE="arm_linux_4.9" \
#fi
ARM_TOOL_PATH="$ARM_TOOL_ROOT/$ARM_TOOL_NANE/$ARM_TOOL_SUBDIR"
NO_TOOL=0
if [ -d $ARM_TOOL_PATH ]; then
echo "The folder \"$ARM_TOOL_PATH\" is already existed, continue the tool chain installation?(Y/N)"
INSTALL=1
while [ $INSTALL == 1 ]
do
read install
case "$install" in
[yY]|[yY][eE][sS] )
INSTALL=0
;;
[nN]|[nN][oO] )
echo "Skip toolchain installation"
INSTALL=2
NO_TOOL=1
;;
* )
echo "Please type yes or no!"
;;
esac
done
if [ $NO_TOOL == 0 ]; then
echo "Do you want to remove this folder first?(Y/N)"
REMOVE=1
while [ $REMOVE == 1 ]
do
read remove
case "$remove" in
[yY]|[yY][eE][sS] )
echo "Now deleteing the folder \"$ARM_TOOL_PATH\"..."
rm -rf $ARM_TOOL_PATH
REMOVE=0
;;
[nN]|[nN][oO] )
echo "This installation will overwirte folder \"$ARM_TOOL_PATH\"!"
REMOVE=0
;;
* )
echo "Please type yes or no!"
;;
esac
done
fi
fi
if [ $NO_TOOL == 0 ]; then
echo "Now installing $ARM_TOOL_NANE toolchain to $ARM_TOOL_ROOT"
echo 'Please wait for a while... '
mkdir -p $ARM_TOOL_PATH
cp $HOST_DIR/usr $ARM_TOOL_ROOT/$ARM_TOOL_NANE -r &
pid=`echo $!`
str="| / - \\"
count=1
while [ -d /proc/$pid ]
do
if [ $count == 5 ]; then
count=1
fi
echo -e -n "\r"`echo $str | awk '{print $'$count'}'`
count=`expr $count + 1`
sleep 1
done
chown root:root -R $ARM_TOOL_PATH
echo -e -n '\r'
fi
echo "Now setting toolchain environment"
PROFILE=/etc/profile
NVTFILE=/etc/profile.d/nvt_arm_linux.sh
#TMPFILE=`mktemp -q /tmp/$0.XXXXXX`
TMPFILE=`mktemp -q /tmp/install.sh.XXXXXX`
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1
fi
# Check toolchain environment setting in PROFILE
REC=$(cat $PROFILE|tr -d '\r'|tr -t '\n' '\r'|sed '1,$s/\\//g' |tr -t '\r' '\n'|grep "PATH="|sed '1,$s/PATH=//g'|tr -t '\n' ':')
NUM=$(echo $REC|awk -F: 'END {print NF}')
i=1
RES=0
while (test $i -le $NUM)
do
TMP=$(echo $REC | awk -F: "{print \$$i}")
if [ "$TMP" = "$ARM_TOOL_PATH/bin" ]; then
RES=1
elif [ "$TMP" = "$ARM_TOOL_PATH/bin/" ]; then
RES=1
fi
i=`expr $i + 1`
done
# Check toolchain environment setting in NVTFILE
if [ -f $NVTFILE ]; then
rm $NVTFILE
fi
echo '## Nuvoton toolchain environment export' >> $NVTFILE
echo 'export PATH='$ARM_TOOL_PATH'/bin:$PATH' >> $NVTFILE
chmod +x $NVTFILE
echo "Installing $ARM_TOOL_NANE toolchain successfully"
echo "Install rootfs, $APPLICATION_VER, $UBOOT_VER and $KERNEL_VER"
echo 'Please enter absolute path for installing(eg:/home/<user name>) :'
read letter
if [ -d $letter ] ;then
echo ''$letter' has existed';
else
echo 'Create '$letter' ';
mkdir $letter;
if [ -z $SUDO_USER ];then
chown -R $USER:$USER $letter;
else
chown $SUDO_USER:$SUDO_USER $letter;
fi
fi
if [ -d $letter/nuc970bsp ];then
echo ''$letter'/nuc970bsp/ existed, (o)verwite, (r)emove or (a)bort?[y/n]';
read remove;
case "$remove" in
[oO] )
echo "Overwrite $letter/nuc970bsp folder"
;;
[rR] )
echo "Remove $letter/nuc970bsp folder"
rm -rf $letter/nuc970bsp/*;
;;
[aA] )
echo 'Abort installation process';
exit 1;
;;
* )
echo 'Abort installation process';
;;
esac
else
mkdir $letter/nuc970bsp;
fi
echo 'Please wait for a while, it will take some time';
mkdir -p $letter/nuc970bsp/rootfs
tar -x -f ${BINARIES_DIR}/rootfs.tar --directory=$letter/nuc970bsp/rootfs
if grep -q "BR2_PACKAGE_APPLICATIONS=y" $BR2_CONFIG; then \
cp ${BUILD_DIR}/$APPLICATION_VER $letter/nuc970bsp/application -r & \
fi
if grep -q "BR2_TARGET_UBOOT=y" $BR2_CONFIG; then \
cp ${BUILD_DIR}/$UBOOT_VER $letter/nuc970bsp/uboot -r & \
fi
pid=`echo $!`
str="| / - \\"
count=1
while [ $? == 0 ]
do
if [ $count == 4 ]; then
count=1
fi
echo -e -n '\r'`echo $str|awk '{print $'$count'}'`
count=`expr $count + 1`
sleep 1
ps aux|awk '$2=='$pid' {print $0}'|grep $pid > /dev/null
done
mkdir -p $letter/nuc970bsp/image
cp ${BUILD_DIR}/image/* $letter/nuc970bsp/image/ -a
cp ${BINARIES_DIR}/* $letter/nuc970bsp/image/ -a
if grep -q "BR2_LINUX_KERNEL=y" $BR2_CONFIG; then \
cp ${BUILD_DIR}/$KERNEL_VER $letter/nuc970bsp/linux-3.10.x -r &
fi
pid=`echo $!`
str="| / - \\"
count=1
while [ $? == 0 ]
do
if [ $count == 4 ]; then
count=1
fi
echo -e -n '\r'`echo $str|awk '{print $'$count'}'`
count=`expr $count + 1`
sleep 1
ps aux|awk '$2=='$pid' {print $0}'|grep $pid > /dev/null
done
find $letter/nuc970bsp -type d|xargs chmod 755
if [ -z $SUDO_USER ];then
chown -R $USER:$USER $letter/nuc970bsp;
else
chown -R $SUDO_USER:$SUDO_USER $letter/nuc970bsp;
fi
echo -e '\rNUC970 BSP installation complete'