summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--configure.ac2
-rw-r--r--src/share/yang/modules/Makefile.am3
-rw-r--r--src/share/yang/modules/utils/.gitignore1
-rw-r--r--src/share/yang/modules/utils/Makefile.am4
-rwxr-xr-xsrc/share/yang/modules/utils/reinstall.sh.in (renamed from src/share/yang/modules/utils/reinstall.sh)37
6 files changed, 36 insertions, 13 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9a4bee84bd..ae3efed8bc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -86,7 +86,7 @@ shellcheck:
- 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 "
diff --git a/configure.ac b/configure.ac
index d1343037f4..3af6b1a9d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1824,6 +1824,8 @@ AC_CONFIG_FILES([src/share/database/scripts/pgsql/wipe_data.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])
diff --git a/src/share/yang/modules/Makefile.am b/src/share/yang/modules/Makefile.am
index c2be6c755c..a0a0bcfc9c 100644
--- a/src/share/yang/modules/Makefile.am
+++ b/src/share/yang/modules/Makefile.am
@@ -3,7 +3,6 @@ SUBDIRS = utils
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
@@ -20,7 +19,7 @@ yangmodules_list += kea-dhcp6-server@2019-08-12.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}
diff --git a/src/share/yang/modules/utils/.gitignore b/src/share/yang/modules/utils/.gitignore
new file mode 100644
index 0000000000..8cf91b2f93
--- /dev/null
+++ b/src/share/yang/modules/utils/.gitignore
@@ -0,0 +1 @@
+/reinstall.sh
diff --git a/src/share/yang/modules/utils/Makefile.am b/src/share/yang/modules/utils/Makefile.am
index 53d050bdf0..58c4087b2a 100644
--- a/src/share/yang/modules/utils/Makefile.am
+++ b/src/share/yang/modules/utils/Makefile.am
@@ -12,8 +12,8 @@ EXTRA_DIST = ${yang_list}
if HAVE_SYSREPO
# Add to the tarball.
-yang_DATA = ${yang_list}
-yang_SCRIPTS = ${yang_list}
+yang_DATA = reinstall.sh
+yang_SCRIPTS = reinstall.sh
# Shell tests
SHTESTS =
diff --git a/src/share/yang/modules/utils/reinstall.sh b/src/share/yang/modules/utils/reinstall.sh.in
index d34084cd48..5beae1371f 100755
--- a/src/share/yang/modules/utils/reinstall.sh
+++ b/src/share/yang/modules/utils/reinstall.sh.in
@@ -8,16 +8,12 @@
# 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
@@ -64,6 +60,31 @@ test -z "${sysrepo+x}" && sysrepo='/usr/local'
#------------------------------------------------------------------------------#
+# 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}
@@ -117,9 +138,9 @@ install_yang_models() {
# 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'