From d5a5f12d156057abf2619810e14ac88ad9618b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 29 Dec 2023 16:10:58 +0100 Subject: [PATCH] tools: fix dep_updaters dir updates Replace directories instead of just copying to take removed files into account. PR-URL: https://github.com/nodejs/node/pull/51294 Reviewed-By: Luigi Pinca Reviewed-By: Marco Ippolito Reviewed-By: Rafael Gonzaga Reviewed-By: Benjamin Gruenbaum --- tools/dep_updaters/update-c-ares.sh | 3 +-- tools/dep_updaters/update-nghttp3.sh | 2 +- tools/dep_updaters/update-ngtcp2.sh | 5 ++--- tools/dep_updaters/update-uvwasi.sh | 4 ++-- tools/dep_updaters/utils.sh | 8 ++++++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/dep_updaters/update-c-ares.sh b/tools/dep_updaters/update-c-ares.sh index 5081a74545dbf2..bf20f5b25f9c7d 100755 --- a/tools/dep_updaters/update-c-ares.sh +++ b/tools/dep_updaters/update-c-ares.sh @@ -63,8 +63,7 @@ cp "$DEPS_DIR/cares/cares.gyp" "$WORKSPACE/cares" cp "$DEPS_DIR/cares/"*.gn "$DEPS_DIR/cares/"*.gni "$WORKSPACE/cares" echo "Replacing existing c-ares" -rm -rf "$DEPS_DIR/cares" -mv "$WORKSPACE/cares" "$DEPS_DIR/" +replace_dir "$DEPS_DIR/cares" "$WORKSPACE/cares" # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need diff --git a/tools/dep_updaters/update-nghttp3.sh b/tools/dep_updaters/update-nghttp3.sh index 539ee27a76012b..50a17e32f8a291 100755 --- a/tools/dep_updaters/update-nghttp3.sh +++ b/tools/dep_updaters/update-nghttp3.sh @@ -59,7 +59,7 @@ autoreconf -i ./configure --prefix="$PWD/build" --enable-lib-only -cp -R lib/* "$DEPS_DIR/ngtcp2/nghttp3/lib/" +replace_dir "$DEPS_DIR/ngtcp2/nghttp3/lib" "lib" # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need diff --git a/tools/dep_updaters/update-ngtcp2.sh b/tools/dep_updaters/update-ngtcp2.sh index a77be7efa8558f..b892ecbab2c864 100755 --- a/tools/dep_updaters/update-ngtcp2.sh +++ b/tools/dep_updaters/update-ngtcp2.sh @@ -63,9 +63,8 @@ autoreconf -i ./configure --prefix="$PWD/build" --enable-lib-only -cp -R lib/* "$DEPS_DIR/ngtcp2/ngtcp2/lib/" - -cp -R crypto/* "$DEPS_DIR/ngtcp2/ngtcp2/crypto/" +replace_dir "$DEPS_DIR/ngtcp2/ngtcp2/lib" "lib" +replace_dir "$DEPS_DIR/ngtcp2/ngtcp2/crypto" "crypto" # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need diff --git a/tools/dep_updaters/update-uvwasi.sh b/tools/dep_updaters/update-uvwasi.sh index 8b4070cb336565..9b9991656bf425 100755 --- a/tools/dep_updaters/update-uvwasi.sh +++ b/tools/dep_updaters/update-uvwasi.sh @@ -68,8 +68,8 @@ mv "$WORKSPACE/"*.gyp "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/uvwasi/" cd "$DEPS_DIR/uvwasi/" echo "Copying new files to deps folder" -cp -r "$UVWASI_ZIP/include" "$DEPS_DIR/uvwasi/" -cp -r "$UVWASI_ZIP/src" "$DEPS_DIR/uvwasi/" +replace_dir "$DEPS_DIR/uvwasi/include" "$UVWASI_ZIP/include" +replace_dir "$DEPS_DIR/uvwasi/src" "$UVWASI_ZIP/src" cp "$UVWASI_ZIP/LICENSE" "$DEPS_DIR/uvwasi/" rm -rf "$UVWASI_ZIP" diff --git a/tools/dep_updaters/utils.sh b/tools/dep_updaters/utils.sh index 8c86b772c96571..774da85aafc303 100644 --- a/tools/dep_updaters/utils.sh +++ b/tools/dep_updaters/utils.sh @@ -77,3 +77,11 @@ log_and_verify_sha256sum() { fi fi } + +# This function replaces the directory of a dependency with the new one. +replace_dir() { + old_dir="$1" + new_dir="$2" + rm -rf "$old_dir" + mv "$new_dir" "$old_dir" +}