|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +die () { |
| 4 | + echo "$*" >&2 |
| 5 | + exit 1 |
| 6 | +} |
| 7 | + |
| 8 | +hex1='[0-9a-fA-F]' |
| 9 | +hex8="$hex1$hex1$hex1$hex1$hex1$hex1$hex1$hex1" |
| 10 | +hex40="$hex8$hex8$hex8$hex8$hex8" |
| 11 | +revision= |
| 12 | +title= |
| 13 | +set -x |
| 14 | +echo "$1" |
| 15 | +case "$1" in |
| 16 | +# 40 hexadecimal characters |
| 17 | +$hex40) revision=$1;; |
| 18 | +*) die "Usage: $0 <revision>";; |
| 19 | +esac |
| 20 | + |
| 21 | +case "$revision" in |
| 22 | +$hex40) ;; # okay |
| 23 | +*) die "Invalid revision: $revision";; |
| 24 | +esac |
| 25 | + |
| 26 | +# `updpkgsums` requires the bare clone `msys2-runtime` to exist |
| 27 | +git init --bare msys2-runtime && |
| 28 | +git --git-dir=msys2-runtime config remote.origin.url https://github.com/cygwin/cygwin && |
| 29 | +git --git-dir=msys2-runtime fetch --tags https://github.com/cygwin/cygwin && |
| 30 | + |
| 31 | +git clone --bare msys2-runtime src/msys2-runtime && |
| 32 | +git --git-dir=src/msys2-runtime config remote.origin.url https://github.com/git-for-windows/msys2-runtime && |
| 33 | +# pretend to be a partial clone |
| 34 | +git --git-dir=src/msys2-runtime config remote.origin.promisor true && |
| 35 | +git --git-dir=src/msys2-runtime config remote.origin.partialCloneFilter blob:none || |
| 36 | +die "Failed to initialize the src/msys2-runtime repository" |
| 37 | + |
| 38 | +git --git-dir=src/msys2-runtime reset --soft "$revision" && |
| 39 | +previous_commit="$(cat msys2-runtime.commit)" && { |
| 40 | + test 0 = $(git --git-dir=src/msys2-runtime rev-list --count "$revision..$previous_commit") || |
| 41 | + die "The revision $revision is not a direct descendant of $previous_commit" |
| 42 | +} && |
| 43 | + |
| 44 | +# update pkgver if needed |
| 45 | +update_pkgver= && |
| 46 | +pkgver=$(git --git-dir=src/msys2-runtime describe --match='cygwin-[0-9]*' "$revision") && |
| 47 | +pkgver=${pkgver#cygwin-} && |
| 48 | +pkgver=${pkgver%%-*} && |
| 49 | +if test "$pkgver" != "$(sed -n 's/^pkgver=\(.*\)/\1/p' PKGBUILD)" |
| 50 | +then |
| 51 | + update_pkgver=t |
| 52 | + sed -i "s/^pkgver=.*/pkgver=$pkgver/" PKGBUILD && |
| 53 | + # the `update-patches.sh` script requires no uncommitted changes, but it also expects |
| 54 | + # the `pkgver` to be set correctly. |
| 55 | + git commit -sm 'msys2-runtime: WIP' PKGBUILD |
| 56 | +fi && |
| 57 | + |
| 58 | +# pre-fetch the required blobs |
| 59 | +git --git-dir=src/msys2-runtime fetch origin \ |
| 60 | + $(git --git-dir=src/msys2-runtime -c core.abbrev=no \ |
| 61 | + log --format='%n' --raw "refs/tags/cygwin-$pkgver..$revision" ^"$revision^{/^Start.the.merging-rebase}" | |
| 62 | + cut -d ' ' -f 3,4 | |
| 63 | + tr ' ' '\n' | |
| 64 | + grep -v '^0*$' | |
| 65 | + sort | |
| 66 | + uniq) && |
| 67 | + |
| 68 | +sh -x ./update-patches.sh && |
| 69 | +if test -n "$update_pkgver" |
| 70 | +then |
| 71 | + git reset --soft HEAD^ && |
| 72 | + sed -i 's/^pkgrel=.*/pkgrel=1/' PKGBUILD |
| 73 | +fi |
0 commit comments