]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Update the Rust library version when generating a tarball
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 22 Sep 2025 09:43:11 +0000 (11:43 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 23 Sep 2025 09:28:40 +0000 (11:28 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
builder-support/helpers/update-rust-library-version.py [new file with mode: 0755]
pdns/dnsdistdist/meson-dist-script.sh

diff --git a/builder-support/helpers/update-rust-library-version.py b/builder-support/helpers/update-rust-library-version.py
new file mode 100755 (executable)
index 0000000..0cd054b
--- /dev/null
@@ -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]} <path/to/Cargo.toml> <package name> <version to set>')
+        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()
index b379bb6b792426e4c27738db0131ad213c6e38ed..0f43316bb9cd68efc4173c2f74e1bd7bc78efd2a 100755 (executable)
@@ -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"