summaryrefslogtreecommitdiffstats
path: root/scripts/poe-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/poe-tasks')
-rwxr-xr-xscripts/poe-tasks/check2
-rwxr-xr-xscripts/poe-tasks/clean6
-rwxr-xr-xscripts/poe-tasks/configure2
-rwxr-xr-xscripts/poe-tasks/doc17
-rwxr-xr-xscripts/poe-tasks/docs10
-rwxr-xr-xscripts/poe-tasks/examples4
-rwxr-xr-xscripts/poe-tasks/kresctl4
-rwxr-xr-xscripts/poe-tasks/man4
-rwxr-xr-xscripts/poe-tasks/run16
-rwxr-xr-xscripts/poe-tasks/test2
-rw-r--r--scripts/poe-tasks/utils/_env.sh64
11 files changed, 72 insertions, 59 deletions
diff --git a/scripts/poe-tasks/check b/scripts/poe-tasks/check
index 8e6507e4..2bf380b9 100755
--- a/scripts/poe-tasks/check
+++ b/scripts/poe-tasks/check
@@ -14,7 +14,7 @@ function check_rv {
aggregate_rv=$(( $aggregate_rv + $1 ))
}
-kres_is_meson_configured
+is_buil_dir_configured
# stop failing early, because we wouldn't do anything else than fail
set +e
diff --git a/scripts/poe-tasks/clean b/scripts/poe-tasks/clean
index 697f7dd2..f5d4ca1a 100755
--- a/scripts/poe-tasks/clean
+++ b/scripts/poe-tasks/clean
@@ -5,16 +5,20 @@ src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
echo
+echo --------------------------------------------
echo Removing mypy, pytest and other cached files
echo --------------------------------------------
rm -vrf .coverage .mypy_cache .pytest_cache
echo
+echo ------------------------------------------
echo Removing Meson build directories and files
echo ------------------------------------------
-rm -vrf $build_dir $install_dir build build_doc dist
+rm -vrf "$build_dir" "$KRES_INSTALL_DIR" "$build_doc_dir" build dist
echo
+echo ------------------------------------------
echo Removing __pycache__ directories and files
echo ------------------------------------------
find . -type d -name '__pycache__' -prune -exec rm -vrf {} +
+echo \ No newline at end of file
diff --git a/scripts/poe-tasks/configure b/scripts/poe-tasks/configure
index d2b38a46..f187cc50 100755
--- a/scripts/poe-tasks/configure
+++ b/scripts/poe-tasks/configure
@@ -4,4 +4,4 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_configure
+meson_setup_configure
diff --git a/scripts/poe-tasks/doc b/scripts/poe-tasks/doc
new file mode 100755
index 00000000..aa1606e3
--- /dev/null
+++ b/scripts/poe-tasks/doc
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/utils/_env.sh
+
+echo
+echo -----------------------------------------------------
+echo Configuring documentation build directory using Meson
+echo -----------------------------------------------------
+meson $build_doc_dir -Ddoc=enabled
+echo
+echo ----------------------------------
+echo Building documentation using ninja
+echo ----------------------------------
+ninja -C $build_doc_dir doc
+echo
diff --git a/scripts/poe-tasks/docs b/scripts/poe-tasks/docs
deleted file mode 100755
index 0364cf72..00000000
--- a/scripts/poe-tasks/docs
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-# ensure consistent behaviour
-src_dir="$(dirname "$(realpath "$0")")"
-source $src_dir/utils/_env.sh
-
-echo Building Knot Resolver documentation
-echo ------------------------------------
-meson build_doc -Ddoc=enabled
-ninja -C build_doc doc
diff --git a/scripts/poe-tasks/examples b/scripts/poe-tasks/examples
index b501ca57..8a211bad 100755
--- a/scripts/poe-tasks/examples
+++ b/scripts/poe-tasks/examples
@@ -4,10 +4,10 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# validate all configuration examples
for example in $PWD/etc/config/config.example.*.yaml;
do
- poe kresctl validate --no-strict $example;
+ python3 -m knot_resolver.client validate --no-strict $example;
done
diff --git a/scripts/poe-tasks/kresctl b/scripts/poe-tasks/kresctl
index d5662fb8..52b8edd2 100755
--- a/scripts/poe-tasks/kresctl
+++ b/scripts/poe-tasks/kresctl
@@ -4,7 +4,7 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# run knot-resolver client
-python3 -m knot_resolver.client $@
+python3 -m knot_resolver.client --config "$KRES_CONFIG_FILE" "$@"
diff --git a/scripts/poe-tasks/man b/scripts/poe-tasks/man
index 60f0ae6e..62092de0 100755
--- a/scripts/poe-tasks/man
+++ b/scripts/poe-tasks/man
@@ -4,6 +4,8 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_build
+meson_setup_configure
+
+ninja_install
man -l .install/share/man/man8/$1*
diff --git a/scripts/poe-tasks/run b/scripts/poe-tasks/run
index cd3ca37d..b137ecaf 100755
--- a/scripts/poe-tasks/run
+++ b/scripts/poe-tasks/run
@@ -4,11 +4,12 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_build
+ninja_install
echo
-echo Building Knot Resolver Python komponents
-echo ----------------------------------------
+echo ---------------------------------------
+echo Building Python komponents using Poetry
+echo ---------------------------------------
poetry build
# copy native modules from build directory to source directory
shopt -s globstar
@@ -22,8 +23,7 @@ shopt -u globstar
shopt -u nullglob
echo
-echo The Knot Resolver API is accessible on http://localhost:5000
-echo ------------------------------------------------------------
-
-# run the knot-resolver manager
-python3 -m knot_resolver.manager $@
+echo --------------------------------------
+echo Starting Knot Resolver wit the Manager
+echo --------------------------------------
+python3 -m knot_resolver.manager --config "$KRES_CONFIG_FILE" "$@"
diff --git a/scripts/poe-tasks/test b/scripts/poe-tasks/test
index 79c6e3a2..2afad2a0 100755
--- a/scripts/poe-tasks/test
+++ b/scripts/poe-tasks/test
@@ -4,7 +4,7 @@
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# run pytest
env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=python/knot_resolver --show-capture=all tests/manager
diff --git a/scripts/poe-tasks/utils/_env.sh b/scripts/poe-tasks/utils/_env.sh
index 86252d68..b6cbb19e 100644
--- a/scripts/poe-tasks/utils/_env.sh
+++ b/scripts/poe-tasks/utils/_env.sh
@@ -18,8 +18,9 @@ fi
cd $gitroot
# build dirs
-build_dir=$gitroot/.build
-install_dir=$gitroot/.install
+build_dir="$gitroot/.build"
+build_doc_dir="$gitroot/.build_doc"
+install_dir="$gitroot/.install"
# ensure consistent environment with virtualenv
if test -z "$VIRTUAL_ENV" -a "$CI" != "true" -a -z "$KNOT_ENV"; then
@@ -38,62 +39,61 @@ PATH="$PATH:$gitroot/node_modules/.bin"
# fail even on unbound variables
set -o nounset
-# create runtime directories
-if [ -z "${KRES_CONFIG_DIR:-}" ]; then
- KRES_CONFIG_DIR="$gitroot/etc/config"
+# Set enviromental variables if not
+if [ -z "${KRES_INSTALL_DIR:-}" ]; then
+ KRES_INSTALL_DIR="$install_dir"
fi
-mkdir -p "$KRES_CONFIG_DIR/runtime" "$KRES_CONFIG_DIR/cache"
-
-# env variables
if [ -z "${KRES_CONFIG_FILE:-}" ]; then
- KRES_CONFIG_FILE="$KRES_CONFIG_DIR/config.dev.yaml"
-fi
-
-if [ -z "${KRES_API_SOCK_FILE:-}" ]; then
- KRES_API_SOCK_FILE="$KRES_CONFIG_DIR/kres-api.sock"
+ KRES_CONFIG_FILE="$gitroot/etc/config/config.dev.yaml"
fi
+export KRES_INSTALL_DIR
export KRES_CONFIG_FILE
-export KRES_API_SOCK_FILE
-function kres_meson_configure {
+function meson_setup_configure {
reconfigure=''
- if [ -f .build/ninja.build ]; then
+ if [ -d .build ]; then
reconfigure='--reconfigure'
fi
echo
- echo Configuring Knot Resolver Meson
- echo -------------------------------
- echo -e "${blue}${reset}"
+ echo ---------------------------------------
+ echo Configuring build directory using Meson
+ echo ---------------------------------------
+ meson setup \
+ $build_dir \
+ $reconfigure \
+ --prefix=$KRES_INSTALL_DIR \
+ -D user=$(id -un) \
+ -D group=$(id -gn) \
+ "$@"
echo
- meson setup $build_dir $reconfigure --prefix=$install_dir -Duser=$(id -un) -Dgroup=$(id -gn) "$@"
- echo
- echo Copying Knot Resolver constants.py module
- echo -----------------------------------------
+ echo -----------------------------------------------
+ echo Copying constants.py module configured by Meson
+ echo -----------------------------------------------
cp -v $build_dir/python/constants.py $gitroot/python/knot_resolver/constants.py
echo
}
-function kres_is_meson_configured {
+function is_buil_dir_configured {
if [ ! -d .build ]; then
echo
- echo Knot Resolver is not configured for building.
+ echo Knot Resolver build directory is not configured by Meson.
echo "Please run './poe configure' (optionally with additional Meson arguments)".
echo
exit 2
fi
}
-function kres_meson_build {
+function ninja_install {
- kres_is_meson_configured
+ is_buil_dir_configured
echo
- echo Building Knot Resolver C komponents
- echo -----------------------------------
- echo -e "${blue}In case of an compilation error, run this command to try to fix it:${reset}"
- echo -e "\t${blue}rm -r $install_dir $build_dir${reset}"
- echo
+ echo --------------------------------------------
+ echo Building/installing C komponents using ninja
+ echo --------------------------------------------
ninja -C $build_dir
ninja install -C $build_dir
+
+ mkdir -vp $KRES_INSTALL_DIR/run/knot-resolver $KRES_INSTALL_DIR/var/cache/knot-resolver
echo
}