-
Notifications
You must be signed in to change notification settings - Fork 4
/
post-build.sh
executable file
·91 lines (70 loc) · 1.76 KB
/
post-build.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
#!/bin/bash -e
TARGET_DIR=$1
shift
RK_LEGACY_PARTITIONS=" \
${RK_OEM_FS_TYPE:+oem:/oem:${RK_OEM_FS_TYPE}}
${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}}
"
# <dev>:<mount point>:<fs type>:<source dir>, for example:
# RK_EXTRA_PARTITIONS="oem:/oem:ext2:oem_normal userdata:/userdata:vfat:userdata_empty"
RK_EXTRA_PARTITIONS=${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}}
function fixup_root()
{
echo "Fixing up rootfs type: $1"
FS_TYPE=$1
sed -i "s#\([[:space:]]/[[:space:]]\+\)\w\+#\1${FS_TYPE}#" \
${TARGET_DIR}/etc/fstab
}
function fixup_part()
{
echo "Fixing up partition: $@"
if echo $1 | grep -qE "^/"; then
DEV=$1
else
DEV="PARTLABEL=$1"
fi
MOUNT=${2:-/$1}
FS_TYPE=${3:-auto}
OPT=${4:-defaults}
sed -i "#[[:space:]]${MOUNT}[[:space:]]#d" ${TARGET_DIR}/etc/fstab
echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${OPT}\t0 2" >> \
${TARGET_DIR}/etc/fstab
mkdir -p ${TARGET_DIR}/${MOUNT}
}
function fixup_fstab()
{
echo "Fixing up /etc/fstab..."
case "${RK_ROOTFS_TYPE}" in
ext[234])
fixup_root ${RK_ROOTFS_TYPE}
;;
*)
fixup_root auto
;;
esac
for part in ${RK_EXTRA_PARTITIONS}; do
fixup_part $(echo "${part}" | xargs -d':')
done
}
function add_build_info()
{
[ -f ${TARGET_DIR}/etc/os-release ] && \
sed -i "/^BUILD_ID=/d" ${TARGET_DIR}/etc/os-release
echo "Adding build-info to /etc/os-release..."
echo "BUILD_INFO=\"$(whoami)@$(hostname) $(date)${@:+ - $@}\"" >> \
${TARGET_DIR}/etc/os-release
}
function add_dirs_and_links()
{
echo "Adding dirs and links..."
cd ${TARGET_DIR}
mkdir -p mnt/sdcard mnt/usb0
# ln -sf media/usb0 udisk
# ln -sf mnt/sdcard sdcard
# ln -sf userdata data
}
echo "Executing $(basename $0)..."
add_build_info $@
[ -f ${TARGET_DIR}/etc/fstab ] && fixup_fstab
add_dirs_and_links
exit 0