blob: 6403a6b3f43eee54447b9f64f1982f79b2fbb656 [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"
xf.lie31de8b2023-12-26 23:38:58 -08007#xz MKSQUASHFS_ARGS
xf.lice873192023-11-08 17:10:35 -08008MKSQUASHFS_ARGS="-nopad -noappend -root-owned -comp xz -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -b 256k -processors 1"
xf.lie31de8b2023-12-26 23:38:58 -08009#zstd MKSQUASHFS_ARGS
10#MKSQUASHFS_ARGS="-nopad -noappend -root-owned -comp zstd -b 256k -processors 1"
xf.lice873192023-11-08 17:10:35 -080011PRIVATE_KEY="$WORKDIR/SignTool/key/RSA_2048/private.k"
12if [ $# -lt 5 ]; then
13 echo "[error] $0 parameter to less"
14 echo "$0 out_name dir_name vol_name selinux_file dm_verity"
15 echo "selinux_file: selinux context file"
16 echo "dm_verity: 0 for disable dm-verity, 1 for enable dm-verity"
17 exit -1
18fi
19OUT_NAME=$1
20DIR_NAME=$2
21VOL_NAME=$3
22selinux_file=$4
23dm_verity=$5
24
25echo "out_name: $OUT_NAME"
26echo "dir_name: $DIR_NAME"
27echo "vol_name: $VOL_NAME"
28echo "ubi_args: $UBI_ARGS"
29
30rm -rf $OUT_NAME verity ${VOL_NAME}.out
31mkdir -p $DIR_NAME
32
33if [ -f $selinux_file ]; then
34 setfiles -m -r $DIR_NAME $selinux_file $DIR_NAME
35 if [ $? -eq 0 ]; then
36 echo "selinux set success"
37 else
38 echo "selinux set fail"
39 exit -1
40 fi
41else
42 echo "selinux_file NOT exist and disable selinux"
43fi
44
45$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'
46if [ $? -ne 0 ]; then
47 echo "mksquashfs error"
48 exit -1
49fi
50
51if [ "$dm_verity" == "1" ]; then
52 ./squashfs_dm-verity.sh ${VOL_NAME}.out ./ ${VOL_NAME}.dm $PRIVATE_KEY $WORKDIR/SignTool/SignImage
53 if [ $? -eq 0 ]; then
54 echo "dm-verity sucess"
55 else
56 echo "dm-verity fail"
57 exit -1
58 fi
59 mv ${VOL_NAME}.dm ${VOL_NAME}.out
60else
61 echo "disable dm-verity"
62fi
63
64./ubinize-static.sh $VOL_NAME $OUT_NAME ${VOL_NAME}.out "$UBI_ARGS"