From 54cda2256e2e36779b1d7fa45e76c95a65578ded Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sun, 7 Jan 2024 15:39:22 +0000 Subject: [PATCH] tools: fix version parsing in brotli update script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update `tools/dep_updaters/update-brotli.sh` to parse the current version of brotli from the newer macros `BROTLI_VERSION_MAJOR`, `BROTLI_VERSION_MINOR` and `BROTLI_VERSION_PATCH`. PR-URL: https://github.com/nodejs/node/pull/51373 Refs: https://github.com/nodejs/node/pull/50804 Refs: https://github.com/nodejs/security-wg/issues/1181 Reviewed-By: Marco Ippolito Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso --- tools/dep_updaters/update-brotli.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/dep_updaters/update-brotli.sh b/tools/dep_updaters/update-brotli.sh index 90b65ed31a284b..41defd7795b66b 100755 --- a/tools/dep_updaters/update-brotli.sh +++ b/tools/dep_updaters/update-brotli.sh @@ -24,12 +24,10 @@ console.log(tag_name.replace('v', '')); EOF )" -VERSION_HEX=$(grep "#define BROTLI_VERSION" ./deps/brotli/c/common/version.h | sed 's/.* //') - -major=$(( ($VERSION_HEX >> 24) & 0xff )) -minor=$(( ($VERSION_HEX >> 12) & 0xfff )) -patch=$(( $VERSION_HEX & 0xfff )) -CURRENT_VERSION="${major}.${minor}.${patch}" +CURRENT_MAJOR_VERSION=$(grep "#define BROTLI_VERSION_MAJOR" ./deps/brotli/c/common/version.h | sed -n "s/^.*MAJOR \(.*\)/\1/p") +CURRENT_MINOR_VERSION=$(grep "#define BROTLI_VERSION_MINOR" ./deps/brotli/c/common/version.h | sed -n "s/^.*MINOR \(.*\)/\1/p") +CURRENT_PATCH_VERSION=$(grep "#define BROTLI_VERSION_PATCH" ./deps/brotli/c/common/version.h | sed -n "s/^.*PATCH \(.*\)/\1/p") +CURRENT_VERSION="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_PATCH_VERSION" # This function exit with 0 if new version and current version are the same compare_dependency_version "brotli" "$NEW_VERSION" "$CURRENT_VERSION"