Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e605402

Browse filesBrowse files
marco-ippolitoMoLow
authored andcommitted
tools: automate zlib update
PR-URL: #47417 Refs: nodejs/security-wg#828 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent e97eefa commit e605402
Copy full SHA for e605402

File tree

Expand file treeCollapse file tree

2 files changed

+72
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+72
-0
lines changed
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ jobs:
200200
cat temp-output
201201
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
202202
rm temp-output
203+
- id: zlib
204+
subsystem: deps
205+
label: dependencies
206+
run: |
207+
./tools/dep_updaters/update-zlib.sh > temp-output
208+
cat temp-output
209+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
210+
rm temp-output
203211
steps:
204212
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
205213
with:
Collapse file

‎tools/dep_updaters/update-zlib.sh‎

Copy file name to clipboard
+64Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update zlib in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
8+
CURRENT_VERSION=$(grep "#define ZLIB_VERSION" "$DEPS_DIR/zlib/zlib.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
9+
10+
NEW_VERSION_ZLIB_H=$(curl -s "https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib/zlib.h?format=TEXT" | base64 --decode)
11+
12+
NEW_VERSION=$(printf '%s' "$NEW_VERSION_ZLIB_H" | grep "#define ZLIB_VERSION" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
13+
14+
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
15+
16+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
17+
echo "Skipped because zlib is on the latest version."
18+
exit 0
19+
fi
20+
21+
echo "Making temporary workspace..."
22+
23+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
24+
25+
cd "$WORKSPACE"
26+
27+
mkdir zlib
28+
29+
ZLIB_TARBALL=zlib.tar.gz
30+
31+
echo "Fetching zlib source archive"
32+
curl -sL -o $ZLIB_TARBALL https://chromium.googlesource.com/chromium/src/+archive/refs/heads/main/third_party/$ZLIB_TARBALL
33+
34+
gzip -dc "$ZLIB_TARBALL" | tar xf - -C zlib/
35+
36+
rm "$ZLIB_TARBALL"
37+
38+
cp "$DEPS_DIR/zlib/zlib.gyp" "$DEPS_DIR/zlib/GN-scraper.py" "$DEPS_DIR/zlib/win32/zlib.def" "$DEPS_DIR"
39+
40+
rm -rf "$DEPS_DIR/zlib" zlib/.git
41+
42+
mv zlib "$DEPS_DIR/"
43+
44+
mv "$DEPS_DIR/zlib.gyp" "$DEPS_DIR/GN-scraper.py" "$DEPS_DIR/zlib/"
45+
46+
mkdir "$DEPS_DIR/zlib/win32"
47+
48+
mv "$DEPS_DIR/zlib.def" "$DEPS_DIR/zlib/win32"
49+
50+
perl -i -pe 's|^#include "chromeconf.h"|//#include "chromeconf.h"|' deps/zlib/zconf.h
51+
52+
echo "All done!"
53+
echo ""
54+
echo "Make sure to update the deps/zlib/zlib.gyp if any significant changes have occurred upstream"
55+
echo ""
56+
echo "Please git add zlib, commit the new version:"
57+
echo ""
58+
echo "$ git add -A deps/zlib"
59+
echo "$ git commit -m \"deps: update zlib to $NEW_VERSION\""
60+
echo ""
61+
62+
# The last line of the script should always print the new version,
63+
# as we need to add it to $GITHUB_ENV variable.
64+
echo "NEW_VERSION=$NEW_VERSION"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.