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