forked from friendlyarm/sd-fuse_rk3588
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-boot-img.sh
executable file
·47 lines (40 loc) · 1.11 KB
/
build-boot-img.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
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 <boot dir> <img filename>"
echo "example:"
echo " tar xvzf NETDISK/rk3588/rootfs/rootfs-debian-buster-desktop-arm64-20190603.tgz"
echo " ./build-boot-img.sh debian-buster-desktop-arm64/boot debian-buster-desktop-arm64/boot.img"
exit 1
fi
TOPPATH=$PWD
BOOT_DIR=$1
IMG_FILE=$2
if [ ! -d ${BOOT_DIR} ]; then
echo "error: path ${BOOT_DIR} not found."
exit 1
fi
. ${TOPPATH}/tools/util.sh
check_and_install_package
# 64M
IMG_SIZE=67108864
TOP=$PWD
HOST_ARCH=
if uname -mpi | grep aarch64 >/dev/null; then
HOST_ARCH="aarch64/"
fi
export MKE2FS_CONFIG="${TOP}/tools/mke2fs.conf"
if [ ! -f ${MKE2FS_CONFIG} ]; then
echo "error: ${MKE2FS_CONFIG} not found."
exit 1
fi
true ${MKFS:="${TOP}/tools/${HOST_ARCH}mke2fs"}
IMG_BLK=$((${IMG_SIZE} / 4096))
INODE_SIZE=$((`find ${BOOT_DIR} | wc -l` + 128))
${MKFS} -N ${INODE_SIZE} -0 -E android_sparse -t ext4 -L boot -M /root -b 4096 -d ${BOOT_DIR} ${IMG_FILE} ${IMG_BLK}
RET=$?
if [ $RET -eq 0 ]; then
echo "generating ${IMG_FILE} done."
else
echo "failed to generate ${IMG_FILE}."
fi
exit $RET