Skip to content

Commit ec2cade

Browse files
richardlautargos
authored andcommitted
tools: add script to update c-ares
Add a script to automate updating of the c-ares dependency and accompanying maintenance guide. PR-URL: #40660 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent e374f3d commit ec2cade

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

doc/guides/maintaining-c-ares.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Maintaining c-ares
2+
3+
Updates to the c-ares dependency involve the following steps:
4+
5+
1. Downloading the source archive for the new version.
6+
2. Unpacking the source in a temporary workspace directory.
7+
3. Removing the `test` directory (to save disk space).
8+
4. Copying over the existing `.gitignore`, pre-generated `config` directory and
9+
`cares.gyp` files.
10+
5. Replacing the existing `deps/cares` with the workspace directory.
11+
6. Modifying the `cares.gyp` file for file additions/deletions.
12+
7. Rebuilding the main Node.js `LICENSE`.
13+
14+
## Running the update script
15+
16+
The `tools/update-cares.sh` script automates the update of the c-ares source
17+
files, preserving the existing files added by Node.js.
18+
19+
In the following examples, `x.y.z` should match the c-ares version to update to.
20+
21+
```console
22+
./tools/update-cares.sh x.y.z
23+
```
24+
25+
e.g.
26+
27+
```console
28+
./tools/update-cares.sh 1.18.1
29+
```
30+
31+
## Check that Node.js still builds and tests
32+
33+
It may be necessary to update `deps/cares/cares.gyp` if any significant changes
34+
have occurred upstream.
35+
36+
## Rebuild the main Node.js license
37+
38+
Run the `tools/license-builder.sh` script to rebuild the main Node.js `LICENSE`
39+
file. This may result in no changes if c-ares' license has not changed.
40+
41+
```console
42+
./tools/license-builder.sh
43+
```
44+
45+
If the updated `LICENSE` contains changes for other dependencies, those should
46+
be done in a separate pull request first.
47+
48+
## Commit the changes
49+
50+
```console
51+
git add -A deps/cares
52+
```
53+
54+
Add the rebuilt `LICENSE` if it has been updated.
55+
56+
```console
57+
git add LICENSE
58+
```
59+
60+
Commit the changes with a message like
61+
62+
```text
63+
deps: update c-ares to x.y.z
64+
65+
Updated as described in doc/guides/maintaining-c-ares.md.
66+
```

tools/update-cares.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update c-ares in the source tree to a specific version
4+
5+
BASE_DIR="$( pwd )"/
6+
DEPS_DIR="$BASE_DIR"deps/
7+
ARES_VERSION=$1
8+
9+
if [ "$#" -le 0 ]; then
10+
echo "Error: please provide an c-ares version to update to"
11+
echo " e.g. $0 1.18.1"
12+
exit 1
13+
fi
14+
15+
echo "Making temporary workspace"
16+
17+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
18+
19+
cleanup () {
20+
EXIT_CODE=$?
21+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
22+
exit $EXIT_CODE
23+
}
24+
25+
trap cleanup INT TERM EXIT
26+
27+
ARES_REF="cares-$(echo "$ARES_VERSION" | tr . _)"
28+
ARES_TARBALL="c-ares-$ARES_VERSION.tar.gz"
29+
30+
cd "$WORKSPACE"
31+
32+
echo "Fetching c-ares source archive"
33+
curl -sL -o "$ARES_TARBALL" "https://github.com/c-ares/c-ares/releases/download/$ARES_REF/$ARES_TARBALL"
34+
gzip -dc "$ARES_TARBALL" | tar xf -
35+
rm "$ARES_TARBALL"
36+
mv "c-ares-$ARES_VERSION" cares
37+
38+
echo "Removing tests"
39+
rm -rf "$WORKSPACE/cares/test"
40+
41+
echo "Copying existing .gitignore, config and gyp files"
42+
cp -R "$DEPS_DIR/cares/config" "$WORKSPACE/cares"
43+
cp "$DEPS_DIR/cares/.gitignore" "$WORKSPACE/cares"
44+
cp "$DEPS_DIR/cares/cares.gyp" "$WORKSPACE/cares"
45+
46+
echo "Replacing existing c-ares"
47+
rm -rf "$DEPS_DIR/cares"
48+
mv "$WORKSPACE/cares" "$DEPS_DIR/"
49+
50+
echo "All done!"
51+
echo ""
52+
echo "Please git add c-ares, commit the new version:"
53+
echo ""
54+
echo "$ git add -A deps/cares"
55+
echo "$ git commit -m \"deps: update c-ares to $ARES_VERSION\""
56+
echo ""

0 commit comments

Comments
 (0)