File 2231-erts-Improve-ryu-update-script.patch of Package erlang
From 039385032e5fa6632249af00ec9f3df6a3b05140 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 9 Feb 2026 18:44:52 +0100
Subject: [PATCH 1/2] erts: Improve ryu update script
---
erts/emulator/ryu/update.sh | 105 ++++++++++++++++++++++++++++--------
1 file changed, 82 insertions(+), 23 deletions(-)
diff --git a/erts/emulator/ryu/update.sh b/erts/emulator/ryu/update.sh
index 2c23a8bd90..99b647878a 100755
--- a/erts/emulator/ryu/update.sh
+++ b/erts/emulator/ryu/update.sh
@@ -22,40 +22,81 @@
GITHUB_TOKEN=${GITHUB_TOKEN:-$(cat ~/.githubtoken)}
-if [ -z "${GITHUB_TOKEN}"]; then
+if [ -z "${GITHUB_TOKEN}" ]; then
echo "You need to set ${GITHUB_TOKEN} to a valid github token"
exit 1
fi
-ORIGIN_REPO="https://github.com/erlang/ryu"
+ORIGIN_REPO="git@github.com:erlang/ryu.git"
UPSTREAM_REPO="https://github.com/ulfjack/ryu"
cd $ERL_TOP/erts/emulator/ryu
-set -exo pipefail
+if [ -d ryu-repo ]; then
+ cd ryu-repo
+ if ! git diff --exit-code HEAD; then
+ cat <<EOF
+#######################################################################
+
+There are uncommited changes in the ryu-repo repo.
+
+Either commit the changes to continue
+or remove the ryu-repo directory to start over.
+
+Then run this script again.
+
+EOF
+ exit 1
+ else
+ cat <<EOF
+#######################################################################
+
+There already is a ryu-repo directory.
+
+EOF
+ read -n1 -p "Do you want to continue using that repo? (y/n): " yn
+
+ if [[ ! $yn =~ ^[Yy]$ ]]; then
+ cat <<EOF
+
+Remove the repo ryu-repo to start over again.
-## Clone reference
-git clone ${ORIGIN_REPO} ryu-copy
+EOF
+ exit 1
+ fi
+ fi
+ # Continue with existing repo. The merge below should succeed
+ # with "Already done" if conflicts has been solved.
-## into ryu-copy
-cd ryu-copy
-git remote add upstream ${UPSTREAM_REPO}
-git fetch upstream
+else
+ ## Clone reference
+ git clone ${ORIGIN_REPO} ryu-repo
-SHA=$(git rev-parse --verify upstream/master)
-SHORT_SHA=$(git rev-parse --verify --short upstream/master)
+ ## into ryu-repo
+ cd ryu-repo
+ git remote add upstream ${UPSTREAM_REPO}
+ git fetch upstream
+fi
+
+set -exo pipefail
+
+RYU_SHA=$(git rev-parse --verify upstream/master)
+RYU_SHORT_SHA=$(git rev-parse --verify --short upstream/master)
if ! git merge upstream/master; then
git status --short | grep "^D" | awk '{print $2}' | xargs git rm -rf
git status --short | grep "^A" | awk '{print $2}' | xargs git rm -rf
if ! git commit; then
- cat <<EOF
+ cat <<EOF
#######################################################################
-Merge of ${SHORT_SHA} to $(git rev-parse --short master) failed, resolve and commit the conflict in
-$(pwd) and push to ${ORIGIN_REPO}.
+Merge of ${RYU_SHORT_SHA} to $(git rev-parse --short master) failed,
+resolve and commit the conflict in $(pwd)
+
+Then run this script again to continue.
+
EOF
- exit 1
+ exit 1
fi
fi
@@ -64,7 +105,8 @@ cd .. ## back to ryu
## Fetch latest version of STL from github
STL_VSN=$(curl -sL -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/microsoft/STL/releases/latest | jq ".tag_name" | sed 's/"//g')
-git clone --filter=blob:none --no-checkout -b ${STL_VSN} https://github.com/microsoft/STL.git
+rm -rf STL
+git clone --filter=blob:none --no-checkout -b ${STL_VSN} https://github.com/microsoft/STL.git STL
cd STL ## into STL
git sparse-checkout init --cone
git sparse-checkout set stl/inc/xcharconv_ryu.h
@@ -80,12 +122,14 @@ if [ "$(cat xcharconv_ryu.h.sha)" != "${STL_CHARCONV_SHA}" ]; then
https://github.com/microsoft/STL/blob/master/stl/inc/xcharconv_ryu.h has been
updated. Check that no changes affect the __to_chars function and if they do
-incorporate them into to_chars.h.
+incorporate them into ryu-repo/to_chars.h.
Once done, update xcharconv_ryu.h.sha with the new sha. i.e.
echo "${STL_CHARCONV_SHA}" > ${ERL_TOP}/erts/emulator/ryu/xcharconv_ryu.h.sha
+Then run this script again to continue.
+
EOF
exit 1
@@ -94,17 +138,17 @@ fi
## Remove old files
shopt -s extglob
-git rm -rf $(ls -d !(update.sh|vendor.info|ryu.mk|obj|README.ryu_update.md|ryu-copy|STL|xcharconv_ryu.h.sha*))
+git rm -rf $(ls -d !(update.sh|vendor.info|ryu.mk|obj|README.ryu_update.md|ryu-repo|STL|xcharconv_ryu.h.sha*))
shopt -u extglob
-cp -r ryu-copy/* .
-rm -rf ryu-copy STL
+cp -r ryu-repo/* .
+rm -rf STL
set -x
## Update vendor info
COMMENTS=$(cat vendor.info | grep "^//")
-NEW_VENDOR_INFO=$(cat vendor.info | grep -v "^//" | jq "map(if .ID == \"erts-ryu\" then .versionInfo = \"${SHA}\" | .sha = \"${SHA}\" else . end)")
+NEW_VENDOR_INFO=$(cat vendor.info | grep -v "^//" | jq "map(if .ID == \"erts-ryu\" then .versionInfo = \"${RYU_SHA}\" | .sha = \"${RYU_SHA}\" else . end)")
NEW_VENDOR_INFO=$(echo "${NEW_VENDOR_INFO}" | jq "map(if .ID == \"ryu-to_chars\" then .versionInfo = \"${STL_VSN}\" | .sha = \"${STL_SHA}\" else . end)")
cat <<EOF > vendor.info
@@ -112,6 +156,21 @@ ${COMMENTS}
${NEW_VENDOR_INFO}
EOF
-git add .
+# Stage all except temp ryu repo dir
+git add . ':!ryu-repo'
+
+git commit -m "erts: Update ryu version to ${RYU_SHA}"
-git commit -m "erts: Update ryu version to ${SHA}"
\ No newline at end of file
+
+cat <<EOF
+#######################################################################
+All commits done.
+Verify it looks ok and then push result.
+
+Don't forget to push to ${ORIGIN_REPO} as well:
+ cd ryu-repo
+ gitk # or whatever to verify
+ git push origin master
+ cd ..
+ rm -rf ryu-repo
+EOF
--
2.51.0