diff --git a/utils/libix.sh b/utils/libix.sh new file mode 100644 index 00000000..0725262c --- /dev/null +++ b/utils/libix.sh @@ -0,0 +1,33 @@ + +resolve_o() +{ + [ -n "$O" ] && return + + if [ -f ".config" ] && [ -d "output" ]; then + # Buildroot + O=./output + elif [ -f "output/.config" ]; then + # BR2_EXTERNAL + O=./output + elif [ -f ".config" ] && [ -d "host" ]; then + # Called from inside output/ directory + O=. + else + echo "*** Error: cannot find Buildroot output dir!" >&2 + exit 1 + fi +} + +resolve_host_dir() +{ + [ -n "$HOST_DIR" ] && return + + resolve_o || exit 1 + + if ! [ -d "$O/host" ]; then + echo "*** Error: cannot find Buildroot host binaries dir!" >&2 + exit 1 + fi + + HOST_DIR="$O/host" +} diff --git a/utils/srop b/utils/srop index e2e58a54..a0a7dfad 100755 --- a/utils/srop +++ b/utils/srop @@ -1,6 +1,8 @@ #!/bin/sh # Interact with sysrepo in a Buildroot setup +. $(dirname $(readlink -f "$0"))/libix.sh + usage() { cat <&2 - exit 1 - fi -fi - -if [ -d "$O/host" ]; then - HOST_DIR="$O/host" -else - echo "*** Error: cannot find Buildroot host binaries dir!" >&2 - exit 1 -fi +resolve_host_dir MOD="$O/target/usr/share/yang/modules/confd/" CTL="$HOST_DIR/bin/sysrepoctl"