From 733afbc04bb546c308eb36f4be8589f6afa33cc8 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Thu, 17 Sep 2026 04:47:05 +0300 Subject: [PATCH] Add a patch backport script --- plugins/python-build/scripts/backport.sh | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/python-build/scripts/backport.sh diff --git a/plugins/python-build/scripts/backport.sh b/plugins/python-build/scripts/backport.sh new file mode 100644 index 00000000..c3159a74 --- /dev/null +++ b/plugins/python-build/scripts/backport.sh @@ -0,0 +1,27 @@ +# source this in Bash +# cd to git repo of CPython + +_python_build_dir=$(cd "${BASH_SOURCE%/*}/.."; pwd -P) + +backport() { + [[ $# -lt 2 ]] && { echo "usage: $FUNCNAME ..." >&2; return 1; } + + (set -euxo pipefail + sha="${1:?}" + shift + for b; do + git checkout "Branch_v$b" || git checkout -b "Branch_v$b" "v$b" + git cherry-pick "$sha" + git format-patch -1 + patch_dir="$_python_build_dir/share/python-build/$b/Python-$b" + shopt -s nullglob + pp=("$patch_dir"/*.patch) + patch_offset=${#pp[@]} + shopt -u nullglob + unset pp + mkdir -p "$patch_dir" + for f in *.patch; do + mv "$f" "$patch_dir/$(printf '%04d' $((${f::4}+patch_offset)))${f:4}" + done + done) +} \ No newline at end of file