blob: 3b52a5de09223916280da796ea0f63cb362ad801 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/env zsh
# Utility to transform a raw patch into a patch to be put on the MPFR
# www server. Assume that update-version is in the same directory.
# MPFR_CURRENT_DIR should contain a path to a directory corresponding
# to /misc/www/mpfr-current in the MPFR repository; if not set, it is
# assumed to be "$HOME/mpfr-misc/www/mpfr-current".
set -e
prg="$0"
upv="$prg:h/update-version"
if [[ $# -gt 3 || $1 == -* ]] then
echo "Usage: $prg [ <patch> [ <patchlevel> [ <patchname> ] ] ]" >&2
exit 1
fi
: ${MPFR_CURRENT_DIR:=$(realpath ~/mpfr-misc/www/mpfr-current)}
base=$MPFR_CURRENT_DIR:t
version=${base#mpfr-}
if [[ -z "$version" ]] then
echo "${prg}: bad version" >&2
exit 2
fi
checkobj()
{
if [[ -e "$1" ]] then
echo "${prg}: $1 is in the way" >&2
exit 3
fi
}
checkobj "$base"
checkobj "$base-a"
checkobj "$base-b"
checkobj "base-patch"
atool -eqx -- "$MPFR_CURRENT_DIR/$base.tar.xz"
pushd "$base"
touch -a "$MPFR_CURRENT_DIR/allpatches"
patch -N -Z -p1 < "$MPFR_CURRENT_DIR/allpatches"
: > PATCHES
popd
mv -T "$base" "$base-a"
cp -aT "$base-a" "$base-b"
if [[ $# -ge 1 ]] then
patchfile=$(realpath "$1")
pushd "$base-b"
echo "Applying patch $1"
if grep -q '^--- mpfr.*/' "$patchfile"; then
p=1
else
p=0
fi
patch --no-backup-if-mismatch -p$p < "$patchfile"
if [[ $# -ge 2 ]] then
~/wd/mpfr/tools/update-version ${(s:.:)version} "p$2" -
if [[ $# -ge 3 ]] then
echo "$3" >> PATCHES
fi
fi
popd
set +e
TZ=UTC diff -Naurd "$base-a" "$base-b" > "$base-patch"
if [[ $? -ne 1 ]] then
echo "${prg}: something has gone wrong with diff" >&2
exit 4
fi
set -e
rm -r "$base-a" "$base-b"
echo "OK, patch in $base-patch"
fi
|