-
Notifications
You must be signed in to change notification settings - Fork 7
/
mk-rootfs-ubuntu.sh
executable file
·305 lines (241 loc) · 10.1 KB
/
mk-rootfs-ubuntu.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/bash -e
# Directory contains the target rootfs
TARGET_ROOTFS_DIR="binary"
if [ -e $TARGET_ROOTFS_DIR ]; then
sudo rm -rf $TARGET_ROOTFS_DIR
fi
if [ "$ARCH" == "armhf" ]; then
ARCH='armhf'
elif [ "$ARCH" == "arm64" ]; then
ARCH='arm64'
else
echo -e "\033[36m please input is: armhf or arm64...... \033[0m"
fi
if [ ! $VERSION ]; then
VERSION="debug"
fi
#if [ ! -e linaro-buster-alip-*.tar.gz ]; then
# echo -e "\033[36m Run mk-base-debian.sh first \033[0m"
# exit -1
#fi
finish() {
sudo umount $TARGET_ROOTFS_DIR/dev/pts
sudo umount $TARGET_ROOTFS_DIR/dev
sudo umount $TARGET_ROOTFS_DIR/sys
sudo umount $TARGET_ROOTFS_DIR/proc
exit -1
}
trap finish ERR
echo -e "\033[36m Extract image \033[0m"
sudo mkdir -p $TARGET_ROOTFS_DIR
sudo tar -C $TARGET_ROOTFS_DIR -xpf ubuntu-base-arm64.tar.gz
# packages folder
#sudo mkdir -p $TARGET_ROOTFS_DIR/packages
#sudo cp -rf packages/$ARCH/* $TARGET_ROOTFS_DIR/packages
# overlay folder
#sudo cp -rf overlay/* $TARGET_ROOTFS_DIR/
sudo cp overlay/lib/systemd/system/resize-helper.service $TARGET_ROOTFS_DIR/lib/systemd/system/resize-helper.service
sudo cp overlay/usr/sbin/resize-helper $TARGET_ROOTFS_DIR/usr/sbin/resize-helper
# overlay-firmware folder
sudo cp -rf overlay-firmware_ubuntu/* $TARGET_ROOTFS_DIR/
# overlay-debug folder
# adb, video, camera test file
#if [ "$VERSION" == "debug" ] || [ "$VERSION" == "jenkins" ]; then
# sudo cp -rf overlay-debug/* $TARGET_ROOTFS_DIR/
#fi
## hack the serial
#sudo cp -f overlay/usr/lib/systemd/system/[email protected] $TARGET_ROOTFS_DIR/lib/systemd/system/[email protected]
# adb
#if [ "$ARCH" == "armhf" ] && [ "$VERSION" == "debug" ]; then
# sudo cp -rf overlay-debug/usr/local/share/adb/adbd-32 $TARGET_ROOTFS_DIR/usr/local/bin/adbd
#elif [ "$ARCH" == "arm64" ]; then
# sudo cp -rf overlay-debug/usr/local/share/adb/adbd-64 $TARGET_ROOTFS_DIR/usr/local/bin/adbd
#fi
# bt/wifi firmware
#if [ "$ARCH" == "armhf" ]; then
# sudo cp overlay-firmware/usr/bin/brcm_patchram_plus1_32 $TARGET_ROOTFS_DIR/usr/bin/brcm_patchram_plus1
# sudo cp overlay-firmware/usr/bin/rk_wifi_init_32 $TARGET_ROOTFS_DIR/usr/bin/rk_wifi_init
#elif [ "$ARCH" == "arm64" ]; then
# sudo cp overlay-firmware/usr/bin/brcm_patchram_plus1_64 $TARGET_ROOTFS_DIR/usr/bin/brcm_patchram_plus1
# sudo cp overlay-firmware/usr/bin/rk_wifi_init_64 $TARGET_ROOTFS_DIR/usr/bin/rk_wifi_init
#fi
sudo mkdir -p $TARGET_ROOTFS_DIR/system/lib/modules/
#sudo find ../kernel/drivers/net/wireless/rockchip_wlan/* -name "*.ko" | \
# xargs -n1 -i sudo cp {} $TARGET_ROOTFS_DIR/system/lib/modules/
# ASUS: Change to copy all the kernel modules built from build.sh.
sudo cp -rf lib_modules/lib/modules $TARGET_ROOTFS_DIR/lib/
# adb
#if [ "$ARCH" == "armhf" ] && [ "$VERSION" == "debug" ]; then
# sudo cp -rf overlay-debug/usr/local/share/adb/adbd-32 $TARGET_ROOTFS_DIR/usr/local/bin/adbd
#elif [ "$ARCH" == "arm64" ]; then
# sudo cp -rf overlay-debug/usr/local/share/adb/adbd-64 $TARGET_ROOTFS_DIR/usr/local/bin/adbd
#fi
# gpio library
#sudo rm -rf $TARGET_ROOTFS_DIR/usr/local/share/gpio_lib_c_rk3399
#sudo rm -rf $TARGET_ROOTFS_DIR/usr/local/share/gpio_lib_python_rk3399
#sudo cp -rf overlay-debug/usr/local/share/gpio_lib_c_rk3399 $TARGET_ROOTFS_DIR/usr/local/share/gpio_lib_c_rk3399
#sudo cp -rf overlay-debug/usr/local/share/gpio_lib_python_rk3399 $TARGET_ROOTFS_DIR/usr/local/share/gpio_lib_python_rk3399
# mraa library
#sudo rm -rf $TARGET_ROOTFS_DIR/usr/local/share/mraa
#sudo cp -rf overlay-debug/usr/local/share/mraa $TARGET_ROOTFS_DIR/usr/local/share/mraa
echo -e "\033[36m Change root.....................\033[0m"
if [ "$ARCH" == "armhf" ]; then
sudo cp /usr/bin/qemu-arm-static $TARGET_ROOTFS_DIR/usr/bin/
elif [ "$ARCH" == "arm64" ]; then
sudo cp /usr/bin/qemu-aarch64-static $TARGET_ROOTFS_DIR/usr/bin/
fi
# Utilize the nameserver configuration from the host.
# This will be reset back to the original one in the end.
sudo cp -b /etc/resolv.conf $TARGET_ROOTFS_DIR/etc/resolv.conf
sudo mount -t proc /proc $TARGET_ROOTFS_DIR/proc
sudo mount -t sysfs /sys $TARGET_ROOTFS_DIR/sys
sudo mount -o bind /dev $TARGET_ROOTFS_DIR/dev
sudo mount -o bind /dev/pts $TARGET_ROOTFS_DIR/dev/pts
cat << EOF | sudo chroot $TARGET_ROOTFS_DIR
#-------ASUS customization start-------
echo tinkerboard2 > /etc/hostname
echo 127.0.0.1$'\t'tinkerboard2 >> /etc/hosts
#-------ASUS customization end-------
apt-get update
#chmod o+x /usr/lib/dbus-1.0/dbus-daemon-launch-helper
#chmod +x /etc/rc.local
#export APT_INSTALL="apt-get install -fy --allow-downgrades"
#---------------power management --------------
#\${APT_INSTALL} busybox pm-utils triggerhappy
#cp /etc/Powermanager/triggerhappy.service /lib/systemd/system/triggerhappy.service
#---------------system--------------
#apt-get install -y git fakeroot devscripts cmake binfmt-support dh-make dh-exec pkg-kde-tools device-tree-compiler \
#bc cpio parted dosfstools mtools libssl-dev dpkg-dev isc-dhcp-client-ddns
#apt-get install -f -y
#---------------Rga--------------
#\${APT_INSTALL} /packages/rga/*.deb
#echo -e "\033[36m Setup Video.................... \033[0m"
#\${APT_INSTALL} gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-alsa \
#gstreamer1.0-plugins-base-apps qtmultimedia5-examples
#apt-get install -f -y
#\${APT_INSTALL} /packages/mpp/*
#\${APT_INSTALL} /packages/gst-rkmpp/*.deb
#---------Audio---------
#chmod 755 /etc/audio/update_device_description.sh
#---------Camera---------
#echo -e "\033[36m Install camera.................... \033[0m"
#\${APT_INSTALL} cheese v4l-utils
#\${APT_INSTALL} /packages/rkisp/*.deb
#\${APT_INSTALL} /packages/libv4l/*.deb
#cp /packages/rkisp/librkisp.so /usr/lib/
#---------Xserver---------
#echo -e "\033[36m Install Xserver.................... \033[0m"
#apt-get build-dep -y xorg-server-source
#apt-get install -y libgl1-mesa-dev libgles1 libgles1 libegl1-mesa-dev libc-dev-bin libc6-dev libfontenc-dev libfreetype6-dev \
#libpciaccess-dev libpng-dev libpng-tools libxfont-dev libxkbfile-dev linux-libc-dev manpages manpages-dev xserver-common zlib1g-dev \
#libdmx1 libpixman-1-dev libxcb-xf86dri0 libxcb-xv0
#apt-get install -f -y
#\${APT_INSTALL} /packages/xserver/*.deb
#---------------Openbox--------------
#echo -e "\033[36m Install openbox.................... \033[0m"
#\${APT_INSTALL} /packages/openbox/*.deb
#------------------pcmanfm------------
#echo -e "\033[36m Install pcmanfm.................... \033[0m"
#\${APT_INSTALL} /packages/pcmanfm/*.deb
#if [ "$VERSION" == "debug" ]; then
#------------------glmark2------------
#echo -e "\033[36m Install glmark2.................... \033[0m"
#\${APT_INSTALL} /packages/glmark2/*.deb
#fi
#------------------ffmpeg------------
#echo -e "\033[36m Install ffmpeg.................... \033[0m"
#apt-get install -y ffmpeg
#dpkg -i /packages/ffmpeg/*.deb
#apt-get install -f -y
#------------------mpv------------
#echo -e "\033[36m Install mpv.................... \033[0m"
#apt-get install -y libmpv1 mpv
#dpkg -i /packages/mpv/*.deb
#apt-get install -f -y
#---------update chromium-----
#\${APT_INSTALL} /packages/chromium/*.deb
#---------modem manager---------
#apt-get install -y modemmanager libqmi-utils libmbim-utils ppp
#------------------libdrm------------
#echo -e "\033[36m Install libdrm.................... \033[0m"
#\${APT_INSTALL} /packages/libdrm/*.deb
#------------------dhcpcd------------
#apt-get install -y dhcpcd5
#---------------tinker-power-management--------------
#cd /usr/local/share/tinker-power-management
#gcc tinker-power-management.c -o tinker-power-management -lncursesw
#mv tinker-power-management /usr/bin
#cd /
# mark package to hold
#apt list --installed | grep -v oldstable | cut -d/ -f1 | xargs apt-mark hold
#---------------Custom Script--------------
#systemctl mask systemd-networkd-wait-online.service
#systemctl mask NetworkManager-wait-online.service
#rm /lib/systemd/system/[email protected]
#-------------blueman--------------
#bash /etc/init.d/blueman.sh
#rm /etc/init.d/blueman.sh
#---------------gpio library --------------
# For gpio wiring c library
#chmod a+x /usr/local/share/gpio_lib_c_rk3399
#cd /usr/local/share/gpio_lib_c_rk3399
#./build
# For gpio python library
#cd /usr/local/share/gpio_lib_python_rk3399/
#python setup.py install
#python3 setup.py install
#cd /
#---------------mraa library --------------
#apt-get install -y swig3.0
#chmod a+x /usr/local/share/mraa
#cd /usr/local/share/mraa
#mkdir build
#cd build
#cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr --BUILDARCH=aarch64 ..
#make
#make install
#cd /
#---------------40 pin permission for user --------------
#groupadd gpiouser
#adduser linaro gpiouser
#groupadd i2cuser
#adduser linaro i2cuser
#groupadd spidevuser
#adduser linaro spidevuser
#groupadd uartuser
#adduser linaro uartuser
#groupadd pwmuser
#adduser linaro pwmuser
#-------------plymouth--------------
#plymouth-set-default-theme script
#-------------Others--------------
#cp /etc/Powermanager/systemd-suspend.service /lib/systemd/system/systemd-suspend.service
#update-alternatives --auto x-terminal-emulator
# Switching iptables/ip6tables to the legacy version
#update-alternatives --set iptables /usr/sbin/iptables-legacy
#update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
#-------ASUS customization start-------
apt-get upgrade -y
DEBIAN_FRONTEND=noninteractive apt-get -y install ubuntu-desktop-minimal \
ubuntu-minimal
echo "# Let NetworkManager manage all devices on this system" > /etc/netplan/01-network-manager-all.yaml
echo "network:" >> /etc/netplan/01-network-manager-all.yaml
echo " version: 2" >> /etc/netplan/01-network-manager-all.yaml
echo " renderer: NetworkManager" >> /etc/netplan/01-network-manager-all.yaml
# Remove packages which are not needed.
apt autoremove -y
systemctl enable resize-helper.service
echo $VERSION_NUMBER-$VERSION > /etc/version
#-------ASUS customization end-------
#---------------Clean--------------
rm -rf /var/lib/apt/lists/*
#-------ASUS customization start-------
apt-get clean
#-------ASUS customization end-------
EOF
sudo umount $TARGET_ROOTFS_DIR/dev/pts
sudo umount $TARGET_ROOTFS_DIR/dev
sudo umount $TARGET_ROOTFS_DIR/sys
sudo umount $TARGET_ROOTFS_DIR/proc
# Reset resolve.conf to the original one.
sudo mv $TARGET_ROOTFS_DIR/etc/resolv.conf~ $TARGET_ROOTFS_DIR/etc/resolv.conf