-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: automate zlib update #47417
Merged
nodejs-github-bot
merged 1 commit into
nodejs:main
from
marco-ippolito:feat/automate-zlib-update
Apr 19, 2023
Merged
tools: automate zlib update #47417
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
set -e | ||
# Shell script to update zlib in the source tree to a specific version | ||
|
||
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) | ||
DEPS_DIR="$BASE_DIR/deps" | ||
|
||
CURRENT_VERSION=$(grep "#define ZLIB_VERSION" "$DEPS_DIR/zlib/zlib.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p") | ||
|
||
NEW_VERSION_ZLIB_H=$(curl -s "https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib/zlib.h?format=TEXT" | base64 --decode) | ||
|
||
NEW_VERSION=$(printf '%s' "$NEW_VERSION_ZLIB_H" | grep "#define ZLIB_VERSION" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p") | ||
|
||
echo "Comparing $NEW_VERSION with $CURRENT_VERSION" | ||
|
||
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then | ||
echo "Skipped because zlib is on the latest version." | ||
exit 0 | ||
fi | ||
|
||
echo "Making temporary workspace..." | ||
|
||
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') | ||
|
||
cd "$WORKSPACE" | ||
|
||
mkdir zlib | ||
|
||
ZLIB_TARBALL=zlib.tar.gz | ||
|
||
echo "Fetching zlib source archive" | ||
curl -sL -o $ZLIB_TARBALL https://chromium.googlesource.com/chromium/src/+archive/refs/heads/main/third_party/$ZLIB_TARBALL | ||
|
||
gzip -dc "$ZLIB_TARBALL" | tar xf - -C zlib/ | ||
|
||
rm "$ZLIB_TARBALL" | ||
|
||
cp "$DEPS_DIR/zlib/zlib.gyp" "$DEPS_DIR/zlib/GN-scraper.py" "$DEPS_DIR/zlib/win32/zlib.def" "$DEPS_DIR" | ||
|
||
rm -rf "$DEPS_DIR/zlib" zlib/.git | ||
|
||
mv zlib "$DEPS_DIR/" | ||
|
||
mv "$DEPS_DIR/zlib.gyp" "$DEPS_DIR/GN-scraper.py" "$DEPS_DIR/zlib/" | ||
|
||
mkdir "$DEPS_DIR/zlib/win32" | ||
|
||
mv "$DEPS_DIR/zlib.def" "$DEPS_DIR/zlib/win32" | ||
|
||
perl -i -pe 's|^#include "chromeconf.h"|//#include "chromeconf.h"|' deps/zlib/zconf.h | ||
|
||
echo "All done!" | ||
echo "" | ||
echo "Make sure to update the deps/zlib/zlib.gyp if any significant changes have occurred upstream" | ||
echo "" | ||
echo "Please git add zlib, commit the new version:" | ||
echo "" | ||
echo "$ git add -A deps/zlib" | ||
echo "$ git commit -m \"deps: update zlib to $NEW_VERSION\"" | ||
echo "" | ||
|
||
# The last line of the script should always print the new version, | ||
# as we need to add it to $GITHUB_ENV variable. | ||
echo "NEW_VERSION=$NEW_VERSION" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but it might remain the same for a very long time. It is not very useful. We refer to the tip of the remote main branch to check if an update is needed. However, afaik, we store the current commit SHA only in the commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent found any other solution to check what's the latest version, I think this might be a reasonable compromise and its not very expensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine but it probably won't find a new version for years. See https://github.com/madler/zlib/tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpinca are you saying that we typically update to something that is not a new release? If so then an option in the script/action to say generate PR based on commit X instead of a new version might make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably change it in the future to something like @tniessen did in this PR #47482