Skip to content

Commit 2674087

Browse files
committed
tools: add script to update c-ares
Add a script to automate updating of the c-ares dependency and accompanying maintenance guide.
1 parent e937662 commit 2674087

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

doc/guides/maintaining-c-ares.md

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

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)