• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2set -e
3
4# Shell script to update llhttp in the source tree to specific version
5
6BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
7DEPS_DIR="${BASE_DIR}/deps"
8LLHTTP_VERSION="$1"
9
10if [ "$#" -le 0 ]; then
11  echo "Error: Please provide an llhttp version to update to."
12  echo "Error: To download directly from GitHub, use the organization/repository syntax, without the .git suffix."
13  exit 1
14fi
15
16cleanup () {
17  EXIT_CODE=$?
18  [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
19  exit $EXIT_CODE
20}
21
22echo "Making temporary workspace ..."
23WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
24trap cleanup INT TERM EXIT
25
26cd "$WORKSPACE"
27
28if echo "$LLHTTP_VERSION" | grep -qs "/" ; then # Download a release
29  REPO="git@github.com:$LLHTTP_VERSION.git"
30  BRANCH=$2
31  [ -z "$BRANCH" ] && BRANCH=main
32
33  echo "Cloning llhttp source archive $REPO ..."
34  git clone "$REPO" llhttp
35  cd llhttp
36  echo "Checking out branch $BRANCH ..."
37  git checkout "$BRANCH"
38
39  echo "Building llhtttp ..."
40  npm install
41  make release
42
43  echo "Copying llhtttp release ..."
44  rm -rf "$DEPS_DIR/llhttp"
45  cp -a release "$DEPS_DIR/llhttp"
46else
47  echo "Download llhttp release $LLHTTP_VERSION ..."
48  curl -sL -o llhttp.tar.gz "https://github.com/nodejs/llhttp/archive/refs/tags/release/v$LLHTTP_VERSION.tar.gz"
49  gzip -dc llhttp.tar.gz | tar xf -
50
51  echo "Copying llhtttp release ..."
52  rm -rf "$DEPS_DIR/llhttp"
53  cp -a "llhttp-release-v$LLHTTP_VERSION" "$DEPS_DIR/llhttp"
54fi
55
56echo ""
57echo "All done!"
58echo ""
59echo "Please git add llhttp, commit the new version:"
60echo ""
61echo "$ git add -A deps/llhttp"
62echo "$ git commit -m \"deps: update llhttp to $LLHTTP_VERSION\""
63echo ""
64