| # SPDX-License-Identifier: GPL-2.0-only |
| # bootconfig utility functions |
| BOOTCONFIG=${BOOTCONFIG:=$XBC_BASEDIR/../bootconfig} |
| if [ ! -x "$BOOTCONFIG" ]; then |
| BOOTCONFIG=`which bootconfig` |
| if [ -z "$BOOTCONFIG" ]; then |
| echo "Erorr: bootconfig command is not found" 1>&2 |
| if [ "$XBC_TMPFILE" ]; then |
| xbc_init() { # bootconfig-file |
| XBC_TMPFILE=`mktemp bconf-XXXX` |
| trap xbc_cleanup EXIT TERM |
| $BOOTCONFIG -l $1 > $XBC_TMPFILE || exit 1 |
| xbc_get_val() { # key [maxnum] |
| grep "^$1 =" $XBC_TMPFILE | cut -d= -f2- | \ |
| sed -e 's/", /" /g' -e "s/',/' /g" | \ |
| grep -q "^$1 =" $XBC_TMPFILE |
| xbc_has_branch() { # prefix-key |
| grep -q "^$1" $XBC_TMPFILE |
| xbc_subkeys() { # prefix-key depth |
| __keys=`echo $1 | sed "s/\./ /g"` |
| grep "^$1" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq |