huangcm
2025-08-25 f350412dc55c15118d0a7925d1071877498e5e24
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
#!/bin/bash
 
#set -e
 
ROOT_DIR=$PWD
TOOLS_DIR=${ROOT_DIR}/../tools/pack/pctools/linux
FIRMWARE_NAME="1.img"
OUTPUT_NAME="vmlinux"
MAINTYPE_NAME="12345678"
SUBTYPE_NAME="123456789VMLINUX"
 
export PATH=${TOOLS_DIR}/mod_update:$PATH
 
show_help()
{
   printf "\nbuild.sh - parser firmware and fetch one file\n"
   echo " this script is used to fetch a file from a firmware"
   echo "  -h  Show help message"
   echo "  -f  firmware_name"
   echo "  -o  output_name"
   echo "  -m  main type in the image.cfg"
   echo "  -s  sub type in the image.cfg"
   echo "  then you can get the file indicated by the image.cfg in the firmware"
   printf "\n\n"
}
 
parser_file()
{
   parser_img $FIRMWARE_NAME $OUTPUT_NAME $MAINTYPE_NAME $SUBTYPE_NAME
   if [ $? -ne 0 ]
   then
       echo -e "\033[40;31;1m [parser file in the firmware fail]\033[0m"
   else
       echo -e "\033[40;32;1m [parser file in the firmware ok]\033[0m"
   fi
}
 
while getopts f:o:m:s: OPTION
do
   case $OPTION in
   f) FIRMWARE_NAME=$OPTARG
   ;;
   o) OUTPUT_NAME=$OPTARG
   ;;
   m) MAINTYPE_NAME=$OPTARG
   ;;
   s) SUBTYPE_NAME=$OPTARG
   ;;
   *) show_help
   exit 0
   ;;
esac
done
 
parser_file