]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts/poe-tasks: improvements
authorAleš Mrázek <ales.mrazek@nic.cz>
Fri, 13 Sep 2024 09:59:13 +0000 (11:59 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 30 Sep 2024 09:16:07 +0000 (11:16 +0200)
13 files changed:
.gitignore
pyproject.toml
scripts/poe-tasks/check
scripts/poe-tasks/clean
scripts/poe-tasks/configure
scripts/poe-tasks/doc [new file with mode: 0755]
scripts/poe-tasks/docs [deleted file]
scripts/poe-tasks/examples
scripts/poe-tasks/kresctl
scripts/poe-tasks/man
scripts/poe-tasks/run
scripts/poe-tasks/test
scripts/poe-tasks/utils/_env.sh

index c6c37c71666f5ddd40f151f8803b6e769e8db5d7..4464dcdd88285015b73ac6ffd597cc2260361833 100644 (file)
@@ -88,5 +88,6 @@ dist/
 .mypy_cache
 .install/
 .build/
+.build_doc/
 poetry.lock
 *.junit.xml
index 4c20d2984783bbe6c901d00de009dd18899df774..b14e2c668dae5fa350d760b51dc96bf1e467e3b6 100644 (file)
@@ -74,7 +74,7 @@ knot-resolver = 'knot_resolver.manager.main:main'
 configure = { cmd = "scripts/poe-tasks/configure", help = "(Re)configure Meson build directory" }
 run = { cmd = "scripts/poe-tasks/run", help = "Run Knot Resolver" }
 run-debug = { cmd = "scripts/poe-tasks/run-debug", help = "Debug Knot Resolver with debugpy" }
-docs = { cmd = "scripts/poe-tasks/docs", help = "Create Knot Resolver HTML documentation" }
+doc = { cmd = "scripts/poe-tasks/doc", help = "Create Knot Resolver HTML documentation" }
 test = { cmd = "scripts/poe-tasks/test", help = "Run pytest unit tests" }
 check = { cmd = "scripts/poe-tasks/check", help = "Check that all dependencies are installed and run static code analysis" }
 examples = { cmd = "scripts/poe-tasks/examples", help = "Validate all configuration examples using 'kresctl validate' utility" }
index 8e6507e4ee8b969ad5ccae5db618275d4cf06ee4..2bf380b9312dbed786a969984d584cbf9dad5a43 100755 (executable)
@@ -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
index 697f7dd2985ae9180c5de01a3b141c3bb379236e..f5d4ca1a4ddc1cbeb7bd704a0edc5e27d648d99d 100755 (executable)
@@ -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
index d2b38a46052327cdfd3013b43bb57d753f8ce6db..f187cc5016e92b5f27430bb7df46f363a019e47d 100755 (executable)
@@ -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 (executable)
index 0000000..aa1606e
--- /dev/null
@@ -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 (executable)
index 0364cf7..0000000
+++ /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
index b501ca572f22a139ba5dd8591e665c180d67dee7..8a211baddd9d2a3e214fd5bcb6de4e29aa09bc38 100755 (executable)
@@ -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
index d5662fb82412e5ce96deb6b4ae36a1fc086c39f7..52b8edd2c3098d8ebeeb91fb6da412f2b56fb380 100755 (executable)
@@ -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" "$@"
index 60f0ae6e76aaa96a66de60415f6c744c9f8b8318..62092de01531ea783812315a5fc1f8eb3c730aec 100755 (executable)
@@ -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*
index cd3ca37dbf0ba5fcfd4ca1637557ae97a9b63566..b137ecaf862c421fdc44ffb4bb5bcb02790c67d5 100755 (executable)
@@ -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" "$@"
index 79c6e3a24ca97b6ad9efd4920e341fa6b4fd0194..2afad2a0a6994fa924e2d0bf029085845d958e85 100755 (executable)
@@ -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
index 86252d68fdf8b67fa8dda56e6a70ea0fa4749532..b6cbb19e2dbf4ea3b6b1d182e96e2f84a40dc5d9 100644 (file)
@@ -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 [ -.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
 }