blob: 97105b9e223fa664fbb46bd339fff44146420cdf (
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
75
76
77
78
79
80
81
82
83
84
|
#!/bin/bash
PTX_PATCHES_HEADER="# generated by git-ptx-patches"
function _md5sum() {
local sum=$(md5sum)
echo "# $sum git-ptx-patches magic"
}
if [ ! -L .ptxdist/patches ]; then
echo "Error: This is not patched by ptxdist. Aborting."
exit 1
fi
if [ ! -L .ptxdist/series ]; then
echo "Error: .ptxdist/series must be a symbolic link. Aborting."
exit 1
fi
remove_old=no
if grep -q "$PTX_PATCHES_HEADER" .ptxdist/series; then
echo "Found series file generated by git-ptx-patches."
lines=$(cat .ptxdist/series | wc -l)
lines=$[lines-1]
magic=$(head -n$lines .ptxdist/series | _md5sum)
if grep -q "^$magic" .ptxdist/series; then
remove_old=yes
else
echo "Warning: .ptxdist/series was modified."
fi
fi
if [ "x$1" = "x--force-remove" ]; then
remove_old="force"
fi
case "$remove_old" in
"no") ;;
"yes")
echo "Removing old patches ..."
while read patch para; do
case "${patch}" in
""|"#"*) continue ;;
*) rm .ptxdist/patches/$patch ;;
esac
done < .ptxdist/series
;;
"force")
echo "Removing old patches (forced) ..."
find .ptxdist/patches/ | while read file; do
case "$file" in
".ptxdist/patches/") continue ;;
".ptxdist/patches/series") continue ;;
".ptxdist/patches/autogen.sh") continue ;;
*) rm -rf "$file" ;;
esac
done
;;
esac
echo "$PTX_PATCHES_HEADER" > .ptxdist/series
git format-patch -N -o .ptxdist/patches/ base | sed -e 's,^.ptxdist/patches/,,' >> .ptxdist/series
cat .ptxdist/series | _md5sum >> .ptxdist/series
# The first line of the patch is 'From <some-git-hash> ...'
# remove it to avoid unnecessary changes in the patch files.
find .ptxdist/patches/ ! -type d | sed -e 's,^.ptxdist/patches/,,' | \
while read patch para; do
case "$patch" in
"series"|"autogen.sh") continue ;;
*) ;;
esac
if grep -q "$patch" .ptxdist/series; then
p=".ptxdist/patches/$patch"
lines=$(cat "$p" | wc -l)
lines=$[lines-1]
tail -n$lines "$p" > ".$patch.ptx-patches"
mv ".$patch.ptx-patches" "$p"
else
echo "Old patch \"$patch\"!"
fi
done
|