#!/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' msys2-runtime.commit && git add $patches msys2-runtime.commit || 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'