Johannes Schindelin 36daff5336 msys2-runtime-3.4(update-patches.sh): do generate stable checksums for the Cygwin code
As of v6.1.0, Pacman no longer generates `SKIP` as SHA-256 checksums for
Git repositories, as per the release notes at
https://gitlab.archlinux.org/pacman/pacman/-/blob/v6.1.0/NEWS?ref_type=tags#L21:

> - Add checksum support for git/mercurial/bzr sources

Instead of outputting `SKIP`, Pacman now runs `git -c core.abbrev=no
archive --format tar <branch-or-tag> | sha256sum` and uses the result:
2fc2ab6cf0

Unfortunately, the output of `git archive` is not stable. For one, the
`core.autoCRLF` setting (which defaults to `true` in Git for Windows)
affects the result.

Let's ensure that that `core.autoCRLF` setting is forced to `false`,
with the idea to add other settings as required.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2024-07-08 14:57:16 +02:00

92 lines
2.6 KiB
Bash
Executable File

#!/bin/sh
die () {
echo "$*" >&2
exit 1
}
cd "$(dirname "$0")" ||
die "Could not cd to msys2-runtime/"
git rev-parse --verify HEAD >/dev/null &&
git update-index -q --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules &&
git diff-index --cached --quiet --ignore-submodules HEAD -- ||
die "Clean worktree required"
git rm 0*.patch ||
die "Could not remove previous patches"
base_tag=refs/tags/cygwin-"$(sed -ne 's/^pkgver=//p' <PKGBUILD)"
msys2_branch=refs/heads/msys2-${base_tag#refs/tags/cygwin-}
url=https://github.com/msys2/msys2-runtime
test -d msys2-runtime || {
git clone --bare $url msys2-runtime &&
git --git-dir=msys2-runtime config remote.origin.url git://sourceware.org/git/newlib-cygwin.git # required by PKGBUILD
} ||
die "Could not clone msys2-runtime"
git -C msys2-runtime fetch --no-tags $url $base_tag:$base_tag $msys2_branch:$msys2_branch
git -c core.abbrev=7 \
-c diff.renames=true \
-c format.from=false \
-c format.numbered=auto \
-c format.useAutoBase=false \
-C msys2-runtime \
format-patch \
--no-signature \
--topo-order \
--diff-algorithm=default \
--no-attach \
--no-add-header \
--no-cover-letter \
--no-thread \
--suffix=.patch \
--subject-prefix=PATCH \
--output-directory .. \
$base_tag..$msys2_branch \
-- ':(exclude).github/' ||
die "Could not generate new patch set"
patches="$(ls -1 0*.patch)" &&
for p in $patches
do
sed -i 's/^\(Subject: \[PATCH [0-9]*\/\)[1-9][0-9]*/\1N/' $p ||
die "Could not fix Subject: line in $p"
done &&
git add $patches ||
die "Could not stage new patch set"
in_sources="$(echo "$patches" | sed "{s/^/ /;:1;N;s/\\n/\\\\n /;b1}")"
in_prepare="$(echo "$patches" | tr '\n' '\\' | sed -e 's/\\$//' -e 's/\\/ &&&n /g')"
sed -i -e "/^ 0.*\.patch$/{:1;N;/[^)]$/b1;s|.*|$in_sources)|}" \
-e "/^ *apply_git_am_with_msg /{:2;N;/[^}]$/b2;s|.*| apply_git_am_with_msg $in_prepare\\n\\}|}" \
PKGBUILD ||
die "Could not update the patch set in PKGBUILD"
if git rev-parse --verify HEAD >/dev/null &&
git update-index -q --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules &&
git diff-index --cached --quiet --ignore-submodules HEAD --
then
echo "Already up to date!" >&2
exit 0
fi
GIT_CONFIG_PARAMETERS="${GIT_CONFIG_PARAMETERS+$GIT_CONFIG_PARAMETERS }'core.autocrlf=false'" \
updpkgsums ||
die "Could not update the patch set checksums in PKGBUILD"
# bump pkgrel
if ! git diff @{u} -- PKGBUILD | grep -q '^+pkgver'
then
pkgrel=$((1+$(sed -n -e 's/^pkgrel=//p' <PKGBUILD))) &&
sed -i -e "s/^\(pkgrel=\).*/\1$pkgrel/" PKGBUILD ||
die "Could not increment pkgrel"
fi
git add PKGBUILD ||
die "Could not stage updates in PKGBUILD"