From 9b72f5d580251add3d1bd90d23ae7d554a91afdd Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Thu, 14 Mar 2024 16:48:20 +0100 Subject: [PATCH 1/2] tools: allow local updates for llhttp --- tools/dep_updaters/update-llhttp.sh | 41 ++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tools/dep_updaters/update-llhttp.sh b/tools/dep_updaters/update-llhttp.sh index 739819e1a45b69..cce19f309370e7 100755 --- a/tools/dep_updaters/update-llhttp.sh +++ b/tools/dep_updaters/update-llhttp.sh @@ -12,18 +12,23 @@ DEPS_DIR="${BASE_DIR}/deps" # shellcheck disable=SC1091 . "$BASE_DIR/tools/dep_updaters/utils.sh" -NEW_VERSION="$("$NODE" --input-type=module <<'EOF' -const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest', - process.env.GITHUB_TOKEN && { - headers: { - "Authorization": `Bearer ${process.env.GITHUB_TOKEN}` - }, - }); -if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res }); -const { tag_name } = await res.json(); -console.log(tag_name.replace('release/v', '')); +if test -e $LOCAL_COPY; then + NEW_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$LOCAL_COPY/package.json', 'utf-8')).version)") + echo $NEW_VERSION +else + NEW_VERSION="$("$NODE" --input-type=module <<'EOF' + const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest', + process.env.GITHUB_TOKEN && { + headers: { + "Authorization": `Bearer ${process.env.GITHUB_TOKEN}` + }, + }); + if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res }); + const { tag_name } = await res.json(); + console.log(tag_name.replace('release/v', '')); EOF )" +fi CURRENT_MAJOR_VERSION=$(grep "#define LLHTTP_VERSION_MAJOR" ./deps/llhttp/include/llhttp.h | sed -n "s/^.*MAJOR \(.*\)/\1/p") CURRENT_MINOR_VERSION=$(grep "#define LLHTTP_VERSION_MINOR" ./deps/llhttp/include/llhttp.h | sed -n "s/^.*MINOR \(.*\)/\1/p") @@ -48,7 +53,19 @@ cd "$WORKSPACE" echo "Replacing existing llhttp (except GYP and GN build files)" mv "$DEPS_DIR/llhttp/"*.gn "$DEPS_DIR/llhttp/"*.gni "$WORKSPACE/" -if echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release +if test -n "$LOCAL_COPY"; then + echo "Copying llhttp release from $LOCAL_COPY ..." + + echo "Building llhttp ..." + cd $BASE_DIR + cd $LOCAL_COPY + npm install + RELEASE=$NEW_VERSION make release + + echo "Copying llhttp release ..." + rm -rf "$DEPS_DIR/llhttp" + cp -a release "$DEPS_DIR/llhttp" +elif echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release REPO="git@github.com:$NEW_VERSION.git" BRANCH=$2 [ -z "$BRANCH" ] && BRANCH=main @@ -61,7 +78,7 @@ if echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release echo "Building llhttp ..." npm install - make release + RELEASE=$NEW_VERSION make release echo "Copying llhttp release ..." rm -rf "$DEPS_DIR/llhttp" From c08c98b4692de92a23940da0e0f731dbe8cbbe1d Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Fri, 15 Mar 2024 08:18:57 +0100 Subject: [PATCH 2/2] tools: linted code --- tools/dep_updaters/update-llhttp.sh | 9 ++++----- tools/dep_updaters/update-openssl.sh | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/dep_updaters/update-llhttp.sh b/tools/dep_updaters/update-llhttp.sh index cce19f309370e7..2f53b0957f46a5 100755 --- a/tools/dep_updaters/update-llhttp.sh +++ b/tools/dep_updaters/update-llhttp.sh @@ -12,9 +12,8 @@ DEPS_DIR="${BASE_DIR}/deps" # shellcheck disable=SC1091 . "$BASE_DIR/tools/dep_updaters/utils.sh" -if test -e $LOCAL_COPY; then +if [ -n "$LOCAL_COPY" ]; then NEW_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$LOCAL_COPY/package.json', 'utf-8')).version)") - echo $NEW_VERSION else NEW_VERSION="$("$NODE" --input-type=module <<'EOF' const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest', @@ -53,12 +52,12 @@ cd "$WORKSPACE" echo "Replacing existing llhttp (except GYP and GN build files)" mv "$DEPS_DIR/llhttp/"*.gn "$DEPS_DIR/llhttp/"*.gni "$WORKSPACE/" -if test -n "$LOCAL_COPY"; then +if [ -n "$LOCAL_COPY" ]; then echo "Copying llhttp release from $LOCAL_COPY ..." echo "Building llhttp ..." - cd $BASE_DIR - cd $LOCAL_COPY + cd "$BASE_DIR" + cd "$LOCAL_COPY" npm install RELEASE=$NEW_VERSION make release diff --git a/tools/dep_updaters/update-openssl.sh b/tools/dep_updaters/update-openssl.sh index 1437e9e8b940bd..1cb1d04b5f4ecf 100755 --- a/tools/dep_updaters/update-openssl.sh +++ b/tools/dep_updaters/update-openssl.sh @@ -120,6 +120,8 @@ main() { * ) echo "unknown command: $1" help 1 + + # shellcheck disable=SC2317 exit 1 ;; esac