tools: fix version parsing in brotli update script

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 <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Richard Lau 2024-01-07 15:39:22 +00:00 committed by GitHub
parent 05f8172188
commit 15b38fa2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"