diff --git a/debian/control b/debian/control index a7a47704..92947cc8 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,8 @@ Depends: device-tree-compiler, parted, pkexec | policykit-1 (<< 122-1), whiptail, - yq, + python3, + python3-yaml, u-boot-menu, ${misc:Depends}, Suggests: aicrf-test, diff --git a/src/usr/lib/rsetup/cli/u-boot-menu.sh b/src/usr/lib/rsetup/cli/u-boot-menu.sh index 5a615dc2..72eff05c 100644 --- a/src/usr/lib/rsetup/cli/u-boot-menu.sh +++ b/src/usr/lib/rsetup/cli/u-boot-menu.sh @@ -3,6 +3,8 @@ # shellcheck source=src/usr/lib/rsetup/mod/overlay.sh source "/usr/lib/rsetup/mod/overlay.sh" +PARSE_DTBO_METADATA="/usr/lib/rsetup/mod/parse_dtbo_metadata" + ALLOWED_RCONFIG_FUNC+=("load_u-boot_setting") check_overlay_conflict_init() { @@ -135,7 +137,7 @@ rebuild_overlays() { parse_dtbo() { local output - output="$(dtc -I dtb -O dts "$1" 2>/dev/null | dtc -I dts -O yaml 2>/dev/null | yq -r ".[0].metadata.$2[0]" | tr '\0' '\n')" + output="$(dtc -I dtb -O dts "$1" 2>/dev/null | dtc -I dts -O yaml 2>/dev/null | "$PARSE_DTBO_METADATA" "$2")" if (( $# >= 3 )) then diff --git a/src/usr/lib/rsetup/mod/parse_dtbo_metadata b/src/usr/lib/rsetup/mod/parse_dtbo_metadata new file mode 100755 index 00000000..76688221 --- /dev/null +++ b/src/usr/lib/rsetup/mod/parse_dtbo_metadata @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- + +from sys import argv, stdin +import yaml + +yaml.CLoader.add_constructor('!u8', yaml.constructor.FullConstructor.construct_yaml_seq) + +try: + print(yaml.load(stdin.read(), Loader=yaml.CLoader)[0]['metadata'][argv[1]][0].replace("\0", "\n")) +except KeyError as e: + print("null")