blob: 2be2acb120e5a5789d284a2a19df030b267298c5 [file] [log] [blame]
xf.lice873192023-11-08 17:10:35 -08001#!/bin/bash
2
3WORKDIR=$PWD
4export PATH=$WORKDIR/bin:$PATH
5
6UBI_ARGS="-m 0x1000 -p 0x40000 -s 0x1000 -Q 1024"
7MKSQUASHFS_ARGS="-nopad -noappend -root-owned -comp xz -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -b 256k -processors 1"
8PRIVATE_KEY="$WORKDIR/SignTool/key/RSA_2048/private.k"
9if [ $# -lt 5 ]; then
10 echo "[error] $0 parameter to less"
11 echo "$0 out_name dir_name vol_name selinux_file dm_verity"
12 echo "selinux_file: selinux context file"
13 echo "dm_verity: 0 for disable dm-verity, 1 for enable dm-verity"
14 exit -1
15fi
16OUT_NAME=$1
17DIR_NAME=$2
18VOL_NAME=$3
19selinux_file=$4
20dm_verity=$5
21
22echo "out_name: $OUT_NAME"
23echo "dir_name: $DIR_NAME"
24echo "vol_name: $VOL_NAME"
25echo "ubi_args: $UBI_ARGS"
26
27rm -rf $OUT_NAME verity ${VOL_NAME}.out
28mkdir -p $DIR_NAME
29
30if [ -f $selinux_file ]; then
31 setfiles -m -r $DIR_NAME $selinux_file $DIR_NAME
32 if [ $? -eq 0 ]; then
33 echo "selinux set success"
34 else
35 echo "selinux set fail"
36 exit -1
37 fi
38else
39 echo "selinux_file NOT exist and disable selinux"
40fi
41
42$WORKDIR/bin/mksquashfs4 $DIR_NAME ${VOL_NAME}.out ${MKSQUASHFS_ARGS} -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
43if [ $? -ne 0 ]; then
44 echo "mksquashfs error"
45 exit -1
46fi
47
48if [ "$dm_verity" == "1" ]; then
49 ./squashfs_dm-verity.sh ${VOL_NAME}.out ./ ${VOL_NAME}.dm $PRIVATE_KEY $WORKDIR/SignTool/SignImage
50 if [ $? -eq 0 ]; then
51 echo "dm-verity sucess"
52 else
53 echo "dm-verity fail"
54 exit -1
55 fi
56 mv ${VOL_NAME}.dm ${VOL_NAME}.out
57else
58 echo "disable dm-verity"
59fi
60
61./ubinize-static.sh $VOL_NAME $OUT_NAME ${VOL_NAME}.out "$UBI_ARGS"