pathtools: add a helper to synchronize all copies

The `mingw-w64-pathtools` directory does not contain a package
definition, on purpose: for ease of maintenance, we do not patch users
of this code to link to a library, but we patch in the source code
directly.

Which means that we have to maintain copies of this code, and after
every update to `mingw-w64-pathtools/pathtools.[ch]`, we have to
synchronize those copies and increment pkgrels.

Let's add a simple shell script to do that job for us.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2021-07-19 10:09:10 +02:00
parent 31374aacd4
commit aff1f38f7e

View File

@@ -0,0 +1,41 @@
#!/bin/sh
# Since mingw-w64-pathtools does not define a package, but its source code is
# copied all over the place, it could be challenging to update the dependencees
# manually. This script should help.
die () {
echo "$*" >&2
exit 1
}
cd "$(dirname "$0")" || die "Could not switch to directory"
get_sha256 () {
sha256sum.exe "$1" | sed 's/ .*//'
}
c_sum="$(get_sha256 pathtools.c)"
h_sum="$(get_sha256 pathtools.h)"
for c in ../*/pathtools.c
do
h=${c%.c}.h
cmp "$c" pathtools.c && cmp "$h" pathtools.h && continue
orig_c_sum="$(get_sha256 "$c")"
orig_h_sum="$(get_sha256 "$h")"
dir=${c%/pathtools.c}
pkgname=${dir#../mingw-w64-}
pkgbuild=$dir/PKGBUILD
grep $orig_c_sum "$pkgbuild" && grep $orig_h_sum "$pkgbuild" || die "$pkgbuild not up to date?"
pkgrel=$(($(sed -n 's/^pkgrel=//p' "$pkgbuild")+1))
cp -f pathtools.[ch] "$dir/" &&
sed -i -e "s/^pkgrel=.*/pkgrel=$pkgrel/" -e "s/$orig_c_sum/$c_sum/" -e "s/$orig_h_sum/$h_sum/" "$pkgbuild" &&
git commit -sm "$pkgname: synchronize pathtools" -- "$dir"/{PKGBUILD,pathtools.c,pathtools.h} ||
die "Could not update $pkgname"
done