From 572596127baa6108e4279cafd257e230698c61c1 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Mon, 5 Aug 2024 13:23:13 +0200 Subject: meson: make -Dmalloc=auto more clever --- meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 0e91427a..251991dd 100644 --- a/meson.build +++ b/meson.build @@ -137,9 +137,15 @@ systemd_files = get_option('systemd_files') systemd_legacy_units = get_option('systemd_legacy_units') libsystemd = dependency('libsystemd', required: systemd_files == 'enabled') +# Uh, lifted this trivial line from tests/meson.build due to dependency sorting: +build_extra_tests = get_option('extra_tests') == 'enabled' + ### Allocator # use empty name to disable the dependency, but still compile the dependent kresd -malloc_name = get_option('malloc') == 'disabled' ? '' : 'jemalloc' +malloc_name = '' +if get_option('malloc') == 'jemalloc' or (get_option('malloc') == 'auto' and not build_extra_tests) + malloc_name = 'jemalloc' +endif malloc = meson.get_compiler('c').find_library( malloc_name, required: get_option('malloc') == 'jemalloc', -- cgit v1.2.3 From a8da26abcf9217c437cab31457714e2222f1711b Mon Sep 17 00:00:00 2001 From: Oto Šťáva Date: Fri, 23 Aug 2024 14:57:31 +0200 Subject: scripts: organize into subdirs and clean up unused --- .gitlab-ci.yml | 4 +- bench/meson.build | 2 +- daemon/lua/kres-gen.sh | 2 +- distro/config/apkg.toml | 2 +- doc/meson.build | 4 +- meson.build | 2 +- scripts/README.md | 18 ++++ scripts/bench.sh | 12 --- scripts/build-in-obs.sh | 32 ------ scripts/ci/build-in-obs.sh | 32 ++++++ scripts/ci/enable-repo-cznic-labs.sh | 30 ++++++ scripts/ci/make-obs.sh | 59 +++++++++++ scripts/coverage_c_combine.sh | 26 ----- scripts/coverage_env.sh | 42 -------- scripts/create_setup.py | 66 ------------ scripts/enable-repo-cznic-labs.sh | 30 ------ scripts/gen-cdefs.sh | 87 ---------------- scripts/get-date.sh | 14 --- scripts/lib/get-date.sh | 14 +++ scripts/lib/upstream-version.sh | 9 ++ scripts/luacov_gen_empty.sh | 18 ---- scripts/luacov_to_info.lua | 57 ---------- scripts/make-doc.sh | 25 ----- scripts/make-obs.sh | 59 ----------- scripts/make-package.sh | 71 ------------- scripts/map_install_src.lua | 168 ------------------------------ scripts/meson/bench.sh | 12 +++ scripts/meson/gen-cdefs.sh | 87 ++++++++++++++++ scripts/meson/make-doc.sh | 25 +++++ scripts/meson/run-pylint.sh | 12 +++ scripts/meson/test-config.sh | 32 ++++++ scripts/meson/test-integration-prepare.sh | 8 ++ scripts/poe-tasks/_env.sh | 72 ------------- scripts/poe-tasks/check | 6 +- scripts/poe-tasks/configure | 2 +- scripts/poe-tasks/docs | 2 +- scripts/poe-tasks/examples | 2 +- scripts/poe-tasks/format | 4 +- scripts/poe-tasks/gen-setuppy | 4 +- scripts/poe-tasks/kresctl | 2 +- scripts/poe-tasks/man | 2 +- scripts/poe-tasks/run | 2 +- scripts/poe-tasks/run-debug | 2 +- scripts/poe-tasks/test | 2 +- scripts/poe-tasks/utils/_env.sh | 72 +++++++++++++ scripts/poe-tasks/utils/create_setup.py | 66 ++++++++++++ scripts/run-pylint.sh | 12 --- scripts/run-scanbuild-with-args.sh | 51 --------- scripts/test-config.sh | 32 ------ scripts/test-integration-prepare.sh | 8 -- scripts/upstream-version.sh | 9 -- tests/config/meson.build | 2 +- tests/integration/meson.build | 2 +- 53 files changed, 501 insertions(+), 916 deletions(-) create mode 100644 scripts/README.md delete mode 100755 scripts/bench.sh delete mode 100755 scripts/build-in-obs.sh create mode 100755 scripts/ci/build-in-obs.sh create mode 100755 scripts/ci/enable-repo-cznic-labs.sh create mode 100755 scripts/ci/make-obs.sh delete mode 100755 scripts/coverage_c_combine.sh delete mode 100755 scripts/coverage_env.sh delete mode 100755 scripts/create_setup.py delete mode 100755 scripts/enable-repo-cznic-labs.sh delete mode 100755 scripts/gen-cdefs.sh delete mode 100755 scripts/get-date.sh create mode 100755 scripts/lib/get-date.sh create mode 100755 scripts/lib/upstream-version.sh delete mode 100755 scripts/luacov_gen_empty.sh delete mode 100755 scripts/luacov_to_info.lua delete mode 100755 scripts/make-doc.sh delete mode 100755 scripts/make-obs.sh delete mode 100755 scripts/make-package.sh delete mode 100755 scripts/map_install_src.lua create mode 100755 scripts/meson/bench.sh create mode 100755 scripts/meson/gen-cdefs.sh create mode 100755 scripts/meson/make-doc.sh create mode 100755 scripts/meson/run-pylint.sh create mode 100755 scripts/meson/test-config.sh create mode 100755 scripts/meson/test-integration-prepare.sh delete mode 100644 scripts/poe-tasks/_env.sh create mode 100644 scripts/poe-tasks/utils/_env.sh create mode 100755 scripts/poe-tasks/utils/create_setup.py delete mode 100755 scripts/run-pylint.sh delete mode 100755 scripts/run-scanbuild-with-args.sh delete mode 100755 scripts/test-config.sh delete mode 100755 scripts/test-integration-prepare.sh delete mode 100755 scripts/upstream-version.sh (limited to 'meson.build') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 832a85f2..945a9c50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -569,7 +569,7 @@ obs:trigger: &obs_trigger - pip install --upgrade pip - pip install apkg - scripts/make-obs.sh - - echo y | scripts/build-in-obs.sh $OBS_REPO + - echo y | scripts/ci/build-in-obs.sh $OBS_REPO obs:release: <<: *obs_trigger @@ -596,7 +596,7 @@ obs:odvr: .enable_repo_build: &enable_repo_build before_script: - - ./scripts/enable-repo-cznic-labs.sh knot-dns + - ./scripts/ci/enable-repo-cznic-labs.sh knot-dns .pkg_test: &pkg_test stage: pkg diff --git a/bench/meson.build b/bench/meson.build index b15dd0f7..a44bf7cc 100644 --- a/bench/meson.build +++ b/bench/meson.build @@ -20,5 +20,5 @@ bench_lru = executable( run_target( 'bench', - command: '../scripts/bench.sh', + command: '../scripts/meson/bench.sh', ) diff --git a/daemon/lua/kres-gen.sh b/daemon/lua/kres-gen.sh index d14c0286..8d0b91c0 100755 --- a/daemon/lua/kres-gen.sh +++ b/daemon/lua/kres-gen.sh @@ -6,7 +6,7 @@ set -o pipefail -o errexit -o nounset cd "$(dirname ${0})" OUTNAME="$1" -CDEFS="../../scripts/gen-cdefs.sh" +CDEFS="../../scripts/meson/gen-cdefs.sh" LIBKRES="${MESON_BUILD_ROOT}/lib/libkres.so" KRESD="${MESON_BUILD_ROOT}/daemon/kresd" if [ ! -e "$LIBKRES" ]; then diff --git a/distro/config/apkg.toml b/distro/config/apkg.toml index 19d4d8be..43a24671 100644 --- a/distro/config/apkg.toml +++ b/distro/config/apkg.toml @@ -7,7 +7,7 @@ make_archive_script = "scripts/make-archive.sh" # needed for get-archive archive_url = "https://secure.nic.cz/files/knot-resolver/knot-resolver-{{ version }}.tar.xz" signature_url = "https://secure.nic.cz/files/knot-resolver/knot-resolver-{{ version }}.tar.xz.asc" -version_script = "scripts/upstream-version.sh" +version_script = "scripts/lib/upstream-version.sh" [apkg] compat = 4 diff --git a/doc/meson.build b/doc/meson.build index 0dfa3cb3..ad6a0f9a 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -4,7 +4,7 @@ # man page man_config = configuration_data() man_config.set('version', meson.project_version()) -man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout()) +man_config.set('date', run_command('../scripts/lib/get-date.sh', check: true).stdout()) man_config.set('man_seealso_systemd', '') if systemd_legacy_units == 'enabled' @@ -72,7 +72,7 @@ if get_option('doc') == 'enabled' endif -make_doc = find_program('../scripts/make-doc.sh') +make_doc = find_program('../scripts/meson/make-doc.sh') run_target( 'doc', command: make_doc diff --git a/meson.build b/meson.build index 251991dd..d2e85b0b 100644 --- a/meson.build +++ b/meson.build @@ -303,7 +303,7 @@ message('--- lint dependencies ---') clangtidy = find_program('clang-tidy', required: false) luacheck = find_program('luacheck', required: false) flake8 = find_program('flake8', required: false) -pylint_run = find_program('scripts/run-pylint.sh') +pylint_run = find_program('scripts/meson/run-pylint.sh') message('-------------------------') if clangtidy.found() diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..dcfe8c68 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,18 @@ +# Knot Resolver scripts + +These are auxillary scripts used for Knot Resolver development. + +The scripts in the root of this directory are meant to be executed directly by +developers. Some may also be run by automated tools. + +There are also the following subdirectories. The scripts in these are *only +ever* meant to be run by automated tools: + +- `ci`: specific to the CI/CD pipeline +- `lib`: (potentially) generally useful scripts to be called by other scripts +- `meson`: specific to the build system +- `poe-tasks`: run by the `poe` script in the repository root + - `utils`: scripts additionally called by the `poe` tasks + +For more information about each script, see its content for explanatory +comments. diff --git a/scripts/bench.sh b/scripts/bench.sh deleted file mode 100755 index d5a9f38e..00000000 --- a/scripts/bench.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o errexit -o nounset - -# Run benchmark -cd "${MESON_SOURCE_ROOT}" - -echo "Test LRU with increasing overfill, misses should increase ~ linearly" - -for num in 65536 32768 16384 8192 4096; do - "${MESON_BUILD_ROOT}/${MESON_SUBDIR}/bench_lru" 23 "${MESON_SOURCE_ROOT}/${MESON_SUBDIR}/bench_lru_set1.tsv" - "${num}" -done diff --git a/scripts/build-in-obs.sh b/scripts/build-in-obs.sh deleted file mode 100755 index 176b9ad4..00000000 --- a/scripts/build-in-obs.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -# -# Push packaging files to OBS -# -# Example usage: -# 1. ./scripts/make-obs.sh -# 2. ./scripts/build-in-obs.sh knot-resolver-latest -set -o errexit -o nounset -o xtrace - -pkgdir='pkg/obs' - -project=home:CZ-NIC:$1 -package=knot-resolver - -if ! [[ "$1" == *-devel || "$1" == *-testing ]]; then - read -p "Pushing to '$project', are you sure? [y/N]: " yn - case $yn in - [Yy]* ) - ;; - * ) - exit 1 - esac -fi - -osc co "${project}" "${package}" -pushd "${project}/${package}" -osc del * ||: -cp -r ../../${pkgdir}/* ./ -osc addremove -osc ci -n -popd diff --git a/scripts/ci/build-in-obs.sh b/scripts/ci/build-in-obs.sh new file mode 100755 index 00000000..eaa54671 --- /dev/null +++ b/scripts/ci/build-in-obs.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Push packaging files to OBS +# +# Example usage: +# 1. ./scripts/ci/make-obs.sh +# 2. ./scripts/ci/build-in-obs.sh knot-resolver-latest +set -o errexit -o nounset -o xtrace + +pkgdir='pkg/obs' + +project=home:CZ-NIC:$1 +package=knot-resolver + +if ! [[ "$1" == *-devel || "$1" == *-testing ]]; then + read -p "Pushing to '$project', are you sure? [y/N]: " yn + case $yn in + [Yy]* ) + ;; + * ) + exit 1 + esac +fi + +osc co "${project}" "${package}" +pushd "${project}/${package}" +osc del * ||: +cp -r ../../${pkgdir}/* ./ +osc addremove +osc ci -n +popd diff --git a/scripts/ci/enable-repo-cznic-labs.sh b/scripts/ci/enable-repo-cznic-labs.sh new file mode 100755 index 00000000..e7c53a82 --- /dev/null +++ b/scripts/ci/enable-repo-cznic-labs.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# enable CZ.NIC Labs Debian/Ubuntu repos - see https://pkg.labs.nic.cz/doc/ +set -e + +REPO=$1 +if [ -z "${REPO}" ]; then + echo "usage: $0 REPOSITORY" + echo -e "\nPlease see: https://pkg.labs.nic.cz/doc/" + exit 1 +fi +if [ "$(whoami)" != "root" ]; then + echo "ERROR: this script must be run as ROOT" + echo -e "\nTry running with sudo:\n\n sudo $0\n" + exit 2 +fi + +# update apt metadata and install requirements +apt-get update +apt-get install -y apt-transport-https ca-certificates lsb-release wget + +DISTRO=$(lsb_release -si | tr '[:upper:]' '[:lower:]') +CODENAME=$(lsb_release -sc) + +echo "Enabling $REPO repo on $DISTRO $CODENAME..." +# get repo signing key +wget -O /usr/share/keyrings/cznic-labs-pkg.gpg https://pkg.labs.nic.cz/gpg +# create repo entry +echo "deb [signed-by=/usr/share/keyrings/cznic-labs-pkg.gpg] https://pkg.labs.nic.cz/$REPO $CODENAME main" > /etc/apt/sources.list.d/cznic-labs-$REPO.list +# update apt metadata from the new repo +apt-get update diff --git a/scripts/ci/make-obs.sh b/scripts/ci/make-obs.sh new file mode 100755 index 00000000..4d0666cb --- /dev/null +++ b/scripts/ci/make-obs.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# +# create OpenSUSE Build System (OBS) source package +# +# this needs to be run on a system with: +# +# * apkg +# * dpkg-buildpackage +# +# usage: +# ./scripts/ci/make-obs.sh [path.to.archive.xz] [1] +# +# supply archives as optional arguments to build from, +# otherwise archive will be built from sources by apkg +# second argument is optional release number (defaults to 1) +# +# output at pkg/obs/ (removed on each run) +set -o errexit -o nounset + +pushd "$(dirname ${0})/../.." + +OUTDIR="pkg/obs" +APKG_OPTS="-O $OUTDIR" + +if [ -z $@ ]; then + echo "building OBS srcpkg from project files" +else + AR=$1 + echo "building OBS srcpkg from specified archive(s)" + APKG_OPTS="-a $AR $APKG_OPTS" + + RELEASE=${2:-} + if [ ! -z "$RELEASE" ]; then + echo "custom release: $RELEASE" + APKG_OPTS="-r $RELEASE $APKG_OPTS" + fi +fi + +set -o xtrace + +: removing existing output files at output dir: $OUTDIR +rm -rf "$OUTDIR" +: making debian source package from archive +apkg srcpkg $APKG_OPTS -d debian +: removing extra debian source package files +rm -f $OUTDIR/*_source.* +: rendering RPM template +apkg srcpkg $APKG_OPTS -d fedora --render-template +: fixing RPM .spec to use debian source archive +sed -i 's/^\(Source0:\s\+\).*/\1knot-resolver_%{version}.orig.tar.xz/' $OUTDIR/*.spec +: rendering PKGBUILD template +apkg srcpkg $APKG_OPTS -d arch --render-template +: fixing PKGBUILD to use debian source archive +sed -i 's/^source=.*/source=("knot-resolver_${pkgver}.orig.tar.xz")/' $OUTDIR/PKGBUILD +popd >/dev/null + +echo "OBS srcpkg ready at: $OUTDIR" + diff --git a/scripts/coverage_c_combine.sh b/scripts/coverage_c_combine.sh deleted file mode 100755 index 46181119..00000000 --- a/scripts/coverage_c_combine.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later - -# $1 = top source directory -# $2 = coverage data directory path -# $3 = output directory for *.info files - -set -o errexit -o nounset -shopt -s nullglob -IFS=$'\n' - -TOPSRCDIR="$1" -DATAROOT="$2" -OUTDIR="$3" - -cd "${TOPSRCDIR}" -for COVNAME in $(find "${DATAROOT}" -name .topdir_kresd_coverage) -do - find "${DATAROOT}" -name '*.gcda' -not -path "${DATAROOT}/*" -delete - COVDIR="$(dirname "${COVNAME}")" - COVDATA_FILENAMES=("${COVDIR}"/*) # filenames in BASH array - (( ${#COVDATA_FILENAMES[*]} )) || continue # skip empty dirs - - cp -r -t ${TOPSRCDIR} "${COVDIR}"/* - ${LCOV} -q --no-external --capture -d lib -d daemon -d modules -o "$(mktemp -p "${OUTDIR}" -t XXXXXXXX.c.info)" > /dev/null -done diff --git a/scripts/coverage_env.sh b/scripts/coverage_env.sh deleted file mode 100755 index 4f55d857..00000000 --- a/scripts/coverage_env.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later - -# generate variables for coverage testing -# $1 = top source directory -# $2 = coverage data directory path -# $3 = name of test/new subdirectory name -# $4 = [optional] --export to generate export commands - -set -o errexit -o nounset -shopt -s nullglob - -test -z "${COVERAGE:-}" && exit 0 # not enabled, do nothing -test ! -z "${V:-}" && set -o xtrace # verbose mode - -EXPORT="" -test "${4:-}" == "--export" && EXPORT="export " -TOPSRCDIR="$1" -DATAROOT="$2" -OUTPATH="$2/$3" - -# check that output directory is empty -# beware: Makefile will always call coverage_env.sh for all targets -# so directories get created but not populated -# i.e. test -d is not sufficient check -OUTPATH_FILENAMES=("${OUTPATH}"/*) # filenames in BASH array -(( ${#OUTPATH_FILENAMES[*]} )) && echo "false" && >&2 echo "fatal: output directory ${OUTPATH} must be empty (or non-existent)" && exit 1 - -mkdir -p "${OUTPATH}" -# convert paths to absolute -pushd "${OUTPATH}" &> /dev/null -touch .topdir_kresd_coverage -OUTPATH="$(pwd -P)" -popd &> /dev/null - -# determine GCOV_PREFIX_STRIP value for current source directory -TOPSRCDIR_SLASHES="${TOPSRCDIR//[^\/]/}" # remove everything except / -GCOV_PREFIX_STRIP="${#TOPSRCDIR_SLASHES}" # number of / == number of components - -KRESD_COVERAGE_STATS="${OUTPATH}/luacov.stats.out" -GCOV_PREFIX="${OUTPATH}" -echo "${EXPORT}KRESD_COVERAGE_STATS=\"${KRESD_COVERAGE_STATS}\" ${EXPORT}GCOV_PREFIX=\"${GCOV_PREFIX}\" ${EXPORT}GCOV_PREFIX_STRIP=\"${GCOV_PREFIX_STRIP}\"" diff --git a/scripts/create_setup.py b/scripts/create_setup.py deleted file mode 100755 index 2240cea8..00000000 --- a/scripts/create_setup.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Original source: -# https://github.com/sdss/flicamera/blob/main/create_setup.py -# We modified the script so that it outputs the setup.py to stdout and that no -# version upper bounds are outputted in the depencency list. -# -# @Author: José Sánchez-Gallego (gallegoj@uw.edu) -# @Date: 2019-12-18 -# @Filename: create_setup.py -# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause) - -# This is a temporary solution for the fact that pip install . fails with -# poetry when there is no setup.py and an extension needs to be compiled. -# See https://github.com/python-poetry/poetry/issues/1516. Running this -# script creates a setup.py filled out with information generated by -# poetry when parsing the pyproject.toml. - -import os -import re -import sys - -from packaging.version import Version - -# If there is a global installation of poetry, prefer that. -lib = os.path.expanduser("~/.poetry/lib") -vendors = os.path.join(lib, "poetry", "_vendor") -current_vendors = os.path.join(vendors, "py{}".format(".".join(str(v) for v in sys.version_info[:2]))) - -sys.path.insert(0, lib) -sys.path.insert(0, current_vendors) - -try: - try: - from poetry.core.factory import Factory - from poetry.core.masonry.builders.sdist import SdistBuilder - except (ImportError, ModuleNotFoundError): - from poetry.masonry.builders.sdist import SdistBuilder - from poetry.factory import Factory - from poetry.__version__ import __version__ -except (ImportError, ModuleNotFoundError) as ee: - raise ImportError(f"install poetry by doing pip install poetry to use this script: {ee}") - - -# Generate a Poetry object that knows about the metadata in pyproject.toml -factory = Factory() -poetry = factory.create_poetry(os.path.dirname(__file__)) - -# Use the SdistBuilder to genrate a blob for setup.py -if Version(__version__) >= Version("1.1.0b1"): - sdist_builder = SdistBuilder(poetry, None) -else: - sdist_builder = SdistBuilder(poetry, None, None) - -setuppy_blob: bytes = sdist_builder.build_setup() - - -# patch the result so that it does not contain upper bounds in dependencies -# (but it should contain them in python version) -setuppy = setuppy_blob.decode("utf8") -setuppy, _ = re.subn(r"(\'[^\']+>=[^<>=,\']*),<[^<>=,\']*\'", "\\1'", setuppy) - -# output the setup.py script to stdout -print(setuppy) -print("\n# This setup.py was autogenerated using Poetry for backward compatibility with setuptools.") diff --git a/scripts/enable-repo-cznic-labs.sh b/scripts/enable-repo-cznic-labs.sh deleted file mode 100755 index e7c53a82..00000000 --- a/scripts/enable-repo-cznic-labs.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# enable CZ.NIC Labs Debian/Ubuntu repos - see https://pkg.labs.nic.cz/doc/ -set -e - -REPO=$1 -if [ -z "${REPO}" ]; then - echo "usage: $0 REPOSITORY" - echo -e "\nPlease see: https://pkg.labs.nic.cz/doc/" - exit 1 -fi -if [ "$(whoami)" != "root" ]; then - echo "ERROR: this script must be run as ROOT" - echo -e "\nTry running with sudo:\n\n sudo $0\n" - exit 2 -fi - -# update apt metadata and install requirements -apt-get update -apt-get install -y apt-transport-https ca-certificates lsb-release wget - -DISTRO=$(lsb_release -si | tr '[:upper:]' '[:lower:]') -CODENAME=$(lsb_release -sc) - -echo "Enabling $REPO repo on $DISTRO $CODENAME..." -# get repo signing key -wget -O /usr/share/keyrings/cznic-labs-pkg.gpg https://pkg.labs.nic.cz/gpg -# create repo entry -echo "deb [signed-by=/usr/share/keyrings/cznic-labs-pkg.gpg] https://pkg.labs.nic.cz/$REPO $CODENAME main" > /etc/apt/sources.list.d/cznic-labs-$REPO.list -# update apt metadata from the new repo -apt-get update diff --git a/scripts/gen-cdefs.sh b/scripts/gen-cdefs.sh deleted file mode 100755 index 968f40b9..00000000 --- a/scripts/gen-cdefs.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o pipefail -o errexit - -if [ "$2" != types ] && [ "$2" != functions ] && [ "$2" != variables ]; then - echo "Usage: $0 libkres (types|functions|variables)" >&2 - echo " and input identifiers, one per line." >&2 - echo " You need debug symbols in the library." >&2 - echo - echo " If you call this on a type that's a typedef, it gets expanded." >&2 - echo " To avoid that, prefix the identifier with 'typedef '." >&2 - exit 1 -fi - -if ! command -v gdb >/dev/null; then - echo "Failed to find gdb" >&2 - exit 1 -fi - -if ! command -v sed >/dev/null; then - echo "Failed to find GNU sed" >&2 - exit 1 -fi - -if ! sed --version | head -1 | grep -q "GNU sed"; then - echo "GNU sed required to run this script" >&2 -fi - -# be very precise with the directories for libraries to not pick wrong library -case "$1" in - libknot) library="$(PATH="$(pkg-config libknot --variable=libdir)" command -v "$1.so")" ;; - libzscanner) library="$(PATH="$(pkg-config libzscanner --variable=libdir)" command -v "$1.so")" ;; - *) library="$(command -v "$1")" # use absolute path to library -esac - -if [ -z "$library" ]; then - echo "$1 not found. Note: only .so platforms work currently." >&2 - exit 1 -fi - -# Let's use an array to hold command-line arguments, to simplify quoting. -GDB=(gdb) -GDB+=(-n -quiet -batch "-symbols=$library") -GDB+=(-iex "set width unlimited" -iex "set max-value-size unlimited") - -grep -v '^#\|^$' | while read -r ident; do - if [ "$2" = functions ]; then - output="$("${GDB[@]}" --ex "info functions ^$ident\$" \ - | sed '0,/^All functions/ d; /^File .*:$/ d')" - elif [ "$2" = types ]; then - case "$ident" in - struct\ *|union\ *|enum\ *) - output="$("${GDB[@]}" --ex "ptype $ident" \ - | sed '0,/^type = /s/^type = /\n/; $ s/$/;/')" - ;; - typedef\ *) # typedef that shouldn't be expanded - output="$("${GDB[@]}" --ex "info types ^"$(echo "$ident" | sed 's/^typedef //')"\$" \ - | sed -e '0,/^File .*:$/ d' -e '/^File .*:$/,$ d')" - # we need to stop early to remove ^^ multiple matches - ;; - *) # we assume it's a typedef that should be expanded - output="$("${GDB[@]}" --ex "ptype $ident" \ - | sed "0,/^type = /s/^type = /typedef /; $ s/$/ $ident;/")" - ;; - esac - elif [ "$2" = variables ]; then - output="$("${GDB[@]}" --ex "info variables -q ^$ident\$" \ - | sed -e '0,/^File .*:$/ d' -e '/^File .*:$/,$ d')" - else - exit 1 - fi - # LuaJIT FFI blows up on "uint" type - output="$(echo "$output" | sed 's/\buint\b/unsigned int/g')" - # GDB 8.2+ added source line prefix to output - output="$(echo "$output" | sed 's/^[0-9]\+:[[:space:]]*//g')" - # use tabs instead of spaces - output="$(echo "$output" | sed 's/ /\t/g')" - - # abort on empty output - if [ -z "$(echo "$output" | tr -d "\n;")" ]; then - echo "Failed to find cdef of $ident" >&2 - exit 1 - fi - echo "$output" | grep -v '^$' -done - -exit 0 diff --git a/scripts/get-date.sh b/scripts/get-date.sh deleted file mode 100755 index fed10048..00000000 --- a/scripts/get-date.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o nounset -cd "$(dirname $0)/.." - -# Get date from NEWS if possible (regular release) -DATE=$(head -n1 < NEWS | sed 's/.*(\(.*\)).*/\1/' | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$$') - -if [[ $? -ne 0 ]]; then - # or use last modification time of NEWS (dev versions) - DATE=$(date -u -r NEWS +%F) -fi - -echo -n $DATE diff --git a/scripts/lib/get-date.sh b/scripts/lib/get-date.sh new file mode 100755 index 00000000..1480f984 --- /dev/null +++ b/scripts/lib/get-date.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o nounset +cd "$(dirname $0)/../.." + +# Get date from NEWS if possible (regular release) +DATE=$(head -n1 < NEWS | sed 's/.*(\(.*\)).*/\1/' | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$$') + +if [[ $? -ne 0 ]]; then + # or use last modification time of NEWS (dev versions) + DATE=$(date -u -r NEWS +%F) +fi + +echo -n $DATE diff --git a/scripts/lib/upstream-version.sh b/scripts/lib/upstream-version.sh new file mode 100755 index 00000000..4efa42db --- /dev/null +++ b/scripts/lib/upstream-version.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# +# return latest upstream version of Knot Resolver +set -o errexit + +REPO=https://gitlab.nic.cz/knot/knot-resolver.git + +git ls-remote --tags --refs $REPO | cut -f2- | sed -n "s#^refs/tags/v##p" | sort -V | tail -1 diff --git a/scripts/luacov_gen_empty.sh b/scripts/luacov_gen_empty.sh deleted file mode 100755 index a953d914..00000000 --- a/scripts/luacov_gen_empty.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -# Generate stats file in luacov format indicating that files named on stdin -# were not processed. -# -# Normally luacov does not know about files which were not loaded so -# without this manual addition the files are missing in coverage report. - -# Usage: -# $ luacov_gen_empty.sh < list_of_lua_files > luacov.empty_stats.out - -set -o errexit -o nounset -IFS=$'\n' - -while read FILENAME -do - echo -e "0:${FILENAME}\n " -done diff --git a/scripts/luacov_to_info.lua b/scripts/luacov_to_info.lua deleted file mode 100755 index b27ba999..00000000 --- a/scripts/luacov_to_info.lua +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env luajit --- SPDX-License-Identifier: GPL-3.0-or-later - -local luacov = require('luacov') -local ReporterBase = require('luacov.reporter').ReporterBase -local LcovReporter = setmetatable({}, ReporterBase) -LcovReporter.__index = LcovReporter - -function LcovReporter:on_new_file(filename) - self.finfo = self.current_files[filename] or {name=filename, coverage={}} -end - -function LcovReporter:on_mis_line(_, lineno, _) - self.finfo.coverage[lineno] = self.finfo.coverage[lineno] or 0 -end - -function LcovReporter:on_hit_line(_, lineno, _, hits) - self.finfo.coverage[lineno] = (self.finfo.coverage[lineno] or 0) + hits -end - -function LcovReporter:on_end_file() - self.current_files[self.finfo.name] = self.finfo - self.finfo = nil -end - --- Write out results in lcov format -local function write_lcov_info(files) - for fname, finfo in pairs(files) do - local instrumented, nonzero = 0, 0 - print('TN:') - print(string.format('SF:%s', fname)) - for i, hits in pairs(finfo.coverage) do - print(string.format('DA:%d,%d', i, hits)) - instrumented = instrumented + 1 - if hits > 0 then - nonzero = nonzero + 1 - end - end - print(string.format('LH:%d', nonzero)) - print(string.format('LF:%d', instrumented)) - print('end_of_record') - end -end - --- Accumulate total coverage -local all_files = {} -for _, fname in ipairs(arg) do - local conf = luacov.load_config() - conf.statsfile = fname - local reporter = assert(LcovReporter:new(conf)) - reporter.current_files = all_files - reporter:run() - reporter:close() -end - --- Write results -write_lcov_info(all_files) diff --git a/scripts/make-doc.sh b/scripts/make-doc.sh deleted file mode 100755 index 503d7943..00000000 --- a/scripts/make-doc.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o errexit -o nounset -cd "$(dirname "${0}")/.." - -# generate JSON schema for the manager's declarative config -pushd manager -## the following python command should hopefully run without any dependencies except for standard python -mkdir -p ../doc/_static/ -python3 -m knot_resolver_manager.cli schema > ../doc/_static/config.schema.json -generate-schema-doc --config expand_buttons=true ../doc/_static/config.schema.json ../doc/_static/schema_doc.html -popd - -# generating the user documentation -SPHINX=$(type -P sphinx-build-3 sphinx-build | head -n1) -rm -rf doc/html -"$SPHINX" "$@" -b html -d doc/user/.doctrees doc/user doc/html - -pushd doc/dev -doxygen -popd - -# generating the developer documentation -rm -rf doc/html/dev -"$SPHINX" "$@" -b html -d doc/dev/.doctrees doc/dev doc/html/dev diff --git a/scripts/make-obs.sh b/scripts/make-obs.sh deleted file mode 100755 index cc0aab73..00000000 --- a/scripts/make-obs.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -# -# create OpenSUSE Build System (OBS) source package -# -# this needs to be run on a system with: -# -# * apkg -# * dpkg-buildpackage -# -# usage: -# ./scripts/make-obs.sh [path.to.archive.xz] [1] -# -# supply archives as optional arguments to build from, -# otherwise archive will be built from sources by apkg -# second argument is optional release number (defaults to 1) -# -# output at pkg/obs/ (removed on each run) -set -o errexit -o nounset - -pushd "$(dirname ${0})/.." - -OUTDIR="pkg/obs" -APKG_OPTS="-O $OUTDIR" - -if [ -z $@ ]; then - echo "building OBS srcpkg from project files" -else - AR=$1 - echo "building OBS srcpkg from specified archive(s)" - APKG_OPTS="-a $AR $APKG_OPTS" - - RELEASE=${2:-} - if [ ! -z "$RELEASE" ]; then - echo "custom release: $RELEASE" - APKG_OPTS="-r $RELEASE $APKG_OPTS" - fi -fi - -set -o xtrace - -: removing existing output files at output dir: $OUTDIR -rm -rf "$OUTDIR" -: making debian source package from archive -apkg srcpkg $APKG_OPTS -d debian -: removing extra debian source package files -rm -f $OUTDIR/*_source.* -: rendering RPM template -apkg srcpkg $APKG_OPTS -d fedora --render-template -: fixing RPM .spec to use debian source archive -sed -i 's/^\(Source0:\s\+\).*/\1knot-resolver_%{version}.orig.tar.xz/' $OUTDIR/*.spec -: rendering PKGBUILD template -apkg srcpkg $APKG_OPTS -d arch --render-template -: fixing PKGBUILD to use debian source archive -sed -i 's/^source=.*/source=("knot-resolver_${pkgver}.orig.tar.xz")/' $OUTDIR/PKGBUILD -popd >/dev/null - -echo "OBS srcpkg ready at: $OUTDIR" - diff --git a/scripts/make-package.sh b/scripts/make-package.sh deleted file mode 100755 index 8b0ba95c..00000000 --- a/scripts/make-package.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset - -function install_pipx { - python3 -m pip install --user pipx - python3 -m pipx ensurepath - export PATH="$PATH:/root/.local/bin" # hack to make binaries installed with pipx work -} - -function pipx { - python3 -m pipx ${@} -} - -function init_debian { - export DEBIAN_FRONTEND=noninteractive - - # upgrade system to latest - apt-get update -qqq - apt-get upgrade -y -qqq - - # configure repository with Knot Resolver dependencies - apt-get -y -qqq install apt-transport-https lsb-release ca-certificates wget curl gnupg2 - sh -c 'echo "deb http://download.opensuse.org/repositories/home:/CZ-NIC:/knot-resolver-build/Debian_10/ /" > /etc/apt/sources.list.d/home:CZ-NIC:knot-resolver-build.list' - sh -c 'curl -fsSL https://download.opensuse.org/repositories/home:CZ-NIC:knot-resolver-build/Debian_10/Release.key | gpg --dearmor > /etc/apt/trusted.gpg.d/home_CZ-NIC_knot-resolver-build.gpg' - apt-get update -qqq - - # apkg - apt-get install -y python3-pip meson git python3-venv -} - -function init_fedora { - # upgrade system to latest and install pip - dnf upgrade -y - dnf install -y python3-pip -} - - -# system setup -if command -v dnf; then - init_fedora -elif command -v apt-get; then - init_debian -else - echo "System not supported." - exit 1 -fi - -# install apkg -install_pipx -pipx install apkg - -# prepare the repo -#git clone https://gitlab.nic.cz/knot/knot-resolver -cd /repo -git config --global user.email "automated-script" -git config --global user.name "Automated Script" -git checkout manager-integration-without-submodule -git submodule update --init --recursive - -# build the package -apkg system-setup -apkg build -b -apkg srcpkg - - - - - - diff --git a/scripts/map_install_src.lua b/scripts/map_install_src.lua deleted file mode 100755 index ffc9a300..00000000 --- a/scripts/map_install_src.lua +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env luajit --- SPDX-License-Identifier: GPL-3.0-or-later - --- parse install commands from stdin --- input: PREFIX=... make install --dry-run --always-make --- output: --- (or sed commands if --sed was specified) - -output = 'list' -if #arg > 1 or arg[1] == '-h' or arg[1] == '--help' then - print(string.format([[ -Read install commands and map install paths to paths in source directory. - -Usage: -$ PREFIX=... make install --dry-run --always-make | %s - -Example output: -/kresd/git/.local/lib/kdns_modules/policy.lua modules/policy/policy.lua - -Option --sed will produce output suitable as input suitable for sed.]], - arg[0])) - os.exit(1) -elseif #arg == 0 then - output = 'list' -elseif arg[1] == '--sed' then - output = 'sed' -else - print('Invalid arguments. See --help.') - os.exit(2) -end - --- remove double // from paths and remove trailing / -function normalize_path(path) - assert(path) - repeat - path, changes = path:gsub('//', '/') - until changes == 0 - return path:gsub('/$', '') -end - -function is_opt(word) - return word:match('^-') -end - --- opts requiring additional argument to be skipped -local ignored_opts_with_arg = { - ['--backup'] = true, - ['-g'] = true, - ['--group'] = true, - ['-m'] = true, - ['--mode'] = true, - ['-o'] = true, - ['--owner'] = true, - ['--strip-program'] = true, - ['--suffix'] = true, -} - --- state machine junctions caused by --opts --- returns: new state (expect, mode) and target name if any -function parse_opts(word, expect, mode) - if word == '--' then - return 'names', mode, nil -- no options anymore - elseif word == '-d' or word == '--directory' then - return 'opt_or_name', 'newdir', nil - elseif word == '-t' or word == '--target-directory' then - return 'targetdir', mode, nil - elseif word:match('^--target-directory=') then - return 'opt_or_name', mode, string.sub(word, 20) - elseif ignored_opts_with_arg[word] then - return 'ignore', mode, nil -- ignore next word - else - return expect, mode, nil -- unhandled opt - end -end - - --- cmd: complete install command line: install -m 0644 -t dest src1 src2 --- dirs: names known to be directories: name => true --- returns: updated dirs -function process_cmd(cmd, dirs) - -- print('# ' .. cmd) - sanity_check(cmd) - local expect = 'install' - local mode = 'copy' -- copy or newdir - local target -- last argument or argument for install -t - local names = {} -- non-option arguments - - for word in cmd:gmatch('%S+') do - if expect == 'install' then -- parsing 'install' - assert(word == 'install') - expect = 'opt_or_name' - elseif expect == 'opt_or_name' then - if is_opt(word) then - expect, mode, newtarget = parse_opts(word, expect, mode) - target = newtarget or target - else - if mode == 'copy' then - table.insert(names, word) - elseif mode == 'newdir' then - local path = normalize_path(word) - dirs[path] = true - else - assert(false, 'bad mode') - end - end - elseif expect == 'targetdir' then - local path = normalize_path(word) - dirs[path] = true - target = word - expect = 'opt_or_name' - elseif expect == 'names' then - table.insert(names, word) - elseif expect == 'ignore' then - expect = 'opt_or_name' - else - assert(false, 'bad expect') - end - end - if mode == 'newdir' then - -- no mapping to print, this cmd just created directory - return dirs - end - - if not target then -- last argument is the target - target = table.remove(names) - end - assert(target, 'fatal: no target in install cmd') - target = normalize_path(target) - - for _, name in pairs(names) do - basename = string.gsub(name, "(.*/)(.*)", "%2") - if not dirs[target] then - print('fatal: target directory "' .. target .. '" was not created yet!') - os.exit(2) - end - -- mapping installed name -> source name - if output == 'list' then - print(target .. '/' .. basename, name) - elseif output == 'sed' then - print(string.format([[s`%s`%s`g]], - target .. '/' .. basename, name)) - else - assert(false, 'unsupported output') - end - end - return dirs -end - -function sanity_check(cmd) - -- shell quotation is not supported - assert(not cmd:match('"'), 'quotes " are not supported') - assert(not cmd:match("'"), "quotes ' are not supported") - assert(not cmd:match('\\'), "escapes like \\ are not supported") - assert(cmd:match('^install%s'), 'not an install command') -end - --- remember directories created by install -d so we can expand relative paths -local dirs = {} -while true do - local cmd = io.read("*line") - if not cmd then - break - end - local isinstall = cmd:match('^install%s') - if isinstall then - dirs = process_cmd(cmd, dirs) - end -end diff --git a/scripts/meson/bench.sh b/scripts/meson/bench.sh new file mode 100755 index 00000000..d5a9f38e --- /dev/null +++ b/scripts/meson/bench.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o errexit -o nounset + +# Run benchmark +cd "${MESON_SOURCE_ROOT}" + +echo "Test LRU with increasing overfill, misses should increase ~ linearly" + +for num in 65536 32768 16384 8192 4096; do + "${MESON_BUILD_ROOT}/${MESON_SUBDIR}/bench_lru" 23 "${MESON_SOURCE_ROOT}/${MESON_SUBDIR}/bench_lru_set1.tsv" - "${num}" +done diff --git a/scripts/meson/gen-cdefs.sh b/scripts/meson/gen-cdefs.sh new file mode 100755 index 00000000..968f40b9 --- /dev/null +++ b/scripts/meson/gen-cdefs.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o pipefail -o errexit + +if [ "$2" != types ] && [ "$2" != functions ] && [ "$2" != variables ]; then + echo "Usage: $0 libkres (types|functions|variables)" >&2 + echo " and input identifiers, one per line." >&2 + echo " You need debug symbols in the library." >&2 + echo + echo " If you call this on a type that's a typedef, it gets expanded." >&2 + echo " To avoid that, prefix the identifier with 'typedef '." >&2 + exit 1 +fi + +if ! command -v gdb >/dev/null; then + echo "Failed to find gdb" >&2 + exit 1 +fi + +if ! command -v sed >/dev/null; then + echo "Failed to find GNU sed" >&2 + exit 1 +fi + +if ! sed --version | head -1 | grep -q "GNU sed"; then + echo "GNU sed required to run this script" >&2 +fi + +# be very precise with the directories for libraries to not pick wrong library +case "$1" in + libknot) library="$(PATH="$(pkg-config libknot --variable=libdir)" command -v "$1.so")" ;; + libzscanner) library="$(PATH="$(pkg-config libzscanner --variable=libdir)" command -v "$1.so")" ;; + *) library="$(command -v "$1")" # use absolute path to library +esac + +if [ -z "$library" ]; then + echo "$1 not found. Note: only .so platforms work currently." >&2 + exit 1 +fi + +# Let's use an array to hold command-line arguments, to simplify quoting. +GDB=(gdb) +GDB+=(-n -quiet -batch "-symbols=$library") +GDB+=(-iex "set width unlimited" -iex "set max-value-size unlimited") + +grep -v '^#\|^$' | while read -r ident; do + if [ "$2" = functions ]; then + output="$("${GDB[@]}" --ex "info functions ^$ident\$" \ + | sed '0,/^All functions/ d; /^File .*:$/ d')" + elif [ "$2" = types ]; then + case "$ident" in + struct\ *|union\ *|enum\ *) + output="$("${GDB[@]}" --ex "ptype $ident" \ + | sed '0,/^type = /s/^type = /\n/; $ s/$/;/')" + ;; + typedef\ *) # typedef that shouldn't be expanded + output="$("${GDB[@]}" --ex "info types ^"$(echo "$ident" | sed 's/^typedef //')"\$" \ + | sed -e '0,/^File .*:$/ d' -e '/^File .*:$/,$ d')" + # we need to stop early to remove ^^ multiple matches + ;; + *) # we assume it's a typedef that should be expanded + output="$("${GDB[@]}" --ex "ptype $ident" \ + | sed "0,/^type = /s/^type = /typedef /; $ s/$/ $ident;/")" + ;; + esac + elif [ "$2" = variables ]; then + output="$("${GDB[@]}" --ex "info variables -q ^$ident\$" \ + | sed -e '0,/^File .*:$/ d' -e '/^File .*:$/,$ d')" + else + exit 1 + fi + # LuaJIT FFI blows up on "uint" type + output="$(echo "$output" | sed 's/\buint\b/unsigned int/g')" + # GDB 8.2+ added source line prefix to output + output="$(echo "$output" | sed 's/^[0-9]\+:[[:space:]]*//g')" + # use tabs instead of spaces + output="$(echo "$output" | sed 's/ /\t/g')" + + # abort on empty output + if [ -z "$(echo "$output" | tr -d "\n;")" ]; then + echo "Failed to find cdef of $ident" >&2 + exit 1 + fi + echo "$output" | grep -v '^$' +done + +exit 0 diff --git a/scripts/meson/make-doc.sh b/scripts/meson/make-doc.sh new file mode 100755 index 00000000..aecf0410 --- /dev/null +++ b/scripts/meson/make-doc.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o errexit -o nounset +cd "$(dirname "${0}")/../.." + +# generate JSON schema for the manager's declarative config +pushd manager +## the following python command should hopefully run without any dependencies except for standard python +mkdir -p ../doc/_static/ +python3 -m knot_resolver_manager.cli schema > ../doc/_static/config.schema.json +generate-schema-doc --config expand_buttons=true ../doc/_static/config.schema.json ../doc/_static/schema_doc.html +popd + +# generating the user documentation +SPHINX=$(type -P sphinx-build-3 sphinx-build | head -n1) +rm -rf doc/html +"$SPHINX" "$@" -b html -d doc/user/.doctrees doc/user doc/html + +pushd doc/dev +doxygen +popd + +# generating the developer documentation +rm -rf doc/html/dev +"$SPHINX" "$@" -b html -d doc/dev/.doctrees doc/dev doc/html/dev diff --git a/scripts/meson/run-pylint.sh b/scripts/meson/run-pylint.sh new file mode 100755 index 00000000..ac23f5c4 --- /dev/null +++ b/scripts/meson/run-pylint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o errexit -o nounset + +cd "$(dirname ${0})/../.." + +# Find Python modules and standalone Python scripts +FILES=$(find ./tests/pytests \ + -type d -exec test -e '{}/__init__.py' \; -print -prune -o \ + -name '*.py' -print) + +python3 -m pylint -j 0 --rcfile ./tests/pytests/pylintrc ${FILES} diff --git a/scripts/meson/test-config.sh b/scripts/meson/test-config.sh new file mode 100755 index 00000000..2b55066d --- /dev/null +++ b/scripts/meson/test-config.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# Utility script used by meson to run config tests post installation +set -o nounset -o errexit + +# if anything fails during test setup, use exit code 77 to mark it as skipped +function skip { + exit 77 +} +trap skip ERR + +TEST_DIR="$(dirname ${TEST_FILE})" +TMP_RUNDIR="$(mktemp -d)" + +function finish { + if [[ "$(jobs -p)" != "" ]] + then + echo "SIGKILLing leftover processes:" + jobs -l + kill -s SIGKILL $(jobs -p) + fi + rm -rf "${TMP_RUNDIR}" +} +trap finish EXIT + +cp -a "${TEST_DIR}/"* "${TMP_RUNDIR}/" +cd "${TMP_RUNDIR}" + +which kresd || (echo "kresd not executable!"; exit 77) +trap ERR # get actual kresd error code from now on + +kresd "$@" diff --git a/scripts/meson/test-integration-prepare.sh b/scripts/meson/test-integration-prepare.sh new file mode 100755 index 00000000..17f08df3 --- /dev/null +++ b/scripts/meson/test-integration-prepare.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +set -o errexit -o nounset + +cd "${1}" + +git submodule update --init --recursive +make depend &>/dev/null diff --git a/scripts/poe-tasks/_env.sh b/scripts/poe-tasks/_env.sh deleted file mode 100644 index 1ea73a39..00000000 --- a/scripts/poe-tasks/_env.sh +++ /dev/null @@ -1,72 +0,0 @@ -# fail on errors -set -o errexit - -# define color codes -red="\033[0;31m" -yellow="\033[0;33m" -green="\033[0;32m" -bright_black="\033[0;90m" -blue="\033[0;34m" -reset="\033[0m" - -# ensure consistent top level directory -gitroot="$(git rev-parse --show-toplevel)" -if test -z "$gitroot"; then - echo -e "${red}This command can be run only in a git repository tree.${reset}" - exit 1 -fi -cd $gitroot - -# ensure consistent environment with virtualenv -if test -z "$VIRTUAL_ENV" -a "$CI" != "true" -a -z "$KNOT_ENV"; then - echo -e "${yellow}You are NOT running the script within the project's virtual environment.${reset}" - echo -e "Do you want to continue regardless? [yN]" - read cont - if test "$cont" != "y" -a "$cont" != "Y"; then - echo -e "${red}Exiting early...${reset}" - exit 1 - fi -fi - -# update PATH with node_modules -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" -fi -mkdir -p "$KRES_CONFIG_DIR/runtime" "$KRES_CONFIG_DIR/cache" - -# env variables -if [ -z "${KRES_MANAGER_CONFIG:-}" ]; then - KRES_MANAGER_CONFIG="$KRES_CONFIG_DIR/config.dev.yaml" -fi - -if [ -z "${KRES_MANAGER_API_SOCK:-}" ]; then - KRES_MANAGER_API_SOCK="$KRES_CONFIG_DIR/manager.sock" -fi -export KRES_MANAGER_CONFIG -export KRES_MANAGER_API_SOCK - -function build_kresd { - if [ -d .build_kresd ]; then - echo - echo Building Knot Resolver - 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 $(realpath .install_kresd) $(realpath .build_kresd)${reset}" - echo - ninja -C .build_kresd - ninja install -C .build_kresd - export PYTHONPATH="$(realpath .build_kresd/python):${PYTHONPATH:-}" - else - echo - echo Knot Resolver daemon is not configured. - echo "Please run './poe configure' (optionally with additional Meson arguments)" - echo - exit 2 - fi -} diff --git a/scripts/poe-tasks/check b/scripts/poe-tasks/check index 5563a9de..ff7bdf9f 100755 --- a/scripts/poe-tasks/check +++ b/scripts/poe-tasks/check @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh aggregate_rv=0 function check_rv { @@ -32,7 +32,7 @@ fi # check formatting using black echo -e "${yellow}Checking formatting using black...${reset}" -black manager/knot_resolver_manager tests/manager scripts/create_setup.py --check --diff +black manager/knot_resolver_manager tests/manager scripts/poe-tasks/utils/create_setup.py --check --diff check_rv $? echo @@ -56,7 +56,7 @@ echo # check that setup.py is not behind pyproject.toml echo -e "${yellow}Checking setup.py${reset}" -python scripts/create_setup.py | diff - setup.py +python scripts/poe-tasks/utils/create_setup.py | diff - setup.py check_rv $? python setup.py --help > /dev/null check_rv $? diff --git a/scripts/poe-tasks/configure b/scripts/poe-tasks/configure index 1ca961a7..d205a6de 100755 --- a/scripts/poe-tasks/configure +++ b/scripts/poe-tasks/configure @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh reconfigure='' if [ -f .build_kresd/ninja.build ]; then diff --git a/scripts/poe-tasks/docs b/scripts/poe-tasks/docs index 6a62eb78..0364cf72 100755 --- a/scripts/poe-tasks/docs +++ b/scripts/poe-tasks/docs @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh echo Building Knot Resolver documentation echo ------------------------------------ diff --git a/scripts/poe-tasks/examples b/scripts/poe-tasks/examples index c214167a..8b0be2c4 100755 --- a/scripts/poe-tasks/examples +++ b/scripts/poe-tasks/examples @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh # validate all configuration examples for example in $PWD/etc/config/config.example.*.yaml; diff --git a/scripts/poe-tasks/format b/scripts/poe-tasks/format index 0a83e3c2..80b2da0d 100755 --- a/scripts/poe-tasks/format +++ b/scripts/poe-tasks/format @@ -2,9 +2,9 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh -dirs="manager/knot_resolver_manager/ tests/manager scripts/create_setup.py build_c_extensions.py" +dirs="manager/knot_resolver_manager/ tests/manager scripts/poe-tasks/utils/create_setup.py build_c_extensions.py" # run black code formater black $dirs diff --git a/scripts/poe-tasks/gen-setuppy b/scripts/poe-tasks/gen-setuppy index 3f337b39..8a6d543e 100755 --- a/scripts/poe-tasks/gen-setuppy +++ b/scripts/poe-tasks/gen-setuppy @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh # create setup.py -python scripts/create_setup.py > setup.py +python scripts/poe-tasks/utils/create_setup.py > setup.py diff --git a/scripts/poe-tasks/kresctl b/scripts/poe-tasks/kresctl index e46ad3c1..38a8b4ea 100755 --- a/scripts/poe-tasks/kresctl +++ b/scripts/poe-tasks/kresctl @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh # run knot-resolver client python3 -m knot_resolver_manager.cli $@ diff --git a/scripts/poe-tasks/man b/scripts/poe-tasks/man index 9b06b360..3cdafb34 100755 --- a/scripts/poe-tasks/man +++ b/scripts/poe-tasks/man @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh build_kresd diff --git a/scripts/poe-tasks/run b/scripts/poe-tasks/run index 907f94c1..23a33959 100755 --- a/scripts/poe-tasks/run +++ b/scripts/poe-tasks/run @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh build_kresd diff --git a/scripts/poe-tasks/run-debug b/scripts/poe-tasks/run-debug index 661b7fe2..f577681b 100755 --- a/scripts/poe-tasks/run-debug +++ b/scripts/poe-tasks/run-debug @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh echo The debug server will be listening on port localhost:5678 echo Use VSCode remote attach feature to connect to the debug server diff --git a/scripts/poe-tasks/test b/scripts/poe-tasks/test index 3c1d7a9c..43aa403a 100755 --- a/scripts/poe-tasks/test +++ b/scripts/poe-tasks/test @@ -2,7 +2,7 @@ # ensure consistent behaviour src_dir="$(dirname "$(realpath "$0")")" -source $src_dir/_env.sh +source $src_dir/utils/_env.sh # run pytest env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=manager/knot_resolver_manager --show-capture=all tests/manager diff --git a/scripts/poe-tasks/utils/_env.sh b/scripts/poe-tasks/utils/_env.sh new file mode 100644 index 00000000..1ea73a39 --- /dev/null +++ b/scripts/poe-tasks/utils/_env.sh @@ -0,0 +1,72 @@ +# fail on errors +set -o errexit + +# define color codes +red="\033[0;31m" +yellow="\033[0;33m" +green="\033[0;32m" +bright_black="\033[0;90m" +blue="\033[0;34m" +reset="\033[0m" + +# ensure consistent top level directory +gitroot="$(git rev-parse --show-toplevel)" +if test -z "$gitroot"; then + echo -e "${red}This command can be run only in a git repository tree.${reset}" + exit 1 +fi +cd $gitroot + +# ensure consistent environment with virtualenv +if test -z "$VIRTUAL_ENV" -a "$CI" != "true" -a -z "$KNOT_ENV"; then + echo -e "${yellow}You are NOT running the script within the project's virtual environment.${reset}" + echo -e "Do you want to continue regardless? [yN]" + read cont + if test "$cont" != "y" -a "$cont" != "Y"; then + echo -e "${red}Exiting early...${reset}" + exit 1 + fi +fi + +# update PATH with node_modules +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" +fi +mkdir -p "$KRES_CONFIG_DIR/runtime" "$KRES_CONFIG_DIR/cache" + +# env variables +if [ -z "${KRES_MANAGER_CONFIG:-}" ]; then + KRES_MANAGER_CONFIG="$KRES_CONFIG_DIR/config.dev.yaml" +fi + +if [ -z "${KRES_MANAGER_API_SOCK:-}" ]; then + KRES_MANAGER_API_SOCK="$KRES_CONFIG_DIR/manager.sock" +fi +export KRES_MANAGER_CONFIG +export KRES_MANAGER_API_SOCK + +function build_kresd { + if [ -d .build_kresd ]; then + echo + echo Building Knot Resolver + 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 $(realpath .install_kresd) $(realpath .build_kresd)${reset}" + echo + ninja -C .build_kresd + ninja install -C .build_kresd + export PYTHONPATH="$(realpath .build_kresd/python):${PYTHONPATH:-}" + else + echo + echo Knot Resolver daemon is not configured. + echo "Please run './poe configure' (optionally with additional Meson arguments)" + echo + exit 2 + fi +} diff --git a/scripts/poe-tasks/utils/create_setup.py b/scripts/poe-tasks/utils/create_setup.py new file mode 100755 index 00000000..2240cea8 --- /dev/null +++ b/scripts/poe-tasks/utils/create_setup.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Original source: +# https://github.com/sdss/flicamera/blob/main/create_setup.py +# We modified the script so that it outputs the setup.py to stdout and that no +# version upper bounds are outputted in the depencency list. +# +# @Author: José Sánchez-Gallego (gallegoj@uw.edu) +# @Date: 2019-12-18 +# @Filename: create_setup.py +# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause) + +# This is a temporary solution for the fact that pip install . fails with +# poetry when there is no setup.py and an extension needs to be compiled. +# See https://github.com/python-poetry/poetry/issues/1516. Running this +# script creates a setup.py filled out with information generated by +# poetry when parsing the pyproject.toml. + +import os +import re +import sys + +from packaging.version import Version + +# If there is a global installation of poetry, prefer that. +lib = os.path.expanduser("~/.poetry/lib") +vendors = os.path.join(lib, "poetry", "_vendor") +current_vendors = os.path.join(vendors, "py{}".format(".".join(str(v) for v in sys.version_info[:2]))) + +sys.path.insert(0, lib) +sys.path.insert(0, current_vendors) + +try: + try: + from poetry.core.factory import Factory + from poetry.core.masonry.builders.sdist import SdistBuilder + except (ImportError, ModuleNotFoundError): + from poetry.masonry.builders.sdist import SdistBuilder + from poetry.factory import Factory + from poetry.__version__ import __version__ +except (ImportError, ModuleNotFoundError) as ee: + raise ImportError(f"install poetry by doing pip install poetry to use this script: {ee}") + + +# Generate a Poetry object that knows about the metadata in pyproject.toml +factory = Factory() +poetry = factory.create_poetry(os.path.dirname(__file__)) + +# Use the SdistBuilder to genrate a blob for setup.py +if Version(__version__) >= Version("1.1.0b1"): + sdist_builder = SdistBuilder(poetry, None) +else: + sdist_builder = SdistBuilder(poetry, None, None) + +setuppy_blob: bytes = sdist_builder.build_setup() + + +# patch the result so that it does not contain upper bounds in dependencies +# (but it should contain them in python version) +setuppy = setuppy_blob.decode("utf8") +setuppy, _ = re.subn(r"(\'[^\']+>=[^<>=,\']*),<[^<>=,\']*\'", "\\1'", setuppy) + +# output the setup.py script to stdout +print(setuppy) +print("\n# This setup.py was autogenerated using Poetry for backward compatibility with setuptools.") diff --git a/scripts/run-pylint.sh b/scripts/run-pylint.sh deleted file mode 100755 index 653d54bd..00000000 --- a/scripts/run-pylint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o errexit -o nounset - -cd "$(dirname ${0})/.." - -# Find Python modules and standalone Python scripts -FILES=$(find ./tests/pytests \ - -type d -exec test -e '{}/__init__.py' \; -print -prune -o \ - -name '*.py' -print) - -python3 -m pylint -j 0 --rcfile ./tests/pytests/pylintrc ${FILES} diff --git a/scripts/run-scanbuild-with-args.sh b/scripts/run-scanbuild-with-args.sh deleted file mode 100755 index fa4a98cd..00000000 --- a/scripts/run-scanbuild-with-args.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o errexit -o nounset - -# following checkers are disabled on purpose: -# Clang does not support attribute cleanup and this is causing false positives in following checkers: -# unix.Malloc -# alpha.unix.SimpleStream -# alpha.unix.Stream -# https://bugs.llvm.org/show_bug.cgi?id=3888 - -# These are disabled for other reasons: -# alpha.clone.CloneChecker # way too many false positives -# alpha.core.CastToStruct # we use this pattern too much, hard to avoid in many cases -# alpha.deadcode.UnreachableCode # false positives/flags sanity checks depending on implementation details -# alpha.security.MallocOverflow # not smart enough to infer max values from data types - -exec scan-build --status-bugs -no-failure-reports \ --analyzer-config aggressive-binary-operation-simplification=true \ --disable-checker unix.Malloc \ --enable-checker alpha.core.BoolAssignment \ --enable-checker alpha.core.CastSize \ --enable-checker alpha.core.Conversion \ --enable-checker alpha.core.DynamicTypeChecker \ --enable-checker alpha.core.FixedAddr \ --enable-checker alpha.core.IdenticalExpr \ --enable-checker alpha.core.PointerArithm \ --enable-checker alpha.core.PointerSub \ --enable-checker alpha.core.SizeofPtr \ --enable-checker alpha.core.TestAfterDivZero \ --enable-checker alpha.cplusplus.IteratorRange \ --enable-checker alpha.security.ArrayBound \ --enable-checker alpha.security.ArrayBoundV2 \ --enable-checker alpha.security.ReturnPtrRange \ --enable-checker alpha.security.taint.TaintPropagation \ --enable-checker alpha.unix.BlockInCriticalSection \ --enable-checker alpha.unix.Chroot \ --enable-checker alpha.unix.PthreadLock \ --enable-checker alpha.unix.cstring.BufferOverlap \ --enable-checker alpha.unix.cstring.NotNullTerminated \ --enable-checker alpha.unix.cstring.OutOfBounds \ --enable-checker nullability.NullableDereferenced \ --enable-checker nullability.NullablePassedToNonnull \ --enable-checker nullability.NullableReturnedFromNonnull \ --enable-checker optin.performance.Padding \ --enable-checker optin.portability.UnixAPI \ --enable-checker security.FloatLoopCounter \ --enable-checker valist.CopyToSelf \ --enable-checker valist.Uninitialized \ --enable-checker valist.Unterminated \ -"$@" diff --git a/scripts/test-config.sh b/scripts/test-config.sh deleted file mode 100755 index 2b55066d..00000000 --- a/scripts/test-config.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -# Utility script used by meson to run config tests post installation -set -o nounset -o errexit - -# if anything fails during test setup, use exit code 77 to mark it as skipped -function skip { - exit 77 -} -trap skip ERR - -TEST_DIR="$(dirname ${TEST_FILE})" -TMP_RUNDIR="$(mktemp -d)" - -function finish { - if [[ "$(jobs -p)" != "" ]] - then - echo "SIGKILLing leftover processes:" - jobs -l - kill -s SIGKILL $(jobs -p) - fi - rm -rf "${TMP_RUNDIR}" -} -trap finish EXIT - -cp -a "${TEST_DIR}/"* "${TMP_RUNDIR}/" -cd "${TMP_RUNDIR}" - -which kresd || (echo "kresd not executable!"; exit 77) -trap ERR # get actual kresd error code from now on - -kresd "$@" diff --git a/scripts/test-integration-prepare.sh b/scripts/test-integration-prepare.sh deleted file mode 100755 index 17f08df3..00000000 --- a/scripts/test-integration-prepare.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -set -o errexit -o nounset - -cd "${1}" - -git submodule update --init --recursive -make depend &>/dev/null diff --git a/scripts/upstream-version.sh b/scripts/upstream-version.sh deleted file mode 100755 index 4efa42db..00000000 --- a/scripts/upstream-version.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-or-later -# -# return latest upstream version of Knot Resolver -set -o errexit - -REPO=https://gitlab.nic.cz/knot/knot-resolver.git - -git ls-remote --tags --refs $REPO | cut -f2- | sed -n "s#^refs/tags/v##p" | sort -V | tail -1 diff --git a/tests/config/meson.build b/tests/config/meson.build index 2a9e2487..681f2cc2 100644 --- a/tests/config/meson.build +++ b/tests/config/meson.build @@ -10,7 +10,7 @@ config_tests += [ ] -run_configtest = find_program('../../scripts/test-config.sh') +run_configtest = find_program('../../scripts/meson/test-config.sh') foreach config_test : config_tests diff --git a/tests/integration/meson.build b/tests/integration/meson.build index 98b661f4..e9ab9e0f 100644 --- a/tests/integration/meson.build +++ b/tests/integration/meson.build @@ -19,7 +19,7 @@ py3_deps += [ ['yaml', 'PyYAML (for deckard)'], ] -prepare_deckard = find_program('../../scripts/test-integration-prepare.sh') +prepare_deckard = find_program('../../scripts/meson/test-integration-prepare.sh') deckard_env = environment() deckard_env.prepend('PATH', sbin_dir) -- cgit v1.2.3 From 279f2a2da1d878f259efd635ba34fb2a7f415951 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Wed, 28 Aug 2024 13:28:05 +0200 Subject: daemon/tls: bump gnutls version requirement It simplifies a bit. No need to support ancient versions. --- NEWS | 4 ++++ daemon/tls.c | 14 -------------- daemon/tls.h | 6 ------ daemon/tls_session_ticket-srv.c | 6 ------ meson.build | 2 +- 5 files changed, 5 insertions(+), 27 deletions(-) (limited to 'meson.build') diff --git a/NEWS b/NEWS index a533561b..53d39a19 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ Bugfixes - daemon/proxyv2: fix informing the engine about TCP/TLS from the actual client (!1578) - forward: fix wrong pin-sha256 length; also log pins on mismatch (!1601, #813) +Incompatible changes +-------------------- +- gnutls < 3.4 support is dropped, released over 9 years ago (!1601) + Knot Resolver 6.0.8 (2024-07-23) ================================ diff --git a/daemon/tls.c b/daemon/tls.c index 1aa24b29..231bff2d 100644 --- a/daemon/tls.c +++ b/daemon/tls.c @@ -340,7 +340,6 @@ static void tls_close(struct pl_tls_sess_data *tls, struct session2 *session, bo } } -#if TLS_CAN_USE_PINS /* DNS-over-TLS Out of band key-pinned authentication profile uses the same form of pins as HPKP: @@ -428,12 +427,6 @@ void tls_credentials_log_pins(struct tls_credentials *tls_credentials) gnutls_free(certs); } } -#else -void tls_credentials_log_pins(struct tls_credentials *tls_credentials) -{ - kr_log_debug(TLS, "could not calculate RFC 7858 OOB key-pin; GnuTLS 3.4.0+ required\n"); -} -#endif static int str_replace(char **where_ptr, const char *with) { @@ -761,7 +754,6 @@ static int client_verify_pin(const unsigned int cert_list_size, { if (kr_fails_assert(params->pins.len > 0)) return GNUTLS_E_CERTIFICATE_ERROR; -#if TLS_CAN_USE_PINS for (int i = 0; i < cert_list_size; i++) { gnutls_x509_crt_t cert; int ret = gnutls_x509_crt_init(&cert); @@ -798,12 +790,6 @@ static int client_verify_pin(const unsigned int cert_list_size, log_all_pins(params); log_all_certificates(cert_list_size, cert_list); return GNUTLS_E_CERTIFICATE_ERROR; - -#else /* TLS_CAN_USE_PINS */ - kr_log_error(TLSCLIENT, "internal inconsistency: TLS_CAN_USE_PINS\n"); - kr_assert(false); - return GNUTLS_E_CERTIFICATE_ERROR; -#endif } /** diff --git a/daemon/tls.h b/daemon/tls.h index ff1bbea2..b24b6165 100644 --- a/daemon/tls.h +++ b/daemon/tls.h @@ -51,12 +51,6 @@ struct tls_credentials { /** Required buffer length for pin_sha256, including the zero terminator. */ #define TLS_SHA256_BASE64_BUFLEN (((TLS_SHA256_RAW_LEN * 8 + 4) / 6) + 3 + 1) -#if GNUTLS_VERSION_NUMBER >= 0x030400 - #define TLS_CAN_USE_PINS 1 -#else - #define TLS_CAN_USE_PINS 0 -#endif - /** TLS authentication parameters for a single address-port pair. */ typedef struct { diff --git a/daemon/tls_session_ticket-srv.c b/daemon/tls_session_ticket-srv.c index 26d41862..ed8a5005 100644 --- a/daemon/tls_session_ticket-srv.c +++ b/daemon/tls_session_ticket-srv.c @@ -33,12 +33,6 @@ #define TST_HASH abort() #endif -#if GNUTLS_VERSION_NUMBER < 0x030400 - /* It's of little use anyway. We may get the secret through lua, - * which creates a copy outside of our control. */ - #define gnutls_memset memset -#endif - /** Fields are internal to tst_key_* functions. */ typedef struct tls_session_ticket_ctx { uv_timer_t timer; /**< timer for rotation of the key */ diff --git a/meson.build b/meson.build index d2e85b0b..b8c5bc86 100644 --- a/meson.build +++ b/meson.build @@ -27,7 +27,7 @@ lmdb = dependency('lmdb', required: false) if not lmdb.found() # darwin workaround: missing pkgconfig lmdb = meson.get_compiler('c').find_library('lmdb') endif -gnutls = dependency('gnutls') +gnutls = dependency('gnutls', version: '>=3.4') luajit = dependency('luajit') message('------------------------------') -- cgit v1.2.3 From 588f2ea5b2a1a3961c90ea53847eb266ec5402f2 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Mon, 30 Sep 2024 09:50:52 +0200 Subject: meson, NEWS: bump minimal libuv version --- NEWS | 2 ++ meson.build | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'meson.build') diff --git a/NEWS b/NEWS index 8642a9cb..8d19f937 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ Improvements - stats: add stale answer counter 'answer.stale' (!1591) - extended_errors: answer with EDE in more cases (!1585, !1588, !1590, !1592) - local-data: make DNAMEs work, i.e. generate CNAMEs (!1609) +- daemon: use connected UDP sockets by default (#326, !1618) Bugfixes -------- @@ -29,6 +30,7 @@ Bugfixes Incompatible changes -------------------- - gnutls < 3.4 support is dropped, released over 9 years ago (!1601) +- libuv < 1.27 support is dropped, released over 5 years ago (!1618) Knot Resolver 6.0.8 (2024-07-23) diff --git a/meson.build b/meson.build index b8c5bc86..0bd46ad6 100644 --- a/meson.build +++ b/meson.build @@ -22,7 +22,7 @@ knot_version = '>=3.3' libknot = dependency('libknot', version: knot_version) libdnssec = dependency('libdnssec', version: knot_version) libzscanner = dependency('libzscanner', version: knot_version) -libuv = dependency('libuv', version: '>=1.7') +libuv = dependency('libuv', version: '>=1.27') # need uv_udp_connect() lmdb = dependency('lmdb', required: false) if not lmdb.found() # darwin workaround: missing pkgconfig lmdb = meson.get_compiler('c').find_library('lmdb') -- cgit v1.2.3 From d2c8db59ebe5e07cb66cc3789e2d5b48302b2703 Mon Sep 17 00:00:00 2001 From: Aleš Mrázek Date: Mon, 16 Sep 2024 17:56:27 +0200 Subject: meson.build: use non-standard prefix for run_dir --- meson.build | 12 ++++++++++-- python/constants.py.in | 2 +- python/meson.build | 1 - 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 0bd46ad6..85c69fa7 100644 --- a/meson.build +++ b/meson.build @@ -33,6 +33,7 @@ message('------------------------------') # Variables +auto_prefixes = ['/', '/usr', '/usr/local'] libkres_soversion = 9 libext = '.so' @@ -54,7 +55,15 @@ modules_dir = lib_dir / 'kres_modules' sbin_dir = prefix / get_option('sbindir') bin_dir = prefix / get_option('bindir') if host_machine.system() == 'linux' - run_dir = '/run' / 'knot-resolver' + # When installing from sources with a non-standard prefix, + # we need to set the correct run directory with the prefix, + # otherwise rwx permissions will fail with a validation error + # on the run directory + if prefix in auto_prefixes + run_dir = '/run' / 'knot-resolver' + else + run_dir = prefix / 'run' / 'knot-resolver' + endif elif host_machine.system() == 'darwin' run_dir = prefix / get_option('localstatedir') / 'run' / 'knot-resolver' else @@ -71,7 +80,6 @@ completion_dir = prefix / 'share' # When installing from sources into a non-standard prefix and the library is # shared/dynamic, we need to set the executables' RPATH so that they can find # `libkresd`, otherwise running them will fail with dynamic linkage errors -auto_prefixes = ['/', '/usr', '/usr/local'] rpath_opt = get_option('install_rpath') if (get_option('default_library') == 'static' or rpath_opt == 'disabled' or diff --git a/python/constants.py.in b/python/constants.py.in index 3f2eb734..0f1c3a88 100644 --- a/python/constants.py.in +++ b/python/constants.py.in @@ -5,7 +5,7 @@ USER = "@user@" GROUP = "@group@" # dirs paths -RUN_DIR = Path("@prefix@@run_dir@") +RUN_DIR = Path("@run_dir@") ETC_DIR = Path("@etc_dir@") SBIN_DIR = Path("@sbin_dir@") CACHE_DIR = Path("@cache_dir@") diff --git a/python/meson.build b/python/meson.build index a0ea0c06..38794daa 100644 --- a/python/meson.build +++ b/python/meson.build @@ -5,7 +5,6 @@ constants_config = configuration_data() constants_config.set('version', meson.project_version()) constants_config.set('user', user) constants_config.set('group', group) -constants_config.set('prefix', prefix) constants_config.set('run_dir', run_dir) constants_config.set('etc_dir', etc_dir) constants_config.set('sbin_dir', sbin_dir) -- cgit v1.2.3 From 9f70c6e5ffa3ec8a5354d101fa05353f739c23db Mon Sep 17 00:00:00 2001 From: Aleš Mrázek Date: Thu, 19 Sep 2024 15:43:30 +0200 Subject: python: meson constants.py template moved to knot_resolver module --- meson.build | 2 +- python/constants.py.in | 19 ------------------- python/knot_resolver/constants.py.in | 19 +++++++++++++++++++ python/knot_resolver/meson.build | 17 +++++++++++++++++ python/meson.build | 17 ----------------- scripts/poe-tasks/check | 2 +- scripts/poe-tasks/configure | 2 +- scripts/poe-tasks/doc-schema | 2 +- scripts/poe-tasks/gen-constantspy | 2 +- 9 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 python/constants.py.in create mode 100644 python/knot_resolver/constants.py.in create mode 100644 python/knot_resolver/meson.build delete mode 100644 python/meson.build (limited to 'meson.build') diff --git a/meson.build b/meson.build index 85c69fa7..82035cec 100644 --- a/meson.build +++ b/meson.build @@ -275,7 +275,7 @@ subdir('lib') ## Remaining code subdir('daemon') subdir('modules') -subdir('python') +subdir('python' / 'knot_resolver') subdir('utils') if get_option('bench') == 'enabled' subdir('bench') diff --git a/python/constants.py.in b/python/constants.py.in deleted file mode 100644 index 0f1c3a88..00000000 --- a/python/constants.py.in +++ /dev/null @@ -1,19 +0,0 @@ -from pathlib import Path - -VERSION = "@version@" -USER = "@user@" -GROUP = "@group@" - -# dirs paths -RUN_DIR = Path("@run_dir@") -ETC_DIR = Path("@etc_dir@") -SBIN_DIR = Path("@sbin_dir@") -CACHE_DIR = Path("@cache_dir@") - -# files paths -CONFIG_FILE = ETC_DIR / "config.yaml" -API_SOCK_FILE = RUN_DIR / "kres-api.sock" - -# executables paths -KRESD_EXECUTABLE = SBIN_DIR / "kresd" -KRES_CACHE_GC_EXECUTABLE = SBIN_DIR / "kres-cache-gc" diff --git a/python/knot_resolver/constants.py.in b/python/knot_resolver/constants.py.in new file mode 100644 index 00000000..0f1c3a88 --- /dev/null +++ b/python/knot_resolver/constants.py.in @@ -0,0 +1,19 @@ +from pathlib import Path + +VERSION = "@version@" +USER = "@user@" +GROUP = "@group@" + +# dirs paths +RUN_DIR = Path("@run_dir@") +ETC_DIR = Path("@etc_dir@") +SBIN_DIR = Path("@sbin_dir@") +CACHE_DIR = Path("@cache_dir@") + +# files paths +CONFIG_FILE = ETC_DIR / "config.yaml" +API_SOCK_FILE = RUN_DIR / "kres-api.sock" + +# executables paths +KRESD_EXECUTABLE = SBIN_DIR / "kresd" +KRES_CACHE_GC_EXECUTABLE = SBIN_DIR / "kres-cache-gc" diff --git a/python/knot_resolver/meson.build b/python/knot_resolver/meson.build new file mode 100644 index 00000000..38794daa --- /dev/null +++ b/python/knot_resolver/meson.build @@ -0,0 +1,17 @@ +# python +# SPDX-License-Identifier: GPL-3.0-or-later + +constants_config = configuration_data() +constants_config.set('version', meson.project_version()) +constants_config.set('user', user) +constants_config.set('group', group) +constants_config.set('run_dir', run_dir) +constants_config.set('etc_dir', etc_dir) +constants_config.set('sbin_dir', sbin_dir) +constants_config.set('cache_dir', systemd_cache_dir) + +configure_file( + input: 'constants.py.in', + output: 'constants.py', + configuration: constants_config, +) diff --git a/python/meson.build b/python/meson.build deleted file mode 100644 index 38794daa..00000000 --- a/python/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# python -# SPDX-License-Identifier: GPL-3.0-or-later - -constants_config = configuration_data() -constants_config.set('version', meson.project_version()) -constants_config.set('user', user) -constants_config.set('group', group) -constants_config.set('run_dir', run_dir) -constants_config.set('etc_dir', etc_dir) -constants_config.set('sbin_dir', sbin_dir) -constants_config.set('cache_dir', systemd_cache_dir) - -configure_file( - input: 'constants.py.in', - output: 'constants.py', - configuration: constants_config, -) diff --git a/scripts/poe-tasks/check b/scripts/poe-tasks/check index 7acd65b7..8cae7fdc 100755 --- a/scripts/poe-tasks/check +++ b/scripts/poe-tasks/check @@ -71,7 +71,7 @@ echo # check python/knot_resolver/constants.py echo -e "${yellow}python/knot_resolver/constants.py${reset}" meson_setup_configure > /dev/null -diff python/knot_resolver/constants.py $build_dir/python/constants.py +diff python/knot_resolver/constants.py $build_dir/python/knot_resolver/constants.py check_rv $? echo diff --git a/scripts/poe-tasks/configure b/scripts/poe-tasks/configure index 8e4fff06..dc4aa074 100755 --- a/scripts/poe-tasks/configure +++ b/scripts/poe-tasks/configure @@ -10,5 +10,5 @@ echo echo ----------------------------------------------- echo Copying constants.py module configured by Meson echo ----------------------------------------------- -cp -v $build_dev_dir/python/constants.py $gitroot/python/knot_resolver/constants.py +cp -v $build_dev_dir/python/knot_resolver/constants.py $gitroot/python/knot_resolver/constants.py echo diff --git a/scripts/poe-tasks/doc-schema b/scripts/poe-tasks/doc-schema index ff7dea46..33ea3bd6 100755 --- a/scripts/poe-tasks/doc-schema +++ b/scripts/poe-tasks/doc-schema @@ -7,7 +7,7 @@ source $src_dir/utils/_env.sh schema_file="$gitroot/doc/_static/config.schema.json" meson_setup_configure > /dev/null -cp $build_dir/python/constants.py $gitroot/python/knot_resolver/constants.py +cp $build_dir/python/knot_resolver/constants.py $gitroot/python/knot_resolver/constants.py python -m knot_resolver.client schema > $schema_file echo New configuration JSON schem saved to $schema_file \ No newline at end of file diff --git a/scripts/poe-tasks/gen-constantspy b/scripts/poe-tasks/gen-constantspy index f71f1577..0f3bb3b6 100755 --- a/scripts/poe-tasks/gen-constantspy +++ b/scripts/poe-tasks/gen-constantspy @@ -10,5 +10,5 @@ echo echo ----------------------------------------------- echo Copying constants.py module configured by Meson echo ----------------------------------------------- -cp -v $build_dir/python/constants.py $gitroot/python/knot_resolver/constants.py +cp -v $build_dir/python/knot_resolver/constants.py $gitroot/python/knot_resolver/constants.py echo \ No newline at end of file -- cgit v1.2.3