blob: 479403809f57bebb55241174a5777857d08514d8 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#!/bin/bash
2
3echo $#
4
5if [ $# -lt 3 ]; then
6 echo "$0 app_list_file rootfs_dir kernel_dir"
7 exit 1
8fi
9APP_LIST_FILE=$1
10ROOTFS_DIR=$2
11KERNEL_DIR=$3
12
13if [ ! -f $APP_LIST_FILE ]; then
14 echo "$APP_LIST_FILE NOT exist"
15 exit 2
16fi
17
18if [ ! -d $KERNEL_DIR ]; then
19 echo "$KERNEL_DIR NOT exist"
20 exit 3
21fi
22
23if [ ! -d $ROOTFS_DIR ]; then
24 echo "$ROOTFS_DIR NOT exist"
25 exit 4
26fi
27VERIFY_APP_HEADER=$KERNEL_DIR/include/linux/verify_app.h
28
29file_array=()
30hash_array=()
31file_cnt=0
32while read file_item; do
33 if [ -f ${ROOTFS_DIR}${file_item} ]; then
34 hash_val=`sha256sum ${ROOTFS_DIR}${file_item} | awk '{ print $1 }'`
35 echo "${file_item} $hash_val ok"
36 file_array+=("$file_item")
37 hash_array+=("$hash_val")
38 let "file_cnt=file_cnt+1"
39 else
40 echo "regular file ${ROOTFS_DIR}${file_item} NOT exist"
41 exit 9
42 fi
43done < "${APP_LIST_FILE}"
44
45# 打印数组中的数据
46
47echo "#ifndef __VERIFY_APP_H" > $VERIFY_APP_HEADER
48echo "#define __VERIFY_APP_H" >> $VERIFY_APP_HEADER
49echo "" >> $VERIFY_APP_HEADER
50
51echo "const int g_verify_app_cnt = $file_cnt;" >> $VERIFY_APP_HEADER
52echo "const char *g_verify_file_array[] = {" >> $VERIFY_APP_HEADER
53for element in "${file_array[@]}"; do
54 echo " \"$element\"," >> $VERIFY_APP_HEADER
55done
56echo "};" >> $VERIFY_APP_HEADER
57
58echo "const char *g_verify_hash_array[] = {" >> $VERIFY_APP_HEADER
59for element in "${hash_array[@]}"; do
60 echo " \"$element\"," >> $VERIFY_APP_HEADER
61done
62echo "};" >> $VERIFY_APP_HEADER
63
64echo "" >> $VERIFY_APP_HEADER
65echo "#endif" >> $VERIFY_APP_HEADER