-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmk-rootfs-stretch.sh
executable file
·148 lines (110 loc) · 3.47 KB
/
mk-rootfs-stretch.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
#!/bin/bash -e
CUR_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
if [ ! $OUT_DIR ] ; then
OUT_DIR=$(dirname $CUR_DIR)/out
fi
if [ ! $DEVICE_DIR ] ; then
DEVICE_DIR=$(dirname $CUR_DIR)/device
fi
[ -z $_TARGET_PLATFORM ] && echo 'source build/envsetup.sh' && exit -1
[ -z $_TARGET_BOARD ] && echo 'source build/envsetup.sh' && exit -1
dev_out_dir=$OUT_DIR/$_TARGET_PLATFORM/$_TARGET_BOARD
# target rootfs
if [ ! $targetdir ] ; then
targetdir=$dev_out_dir/$_TARGET_OS/target
fi
if [ ! -d $targetdir ] ; then
mkdir -p $targetdir
fi
finish() {
mount | grep $targetdir/dev > /dev/null
if [ $? -eq 0 ] ; then
sudo umount $targetdir/dev
fi
exit -1
}
trap finish ERR
if [ ! -f $targetdir/tmp/.stamp_extracted ] ; then
echo 'Extrace basic rootfs'
if [ "x$_TARGET_OS" = "xdebian" ] ; then
sudo tar -xzpf stretch-alip.tar.gz -C $targetdir
elif [ "x$_TARGET_OS" = "xdebian-hf" ] ; then
sudo tar -xzpf stretch-hf-alip.tar.gz -C $targetdir
else
echo "Invalid OS type"
exit -1
fi
touch $targetdir/tmp/.stamp_extracted
else
echo 'Skip extract basic rootfs'
fi
echo 'Copy modules'
sudo cp -rf ${dev_out_dir}/kernel/lib/modules $targetdir/lib
echo 'Copy overlay'
sudo cp -rf overlay/* $targetdir
if [ -d ${DEVICE_DIR}/${_TARGET_PLATFORM}/rootfs ] ; then
sudo cp -rf ${DEVICE_DIR}/${_TARGET_PLATFORM}/rootfs/* $targetdir
fi
if [ -d ${DEVICE_DIR}/${_TARGET_PLATFORM}/boards/${_TARGET_BOARD}/rootfs ] ; then
sudo cp -rf ${DEVICE_DIR}/${_TARGET_PLATFORM}/boards/${_TARGET_BOARD}/rootfs/* $targetdir
fi
echo 'Change root'
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin
sudo mount -o bind /dev $targetdir/dev
cat <<EOF | sudo LC_ALL=C LANGUAGE=C LANG=C chroot $targetdir
export DEBIAN_FRONTEND=noninteractive
error()
{
echo ""
echo "Error occur"
echo ""
exit -1
}
trap error ERR
if [ ! -f /etc/systemd/system/multi-user.target.wants/depmod.service ] ; then
systemctl enable depmod.service
fi
apt-get update
if ! dpkg -s locales > /dev/null 2>&1 ; then
apt-get install -y locales
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
echo 'LANG=en_US.UTF-8' >> /etc/default/locale
dpkg-reconfigure -f noninteractive locales
update-locale LANG=en_US.UTF-8
fi
apt-get install -y insserv zlib1g libgoogle-glog0v5 libgoogle-glog-dev libasound2-dev libasound2
if insserv -s | grep mpp > /dev/null ; then
insserv /etc/init.d/mpp
fi
if insserv -s | grep bt > /dev/null ; then
insserv /etc/init.d/bt
fi
apt-get install -y bash-completion
apt-get install -y lxde-core gpicview leafpad lxterminal
apt-get --purge remove -y xscreensaver
apt-get install -y net-tools wicd wicd-curses wicd-gtk
if ! groups ai | grep netdev > /dev/null ; then
gpasswd -a ai netdev
fi
apt-get install -y openssh-server
apt-get install -y bluez
apt-get install -y python python-pip idle-python2.7 python-pyaudio python-opencv python-usb python-pyqt5 python-bluez
apt-get install -y xfonts-intl-chinese xfonts-wqy
apt-get install -y alsa-utils lxmusic
if ! groups ai | grep audio > /dev/null ; then
gpasswd -a ai audio
fi
apt-get install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-alsa
touch /tmp/.stamp_installed
apt-get autoclean
apt-get clean
apt-get autoremove -y
EOF
sudo umount $targetdir/dev
if [ ! -f $targetdir/tmp/.stamp_installed ] ; then
echo ""
echo "Some unknown error occurred when installed packages"
echo "Please re-run build script again"
echo ""
exit -1
fi