forked from friendlyarm/sd-fuse_s5p6818
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-boot-img.sh
executable file
·53 lines (46 loc) · 1.23 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
48
49
50
51
52
53
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 <boot dir> <img filename>"
echo "example:"
echo " tar xvzf NETDISK/S5P6818/rootfs/rootfs-friendlycore-arm64.tgz"
echo " ./build-boot-img.sh friendlycore-arm64/boot friendlycore-arm64/boot.img"
exit 1
fi
TOPPATH=$PWD
BOOT_DIR=$1
IMG_FILE=$2
if [ ! -d ${BOOT_DIR} ]; then
echo "path '${BOOT_DIR}' not found."
exit 1
fi
# Automatically re-run script under sudo if not root
if [ $(id -u) -ne 0 ]; then
echo "Re-running script under sudo..."
sudo --preserve-env "$0" "$@"
exit
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