Skip to content

Commit

Permalink
tools: fix version parsing in brotli update script
Browse files Browse the repository at this point in the history
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: #51373
Refs: #50804
Refs: nodejs/security-wg#1181
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
richardlau authored Jan 7, 2024
1 parent 05f8172 commit 15b38fa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tools/dep_updaters/update-brotli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 15b38fa

Please sign in to comment.