From: Francis Dupont Date: Wed, 22 Aug 2018 12:24:44 +0000 (+0200) Subject: [24-script-to-install-yang-models] Added script to install yang models X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bb1c120d215e3d290c6d3ae9c1432f181d356b0;p=thirdparty%2Fkea.git [24-script-to-install-yang-models] Added script to install yang models --- diff --git a/configure.ac b/configure.ac index 080a637c57..deb564c38a 100644 --- a/configure.ac +++ b/configure.ac @@ -883,6 +883,7 @@ if test "$SYSREPO_CONFIG" != "" ; then SYSREPO_CPPFLAGS="$SYSREPO_INCLUDEDIR `$SYSREPO_CONFIG --cflags-only-other libsysrepo`" SYSREPO_LIBS="`$SYSREPO_CONFIG --libs libsysrepo`" SYSREPO_VERSION=`$SYSREPO_CONFIG --modversion libsysrepo` + SYSREPO_REPO=`$SYSREPO_CONFIG --variable=SR_REPOSITORY_LOC libsysrepo` # Now get the environment for C++ bindings for Sysrepo. SYSREPOCPP_INCLUDEDIR=`$SYSREPO_CONFIG --cflags-only-I libSysrepo-cpp` @@ -906,6 +907,7 @@ if test "$SYSREPO_CONFIG" != "" ; then AC_SUBST(SYSREPO_CPPFLAGS) AC_SUBST(SYSREPO_LIBS) + AC_SUBST(SYSREPO_REPO) # Check that a simple program using Sysrepo functions can compile and link. CPPFLAGS_SAVED="$CPPFLAGS" @@ -1588,6 +1590,7 @@ AC_CONFIG_FILES([Makefile src/lib/util/threads/Makefile src/lib/util/threads/tests/Makefile src/lib/util/unittests/Makefile + src/lib/yang/models/yang-install.sh src/share/Makefile src/share/database/Makefile src/share/database/scripts/Makefile @@ -1635,6 +1638,7 @@ AC_CONFIG_COMMANDS([permissions], [ chmod +x src/lib/log/tests/severity_test.sh chmod +x src/lib/util/python/gen_wiredata.py chmod +x src/lib/util/tests/process_spawn_app.sh + chmod +x src/lib/yang/models/yang-install.sh chmod +x tools/path_replacer.sh ]) @@ -1795,6 +1799,7 @@ Sysrepo: SYSREPO_VERSION: ${SYSREPO_VERSION} SYSREPO_CPPFLAGS: ${SYSREPO_CPPFLAGS} SYSREPO_LIBS: ${SYSREPO_LIBS} + SYSREPO_REPO: ${SYSREPO_REPO} END else cat >> config.report << END diff --git a/doc/guide/netconf.xml b/doc/guide/netconf.xml index 110de77a64..c2ddf4e21b 100644 --- a/doc/guide/netconf.xml +++ b/doc/guide/netconf.xml @@ -89,7 +89,9 @@ located at https://github.com/sysrepo/sysrepo. $ sysrepoctl -l -After installation the result should be similar to this: +After installation the result should be similar to this, assuming that +the sysrepo repository path is +/home/thomson/devel/sysrepo-0.7.4/build/repository: Sysrepo schema directory: /home/thomson/devel/sysrepo-0.7.4/build/repository/yang/ Sysrepo data directory: /home/thomson/devel/sysrepo-0.7.4/build/repository/data/ @@ -120,18 +122,13 @@ src/lib/libyang/models. To install Kea models, do the following: cd src/lib/yang/models -sudo sysrepoctl -i -g kea-dhcpv4-server.yang -s /home/thomson/devel/sysrepo-0.7.4/build/repository/yang/ -s ./ -sudo sysrepoctl -i -g ietf-dhcpv6-server.yang -s /home/thomson/devel/sysrepo-0.7.4/build/repository/yang/ -s ./ +sudo ./yang-install.sh kea-dhcpv4-server.yang +sudo ./yang-install.sh ietf-dhcpv6-server.yang -Note the first -s parameter specifies the location of your YANG schema -directory. You can check it with sysrepoctl -l. This is a parameter that is -configured during sysrepo compilation. - - The installation should look similar to the following: -$ sudo sysrepoctl -i -g ietf-dhcpv4-server.yang -s /home/thomson/devel/sysrepo-0.7.4/build/repository/yang/ -s ./ +$ sudo ./yang-install.sh kea-dhcpv4-server.yang Installing a new module from file 'ietf-dhcpv4-server.yang'... Installing the YANG file to '/home/thomson/devel/sysrepo-0.7.4/build/repository/yang/ietf-dhcpv4-server@2018-07-14.yang'... Resolving dependency: 'ietf-dhcpv4-server' imports 'ietf-dhcpv4-options'... diff --git a/src/lib/yang/models/yang-install.sh.in b/src/lib/yang/models/yang-install.sh.in new file mode 100644 index 0000000000..168226fb0b --- /dev/null +++ b/src/lib/yang/models/yang-install.sh.in @@ -0,0 +1,9 @@ +#!/bin/sh +# install a yang model + +if test $# -ne 1; then + echo "Usage: $0 .yang" + exit 1 +fi + +exec sysrepoctl -i -g $1 -s @SYSREPO_REPO@/yang -s . diff --git a/tools/sysrepo_config b/tools/sysrepo_config index 6da9404e63..463a596a0a 100755 --- a/tools/sysrepo_config +++ b/tools/sysrepo_config @@ -39,6 +39,8 @@ then echo " get lib path" echo "--modversion" echo " get version" + echo "--variable=SR_REPOSITORY_LOC" + echo " get repo path" echo "libraries:" echo " libsysrepo" exit 0 @@ -78,5 +80,9 @@ then echo "${MAJOR}.${MINOR}.${PATCH}" exit 0 fi +if [ $1 == "--variable=SR_REPOSITORY_LOC" ] +then + echo "${SYSREPO_PATH}/build/repository" +fi echo "wrong parameter" echo "run: \`$0 --help\` for more help"