summaryrefslogtreecommitdiff
path: root/util/vboot_list/vboot_list.sh
blob: 8c6a1a17aa3e040acf7baf0ef47408804cc13a08 (plain)
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
#!/usr/bin/env bash

TOP="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../.. >/dev/null 2>&1 && pwd )"
MAINBOARDS="src/mainboard"
OUTPUT_FILE=${1:-$TOP/Documentation/security/vboot/list_vboot.md}

function has_vboot
{
	local DIR=$1

	grep -rq "config VBOOT" $DIR
	return $?
}

function get_vendor_name
{
	local VENDORDIR=$1

	sed -n '/config VENDOR/{n;s/^[\t[:space:]]\+bool "\(.*\)"/\1/;p;}' \
		$VENDORDIR/Kconfig.name
}

function get_board_name
{
	local BOARDDIR=$1

	sed -n '/config BOARD/{n;s/^[\t[:space:]]\+bool "\(->\s\+\)\?\(.*\)"/\2/;p;}' \
		$BOARDDIR/Kconfig.name
}

function list_vboot_boards
{
	local VENDORDIR=$1
	for BOARD in $(ls -d $VENDORDIR/*/)
	do
		has_vboot $BOARD || continue
		get_board_name $BOARD
	done
}

function generate_vboot_list
{
for VENDOR in $(ls -d $TOP/$MAINBOARDS/*/)
do
	has_vboot $VENDOR || continue
	echo -e "\n## $(get_vendor_name $VENDOR)"
	IFS=$'\n'
	for BOARD in $(list_vboot_boards $VENDOR)
	do
		echo "- $BOARD"
	done
done
}

(echo "# vboot-enabled devices"; generate_vboot_list) > $OUTPUT_FILE