2 # SPDX-License-Identifier: GPL-2.0-only
4 # bootconfig utility functions
7 XBC_BASEDIR
=`dirname $0`
8 BOOTCONFIG
=${BOOTCONFIG:=$XBC_BASEDIR/../bootconfig}
9 if [ ! -x "$BOOTCONFIG" ]; then
10 BOOTCONFIG
=`which bootconfig`
11 if [ -z "$BOOTCONFIG" ]; then
12 echo "Erorr: bootconfig command is not found" 1>&2
18 if [ "$XBC_TMPFILE" ]; then
23 xbc_init
() { # bootconfig-file
25 XBC_TMPFILE
=`mktemp bconf-XXXX`
26 trap xbc_cleanup EXIT TERM
28 $BOOTCONFIG -l $1 > $XBC_TMPFILE ||
exit 1
35 xbc_get_val
() { # key [maxnum]
39 grep "^$1 =" $XBC_TMPFILE | cut
-d= -f2- | \
40 sed -e 's/", /" /g' -e "s/',/' /g" | \
41 xargs $MAXOPT -n 1 echo
45 grep -q "^$1 =" $XBC_TMPFILE
48 xbc_has_branch
() { # prefix-key
49 grep -q "^$1" $XBC_TMPFILE
52 xbc_subkeys
() { # prefix-key depth
53 __keys
=`echo $1 | sed "s/\./ /g"`
55 grep "^$1" $XBC_TMPFILE | cut
-d= -f1| cut
-d.
-f$
((__s
+ 1))-$
((__s
+ $2)) |
uniq