- SCRIPTS+="src/share/yang/modules/utils/check-hashes.sh "
- SCRIPTS+="src/share/yang/modules/utils/check-revisions.sh "
- SCRIPTS+="src/share/yang/modules/utils/gen-revisions.sh "
- - SCRIPTS+="src/share/yang/modules/utils/reinstall.sh "
+ - SCRIPTS+="src/share/yang/modules/utils/reinstall.sh.in "
- SCRIPTS+="tools/add-config-h.sh "
- SCRIPTS+="tools/bump-lib-versions.sh "
- SCRIPTS+="tools/check-for-duplicate-includes.sh "
AC_CONFIG_FILES([src/share/yang/Makefile])
AC_CONFIG_FILES([src/share/yang/modules/Makefile])
AC_CONFIG_FILES([src/share/yang/modules/utils/Makefile])
+AC_CONFIG_FILES([src/share/yang/modules/utils/reinstall.sh],
+ [chmod +x src/share/yang/modules/utils/reinstall.sh])
AC_CONFIG_FILES([tools/Makefile])
AC_CONFIG_FILES([tools/path_replacer.sh],
[chmod +x tools/path_replacer.sh])
yangmodulesdir = ${datarootdir}/${PACKAGE_NAME}/yang/modules
yangmodules_list =
-yangmodules_list += hashes
yangmodules_list += ietf-dhcpv6-client@2018-09-04.yang
yangmodules_list += ietf-interfaces@2018-02-20.yang
yangmodules_list += ietf-dhcpv6-options@2018-09-04.yang
yangmodules_list += kea-types@2019-08-12.yang
yangmodules_list += keatest-module@2018-11-20.yang
-EXTRA_DIST = ${yangmodules_list}
+EXTRA_DIST = hashes ${yangmodules_list}
if HAVE_SYSREPO
yangmodules_DATA = ${yangmodules_list}
# Usage:
#
-# ./src/share/yang/modules/reinstall.sh [-d|--debug] [-h|--help] [-s|--sysrepo ${SYSREPO_INSTALLATION}]
+# reinstall.sh [-d|--debug] [-h|--help] [-s|--sysrepo ${SYSREPO_INSTALLATION}]
# Exit with error if commands exit with non-zero and if undefined variables are
# used.
set -eu
-script_path=$(cd "$(dirname "${0}")" && pwd)
-kea_sources=$(cd "${script_path}/../../../../.." && pwd)
-modules="${kea_sources}/src/share/yang/modules"
-
# Print usage.
# Expressions don't expand in single quotes, use double quotes for that. [SC2016]
# shellcheck disable=SC2016
#------------------------------------------------------------------------------#
+# Get script path.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+
+# shellcheck disable=SC2034
+# prefix appears unused. Verify use (or export if used externally).
+# reason: prefix is used in datarootdir (@datarootdir@) below.
+prefix="@prefix@"
+
+# Find modules location.
+# If script is in sources, use modules from sources.
+# If script is in installation, use modules from installation.
+for i in \
+ "@datarootdir@/@PACKAGE_NAME@/yang/modules" \
+ "@abs_top_builddir@/src/share/yang/modules" \
+; do
+ if test "${script_path}" = "${i}/utils"; then
+ modules="${i}"
+ break
+ fi
+done
+if test -z "${modules+x}"; then
+ printf 'ERROR: cannot find location of modules. Use this script from sources or from installation.' >&2
+ exit 1
+fi
+
# Check if model is installed.
is_model_installed() {
model=${1}
# Internal module "ietf-inet-types" cannot be uninstalled.
# Something about another module depending on ietf-inet-types.
# Might be related to a module that is internal to sysrepo.
-# Might be for the better since installing YANG modules is idempotent and
-# actually has logic to only install if the revision is newer which is arguably
-# beneficial.
+# Might be for the better to not uninstall them since installing YANG modules is
+# idempotent and actually has logic to only install if the revision is newer
+# which is arguably beneficial.
uninstall_yang_models() {
uninstall_model 'kea-dhcp6-server'
uninstall_model 'kea-dhcp4-server'