-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathprepare.sh
executable file
·70 lines (62 loc) · 1.9 KB
/
prepare.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
#!/bin/bash
MYTMPDIR="/tmp/r89-boot-tmp"
if [ "$#" = "0" ]; then
echo ""
echo "usage: $0 kernel-version"
echo ""
echo "example: $0 4.19.32-stb-av7+"
echo ""
exit 1
fi
export kver=$1
if [ ! -f /boot/zImage-${kver} ]; then
echo ""
echo "cannot find kernel image /boot/zImage-${kver} - giving up"
echo ""
exit 1
fi
if [ ! -f /boot/initrd.img-${kver} ]; then
echo ""
echo "cannot find initrd image /boot/initrd.img-${kver} - giving up"
echo ""
exit 1
fi
if [ ! -f /boot/dtb-${kver}/rk3288-r89.dtb ]; then
echo ""
echo "cannot find dtb file /boot/dtb-${kver}/rk3288-r89.dtb - giving up"
echo ""
exit 1
fi
rm ${MYTMPDIR}/*
mkdir -p ${MYTMPDIR}
echo "- creating kernel image"
/boot/r89-boot/mkkrnlimg -a /boot/zImage-${kver} ${MYTMPDIR}/kernel-linux.img
file /boot/initrd.img-${kver} | grep -qi "gzip compressed"
if [ "$?" = "0" ]; then
cp /boot/initrd.img-${kver} ${MYTMPDIR}/initrd.img-${kver}.gz
gunzip ${MYTMPDIR}/initrd.img-${kver}.gz
else
file /boot/initrd.img-${kver} | grep -qi "lz4 compressed"
if [ "$?" = "0" ]; then
cp /boot/initrd.img-${kver} ${MYTMPDIR}/initrd.img-${kver}.lz4
unlz4 ${MYTMPDIR}/initrd.img-${kver}.lz4
else
file /boot/initrd.img-${kver} | grep -qi "Zstandard compressed data"
if [ "$?" = "0" ]; then
cp /boot/initrd.img-${kver} ${MYTMPDIR}/initrd.img-${kver}.zst
unzstd ${MYTMPDIR}/initrd.img-${kver}.zst
else
echo ""
echo "unsupported initrd format - only gzip, lz4 and zstd are supported - giving up"
echo ""
exit 1
fi
fi
fi
echo "- creating initrd image"
/boot/r89-boot/mkkrnlimg -a ${MYTMPDIR}/initrd.img-${kver} ${MYTMPDIR}/boot-linux.img
rm ${MYTMPDIR}/initrd.img-${kver}
cp /boot/dtb-${kver}/rk3288-r89.dtb ${MYTMPDIR}/rk-kernel.dtb
echo "- creating resource image"
( cd ${MYTMPDIR} && /boot/r89-boot/resource_tool rk-kernel.dtb && mv resource.img resource-linux.img )
rm ${MYTMPDIR}/rk-kernel.dtb