From: Remi Gacogne Date: Mon, 22 Sep 2025 09:43:11 +0000 (+0200) Subject: dnsdist: Update the Rust library version when generating a tarball X-Git-Tag: rec-5.4.0-alpha1~258^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ec5492f189b694ed3b62db94aeee68f714a6244;p=thirdparty%2Fpdns.git dnsdist: Update the Rust library version when generating a tarball Signed-off-by: Remi Gacogne --- 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 0000000000..0cd054b8a3 --- /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 b379bb6b79..0f43316bb9 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"