11cb0ef41Sopenharmony_ci#!/bin/sh 21cb0ef41Sopenharmony_ciset -e 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci# Shell script to update llhttp in the source tree to specific version 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciBASE_DIR=$(cd "$(dirname "$0")/.." && pwd) 71cb0ef41Sopenharmony_ciDEPS_DIR="${BASE_DIR}/deps" 81cb0ef41Sopenharmony_ciLLHTTP_VERSION="$1" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif [ "$#" -le 0 ]; then 111cb0ef41Sopenharmony_ci echo "Error: Please provide an llhttp version to update to." 121cb0ef41Sopenharmony_ci echo "Error: To download directly from GitHub, use the organization/repository syntax, without the .git suffix." 131cb0ef41Sopenharmony_ci exit 1 141cb0ef41Sopenharmony_cifi 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cicleanup () { 171cb0ef41Sopenharmony_ci EXIT_CODE=$? 181cb0ef41Sopenharmony_ci [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" 191cb0ef41Sopenharmony_ci exit $EXIT_CODE 201cb0ef41Sopenharmony_ci} 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciecho "Making temporary workspace ..." 231cb0ef41Sopenharmony_ciWORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') 241cb0ef41Sopenharmony_citrap cleanup INT TERM EXIT 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cicd "$WORKSPACE" 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciif echo "$LLHTTP_VERSION" | grep -qs "/" ; then # Download a release 291cb0ef41Sopenharmony_ci REPO="git@github.com:$LLHTTP_VERSION.git" 301cb0ef41Sopenharmony_ci BRANCH=$2 311cb0ef41Sopenharmony_ci [ -z "$BRANCH" ] && BRANCH=main 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci echo "Cloning llhttp source archive $REPO ..." 341cb0ef41Sopenharmony_ci git clone "$REPO" llhttp 351cb0ef41Sopenharmony_ci cd llhttp 361cb0ef41Sopenharmony_ci echo "Checking out branch $BRANCH ..." 371cb0ef41Sopenharmony_ci git checkout "$BRANCH" 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci echo "Building llhtttp ..." 401cb0ef41Sopenharmony_ci npm install 411cb0ef41Sopenharmony_ci make release 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci echo "Copying llhtttp release ..." 441cb0ef41Sopenharmony_ci rm -rf "$DEPS_DIR/llhttp" 451cb0ef41Sopenharmony_ci cp -a release "$DEPS_DIR/llhttp" 461cb0ef41Sopenharmony_cielse 471cb0ef41Sopenharmony_ci echo "Download llhttp release $LLHTTP_VERSION ..." 481cb0ef41Sopenharmony_ci curl -sL -o llhttp.tar.gz "https://github.com/nodejs/llhttp/archive/refs/tags/release/v$LLHTTP_VERSION.tar.gz" 491cb0ef41Sopenharmony_ci gzip -dc llhttp.tar.gz | tar xf - 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci echo "Copying llhtttp release ..." 521cb0ef41Sopenharmony_ci rm -rf "$DEPS_DIR/llhttp" 531cb0ef41Sopenharmony_ci cp -a "llhttp-release-v$LLHTTP_VERSION" "$DEPS_DIR/llhttp" 541cb0ef41Sopenharmony_cifi 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ciecho "" 571cb0ef41Sopenharmony_ciecho "All done!" 581cb0ef41Sopenharmony_ciecho "" 591cb0ef41Sopenharmony_ciecho "Please git add llhttp, commit the new version:" 601cb0ef41Sopenharmony_ciecho "" 611cb0ef41Sopenharmony_ciecho "$ git add -A deps/llhttp" 621cb0ef41Sopenharmony_ciecho "$ git commit -m \"deps: update llhttp to $LLHTTP_VERSION\"" 631cb0ef41Sopenharmony_ciecho "" 64