diff options
Diffstat (limited to 'utils/nwztools/database/nvp/parse_nvp_nodes.sh')
-rwxr-xr-x | utils/nwztools/database/nvp/parse_nvp_nodes.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/utils/nwztools/database/nvp/parse_nvp_nodes.sh b/utils/nwztools/database/nvp/parse_nvp_nodes.sh new file mode 100755 index 0000000000..cf42504e32 --- /dev/null +++ b/utils/nwztools/database/nvp/parse_nvp_nodes.sh | |||
@@ -0,0 +1,58 @@ | |||
1 | # usage | ||
2 | # parse_nodes.sh /path/to/icx_nvp_emmc.ko output_file | ||
3 | # parse_nodes.sh /path/to/rootfs/dir output_file | ||
4 | # parse_nodes.sh /path/to/rootfs.tgz output_file | ||
5 | # | ||
6 | if [ "$#" -lt 2 ]; then | ||
7 | >&2 echo "usage: parse_header.sh /path/to/icx_nvp.ko|/path/to/rootfs/dir|/path/to/rootfs.tgz output_file" | ||
8 | exit 1 | ||
9 | fi | ||
10 | |||
11 | FILE="$1" | ||
12 | IN_TGZ="0" | ||
13 | OUTPUT="$2" | ||
14 | |||
15 | # for directories, list all files | ||
16 | if [ -d "$FILE" ]; then | ||
17 | LIST=`find "$FILE"` | ||
18 | else | ||
19 | # otherwise try un unpack it using tar, to see if it's an archive | ||
20 | LIST=`tar -tzf "$FILE"` | ||
21 | if [ "$?" == 0 ]; then | ||
22 | IN_TGZ="1" | ||
23 | TGZ="$FILE" | ||
24 | else | ||
25 | # assume the input is just the right file | ||
26 | LIST="$FILE" | ||
27 | fi | ||
28 | fi | ||
29 | |||
30 | # look for icx_nvp_emmc.ko | ||
31 | LIST=`echo "$LIST" | grep "icx[[:digit:]]*_nvp[[:alpha:]_]*.ko"` | ||
32 | LIST_CNT=`echo "$LIST" | wc -l` | ||
33 | if [ "$LIST" == "" ]; then | ||
34 | >&2 echo "No icx nvp file found" | ||
35 | exit 1 | ||
36 | elif [ "$LIST_CNT" != "1" ]; then | ||
37 | >&2 echo "Several matches for icx nvp:" | ||
38 | >&2 echo "$LIST" | ||
39 | exit 1 | ||
40 | else | ||
41 | FILE="$LIST" | ||
42 | fi | ||
43 | |||
44 | # if file is in archive, we need to extract it | ||
45 | if [ "$IN_TGZ" = "1" ]; then | ||
46 | >&2 echo "Extracting $FILE from $TGZ" | ||
47 | TMP=`mktemp` | ||
48 | tar -Ozxf "$TGZ" "$FILE" > $TMP | ||
49 | if [ "$?" != 0 ]; then | ||
50 | >&2 echo "Extraction failed" | ||
51 | exit 1 | ||
52 | fi | ||
53 | FILE="$TMP" | ||
54 | else | ||
55 | >&2 echo "Analyzing $FILE" | ||
56 | fi | ||
57 | |||
58 | ./nvptool -x "$FILE" -o "$OUTPUT" >/dev/null | ||