From 1ec5492f189b694ed3b62db94aeee68f714a6244 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 22 Sep 2025 11:43:11 +0200 Subject: [PATCH] dnsdist: Update the Rust library version when generating a tarball Signed-off-by: Remi Gacogne --- .../helpers/update-rust-library-version.py | 32 +++++++++++++++++++ pdns/dnsdistdist/meson-dist-script.sh | 2 ++ 2 files changed, 34 insertions(+) create mode 100755 builder-support/helpers/update-rust-library-version.py diff --git a/builder-support/helpers/update-rust-library-version.py b/builder-support/helpers/update-rust-library-version.py new file mode 100755 index 000000000..0cd054b8a --- /dev/null +++ b/builder-support/helpers/update-rust-library-version.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +"""Update the Rust library version in the Cargo.toml file to keep it in sync with the product version.""" + +import shutil +import sys +import tempfile + +def main(): + if len(sys.argv) != 4: + print(f'Usage: {sys.argv[0]} ') + sys.exit(1) + + file_name = sys.argv[1] + package_name = sys.argv[2] + version = sys.argv[3] + + with tempfile.NamedTemporaryFile(mode='w+t', encoding='utf-8', delete=False) as generated_fp: + with open(file_name, "r") as cargo_file: + in_dnsdist_rust_package_section = False + for line in cargo_file: + if line.startswith('['): + in_dnsdist_rust_package_section = False + elif line == f'name = "{package_name}"\n': + in_dnsdist_rust_package_section = True + elif in_dnsdist_rust_package_section and line.startswith("version ="): + generated_fp.write(f"version = \"{version}\"\n") + continue + generated_fp.write(line) + shutil.move(generated_fp.name, file_name) + +if __name__ == '__main__': + main() diff --git a/pdns/dnsdistdist/meson-dist-script.sh b/pdns/dnsdistdist/meson-dist-script.sh index b379bb6b7..0f43316bb 100755 --- a/pdns/dnsdistdist/meson-dist-script.sh +++ b/pdns/dnsdistdist/meson-dist-script.sh @@ -25,6 +25,8 @@ echo Running autoreconf -vi so distfile is still usable for autotools building # Run autoconf for people using autotools to build, this creates a configure sc autoreconf -vi rm -rf "$MESON_PROJECT_DIST_ROOT"/autom4te.cache +echo Updating the version of the Rust library to ${BUILDER_VERSION} +"$MESON_SOURCE_ROOT"/../../builder-support/helpers/update-rust-library-version.py "$MESON_PROJECT_DIST_ROOT"/dnsdist-rust-lib/rust/Cargo.toml dnsdist-rust ${BUILDER_VERSION} cd "$MESON_PROJECT_BUILD_ROOT" -- 2.47.3